zrhoffman commented on code in PR #7353:
URL: https://github.com/apache/trafficcontrol/pull/7353#discussion_r1116031490


##########
experimental/traffic-portal/src/app/api/cdn.service.ts:
##########
@@ -48,4 +48,65 @@ export class CDNService extends APIService {
                }
                return this.get<Array<ResponseCDN>>(path).toPromise();
        }
+
+       /**
+        * Deletes a CDN.
+        *
+        * @param cdn The CDN to be deleted, or just its ID.
+        */
+       public async deleteCDN(cdn: ResponseCDN | number): Promise<void> {
+               const id = typeof cdn === "number" ? cdn : cdn.id;
+               return this.delete(`cdns/${id}`).toPromise();
+       }
+
+       /**
+        * Creates a new CDN.
+        *
+        * @param cdn The CDN to create.
+        */
+       public async createCDN(cdn: RequestCDN): Promise<ResponseCDN> {
+               return this.post<ResponseCDN>("cdns", cdn).toPromise();
+       }
+
+       /**
+        * Replaces an existing CDN with the provided new definition of a
+        * CDN.
+        *
+        * @param id The if of the CDN being updated.
+        * @param cdn The new definition of the CDN.
+        */
+       public async updateCDN(id: number, cdn: RequestCDN): 
Promise<ResponseCDN>;
+       /**
+        * Replaces an existing CDN with the provided new definition of a
+        * CDN.
+        *
+        * @param cdn The full new definition of the CDN being
+        * updated.
+        */
+       public async updateCDN(cdn: ResponseCDN): Promise<ResponseCDN>;
+       /**
+        * Replaces an existing CDN with the provided new definition of a
+        * CDN.
+        *
+        * @param cdnOrID The full new definition of the CDN being
+        * updated, or just its ID.
+        * @param payload The new definition of the CDN. This is required if
+        * `cdnOrID` is an ID, and ignored otherwise.
+        */
+       public async updateCDN(cdnOrID: ResponseCDN | number, payload?: 
RequestCDN): Promise<ResponseCDN> {
+               let id;
+               let body;
+               if (typeof(cdnOrID) === "number") {
+                       if (!payload) {
+                               throw new TypeError("invalid call signature - 
missing request payload");
+                       }
+                       body = payload;
+                       id = cdnOrID;
+               } else {
+                       body = cdnOrID;
+                       ({id} = cdnOrID);
+               }
+
+               return this.put<ResponseCDN>(`cdns/${id}`, body).toPromise();
+       }

Review Comment:
   Methods added to the CDN testing service in 9ef742087b



##########
experimental/traffic-portal/src/app/core/cdns/cdn-detail/cdn-detail.component.ts:
##########
@@ -0,0 +1,139 @@
+/*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { Location } from "@angular/common";
+import { Component, OnInit } from "@angular/core";
+import { MatDialog } from "@angular/material/dialog";
+import { ActivatedRoute } from "@angular/router";
+import { ResponseCDN } from "trafficops-types";
+
+import { CDNService } from "src/app/api";
+import {
+       DecisionDialogComponent,
+       DecisionDialogData,
+} from "src/app/shared/dialogs/decision-dialog/decision-dialog.component";
+import { NavigationService } from 
"src/app/shared/navigation/navigation.service";
+
+/**
+ * CDNDetailComponent is the controller for a CDN's "detail" page.
+ */
+@Component({
+       selector: "tp-cdn-detail",
+       styleUrls: ["./cdn-detail.component.scss"],
+       templateUrl: "./cdn-detail.component.html",
+})
+export class CDNDetailComponent implements OnInit {
+       public new = false;
+       public cdn: ResponseCDN = {
+               dnssecEnabled: false,
+               domainName: "",
+               id: -1,
+               lastUpdated: new Date(),
+               name: "",
+       };
+       public showErrors = false;
+       public cdns: Array<ResponseCDN> = [];
+
+       constructor(
+               private readonly route: ActivatedRoute,
+               private readonly api: CDNService,
+               private readonly location: Location,
+               private readonly dialog: MatDialog,
+               private readonly navSvc: NavigationService
+       ) {
+       }
+
+       /**
+        * Angular lifecycle hook where data is initialized.
+        */
+       public async ngOnInit(): Promise<void> {
+               const ID = this.route.snapshot.paramMap.get("id");
+               if (ID === null) {
+                       console.error("missing required route parameter 'id'");
+                       return;
+               }
+
+               const cdnsPromise = this.api.getCDNs().then(cdns => this.cdns = 
cdns);
+               if (ID === "new") {
+                       this.setTitle();
+                       this.new = true;

Review Comment:
   Thanks, flipped the order in 2c62c14d68.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to