ocket8888 commented on code in PR #7358: URL: https://github.com/apache/trafficcontrol/pull/7358#discussion_r1178523961
########## experimental/traffic-portal/src/app/core/statuses/statuses-table/statuses-table.component.ts: ########## @@ -0,0 +1,148 @@ +/* + * 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 } from "@angular/router"; +import { BehaviorSubject } from "rxjs"; +import { ResponseStatus } from "trafficops-types"; + +import { ServerService } from "src/app/api"; +import { CurrentUserService } from "src/app/shared/current-user/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 { NavigationService } from "src/app/shared/navigation/navigation.service"; + +/** + * StatusesTableComponent is the controller for the statuses page - which + * principally contains a table. + */ +@Component({ + selector: "tp-statuses-table", + styleUrls: ["./statuses-table.component.scss"], + templateUrl: "./statuses-table.component.html", +}) +export class StatusesTableComponent implements OnInit { + + /** All of the statues which should appear in the table. */ + public statuses: Promise<Array<ResponseStatus>>; + + /** Definitions of the table's columns according to the ag-grid API */ + public columnDefs = [ + { + field: "name", + headerName: "Name", + hide: false + }, + { + field: "description", + headerName: "Description", + hide: false + }, + { + field: "id", + headerName: "ID", + hide: true + }, + { + field: "lastUpdated", + headerName: "Last Updated", + hide: true + }]; + + /** The current search text. */ + public searchText = ""; + + /** Definitions for the context menu items (which act on statuses data). */ + public contextMenuItems: Array<ContextMenuItem<ResponseStatus>> = [ + { + href: (u: ResponseStatus): string => `${u.id}`, + name: "View Status Details" + }, + { + href: (u: ResponseStatus): string => `${u.id}`, + name: "Edit" + }, Review Comment: There's no difference between these two context menu items; one should open it in a new tab like on other pages. Also the name should be updated to reflect that. ########## experimental/traffic-portal/src/app/core/statuses/status-details/status-details.component.html: ########## @@ -0,0 +1,45 @@ +<!-- +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. +--> + +<mat-card class="statuses-details"> + <tp-loading *ngIf="loading"></tp-loading> + <form [formGroup]="statusDetailsForm" (ngSubmit)="onSubmit($event)" *ngIf="!loading"> + <mat-card-content> + <mat-form-field *ngIf="!new"> + <mat-label>ID</mat-label> + <input matInput type="text" name="id" disabled readonly [defaultValue]="statusDetails.id" /> + </mat-form-field> + <mat-form-field> + <mat-label>Name</mat-label> + <input matInput type="text" name="name" required formControlName="name"> + </mat-form-field> + <mat-form-field> + <mat-label>Description</mat-label> + <input matInput type="text" name="description" formControlName="description"> + </mat-form-field> + <mat-form-field *ngIf="!new"> + <mat-label>Last Updated</mat-label> + <input matInput type="text" name="lastUpdated" disabled readonly + [defaultValue]="statusDetails.lastUpdated" /> + </mat-form-field> + </mat-card-content> + <mat-card-actions align="end"> + <button mat-raised-button type="button" color="warn" (click)="deleteStatus()" *ngIf="!new">Delete</button> + <button mat-raised-button type="button" routerLink="/core/statuses">Cancel</button> Review Comment: Buttons should never have `routerLink` attributes. But also, this button doesn't need to exist, since this navigation is available from the menu on the left. -- 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]
