diff --git a/src/app/components/app-build-details/app-build-details.component.html b/src/app/components/app-build-details/app-build-details.component.html index cef2304bc..141c0a1fe 100644 --- a/src/app/components/app-build-details/app-build-details.component.html +++ b/src/app/components/app-build-details/app-build-details.component.html @@ -13,7 +13,7 @@
-
+
-
+
+ +

-
-

{{ build?.data?.pull_request?.title }}

-

{{ build?.data?.commits[build?.data?.commits.length - 1]?.message }}

-

{{ build?.data?.head_commit?.message }}

-
-
+

@@ -51,7 +56,12 @@

{{ build?.data?.head_commit?.message }}

{{ build?.data?.after.slice(0, 7) }}

-
+
+

{{ build?.data?.pull_request?.title }}

+

{{ build?.data?.commits[build?.data?.commits.length - 1]?.message }}

+

{{ build?.data?.head_commit?.message }}

+
+

@@ -112,7 +122,7 @@

{{ build?.data?.head_commit?.message }}

{{ job.time }}
- + @@ -121,7 +131,7 @@

{{ build?.data?.head_commit?.message }}

- + diff --git a/src/app/components/app-build-details/app-build-details.component.ts b/src/app/components/app-build-details/app-build-details.component.ts index 89a526140..8f86b7646 100644 --- a/src/app/components/app-build-details/app-build-details.component.ts +++ b/src/app/components/app-build-details/app-build-details.component.ts @@ -5,6 +5,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { ApiService } from '../../services/api.service'; import { SocketService } from '../../services/socket.service'; import { distanceInWordsToNow, distanceInWordsStrict, format } from 'date-fns'; +import { Subscription } from 'rxjs/Subscription'; @Component({ selector: 'app-build-details', @@ -22,6 +23,8 @@ export class AppBuildDetailsComponent implements OnInit, OnDestroy { approximatelyRemainingTime: string; tag: string = null; updateInterval: any; + subStatus: Subscription; + sub: Subscription; constructor( private socketService: SocketService, @@ -57,7 +60,7 @@ export class AppBuildDetailsComponent implements OnInit, OnDestroy { this.status = this.getBuildStatus(); this.startUpdating(); - this.socketService.outputEvents + this.subStatus = this.socketService.outputEvents .filter(event => event.type === 'process') .subscribe(event => { let index = this.build.jobs.findIndex(job => job.id === event.job_id); @@ -76,11 +79,12 @@ export class AppBuildDetailsComponent implements OnInit, OnDestroy { this.build.jobs[index].status = 'queued'; } + this.build.jobs[index].processing = false; this.status = this.getBuildStatus(); } }); - this.socketService.outputEvents + this.sub = this.socketService.outputEvents .filter(event => event.type === 'buildRestarted' || event.type === 'buildStopped') .subscribe(event => { this.processingBuild = false; @@ -90,6 +94,14 @@ export class AppBuildDetailsComponent implements OnInit, OnDestroy { } ngOnDestroy() { + if (this.sub) { + this.sub.unsubscribe(); + } + + if (this.subStatus) { + this.subStatus.unsubscribe(); + } + this.document.getElementById('favicon').setAttribute('href', 'images/favicon.png'); this.titleService.setTitle('Abstruse CI'); this.stopUpdating(); @@ -157,9 +169,9 @@ export class AppBuildDetailsComponent implements OnInit, OnDestroy { favicon = 'images/favicon.png'; } + const name = this.build.repository.full_name; this.document.getElementById('favicon').setAttribute('href', favicon); - const titleStatus = status.charAt(0).toUpperCase() + status.slice(1); - this.titleService.setTitle(`Abstruse CI - Build ${titleStatus}`); + this.titleService.setTitle(`${name} - ${status}`); return status; } @@ -168,6 +180,8 @@ export class AppBuildDetailsComponent implements OnInit, OnDestroy { e.preventDefault(); e.stopPropagation(); + const index = this.build.jobs.findIndex(job => job.id === jobId); + this.build.jobs[index].processing = true; this.socketService.emit({ type: 'restartJob', data: { jobId: jobId } }); } @@ -175,6 +189,8 @@ export class AppBuildDetailsComponent implements OnInit, OnDestroy { e.preventDefault(); e.stopPropagation(); + const index = this.build.jobs.findIndex(job => job.id === jobId); + this.build.jobs[index].processing = true; this.socketService.emit({ type: 'stopJob', data: { jobId: jobId } }); } diff --git a/src/app/components/app-builds/app-builds.component.ts b/src/app/components/app-builds/app-builds.component.ts index 6f13cca5b..5e584fb5e 100644 --- a/src/app/components/app-builds/app-builds.component.ts +++ b/src/app/components/app-builds/app-builds.component.ts @@ -13,6 +13,7 @@ export class AppBuildsComponent implements OnInit, OnDestroy { loading: boolean; fetching: boolean; hideMoreButton: boolean; + subAdded: Subscription; sub: Subscription; builds: any[]; limit: number; @@ -33,7 +34,7 @@ export class AppBuildsComponent implements OnInit, OnDestroy { ngOnInit() { this.fetch(); - this.sub = this.socketService.outputEvents + this.subAdded = this.socketService.outputEvents .filter(x => x.type !== 'data') .subscribe(event => { if (!this.builds || !event.data) { @@ -45,7 +46,7 @@ export class AppBuildsComponent implements OnInit, OnDestroy { } }); - this.socketService.outputEvents + this.sub = this.socketService.outputEvents .filter(x => { x = x.data ? x.data.toString() : ''; return x.startsWith('job'); @@ -85,7 +86,14 @@ export class AppBuildsComponent implements OnInit, OnDestroy { } ngOnDestroy() { - this.sub.unsubscribe(); + if (this.subAdded) { + this.subAdded.unsubscribe(); + } + + if (this.sub) { + this.sub.unsubscribe(); + } + this.stopUpdating(); } diff --git a/src/app/components/app-job/app-job.component.html b/src/app/components/app-job/app-job.component.html index dbfe1e864..87beb8208 100644 --- a/src/app/components/app-job/app-job.component.html +++ b/src/app/components/app-job/app-job.component.html @@ -54,11 +54,11 @@


-

{{ build?.job?.data?.pull_request?.title }}

-

{{ build?.job?.data?.commits[build?.data?.commits.length - 1]?.message }}

+

{{ job?.build?.data?.pull_request?.title }}

+

{{ job?.build?.data?.commits[job?.build?.data?.commits.length - 1]?.message }}

{{ job?.build?.data?.head_commit?.message }}

-
+

@@ -67,7 +67,7 @@

{{ job?.build?.data?.head_commit?.message }}

{{ job?.build?.data?.after.slice(0, 7) }}

-
+

diff --git a/src/app/components/app-job/app-job.component.ts b/src/app/components/app-job/app-job.component.ts index c90779757..469131ab8 100644 --- a/src/app/components/app-job/app-job.component.ts +++ b/src/app/components/app-job/app-job.component.ts @@ -117,8 +117,14 @@ export class AppJobComponent implements OnInit, OnDestroy { } ngOnDestroy() { - this.termSub.unsubscribe(); - this.sub.unsubscribe(); + if (this.termSub) { + this.termSub.unsubscribe(); + } + + if (this.sub) { + this.sub.unsubscribe(); + } + this.document.getElementById('favicon').setAttribute('href', 'images/favicon.png'); this.titleService.setTitle('Abstruse CI'); } @@ -145,8 +151,9 @@ export class AppJobComponent implements OnInit, OnDestroy { default: favicon = 'images/favicon.png'; break; } - const status = this.jobRun.status.charAt(0).toUpperCase() + this.jobRun.status.slice(1); - this.titleService.setTitle(`Abstruse CI - Job ${status}`); + const name = this.job.build.repository.full_name; + const status = this.jobRun.status; + this.titleService.setTitle(`${name} - ${status}`); this.document.getElementById('favicon').setAttribute('href', favicon); } diff --git a/src/app/styles/build-details.sass b/src/app/styles/build-details.sass index 30dd8f3ab..2ccc57f56 100644 --- a/src/app/styles/build-details.sass +++ b/src/app/styles/build-details.sass @@ -16,7 +16,7 @@ .build-top-content padding: 20px - background: linear-gradient(to bottom, $background, $background-secondary) + background: $background-secondary .ssh padding: 5px 10px