Skip to content

Commit 892dc90

Browse files
committed
fix(hotfix): fix build item functionality
1 parent 30cf8ac commit 892dc90

File tree

4 files changed

+28
-46
lines changed

4 files changed

+28
-46
lines changed

src/app/components/app-build-item/app-build-item.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<span class="build-time">{{ build?.totalTime }}</span>
2626
</div>
2727
<div class="column is-1 justify-end">
28-
<span class="icon restart-build" (click)="restartBuild($event, build.id)" [class.disabled]="build.processingRequest">
28+
<span class="icon restart-build" (click)="restartBuild($event, build.id)" [class.disabled]="processingRequest">
2929
<svg width="15px" height="14px" viewBox="0 0 15 14" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3030
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3131
<g id="icon" fill-rule="nonzero" fill="#FFFFFF">
@@ -34,7 +34,7 @@
3434
</g>
3535
</svg>
3636
</span>
37-
<span class="icon stop-build" (click)="stopBuild($event, build.id)" [class.disabled]="build.processingRequest">
37+
<span class="icon stop-build" (click)="stopBuild($event, build.id)" [class.disabled]="processingRequest">
3838
<svg width="44px" height="44px" viewBox="0 0 44 44" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3939
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
4040
<g id="cancel-2" fill-rule="nonzero" fill="#FFFFFF">
Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Component, Input, HostBinding } from '@angular/core';
1+
import { Component, Input, HostBinding, OnInit } from '@angular/core';
2+
import { SocketService } from '../../services/socket.service';
23

34
@Component({
45
selector: 'app-build-item',
@@ -7,4 +8,28 @@ import { Component, Input, HostBinding } from '@angular/core';
78
export class AppBuildItemComponent {
89
@Input() build: any;
910
@HostBinding('class') classes = 'column is-12';
11+
12+
processingRequest: boolean;
13+
14+
constructor(private socketService: SocketService) { }
15+
16+
ngOnInit() {
17+
this.socketService.outputEvents
18+
.filter(x => x.type === 'buildRestarted' || x.type === 'buildStopped')
19+
.subscribe(e => this.processingRequest = false);
20+
}
21+
22+
restartBuild(e: MouseEvent, id: number): void {
23+
e.preventDefault();
24+
e.stopPropagation();
25+
this.processingRequest = true;
26+
this.socketService.emit({ type: 'restartBuild', data: { buildId: id } });
27+
}
28+
29+
stopBuild(e: MouseEvent, id: number): void {
30+
e.preventDefault();
31+
e.stopPropagation();
32+
this.processingRequest = true;
33+
this.socketService.emit({ type: 'stopBuild', data: { buildId: id } });
34+
}
1035
}

src/app/components/app-builds/app-builds.component.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ export class AppBuildsComponent implements OnInit, OnDestroy {
3636
return;
3737
}
3838

39-
if (event.type === 'buildRestarted' || event.type === 'buildStopped') {
40-
const buildIndex = this.builds.findIndex(build => build.id === event.data);
41-
this.builds[buildIndex].processingRequest = false;
42-
}
43-
4439
if (event.data === 'jobAdded') {
4540
this.show = 5;
4641
this.offset = 0;
@@ -85,7 +80,6 @@ export class AppBuildsComponent implements OnInit, OnDestroy {
8580

8681
fetch(): void {
8782
this.apiService.getBuilds(this.show, this.offset).subscribe(builds => {
88-
console.log(builds);
8983
this.builds = builds;
9084
this.updateJobs();
9185
setInterval(() => this.updateJobs(), 1000);
@@ -147,22 +141,6 @@ export class AppBuildsComponent implements OnInit, OnDestroy {
147141
});
148142
}
149143

150-
restartBuild(e: MouseEvent, id: number): void {
151-
e.preventDefault();
152-
e.stopPropagation();
153-
const buildIndex = this.builds.findIndex(build => build.id === id);
154-
this.builds[buildIndex].processingRequest = true;
155-
this.socketService.emit({ type: 'restartBuild', data: { buildId: id } });
156-
}
157-
158-
stopBuild(e: MouseEvent, id: number): void {
159-
e.preventDefault();
160-
e.stopPropagation();
161-
const buildIndex = this.builds.findIndex(build => build.id === id);
162-
this.builds[buildIndex].processingRequest = true;
163-
this.socketService.emit({ type: 'stopBuild', data: { buildId: id } });
164-
}
165-
166144
gotoBuild(buildId: number) {
167145
this.router.navigate(['build', buildId]);
168146
}

src/app/components/app-repository/app-repository.component.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ export class AppRepositoryComponent implements OnInit, OnDestroy {
4848
return;
4949
}
5050

51-
if (event.type === 'buildRestarted' || event.type === 'buildStopped') {
52-
const buildIndex = this.repo.builds.findIndex(build => build.id === event.data);
53-
this.repo.builds[buildIndex].processingRequest = false;
54-
}
55-
5651
if (event.data === 'jobAdded') {
5752
this.fetch();
5853
}
@@ -155,22 +150,6 @@ export class AppRepositoryComponent implements OnInit, OnDestroy {
155150
});
156151
}
157152

158-
restartBuild(e: MouseEvent, id: number): void {
159-
e.preventDefault();
160-
e.stopPropagation();
161-
const buildIndex = this.repo.builds.findIndex(build => build.id === id);
162-
this.repo.builds[buildIndex].processingRequest = true;
163-
this.socketService.emit({ type: 'restartBuild', data: { buildId: id } });
164-
}
165-
166-
stopBuild(e: MouseEvent, id: number): void {
167-
e.preventDefault();
168-
e.stopPropagation();
169-
const buildIndex = this.repo.builds.findIndex(build => build.id === id);
170-
this.repo.builds[buildIndex].processingRequest = true;
171-
this.socketService.emit({ type: 'stopBuild', data: { buildId: id } });
172-
}
173-
174153
gotoBuild(buildId: number) {
175154
this.router.navigate(['build', buildId]);
176155
}

0 commit comments

Comments
 (0)