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


##########
experimental/traffic-portal/src/app/core/cache-groups/regions/table/regions-table.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 { Component, OnInit } from "@angular/core";
+import { FormControl } from "@angular/forms";
+import { MatDialog } from "@angular/material/dialog";
+import { ActivatedRoute, Router } from "@angular/router";
+import { BehaviorSubject } from "rxjs";
+import { Region, ResponseRegion } from "trafficops-types";
+
+import { CacheGroupService } from "src/app/api";
+import { CurrentUserService } from 
"src/app/shared/currentUser/current-user.service";
+import { DecisionDialogComponent } from 
"src/app/shared/dialogs/decision-dialog/decision-dialog.component";
+import { ContextMenuActionEvent, ContextMenuItem } from 
"src/app/shared/generic-table/generic-table.component";
+import { TpHeaderService } from "src/app/shared/tp-header/tp-header.service";
+
+/**
+ * RegionsTableComponent is the controller for the "Regions" table.
+ */
+@Component({
+       selector: "tp-regions",
+       styleUrls: ["./regions-table.component.scss"],
+       templateUrl: "./regions-table.component.html"
+})
+export class RegionsTableComponent implements OnInit {
+       /** List of regions */
+       public readonly regions: Promise<Array<ResponseRegion>>;
+
+       constructor(private readonly route: ActivatedRoute, private readonly 
headerSvc: TpHeaderService, private readonly router: Router,
+               private readonly api: CacheGroupService, private readonly 
dialog: MatDialog, public readonly auth: CurrentUserService) {
+               this.fuzzySubject = new BehaviorSubject<string>("");
+               this.regions = this.api.getRegions();
+       }
+
+       /** Initializes table data, loading it from Traffic Ops. */
+       public ngOnInit(): void {
+               this.route.queryParamMap.subscribe(
+                       m => {
+                               const search = m.get("search");
+                               if (search) {
+                                       
this.fuzzControl.setValue(decodeURIComponent(search));
+                                       this.updateURL();
+                               }
+                       },
+                       e => {
+                               console.error("Failed to get query 
parameters:", e);
+                       }
+               );
+               this.headerSvc.headerTitle.next("Regions");
+       }
+
+       /** Definitions of the table's columns according to the ag-grid API */
+       public columnDefs = [
+               {
+                       field: "name",
+                       headerName: "Name"
+               },
+               {
+                       field: "divisionName",
+                       headerName: "Division"
+               },
+               {
+                       field: "id",
+                       headerName:" ID",
+                       hide: true
+               },
+               {
+                       field: "lastUpdated",
+                       headerName: "Last Updated"
+               }
+       ];
+
+       /** Definitions for the context menu items (which act on augmented 
region data). */
+       public contextMenuItems: Array<ContextMenuItem<Region>> = [
+               {
+                       action: "edit",
+                       multiRow: false,
+                       name: "Edit"
+               },
+               {
+                       action: "delete",
+                       multiRow: false,
+                       name: "Delete"
+               },
+               {
+                       action: "viewRegions",
+                       multiRow: false,
+                       name: "View Regions"
+               }
+       ];
+
+       /** A subject that child components can subscribe to for access to the 
fuzzy search query text */
+       public fuzzySubject: BehaviorSubject<string>;
+
+       /** Form controller for the user search input. */
+       public fuzzControl: FormControl = new FormControl<string>("");

Review Comment:
   Well yeah, if you remove `FormControl` you also have to remove the 
<kbd>:</kbd> that tells TypeScript to expect a type expression.



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