Skip to content

Commit

Permalink
Development: Migrate build agents components (#9923)
Browse files Browse the repository at this point in the history
  • Loading branch information
BBesrour authored Dec 10, 2024
1 parent 3744a6d commit 32093a2
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/main/webapp/app/admin/admin.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ const ENTITY_STATES = [...adminState];
StandardizedCompetencyDetailComponent,
DeleteUsersButtonComponent,
ProfilePictureComponent,
BuildAgentSummaryComponent,
BuildAgentDetailsComponent,
],
declarations: [
AuditsComponent,
Expand All @@ -97,8 +99,6 @@ const ENTITY_STATES = [...adminState];
OrganizationManagementUpdateComponent,
LtiConfigurationComponent,
EditLtiConfigurationComponent,
BuildAgentSummaryComponent,
BuildAgentDetailsComponent,
StandardizedCompetencyEditComponent,
KnowledgeAreaEditComponent,
StandardizedCompetencyManagementComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -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'];
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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' }) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit 32093a2

Please sign in to comment.