* timers refactored into a timer service from the app.component * settings service now provides observable setting changes * slideshow is now working * commit-tracker style changed to dark look, colored lines were removed * dashboard menu order changed * slide/committracker is now animated
144 lines
5.5 KiB
TypeScript
144 lines
5.5 KiB
TypeScript
import { Component, HostBinding, OnDestroy, OnInit } from '@angular/core';
|
|
import { Title } from '@angular/platform-browser';
|
|
import { ActivatedRoute } from '@angular/router';
|
|
import { Subscription } from 'rxjs/Subscription';
|
|
import { TimerObservable } from 'rxjs/observable/TimerObservable';
|
|
|
|
import { slideInOutAnimation } from '../../shared/slide-in-out-animation';
|
|
import { CommitTrackerService } from '../../shared/service/commit-tracker.service';
|
|
import { SettingsService } from '../../shared/service/settings.service';
|
|
import { Commit } from '../../shared/commit';
|
|
import { CommitStatus } from '../../shared/commit-status.enum';
|
|
import { Result } from '../../shared/result.enum';
|
|
import { Build } from '../../shared/build';
|
|
|
|
const TIMER_COMMITTRACKER_REFRESH = 10000;
|
|
|
|
@Component({
|
|
selector: 'app-commit-tracker',
|
|
templateUrl: './commit-tracker.component.html',
|
|
styleUrls: ['./commit-tracker.component.css'],
|
|
animations: [slideInOutAnimation]
|
|
})
|
|
export class CommitTrackerComponent implements OnInit, OnDestroy {
|
|
|
|
public CommitStatus = CommitStatus;
|
|
private refreshCommitTrackerTimer: Subscription;
|
|
|
|
@HostBinding('@slideInOutAnimation')
|
|
slideIn = false;
|
|
|
|
constructor(private commitTrackerService: CommitTrackerService,
|
|
private settings: SettingsService,
|
|
private titleService: Title,
|
|
private route: ActivatedRoute) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.titleService.setTitle('Commit-tracker : MTAStv');
|
|
this.route.data.subscribe((data: { commits: Array<Commit> }) => this.commits = data.commits);
|
|
|
|
const timerCT = TimerObservable.create(TIMER_COMMITTRACKER_REFRESH, TIMER_COMMITTRACKER_REFRESH);
|
|
this.refreshCommitTrackerTimer = timerCT.subscribe(() => {
|
|
this.commitTrackerService.getTeamCommits(this.settings.team.members.map(member => member.signum))
|
|
.subscribe(commits => this.commits = commits);
|
|
});
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.refreshCommitTrackerTimer.unsubscribe();
|
|
}
|
|
|
|
get commits(): Array<Commit> {
|
|
return this.commitTrackerService.commits;
|
|
}
|
|
|
|
set commits(commits: Array<Commit>) {
|
|
this.commitTrackerService.commits = commits;
|
|
}
|
|
|
|
public labelClasses(commit: Commit, commitStatus: String) {
|
|
const classes: Object = {
|
|
ui: true,
|
|
big: true,
|
|
circular: true,
|
|
label: true,
|
|
};
|
|
|
|
switch (commitStatus) {
|
|
case CommitStatus.Verified:
|
|
return Object.assign(classes, {
|
|
green: commit.gerrit_verified === 1,
|
|
red: commit.gerrit_verified === -1,
|
|
});
|
|
case CommitStatus.CodeReview:
|
|
return Object.assign(classes, {
|
|
green: commit.gerrit_code_review === 2,
|
|
yellow: commit.gerrit_code_review === 1 || commit.gerrit_code_review === -1,
|
|
red: commit.gerrit_code_review === -2,
|
|
});
|
|
case CommitStatus.CommitFeedbackLoop:
|
|
return Object.assign(classes, {
|
|
'blue inprogress': commit.cfl_result === Result.Building,
|
|
'blue-yellow inprogress': commit.cfl_result === Result.Building
|
|
&& this.hasSubbuildWithCode(commit.cfl_sub_builds, Result.Unstable),
|
|
'blue-red inprogress': commit.cfl_result === Result.Building
|
|
&& this.hasSubbuildWithCode(commit.cfl_sub_builds, Result.Failure),
|
|
green: commit.cfl_result === Result.Success,
|
|
grey: commit.cfl_result === Result.Aborted,
|
|
yellow: commit.cfl_result === Result.Unstable,
|
|
red: commit.cfl_result === Result.Failure,
|
|
brown: commit.cfl_result === Result.NotBuilt,
|
|
});
|
|
case CommitStatus.ShortFeedbackLoop:
|
|
return Object.assign(classes, {
|
|
'blue inprogress': commit.sfl_result === Result.Building,
|
|
'blue-yellow inprogress': commit.sfl_result === Result.Building
|
|
&& this.hasSubbuildWithCode(commit.sfl_sub_builds, Result.Unstable),
|
|
'blue-red inprogress': commit.sfl_result === Result.Building
|
|
&& this.hasSubbuildWithCode(commit.sfl_sub_builds, Result.Failure),
|
|
green: commit.sfl_result === Result.Success,
|
|
grey: commit.sfl_result === Result.Aborted,
|
|
yellow: commit.sfl_result === Result.Unstable,
|
|
red: commit.sfl_result === Result.Failure,
|
|
brown: commit.sfl_result === Result.NotBuilt,
|
|
});
|
|
case CommitStatus.NightlyFeedbackLoop:
|
|
return Object.assign(classes, {
|
|
'blue inprogress': commit.nfl_result === Result.Building,
|
|
'blue-yellow inprogress': commit.nfl_result === Result.Building
|
|
&& this.hasSubbuildWithCode(commit.nfl_sub_builds, Result.Unstable),
|
|
'blue-red inprogress': commit.nfl_result === Result.Building
|
|
&& this.hasSubbuildWithCode(commit.nfl_sub_builds, Result.Failure),
|
|
green: commit.nfl_result === Result.Success,
|
|
grey: commit.nfl_result === Result.Aborted,
|
|
yellow: commit.nfl_result === Result.Unstable,
|
|
red: commit.nfl_result === Result.Failure,
|
|
brown: commit.nfl_result === Result.NotBuilt,
|
|
});
|
|
default:
|
|
return classes;
|
|
}
|
|
}
|
|
|
|
private hasSubbuildWithCode(build: Build, status: Result): boolean {
|
|
if (build === null) {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
return build.build.subBuild.some(subBuild => {
|
|
let thing = false;
|
|
if (subBuild.build.subBuild) {
|
|
thing = subBuild.build.subBuild.some(subSubBuild => this.hasSubbuildWithCode(
|
|
subSubBuild, status
|
|
));
|
|
}
|
|
return subBuild.result === status || thing;
|
|
});
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|