Re: [PR] Add Origins page Traffic Portal v2 [trafficcontrol]

2024-02-07 Thread via GitHub


ocket merged PR #7881:
URL: https://github.com/apache/trafficcontrol/pull/7881


-- 
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-unsubscr...@trafficcontrol.apache.org

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



Re: [PR] Add Origins page Traffic Portal v2 [trafficcontrol]

2024-01-31 Thread via GitHub


ntheanh201 commented on code in PR #7881:
URL: https://github.com/apache/trafficcontrol/pull/7881#discussion_r1472647506


##
experimental/traffic-portal/src/app/core/origins/detail/origin-detail.component.spec.ts:
##
@@ -0,0 +1,124 @@
+/*
+ * 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 { HarnessLoader } from "@angular/cdk/testing";
+import { TestbedHarnessEnvironment } from "@angular/cdk/testing/testbed";
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { MatButtonHarness } from "@angular/material/button/testing";
+import { MatDialogModule } from "@angular/material/dialog";
+import { MatDialogHarness } from "@angular/material/dialog/testing";
+import { ActivatedRoute } from "@angular/router";
+import { RouterTestingModule } from "@angular/router/testing";
+import { ReplaySubject } from "rxjs";
+
+import { OriginService } from "src/app/api";
+import { APITestingModule } from "src/app/api/testing";
+import { NavigationService } from 
"src/app/shared/navigation/navigation.service";
+
+import { OriginDetailComponent } from "./origin-detail.component";
+
+describe("OriginDetailComponent", () => {
+   let component: OriginDetailComponent;
+   let fixture: ComponentFixture;
+   let route: ActivatedRoute;
+   let paramMap: jasmine.Spy;
+   let loader: HarnessLoader;
+   let service: OriginService;
+
+   const navSvc = jasmine.createSpyObj([], {
+   headerHidden: new ReplaySubject(),
+   headerTitle: new ReplaySubject(),
+   });
+   beforeEach(async () => {
+   await TestBed.configureTestingModule({
+   declarations: [OriginDetailComponent],
+   imports: [APITestingModule, RouterTestingModule, 
MatDialogModule],

Review Comment:
   Thanks @ocket. I could make it works



-- 
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-unsubscr...@trafficcontrol.apache.org

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



Re: [PR] Add Origins page Traffic Portal v2 [trafficcontrol]

2024-01-31 Thread via GitHub


ntheanh201 commented on code in PR #7881:
URL: https://github.com/apache/trafficcontrol/pull/7881#discussion_r1472647506


##
experimental/traffic-portal/src/app/core/origins/detail/origin-detail.component.spec.ts:
##
@@ -0,0 +1,124 @@
+/*
+ * 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 { HarnessLoader } from "@angular/cdk/testing";
+import { TestbedHarnessEnvironment } from "@angular/cdk/testing/testbed";
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { MatButtonHarness } from "@angular/material/button/testing";
+import { MatDialogModule } from "@angular/material/dialog";
+import { MatDialogHarness } from "@angular/material/dialog/testing";
+import { ActivatedRoute } from "@angular/router";
+import { RouterTestingModule } from "@angular/router/testing";
+import { ReplaySubject } from "rxjs";
+
+import { OriginService } from "src/app/api";
+import { APITestingModule } from "src/app/api/testing";
+import { NavigationService } from 
"src/app/shared/navigation/navigation.service";
+
+import { OriginDetailComponent } from "./origin-detail.component";
+
+describe("OriginDetailComponent", () => {
+   let component: OriginDetailComponent;
+   let fixture: ComponentFixture;
+   let route: ActivatedRoute;
+   let paramMap: jasmine.Spy;
+   let loader: HarnessLoader;
+   let service: OriginService;
+
+   const navSvc = jasmine.createSpyObj([], {
+   headerHidden: new ReplaySubject(),
+   headerTitle: new ReplaySubject(),
+   });
+   beforeEach(async () => {
+   await TestBed.configureTestingModule({
+   declarations: [OriginDetailComponent],
+   imports: [APITestingModule, RouterTestingModule, 
MatDialogModule],

Review Comment:
   Thanks @ocket. I could make it work



-- 
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-unsubscr...@trafficcontrol.apache.org

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



Re: [PR] Add Origins page Traffic Portal v2 [trafficcontrol]

2024-01-30 Thread via GitHub


ocket commented on code in PR #7881:
URL: https://github.com/apache/trafficcontrol/pull/7881#discussion_r1471588991


##
experimental/traffic-portal/src/app/core/origins/detail/origin-detail.component.spec.ts:
##
@@ -0,0 +1,124 @@
+/*
+ * 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 { HarnessLoader } from "@angular/cdk/testing";
+import { TestbedHarnessEnvironment } from "@angular/cdk/testing/testbed";
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { MatButtonHarness } from "@angular/material/button/testing";
+import { MatDialogModule } from "@angular/material/dialog";
+import { MatDialogHarness } from "@angular/material/dialog/testing";
+import { ActivatedRoute } from "@angular/router";
+import { RouterTestingModule } from "@angular/router/testing";
+import { ReplaySubject } from "rxjs";
+
+import { OriginService } from "src/app/api";
+import { APITestingModule } from "src/app/api/testing";
+import { NavigationService } from 
"src/app/shared/navigation/navigation.service";
+
+import { OriginDetailComponent } from "./origin-detail.component";
+
+describe("OriginDetailComponent", () => {
+   let component: OriginDetailComponent;
+   let fixture: ComponentFixture;
+   let route: ActivatedRoute;
+   let paramMap: jasmine.Spy;
+   let loader: HarnessLoader;
+   let service: OriginService;
+
+   const navSvc = jasmine.createSpyObj([], {
+   headerHidden: new ReplaySubject(),
+   headerTitle: new ReplaySubject(),
+   });
+   beforeEach(async () => {
+   await TestBed.configureTestingModule({
+   declarations: [OriginDetailComponent],
+   imports: [APITestingModule, RouterTestingModule, 
MatDialogModule],

Review Comment:
   The reason your tests are failing is because the dialog never actually 
closes in time for the tests, and things waiting for it to close never happen. 
The problem is you're waiting on animations, but without explicitly providing 
an animations module. As you can see in [the testing example in the Angular 
Material Dialog component 
documentation](https://material.angular.io/components/dialog/examples#dialog-harness),
 you should provide the `NoopAnimationsModule` from 
`@angular/platform-browser/animations`.



##
experimental/traffic-portal/src/app/core/origins/detail/origin-detail.component.spec.ts:
##
@@ -0,0 +1,124 @@
+/*
+ * 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 { HarnessLoader } from "@angular/cdk/testing";
+import { TestbedHarnessEnvironment } from "@angular/cdk/testing/testbed";
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { MatButtonHarness } from "@angular/material/button/testing";
+import { MatDialogModule } from "@angular/material/dialog";
+import { MatDialogHarness } from "@angular/material/dialog/testing";
+import { ActivatedRoute } from "@angular/router";
+import { RouterTestingModule } from "@angular/router/testing";
+import { ReplaySubject } from "rxjs";
+
+import { OriginService } from "src/app/api";
+import { APITestingModule } from "src/app/api/testing";
+import { NavigationService } from 
"src/app/shared/navigation/navigation.service";
+
+import { OriginDetailComponent } from "./origin-detail.component";
+
+describe("OriginDetailComponent", () => {
+   let component: OriginDetailComponent;
+   let fixture: ComponentFixture;
+   let route: ActivatedRoute;
+   let paramMap: jasmine.Spy;
+   let loader: HarnessLoader;
+   let service: OriginService;
+
+   const navSvc = jasmine.createSpyObj([], {
+   headerHidden: new ReplaySubject(),
+   headerTitle: new ReplaySubject(),
+   });
+   beforeEach(async () => {
+   await TestBed.configureTestingModule({
+   declarations: [OriginDetailComponent],
+   imports: 

Re: [PR] Add Origins page Traffic Portal v2 [trafficcontrol]

2024-01-24 Thread via GitHub


ntheanh201 commented on code in PR #7881:
URL: https://github.com/apache/trafficcontrol/pull/7881#discussion_r1465075242


##
experimental/traffic-portal/src/app/core/origins/detail/origin-detail.component.spec.ts:
##
@@ -0,0 +1,124 @@
+/*
+ * 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 { HarnessLoader } from "@angular/cdk/testing";
+import { TestbedHarnessEnvironment } from "@angular/cdk/testing/testbed";
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { MatButtonHarness } from "@angular/material/button/testing";
+import { MatDialogModule } from "@angular/material/dialog";
+import { MatDialogHarness } from "@angular/material/dialog/testing";
+import { ActivatedRoute } from "@angular/router";
+import { RouterTestingModule } from "@angular/router/testing";
+import { ReplaySubject } from "rxjs";
+
+import { OriginService } from "src/app/api";
+import { APITestingModule } from "src/app/api/testing";
+import { NavigationService } from 
"src/app/shared/navigation/navigation.service";
+
+import { OriginDetailComponent } from "./origin-detail.component";
+
+describe("OriginDetailComponent", () => {
+   let component: OriginDetailComponent;
+   let fixture: ComponentFixture;
+   let route: ActivatedRoute;
+   let paramMap: jasmine.Spy;
+   let loader: HarnessLoader;
+   let service: OriginService;
+
+   const navSvc = jasmine.createSpyObj([], {
+   headerHidden: new ReplaySubject(),
+   headerTitle: new ReplaySubject(),
+   });
+   beforeEach(async () => {
+   await TestBed.configureTestingModule({
+   declarations: [OriginDetailComponent],
+   imports: [APITestingModule, RouterTestingModule, 
MatDialogModule],
+   providers: [{provide: NavigationService, useValue: 
navSvc}],
+   }).compileComponents();
+
+   route = TestBed.inject(ActivatedRoute);
+   paramMap = spyOn(route.snapshot.paramMap, "get");
+   paramMap.and.returnValue(null);
+   fixture = TestBed.createComponent(OriginDetailComponent);
+   component = fixture.componentInstance;
+   fixture.detectChanges();
+   service = TestBed.inject(OriginService);
+   loader = TestbedHarnessEnvironment.documentRootLoader(fixture);
+   await fixture.whenStable();
+   });
+
+   it("should create", () => {
+   expect(component).toBeTruthy();
+   });
+
+   it("new origin", async () => {
+   paramMap.and.returnValue("new");
+
+   fixture = TestBed.createComponent(OriginDetailComponent);
+   component = fixture.componentInstance;
+   fixture.detectChanges();
+   await fixture.whenStable();
+   expect(paramMap).toHaveBeenCalled();
+   expect(component.origin).not.toBeNull();
+   expect(component.origin.name).toBe("");
+   expect(component.new).toBeTrue();
+   });
+
+   it("existing origin", async () => {
+   const id = 1;
+   paramMap.and.returnValue(id);
+   const origin = await service.getOrigins(id);
+   fixture = TestBed.createComponent(OriginDetailComponent);
+   component = fixture.componentInstance;
+   fixture.detectChanges();
+   await fixture.whenStable();
+   expect(paramMap).toHaveBeenCalled();
+   expect(component.origin).not.toBeNull();
+   expect(component.origin.name).toBe(origin.name);
+   expect(component.new).toBeFalse();
+   });
+
+   it("deletes existing Origins", async () => {

Review Comment:
   @ocket I've added the test for delete origin but I still have no idea 
why this.originService.deleteOrigin wasn't to be called



-- 
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-unsubscr...@trafficcontrol.apache.org

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



Re: [PR] Add Origins page Traffic Portal v2 [trafficcontrol]

2024-01-10 Thread via GitHub


ocket commented on code in PR #7881:
URL: https://github.com/apache/trafficcontrol/pull/7881#discussion_r1447725039


##
experimental/traffic-portal/src/app/api/coordinate.service.spec.ts:
##
@@ -79,6 +79,38 @@ describe("CoordinateService", () => {
await expectAsync(responseP).toBeResolvedTo(coordinate);
});
 
+   it("sends requests for multiple coordinates by ID", async () => {

Review Comment:
   These `it`s make it seem like the service should be doing something 
successfully. We're actually testing that it throws an error when a request 
that's supposed to only return one thing instead returns many.



-- 
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-unsubscr...@trafficcontrol.apache.org

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



Re: [PR] Add Origins page Traffic Portal v2 [trafficcontrol]

2024-01-08 Thread via GitHub


ocket commented on code in PR #7881:
URL: https://github.com/apache/trafficcontrol/pull/7881#discussion_r1445386640


##
experimental/traffic-portal/src/app/api/coordinate.service.ts:
##
@@ -0,0 +1,85 @@
+/*
+ * 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 { HttpClient } from "@angular/common/http";
+import { Injectable } from "@angular/core";
+import type { ResponseCoordinate } from "trafficops-types";
+
+import { APIService } from "./base-api.service";
+
+/**
+ * CoordinateService exposes API functionality relating to Coordinates.
+ */
+@Injectable()
+export class CoordinateService extends APIService {
+   /**
+* Gets a specific Coordinate from Traffic Ops.
+*
+* @param idOrName Either the integral, unique identifier (number) or 
name
+* (string) of the Coordinate to be returned.
+* @returns The requested Coordinate.
+*/
+   public async getCoordinates(
+   idOrName: number | string
+   ): Promise;
+   /**
+* Gets Coordinates from Traffic Ops.
+*
+* @returns An Array of all Coordinates from Traffic Ops.
+*/
+   public async getCoordinates(): Promise>;
+
+   /**
+* Gets one or all Coordinates from Traffic Ops.
+*
+* @param idOrName Optionally the integral, unique identifier (number) 
or
+* name (string) of a single Coordinate to be returned.
+* @returns The requested Coordinate(s).
+*/
+   public async getCoordinates(
+   idOrName?: number | string
+   ): Promise> {
+   const path = "coordinates";
+   if (idOrName !== undefined) {
+   let params;
+   switch (typeof idOrName) {
+   case "string":
+   params = { name: idOrName };
+   break;
+   case "number":
+   params = { id: idOrName };
+   }
+   const r = await this.get<[ResponseCoordinate]>(
+   path,
+   undefined,
+   params
+   ).toPromise();
+   if (r.length !== 1) {
+   throw new Error(

Review Comment:
   this statement is not covered by tests



##
experimental/traffic-portal/src/app/core/origins/detail/origin-detail.component.ts:
##
@@ -0,0 +1,198 @@
+/*
+ * 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 type {
+   RequestOrigin,
+   RequestOriginResponse,
+   ResponseCacheGroup,
+   ResponseCoordinate,
+   ResponseDeliveryService,
+   ResponseProfile,
+   ResponseTenant,
+} from "trafficops-types";
+
+import {
+   CacheGroupService,
+   CoordinateService,
+   DeliveryServiceService,
+   OriginService,
+   ProfileService,
+   UserService,
+} from "src/app/api";
+import { DecisionDialogComponent } from 
"src/app/shared/dialogs/decision-dialog/decision-dialog.component";
+import { LoggingService } from "src/app/shared/logging.service";
+import { NavigationService } from 
"src/app/shared/navigation/navigation.service";
+
+/**
+ * OriginDetailComponent is the controller for the origin add/edit form.
+ */
+@Component({
+   selector: "tp-origins-detail",
+   styleUrls: ["./origin-detail.component.scss"],
+   templateUrl: "./origin-detail.component.html",
+})
+export class OriginDetailComponent implements OnInit {
+   public new = false;
+   public origin!: RequestOriginResponse;
+   public tenants = new 

Re: [PR] Add Origins page Traffic Portal v2 [trafficcontrol]

2024-01-06 Thread via GitHub


ocket commented on code in PR #7881:
URL: https://github.com/apache/trafficcontrol/pull/7881#discussion_r1443832263


##
experimental/traffic-portal/src/app/api/coordinate.service.ts:
##
@@ -0,0 +1,83 @@
+/*
+ * 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 { HttpClient } from "@angular/common/http";
+import { Injectable } from "@angular/core";
+import type { ResponseCoordinate } from "trafficops-types";
+
+import { APIService } from "./base-api.service";
+
+/**
+ * CoordinateService exposes API functionality relating to Coordinates.
+ */
+@Injectable()
+export class CoordinateService extends APIService {
+   /**
+* Gets a specific Coordinate from Traffic Ops.
+*
+* @param idOrName Either the integral, unique identifier (number) or 
name
+* (string) of the Coordinate to be returned.
+* @returns The requested Coordinate.
+*/
+   public async getCoordinates(
+   idOrName: number | string
+   ): Promise;
+   /**
+* Gets Coordinates from Traffic Ops.

Review Comment:
   Missing `@returns` annotation



-- 
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-unsubscr...@trafficcontrol.apache.org

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



Re: [PR] Add Origins page Traffic Portal v2 [trafficcontrol]

2023-12-15 Thread via GitHub


ntheanh201 commented on PR #7881:
URL: https://github.com/apache/trafficcontrol/pull/7881#issuecomment-1857476743

   @ocket Can you take a look?


-- 
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-unsubscr...@trafficcontrol.apache.org

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



Re: [PR] Add Origins page Traffic Portal v2 [trafficcontrol]

2023-12-05 Thread via GitHub


ntheanh201 commented on PR #7881:
URL: https://github.com/apache/trafficcontrol/pull/7881#issuecomment-1841911516

   > I'm assuming you opened this PR to look for feedback, even though it's 
still a draft. I realize parts of it aren't ready for that yet, but I commented 
on them a couple times anyway, just in case. The table controller looks 
_mostly_ good, although I haven't compared it to the functionality of the TPv1 
counterpart. Obviously testing needs a lot of work. I'm gonna try to work on 
migrating our tests to cypress over the holidays, which will hopefully make the 
e2e testing easier.
   
   Yeah, I made it in draft because it's not ready for review yet. But thanks 
for your review, I'll check it. The code is copied from some other components 
and some parts I didn't change it ^^


-- 
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-unsubscr...@trafficcontrol.apache.org

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



Re: [PR] Add Origins page Traffic Portal v2 [trafficcontrol]

2023-12-05 Thread via GitHub


ocket commented on code in PR #7881:
URL: https://github.com/apache/trafficcontrol/pull/7881#discussion_r1416060002


##
experimental/traffic-portal/src/app/api/origin.service.ts:
##
@@ -0,0 +1,128 @@
+/*
+* 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 { HttpClient } from "@angular/common/http";
+import { Injectable } from "@angular/core";
+import {RequestOrigin, ResponseOrigin} from "trafficops-types/dist/origin";
+
+import { APIService } from "./base-api.service";
+
+/** The allowed values for the 'useInTables' query parameter of GET requests 
to /origins. */
+type UseInTable = "cachegroup" |
+"server" |
+"deliveryservice" |
+"to_extension" |
+"federation_resolver" |
+"regex" |
+"staticdnsentry" |
+"steering_target";
+
+/**
+ * OriginService exposes API functionality relating to Origins.
+ */
+@Injectable()
+export class OriginService extends APIService {
+   /**
+* Gets a specific Origin from Traffic Ops.
+*
+* @param idOrName Either the integral, unique identifier (number) or 
name
+* (string) of the Origin to be returned.
+* @returns The requested Origin.
+*/
+   public async getOrigins(idOrName: number | string): 
Promise;
+   /**
+* Gets Origins from Traffic Ops.
+*
+* @param idOrName Either the integral, unique identifier (number) or 
name
+* (string) of a single Origin to be returned.
+* @returns The requested Origin(s).
+*/
+   public async getOrigins(): Promise>;
+   /**
+* Gets one or all Origins from Traffic Ops.
+*
+* @param idOrName Optionally the integral, unique identifier (number) 
or
+* name (string) of a single Origin to be returned.
+* @returns The requested Origin(s).
+*/
+   public async getOrigins(idOrName?: number | string): 
Promise> {
+   const path = "origins";
+   if (idOrName !== undefined) {
+   let params;
+   switch (typeof idOrName) {
+   case "string":
+   params = {name: idOrName};
+   break;
+   case "number":
+   params = {id: idOrName};
+   }
+   const r = await this.get<[ResponseOrigin]>(path, 
undefined, params).toPromise();
+   if (r.length !== 1) {
+   throw new Error(`Traffic Ops responded with 
${r.length} Origins by identifier ${idOrName}`);
+   }
+   return r[0];
+   }
+   return this.get>(path).toPromise();
+   }
+
+   /**
+* Gets all Origins used by specific database table.
+*
+* @param useInTable The database table for which to retrieve Origins.
+* @returns The requested Origins.
+*/
+   public async getOriginsInTable(useInTable: UseInTable): 
Promise> {

Review Comment:
   This method shouldn't exist, it doesn't appear to actually relate to Origins 
at all.



##
experimental/traffic-portal/src/app/api/origin.service.ts:
##
@@ -0,0 +1,128 @@
+/*
+* 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 { HttpClient } from "@angular/common/http";
+import { Injectable } from "@angular/core";
+import {RequestOrigin, ResponseOrigin} from "trafficops-types/dist/origin";
+
+import { APIService } from "./base-api.service";
+
+/** The allowed values for the 'useInTables' query parameter of GET requests 
to /origins. */
+type UseInTable = "cachegroup" |

Review Comment:
   you shouldn't need this type



##
experimental/traffic-portal/src/app/api/origin.service.ts:
##
@@ -0,0 +1,128 @@
+/*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the 

Re: [PR] Add Origins page Traffic Portal v2 [trafficcontrol]

2023-12-05 Thread via GitHub


codecov[bot] commented on PR #7881:
URL: https://github.com/apache/trafficcontrol/pull/7881#issuecomment-1840458330

   ## 
[Codecov](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881?src=pr=h1_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 Report
   Attention: `24 lines` in your changes are missing coverage. Please review.
   > Comparison is base 
[(`80255a0`)](https://app.codecov.io/gh/apache/trafficcontrol/commit/80255a0907c7f8510f228fcbe89de0c636c23ed1?el=desc_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 31.83% compared to head 
[(`ced1c98`)](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881?src=pr=desc_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 65.53%.
   > Report is 2 commits behind head on master.
   
   | 
[Files](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881?src=pr=tree_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...ental/traffic-portal/src/app/api/origin.service.ts](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881?src=pr=tree_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache#diff-ZXhwZXJpbWVudGFsL3RyYWZmaWMtcG9ydGFsL3NyYy9hcHAvYXBpL29yaWdpbi5zZXJ2aWNlLnRz)
 | 4.00% | [24 Missing :warning: 
](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881?src=pr=tree_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 |
   
   Additional details and impacted files
   
   
   ```diff
   @@  Coverage Diff  @@
   ## master#7881   +/-   ##
   =
   + Coverage 31.83%   65.53%   +33.69% 
 Complexity   98   98   
   =
 Files   719  324  -395 
 Lines 8272612861-69865 
 Branches970  974+4 
   =
   - Hits  26336 8428-17908 
   + Misses54233 4074-50159 
   + Partials   2157  359 -1798 
   ```
   
   | 
[Flag](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881/flags?src=pr=flags_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[golib_unit](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881/flags?src=pr=flag_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 | `?` | |
   | 
[grove_unit](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881/flags?src=pr=flag_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 | `?` | |
   | 
[t3c_unit](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881/flags?src=pr=flag_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 | `?` | |
   | 
[traffic_monitor_unit](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881/flags?src=pr=flag_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 | `?` | |
   | 
[traffic_ops_unit](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881/flags?src=pr=flag_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 | `?` | |
   | 
[traffic_portal_v2](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881/flags?src=pr=flag_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 | `74.05% <4.00%> (-0.28%)` | :arrow_down: |
   | 
[traffic_stats_unit](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881/flags?src=pr=flag_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 | `?` | |
   | 
[unit_tests](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881/flags?src=pr=flag_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 | `74.05% <4.00%> (+44.89%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click 
here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache#carryforward-flags-in-the-pull-request-comment)
 to find out more.
   
   
   
   
   [:umbrella: View full report in Codecov by 
Sentry](https://app.codecov.io/gh/apache/trafficcontrol/pull/7881?src=pr=continue_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache).
   
   :loudspeaker: Have feedback on the report? [Share it 
here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache).
   


-- 
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-unsubscr...@trafficcontrol.apache.org

For queries about