ocket8888 commented on code in PR #7203:
URL: https://github.com/apache/trafficcontrol/pull/7203#discussion_r1028530633


##########
experimental/traffic-portal/src/app/core/cache-groups/divisions/detail/division-detail.component.ts:
##########
@@ -0,0 +1,102 @@
+/*
+* 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 { ResponseDivision } from "trafficops-types";
+
+import { CacheGroupService } from "src/app/api";
+import { DecisionDialogComponent } from 
"src/app/shared/dialogs/decision-dialog/decision-dialog.component";
+
+/**
+ * DivisionDetailsComponent is the controller for the division add/edit form.
+ */
+@Component({
+       selector: "tp-divisions-detail",
+       styleUrls: ["./division-detail.component.scss"],
+       templateUrl: "./division-detail.component.html"
+})
+export class DivisionDetailComponent implements OnInit {
+       public new = false;
+       public division!: ResponseDivision;
+
+       constructor(private readonly route: ActivatedRoute, private readonly 
cacheGroupService: CacheGroupService,
+               private readonly location: Location, private readonly dialog: 
MatDialog) { }
+
+       /**
+        * 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;
+               }
+
+               if (ID === "new") {
+                       this.new = true;
+                       this.division = {
+                               id: -1,
+                               lastUpdated: new Date(),
+                               name: ""
+                       };
+                       return;
+               }
+               const numID = parseInt(ID, 10);
+               if (Number.isNaN(numID)) {
+                       console.error("route parameter 'id' was non-number:", 
ID);
+                       return;
+               }
+
+               this.division = await 
this.cacheGroupService.getDivisions(numID);
+       }

Review Comment:
   this should set the TP-Header value to the name of the division (or "New 
Division") once it's known



-- 
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