From f50df4226d23d75296c1baa54a86210597baa2c6 Mon Sep 17 00:00:00 2001 From: simon987 Date: Sat, 9 Mar 2019 14:16:14 -0500 Subject: [PATCH] Apply CodeRefactor manual fixes --- Dockerfile | 4 +-- api/task.go | 2 +- jenkins/Jenkinsfile | 1 + web/angular/src/app/api.service.ts | 3 +- web/angular/src/app/app-routing.module.ts | 2 +- web/angular/src/app/app.component.css | 3 -- web/angular/src/app/app.component.html | 28 +++++++-------- web/angular/src/app/login/login.component.ts | 2 +- web/angular/src/app/logs/logs.component.css | 4 --- .../manager-list/manager-list.component.ts | 4 +-- .../manager-select.component.html | 2 +- web/angular/src/app/models/manager.ts | 8 ++--- .../project-dashboard.component.ts | 34 +++++++++---------- .../project-list/project-list.component.html | 4 +-- .../project-perms.component.html | 2 +- .../project-perms/project-perms.component.ts | 4 +-- .../project-select.component.html | 2 +- 17 files changed, 51 insertions(+), 58 deletions(-) diff --git a/Dockerfile b/Dockerfile index 310db2f..ea9861e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ # Build -FROM golang:latest as go_build +FROM golang:1.11.5 as go_build WORKDIR /go/src/github.com/simon987/task_tracker/ COPY . . RUN go get ./main/ && GOOS=linux CGO_ENABLED=0 go build -a -installsuffix cgo -o tt_api ./main/ # Execute in alpine -FROM alpine:latest +FROM alpine:3.9.2 WORKDIR /root COPY --from=go_build ["/go/src/github.com/simon987/task_tracker/tt_api",\ diff --git a/api/task.go b/api/task.go index f01cea6..7c71a15 100644 --- a/api/task.go +++ b/api/task.go @@ -138,7 +138,7 @@ func (api *WebAPI) GetTaskFromProject(r *Request) { }) } -func (api WebAPI) validateSignature(r *Request) (*storage.Worker, error) { +func (api *WebAPI) validateSignature(r *Request) (*storage.Worker, error) { widStr := string(r.Ctx.Request.Header.Peek("X-Worker-Id")) timeStampStr := string(r.Ctx.Request.Header.Peek("Timestamp")) diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index 678679d..501704a 100644 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -36,6 +36,7 @@ pipeline { agent { docker { image 'golang:latest' + args '--network "host"' } } steps { diff --git a/web/angular/src/app/api.service.ts b/web/angular/src/app/api.service.ts index 0177ab1..93f26ac 100755 --- a/web/angular/src/app/api.service.ts +++ b/web/angular/src/app/api.service.ts @@ -6,8 +6,7 @@ import {Credentials} from './models/credentials'; @Injectable() export class ApiService { - // public url: string = window.location.protocol + "//" + window.location.hostname + "/api"; - public url = 'https://tt.simon987.net/api'; + public url: string = window.location.protocol + '//' + window.location.hostname + '/api'; private options: { withCredentials: true, responseType: 'json' diff --git a/web/angular/src/app/app-routing.module.ts b/web/angular/src/app/app-routing.module.ts index d34ef69..af504a7 100755 --- a/web/angular/src/app/app-routing.module.ts +++ b/web/angular/src/app/app-routing.module.ts @@ -52,7 +52,7 @@ export class AppRoutingModule { private updateTitle(tr: TranslateService, title: Title, url: string) { url = url.substr(1); - tr.get('title.' + url.substring(0, url.indexOf('/') == -1 ? url.length : url.indexOf('/'))) + tr.get('title.' + url.substring(0, url.indexOf('/') === -1 ? url.length : url.indexOf('/'))) .subscribe((t) => title.setTitle(t)); } } diff --git a/web/angular/src/app/app.component.css b/web/angular/src/app/app.component.css index b1851ff..983073e 100755 --- a/web/angular/src/app/app.component.css +++ b/web/angular/src/app/app.component.css @@ -2,9 +2,6 @@ padding: 0 14px; } -.nav-link { -} - .large-nav { display: none; } diff --git a/web/angular/src/app/app.component.html b/web/angular/src/app/app.component.html index 61c121b..c7fce61 100755 --- a/web/angular/src/app/app.component.html +++ b/web/angular/src/app/app.component.html @@ -1,17 +1,17 @@
- - - - - - @@ -21,28 +21,28 @@ more_vert - - - - - -
- - diff --git a/web/angular/src/app/login/login.component.ts b/web/angular/src/app/login/login.component.ts index d148934..6a4b6af 100644 --- a/web/angular/src/app/login/login.component.ts +++ b/web/angular/src/app/login/login.component.ts @@ -33,6 +33,6 @@ export class LoginComponent implements OnInit { canCreate(): boolean { return this.credentials.username && this.credentials.username != '' && - this.credentials.password == this.credentials.repeatPassword; + this.credentials.password === this.credentials.repeatPassword; } } diff --git a/web/angular/src/app/logs/logs.component.css b/web/angular/src/app/logs/logs.component.css index 2a9d42e..8394c8f 100644 --- a/web/angular/src/app/logs/logs.component.css +++ b/web/angular/src/app/logs/logs.component.css @@ -1,7 +1,3 @@ -.table-container { - /*height: 600px;*/ -} - .mat-table { height: 100%; overflow: scroll; diff --git a/web/angular/src/app/manager-list/manager-list.component.ts b/web/angular/src/app/manager-list/manager-list.component.ts index 0281513..888c674 100644 --- a/web/angular/src/app/manager-list/manager-list.component.ts +++ b/web/angular/src/app/manager-list/manager-list.component.ts @@ -42,7 +42,7 @@ export class ManagerListComponent implements OnInit { } canDemote(manager: Manager) { - return manager.tracker_admin && manager.username != this.authService.account.username; + return manager.tracker_admin && manager.username !== this.authService.account.username; } public promote(manager: Manager) { @@ -61,7 +61,7 @@ export class ManagerListComponent implements OnInit { this.data.data = data['content']['managers']; }, error => { - if (error && (error.status == 401 || error.status == 403)) { + if (error && (error.status === 401 || error.status === 403)) { console.log(error.error.message); this.translate.get('manager_list.unauthorized') .subscribe(t => this.messengerService.show(t)); diff --git a/web/angular/src/app/manager-select/manager-select.component.html b/web/angular/src/app/manager-select/manager-select.component.html index a2bcb05..27d2a8f 100644 --- a/web/angular/src/app/manager-select/manager-select.component.html +++ b/web/angular/src/app/manager-select/manager-select.component.html @@ -4,7 +4,7 @@ [placeholder]="'perms.manager_select' | translate" (opened)="loadManagerList()"> - + {{"project_select.loading" | translate}} diff --git a/web/angular/src/app/models/manager.ts b/web/angular/src/app/models/manager.ts index 105a729..42d512c 100644 --- a/web/angular/src/app/models/manager.ts +++ b/web/angular/src/app/models/manager.ts @@ -17,7 +17,7 @@ export class ManagerRoleOnProject { } get readRole(): boolean { - return (this.role & 1) != 0; + return (this.role & 1) !== 0; } set readRole(role: boolean) { @@ -29,7 +29,7 @@ export class ManagerRoleOnProject { } get editRole(): boolean { - return (this.role & 2) != 0; + return (this.role & 2) !== 0; } set editRole(role: boolean) { @@ -41,7 +41,7 @@ export class ManagerRoleOnProject { } get manageRole(): boolean { - return (this.role & 4) != 0; + return (this.role & 4) !== 0; } set manageRole(role: boolean) { @@ -53,7 +53,7 @@ export class ManagerRoleOnProject { } get secretRole(): boolean { - return (this.role & 8) != 0; + return (this.role & 8) !== 0; } set secretRole(role: boolean) { diff --git a/web/angular/src/app/project-dashboard/project-dashboard.component.ts b/web/angular/src/app/project-dashboard/project-dashboard.component.ts index 2f58335..1bfa41e 100644 --- a/web/angular/src/app/project-dashboard/project-dashboard.component.ts +++ b/web/angular/src/app/project-dashboard/project-dashboard.component.ts @@ -66,7 +66,7 @@ export class ProjectDashboardComponent implements OnInit { } public isSafeUrl(url: string) { - if (url.substr(0, 'http'.length) == 'http') { + if (url.substr(0, 'http'.length) === 'http') { return true; } } @@ -82,10 +82,10 @@ export class ProjectDashboardComponent implements OnInit { return b.time_stamp - a.time_stamp; })[0] : null; - if (this.lastSnapshot == null || (this.lastSnapshot.awaiting_verification_count == 0 && - this.lastSnapshot.closed_task_count == 0 && - this.lastSnapshot.new_task_count == 0 && - this.lastSnapshot.failed_task_count == 0)) { + if (this.lastSnapshot === null || (this.lastSnapshot.awaiting_verification_count === 0 && + this.lastSnapshot.closed_task_count === 0 && + this.lastSnapshot.new_task_count === 0 && + this.lastSnapshot.failed_task_count === 0)) { this.noTasks = true; return; } @@ -114,8 +114,8 @@ export class ProjectDashboardComponent implements OnInit { this.statusPie.update(); this.apiService.getAssigneeStats(this.projectId) - .subscribe((data: any) => { - this.assignees = data.content.assignees; + .subscribe((statsData: any) => { + this.assignees = statsData.content.assignees; const colors = this.assignees.map(() => { return this.colors.random[Math.floor(Math.random() * this.colors.random.length)]; }); @@ -218,10 +218,10 @@ export class ProjectDashboardComponent implements OnInit { private setupStatusPie() { - if (this.lastSnapshot == undefined || (this.lastSnapshot.awaiting_verification_count == 0 && - this.lastSnapshot.closed_task_count == 0 && - this.lastSnapshot.new_task_count == 0 && - this.lastSnapshot.failed_task_count == 0)) { + if (this.lastSnapshot === undefined || (this.lastSnapshot.awaiting_verification_count === 0 && + this.lastSnapshot.closed_task_count === 0 && + this.lastSnapshot.new_task_count === 0 && + this.lastSnapshot.failed_task_count === 0)) { this.noTasks = true; this.lastSnapshot = { @@ -324,8 +324,8 @@ export class ProjectDashboardComponent implements OnInit { this.project = data.content.project; this.apiService.getMonitoringSnapshots(60, this.projectId) - .subscribe((data: any) => { - this.snapshots = data.content.snapshots; + .subscribe((monitoringData: any) => { + this.snapshots = monitoringData.content.snapshots; this.lastSnapshot = this.snapshots ? this.snapshots.sort((a, b) => { return b.time_stamp - a.time_stamp; })[0] : null; @@ -338,8 +338,8 @@ export class ProjectDashboardComponent implements OnInit { } this.apiService.getAssigneeStats(this.projectId) - .subscribe((data: any) => { - this.assignees = data.content.assignees; + .subscribe((assigneeData: any) => { + this.assignees = assigneeData.content.assignees; this.setupAssigneesPie(); }); @@ -387,7 +387,7 @@ export class ProjectDashboardComponent implements OnInit { return NaN; } else { return xs.reduce( - ([acc, last], x) => [acc + (x - last), x], + ([acc, last], y) => [acc + (y - last), y], [0, x] ) [0] / xs.length; } @@ -395,7 +395,7 @@ export class ProjectDashboardComponent implements OnInit { const interval = this.snapshots.length > 1 ? this.snapshots[0].time_stamp - this.snapshots[1].time_stamp : 0; - if (interval != 0) { + if (interval !== 0) { this.avgTask = averageDelta(this.snapshots.reverse().map(s => s.closed_task_count) as any) / interval; } else { return 0; diff --git a/web/angular/src/app/project-list/project-list.component.html b/web/angular/src/app/project-list/project-list.component.html index b530eaf..7714bb3 100755 --- a/web/angular/src/app/project-list/project-list.component.html +++ b/web/angular/src/app/project-list/project-list.component.html @@ -37,11 +37,11 @@ {{"project.secret" | translate}} - + {{"projects.empty" | translate}} + *ngIf="projects === null"> diff --git a/web/angular/src/app/project-perms/project-perms.component.html b/web/angular/src/app/project-perms/project-perms.component.html index 5465358..9a0d58d 100644 --- a/web/angular/src/app/project-perms/project-perms.component.html +++ b/web/angular/src/app/project-perms/project-perms.component.html @@ -33,7 +33,7 @@ -

{{"perms.no_workers"|translate}}

+

{{"perms.no_workers"|translate}}

{{"perms.managers" | translate}}

diff --git a/web/angular/src/app/project-perms/project-perms.component.ts b/web/angular/src/app/project-perms/project-perms.component.ts index d1fe594..cf11612 100644 --- a/web/angular/src/app/project-perms/project-perms.component.ts +++ b/web/angular/src/app/project-perms/project-perms.component.ts @@ -68,7 +68,7 @@ export class ProjectPermsComponent implements OnInit { this.accesses = data['content']['accesses']; }, error => { - if (error && (error.status == 401 || error.status == 403)) { + if (error && (error.status === 401 || error.status === 403)) { this.unauthorized = true; } }); @@ -88,7 +88,7 @@ export class ProjectPermsComponent implements OnInit { } public onSelectManager(manager: Manager) { - if (manager.id != this.auth.account.id) { + if (manager.id !== this.auth.account.id) { this.apiService.setManagerRoleOnProject(this.projectId, 1, manager.id) .subscribe(() => this.refresh()); } diff --git a/web/angular/src/app/project-select/project-select.component.html b/web/angular/src/app/project-select/project-select.component.html index 60e7c37..570adbe 100644 --- a/web/angular/src/app/project-select/project-select.component.html +++ b/web/angular/src/app/project-select/project-select.component.html @@ -4,7 +4,7 @@ [placeholder]="'project.chain' | translate" (opened)="loadProjectList()"> {{project?.name}} - + {{"project_select.loading" | translate}}