You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by "ocket8888 (via GitHub)" <gi...@apache.org> on 2023/02/20 19:43:38 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a diff in pull request #7355: Adding Types table and details

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


##########
experimental/traffic-portal/nightwatch/globals/globals.ts:
##########
@@ -54,9 +54,12 @@ import {
 	RequestCacheGroup,
 	ResponseCacheGroup,
 	ResponsePhysicalLocation,
-	RequestPhysicalLocation
+	RequestPhysicalLocation, RequestType

Review Comment:
   this should be on its own line, in keeping with the way the rest of this statement is organized



##########
experimental/traffic-portal/src/app/core/types/detail/type-detail.component.html:
##########
@@ -0,0 +1,49 @@
+<!--
+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>
+	<tp-loading *ngIf="!type"></tp-loading>
+	<form ngNativeValidate (ngSubmit)="submit($event)" *ngIf="type">
+		<mat-card-content>
+			<mat-form-field *ngIf="!new">
+				<mat-label>ID</mat-label>
+				<input matInput type="text" name="id" disabled readonly [defaultValue]="type.id" />
+			</mat-form-field>
+			<mat-form-field>
+				<mat-label>Name</mat-label>
+				<input matInput type="text" name="name" required [(ngModel)]="type.name" />
+			</mat-form-field>
+			<mat-form-field>
+				<mat-label>Description</mat-label>
+				<input matInput type="text" name="description" required [(ngModel)]="type.description" />
+			</mat-form-field>
+			<mat-form-field *ngIf="!new">
+				<mat-label>Use In Table</mat-label>
+				<input matInput type="text" name="useInTable" disabled readonly [(ngModel)]="type.useInTable" />
+			</mat-form-field>
+			<mat-form-field *ngIf="new">
+				<mat-label>Use In Table</mat-label>
+				<input matInput type="text" name="useInTable" disabled readonly value="server" />
+			</mat-form-field>

Review Comment:
   Looking below, it seems like you are setting `useInTable` immediately on new Types, so yeah that can just be `type.useInTable`.



##########
experimental/traffic-portal/src/app/api/type.service.ts:
##########
@@ -79,6 +79,37 @@ export class TypeService extends APIService {
 		return this.getTypesInTable("server");
 	}
 
+	/**
+	 * Deletes an existing type.
+	 *
+	 * @param id ID of the type to delete.
+	 * @returns The deleted type.
+	 */
+	public async deleteType(id: number): Promise<TypeFromResponse> {

Review Comment:
   Ideally anywhere you can pass the ID, you should also be able to pass the response form of the object (i.e. `TypeFromResponse` in this case).



##########
experimental/traffic-portal/src/app/core/types/detail/type-detail.component.html:
##########
@@ -0,0 +1,49 @@
+<!--
+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>
+	<tp-loading *ngIf="!type"></tp-loading>
+	<form ngNativeValidate (ngSubmit)="submit($event)" *ngIf="type">
+		<mat-card-content>
+			<mat-form-field *ngIf="!new">
+				<mat-label>ID</mat-label>
+				<input matInput type="text" name="id" disabled readonly [defaultValue]="type.id" />
+			</mat-form-field>
+			<mat-form-field>
+				<mat-label>Name</mat-label>
+				<input matInput type="text" name="name" required [(ngModel)]="type.name" />
+			</mat-form-field>
+			<mat-form-field>
+				<mat-label>Description</mat-label>
+				<input matInput type="text" name="description" required [(ngModel)]="type.description" />
+			</mat-form-field>
+			<mat-form-field *ngIf="!new">
+				<mat-label>Use In Table</mat-label>
+				<input matInput type="text" name="useInTable" disabled readonly [(ngModel)]="type.useInTable" />

Review Comment:
   2-way binding is unnecessary when the control is read-only; this should probably use `defaultValue` just like the ID field.



##########
experimental/traffic-portal/src/app/core/types/detail/type-detail.component.html:
##########
@@ -0,0 +1,49 @@
+<!--
+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>
+	<tp-loading *ngIf="!type"></tp-loading>
+	<form ngNativeValidate (ngSubmit)="submit($event)" *ngIf="type">
+		<mat-card-content>
+			<mat-form-field *ngIf="!new">
+				<mat-label>ID</mat-label>
+				<input matInput type="text" name="id" disabled readonly [defaultValue]="type.id" />
+			</mat-form-field>
+			<mat-form-field>
+				<mat-label>Name</mat-label>
+				<input matInput type="text" name="name" required [(ngModel)]="type.name" />
+			</mat-form-field>
+			<mat-form-field>
+				<mat-label>Description</mat-label>
+				<input matInput type="text" name="description" required [(ngModel)]="type.description" />
+			</mat-form-field>
+			<mat-form-field *ngIf="!new">
+				<mat-label>Use In Table</mat-label>
+				<input matInput type="text" name="useInTable" disabled readonly [(ngModel)]="type.useInTable" />
+			</mat-form-field>
+			<mat-form-field *ngIf="new">
+				<mat-label>Use In Table</mat-label>
+				<input matInput type="text" name="useInTable" disabled readonly value="server" />
+			</mat-form-field>

Review Comment:
   It seems like the only difference between these two is the value, and thus they can be combined into one like
   ```html
   <mat-form-field>
   	<mat-label>Use In Table</mat-label>
   	<input matInput type="text" name="useInTable" disabled readonly [defaultValue]="new ? 'server' : type.useInTable" />
   </mat-form-field>
   ```
   Although, what would be even better is to reduce `new ? 'server' : type.useInTable` to just `type.useInTable`, and set the `useInTable` property of new Types to `"server"` immediately within the controller.



-- 
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: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org