From 32093a29dfafad13d25ad200cbcc00e1d2dfd3e4 Mon Sep 17 00:00:00 2001 From: Mohamed Bilel Besrour <58034472+BBesrour@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:55:51 +0100 Subject: [PATCH] Development: Migrate build agents components (#9923) --- src/main/webapp/app/admin/admin.module.ts | 4 ++-- .../build-agent-details.component.ts | 22 ++++++++++-------- .../build-agent-summary.component.ts | 23 +++++++++++-------- .../build-agents/build-agents.service.ts | 4 ++-- .../build-agent-details.component.spec.ts | 8 +++---- .../build-agent-summary.component.spec.ts | 8 +++---- 6 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/main/webapp/app/admin/admin.module.ts b/src/main/webapp/app/admin/admin.module.ts index 28283dd58512..1d5d5e8314ed 100644 --- a/src/main/webapp/app/admin/admin.module.ts +++ b/src/main/webapp/app/admin/admin.module.ts @@ -75,6 +75,8 @@ const ENTITY_STATES = [...adminState]; StandardizedCompetencyDetailComponent, DeleteUsersButtonComponent, ProfilePictureComponent, + BuildAgentSummaryComponent, + BuildAgentDetailsComponent, ], declarations: [ AuditsComponent, @@ -97,8 +99,6 @@ const ENTITY_STATES = [...adminState]; OrganizationManagementUpdateComponent, LtiConfigurationComponent, EditLtiConfigurationComponent, - BuildAgentSummaryComponent, - BuildAgentDetailsComponent, StandardizedCompetencyEditComponent, KnowledgeAreaEditComponent, StandardizedCompetencyManagementComponent, diff --git a/src/main/webapp/app/localci/build-agents/build-agent-details/build-agent-details/build-agent-details.component.ts b/src/main/webapp/app/localci/build-agents/build-agent-details/build-agent-details/build-agent-details.component.ts index 1408b83c2495..3f1b1628d951 100644 --- a/src/main/webapp/app/localci/build-agents/build-agent-details/build-agent-details/build-agent-details.component.ts +++ b/src/main/webapp/app/localci/build-agents/build-agent-details/build-agent-details/build-agent-details.component.ts @@ -1,4 +1,4 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, OnDestroy, OnInit, inject } from '@angular/core'; import { BuildAgentInformation } from 'app/entities/programming/build-agent-information.model'; import { BuildAgentsService } from 'app/localci/build-agents/build-agents.service'; import { Subscription } from 'rxjs'; @@ -9,13 +9,25 @@ import { ActivatedRoute } from '@angular/router'; import { JhiWebsocketService } from 'app/core/websocket/websocket.service'; import { BuildQueueService } from 'app/localci/build-queue/build-queue.service'; import { AlertService, AlertType } from 'app/core/util/alert.service'; +import { ArtemisSharedModule } from 'app/shared/shared.module'; +import { ArtemisDataTableModule } from 'app/shared/data-table/data-table.module'; +import { NgxDatatableModule } from '@siemens/ngx-datatable'; +import { SubmissionResultStatusModule } from 'app/overview/submission-result-status.module'; @Component({ selector: 'jhi-build-agent-details', templateUrl: './build-agent-details.component.html', styleUrl: './build-agent-details.component.scss', + standalone: true, + imports: [ArtemisSharedModule, NgxDatatableModule, ArtemisDataTableModule, SubmissionResultStatusModule], }) export class BuildAgentDetailsComponent implements OnInit, OnDestroy { + private readonly websocketService = inject(JhiWebsocketService); + private readonly buildAgentsService = inject(BuildAgentsService); + private readonly route = inject(ActivatedRoute); + private readonly buildQueueService = inject(BuildQueueService); + private readonly alertService = inject(AlertService); + protected readonly TriggeredByPushTo = TriggeredByPushTo; buildAgent: BuildAgentInformation; agentName: string; @@ -32,14 +44,6 @@ export class BuildAgentDetailsComponent implements OnInit, OnDestroy { readonly faPause = faPause; readonly faPlay = faPlay; - constructor( - private websocketService: JhiWebsocketService, - private buildAgentsService: BuildAgentsService, - private route: ActivatedRoute, - private buildQueueService: BuildQueueService, - private alertService: AlertService, - ) {} - ngOnInit() { this.paramSub = this.route.queryParams.subscribe((params) => { this.agentName = params['agentName']; diff --git a/src/main/webapp/app/localci/build-agents/build-agent-summary/build-agent-summary.component.ts b/src/main/webapp/app/localci/build-agents/build-agent-summary/build-agent-summary.component.ts index 5e79ceac3c75..b3a9e8fcf5c8 100644 --- a/src/main/webapp/app/localci/build-agents/build-agent-summary/build-agent-summary.component.ts +++ b/src/main/webapp/app/localci/build-agents/build-agent-summary/build-agent-summary.component.ts @@ -1,4 +1,4 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, OnDestroy, OnInit, inject } from '@angular/core'; import { BuildAgentInformation, BuildAgentStatus } from 'app/entities/programming/build-agent-information.model'; import { JhiWebsocketService } from 'app/core/websocket/websocket.service'; import { BuildAgentsService } from 'app/localci/build-agents/build-agents.service'; @@ -9,13 +9,25 @@ import { Router } from '@angular/router'; import { BuildAgent } from 'app/entities/programming/build-agent.model'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { AlertService, AlertType } from 'app/core/util/alert.service'; +import { ArtemisSharedModule } from 'app/shared/shared.module'; +import { ArtemisDataTableModule } from 'app/shared/data-table/data-table.module'; +import { NgxDatatableModule } from '@siemens/ngx-datatable'; @Component({ selector: 'jhi-build-agents', + standalone: true, templateUrl: './build-agent-summary.component.html', styleUrl: './build-agent-summary.component.scss', + imports: [ArtemisSharedModule, NgxDatatableModule, ArtemisDataTableModule], }) export class BuildAgentSummaryComponent implements OnInit, OnDestroy { + private readonly websocketService = inject(JhiWebsocketService); + private readonly buildAgentsService = inject(BuildAgentsService); + private readonly buildQueueService = inject(BuildQueueService); + private readonly router = inject(Router); + private readonly modalService = inject(NgbModal); + private readonly alertService = inject(AlertService); + buildAgents: BuildAgentInformation[] = []; buildCapacity = 0; currentBuilds = 0; @@ -29,15 +41,6 @@ export class BuildAgentSummaryComponent implements OnInit, OnDestroy { protected readonly faPause = faPause; protected readonly faPlay = faPlay; - constructor( - private websocketService: JhiWebsocketService, - private buildAgentsService: BuildAgentsService, - private buildQueueService: BuildQueueService, - private router: Router, - private modalService: NgbModal, - private alertService: AlertService, - ) {} - ngOnInit() { this.routerLink = this.router.url; this.load(); diff --git a/src/main/webapp/app/localci/build-agents/build-agents.service.ts b/src/main/webapp/app/localci/build-agents/build-agents.service.ts index c3b388586bcf..bfe25213e61c 100644 --- a/src/main/webapp/app/localci/build-agents/build-agents.service.ts +++ b/src/main/webapp/app/localci/build-agents/build-agents.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable, throwError } from 'rxjs'; import { BuildAgentInformation } from 'app/entities/programming/build-agent-information.model'; @@ -8,7 +8,7 @@ import { catchError } from 'rxjs/operators'; export class BuildAgentsService { public adminResourceUrl = 'api/admin'; - constructor(private http: HttpClient) {} + private readonly http = inject(HttpClient); /** * Get all build agents diff --git a/src/test/javascript/spec/component/localci/build-agents/build-agent-details.component.spec.ts b/src/test/javascript/spec/component/localci/build-agents/build-agent-details.component.spec.ts index 0b14d136c97c..606bc59a0ed8 100644 --- a/src/test/javascript/spec/component/localci/build-agents/build-agent-details.component.spec.ts +++ b/src/test/javascript/spec/component/localci/build-agents/build-agent-details.component.spec.ts @@ -5,10 +5,8 @@ import { of, throwError } from 'rxjs'; import { BuildJob } from 'app/entities/programming/build-job.model'; import dayjs from 'dayjs/esm'; import { ArtemisTestModule } from '../../../test.module'; -import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe'; import { DataTableComponent } from 'app/shared/data-table/data-table.component'; -import { MockComponent, MockPipe, MockProvider } from 'ng-mocks'; -import { NgxDatatableModule } from '@siemens/ngx-datatable'; +import { MockProvider } from 'ng-mocks'; import { BuildAgentInformation, BuildAgentStatus } from '../../../../../../main/webapp/app/entities/programming/build-agent-information.model'; import { RepositoryInfo, TriggeredByPushTo } from 'app/entities/programming/repository-info.model'; import { JobTimingInfo } from 'app/entities/job-timing-info.model'; @@ -125,8 +123,8 @@ describe('BuildAgentDetailsComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ - imports: [ArtemisTestModule, NgxDatatableModule], - declarations: [BuildAgentDetailsComponent, MockPipe(ArtemisTranslatePipe), MockComponent(DataTableComponent)], + imports: [ArtemisTestModule], + declarations: [], providers: [ { provide: JhiWebsocketService, useValue: mockWebsocketService }, { provide: ActivatedRoute, useValue: new MockActivatedRoute({ key: 'ABC123' }) }, diff --git a/src/test/javascript/spec/component/localci/build-agents/build-agent-summary.component.spec.ts b/src/test/javascript/spec/component/localci/build-agents/build-agent-summary.component.spec.ts index f71ad2c8d920..0d798185a915 100644 --- a/src/test/javascript/spec/component/localci/build-agents/build-agent-summary.component.spec.ts +++ b/src/test/javascript/spec/component/localci/build-agents/build-agent-summary.component.spec.ts @@ -6,10 +6,8 @@ import { of, throwError } from 'rxjs'; import { BuildJob } from 'app/entities/programming/build-job.model'; import dayjs from 'dayjs/esm'; import { ArtemisTestModule } from '../../../test.module'; -import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe'; import { DataTableComponent } from 'app/shared/data-table/data-table.component'; -import { MockComponent, MockPipe, MockProvider } from 'ng-mocks'; -import { NgxDatatableModule } from '@siemens/ngx-datatable'; +import { MockProvider } from 'ng-mocks'; import { BuildAgentInformation, BuildAgentStatus } from '../../../../../../main/webapp/app/entities/programming/build-agent-information.model'; import { RepositoryInfo, TriggeredByPushTo } from 'app/entities/programming/repository-info.model'; import { JobTimingInfo } from 'app/entities/job-timing-info.model'; @@ -143,8 +141,8 @@ describe('BuildAgentSummaryComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ - imports: [ArtemisTestModule, NgxDatatableModule], - declarations: [BuildAgentSummaryComponent, MockPipe(ArtemisTranslatePipe), MockComponent(DataTableComponent)], + imports: [ArtemisTestModule], + declarations: [], providers: [ { provide: JhiWebsocketService, useValue: mockWebsocketService }, { provide: BuildAgentsService, useValue: mockBuildAgentsService },