mirror of
https://github.com/simon987/task_tracker.git
synced 2025-04-10 05:56:42 +00:00
Merge pull request #3 from simon987/master-cf-autofix
Apply fixes from CodeFactor
This commit is contained in:
commit
be9bcc087a
@ -1,5 +1,5 @@
|
||||
import {MatPaginatorIntl} from "@angular/material";
|
||||
import {TranslateService} from "@ngx-translate/core";
|
||||
import {MatPaginatorIntl} from '@angular/material';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
|
||||
export function TranslatedPaginator(translate: TranslateService) {
|
||||
|
||||
@ -8,7 +8,7 @@ export function TranslatedPaginator(translate: TranslateService) {
|
||||
getTranslations(translate, paginatorIntl);
|
||||
|
||||
translate.onLangChange.subscribe(() => {
|
||||
getTranslations(translate, paginatorIntl)
|
||||
getTranslations(translate, paginatorIntl);
|
||||
});
|
||||
|
||||
return paginatorIntl;
|
||||
@ -16,12 +16,12 @@ export function TranslatedPaginator(translate: TranslateService) {
|
||||
|
||||
function getTranslations(tr: TranslateService, p: MatPaginatorIntl) {
|
||||
|
||||
tr.get("logs.first_page_label").subscribe((t) => p.firstPageLabel = t);
|
||||
tr.get("logs.last_page_label").subscribe((t) => p.lastPageLabel = t);
|
||||
tr.get("logs.items_per_page").subscribe((t) => p.itemsPerPageLabel = t);
|
||||
tr.get("logs.next_page").subscribe((t) => p.nextPageLabel = t);
|
||||
tr.get("logs.prev_page").subscribe((t) => p.previousPageLabel = t);
|
||||
tr.get("logs.of").subscribe((of) =>
|
||||
tr.get('logs.first_page_label').subscribe((t) => p.firstPageLabel = t);
|
||||
tr.get('logs.last_page_label').subscribe((t) => p.lastPageLabel = t);
|
||||
tr.get('logs.items_per_page').subscribe((t) => p.itemsPerPageLabel = t);
|
||||
tr.get('logs.next_page').subscribe((t) => p.nextPageLabel = t);
|
||||
tr.get('logs.prev_page').subscribe((t) => p.previousPageLabel = t);
|
||||
tr.get('logs.of').subscribe((of) =>
|
||||
p.getRangeLabel = (page, pageSize, length) => `${page * pageSize + 1}-${Math.min(pageSize * (page + 1), length)} ${of} ${length}`
|
||||
);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {AuthService} from "../auth.service";
|
||||
import {AuthService} from '../auth.service';
|
||||
|
||||
import * as moment from "moment"
|
||||
import * as moment from 'moment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-account-details',
|
||||
|
@ -1,16 +1,16 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {Project} from "./models/project";
|
||||
import {Credentials} from "./models/credentials";
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Project} from './models/project';
|
||||
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 = 'https://tt.simon987.net/api';
|
||||
private options: {
|
||||
withCredentials: true,
|
||||
responseType: "json"
|
||||
responseType: 'json'
|
||||
};
|
||||
|
||||
constructor(
|
||||
@ -19,104 +19,104 @@ export class ApiService {
|
||||
}
|
||||
|
||||
getLogs(level: number) {
|
||||
return this.http.post(this.url + "/logs", {level: level, since: 1}, this.options);
|
||||
return this.http.post(this.url + '/logs', {level: level, since: 1}, this.options);
|
||||
}
|
||||
|
||||
getProjects() {
|
||||
return this.http.get(this.url + "/project/list", this.options)
|
||||
return this.http.get(this.url + '/project/list', this.options);
|
||||
}
|
||||
|
||||
getProject(id: number) {
|
||||
return this.http.get(this.url + "/project/get/" + id, this.options)
|
||||
return this.http.get(this.url + '/project/get/' + id, this.options);
|
||||
}
|
||||
|
||||
createProject(project: Project) {
|
||||
return this.http.post(this.url + "/project/create", project, this.options)
|
||||
return this.http.post(this.url + '/project/create', project, this.options);
|
||||
}
|
||||
|
||||
updateProject(project: Project) {
|
||||
return this.http.post(this.url + "/project/update/" + project.id, project, this.options)
|
||||
return this.http.post(this.url + '/project/update/' + project.id, project, this.options);
|
||||
}
|
||||
|
||||
register(credentials: Credentials) {
|
||||
return this.http.post(this.url + "/register", credentials, this.options)
|
||||
return this.http.post(this.url + '/register', credentials, this.options);
|
||||
}
|
||||
|
||||
login(credentials: Credentials) {
|
||||
return this.http.post(this.url + "/login", credentials, this.options)
|
||||
return this.http.post(this.url + '/login', credentials, this.options);
|
||||
}
|
||||
|
||||
logout() {
|
||||
return this.http.get(this.url + "/logout", this.options)
|
||||
return this.http.get(this.url + '/logout', this.options);
|
||||
}
|
||||
|
||||
getAccountDetails() {
|
||||
return this.http.get(this.url + "/account", this.options)
|
||||
return this.http.get(this.url + '/account', this.options);
|
||||
}
|
||||
|
||||
getMonitoringSnapshots(count: number, project: number) {
|
||||
return this.http.get(this.url + `/project/monitoring/${project}?count=${count}`, this.options)
|
||||
return this.http.get(this.url + `/project/monitoring/${project}?count=${count}`, this.options);
|
||||
}
|
||||
|
||||
getAssigneeStats(project: number) {
|
||||
return this.http.get(this.url + `/project/assignees/${project}`, this.options)
|
||||
return this.http.get(this.url + `/project/assignees/${project}`, this.options);
|
||||
}
|
||||
|
||||
getWorkerStats() {
|
||||
return this.http.get(this.url + `/worker/stats`, this.options)
|
||||
return this.http.get(this.url + `/worker/stats`, this.options);
|
||||
}
|
||||
|
||||
getProjectAccess(project: number) {
|
||||
return this.http.get(this.url + `/project/access_list/${project}`, this.options)
|
||||
return this.http.get(this.url + `/project/access_list/${project}`, this.options);
|
||||
}
|
||||
|
||||
getManagerList() {
|
||||
return this.http.get(this.url + "/manager/list", this.options)
|
||||
return this.http.get(this.url + '/manager/list', this.options);
|
||||
}
|
||||
|
||||
getManagerListWithRoleOn(project: number) {
|
||||
return this.http.get(this.url + "/manager/list_for_project/" + project, this.options)
|
||||
return this.http.get(this.url + '/manager/list_for_project/' + project, this.options);
|
||||
}
|
||||
|
||||
promote(managerId: number) {
|
||||
return this.http.get(this.url + `/manager/promote/${managerId}`, this.options)
|
||||
return this.http.get(this.url + `/manager/promote/${managerId}`, this.options);
|
||||
}
|
||||
|
||||
demote(managerId: number) {
|
||||
return this.http.get(this.url + `/manager/demote/${managerId}`, this.options)
|
||||
return this.http.get(this.url + `/manager/demote/${managerId}`, this.options);
|
||||
}
|
||||
|
||||
acceptWorkerAccessRequest(wid: number, pid: number) {
|
||||
return this.http.post(this.url + `/project/accept_request/${pid}/${wid}`, null, this.options)
|
||||
return this.http.post(this.url + `/project/accept_request/${pid}/${wid}`, null, this.options);
|
||||
}
|
||||
|
||||
rejectWorkerAccessRequest(wid: number, pid: number) {
|
||||
return this.http.post(this.url + `/project/reject_request/${pid}/${wid}`, null, this.options)
|
||||
return this.http.post(this.url + `/project/reject_request/${pid}/${wid}`, null, this.options);
|
||||
}
|
||||
|
||||
setManagerRoleOnProject(pid: number, role: number, manager: number) {
|
||||
return this.http.post(this.url + `/manager/set_role_for_project/${pid}`,
|
||||
{"role": role, "manager": manager}, this.options)
|
||||
{'role': role, 'manager': manager}, this.options);
|
||||
}
|
||||
|
||||
getSecret(pid: number) {
|
||||
return this.http.get(this.url + `/project/secret/${pid}`, this.options)
|
||||
return this.http.get(this.url + `/project/secret/${pid}`, this.options);
|
||||
}
|
||||
|
||||
setSecret(pid: number, secret: string) {
|
||||
return this.http.post(this.url + `/project/secret/${pid}`, {"secret": secret}, this.options)
|
||||
return this.http.post(this.url + `/project/secret/${pid}`, {'secret': secret}, this.options);
|
||||
}
|
||||
|
||||
getWebhookSecret(pid: number) {
|
||||
return this.http.get(this.url + `/project/webhook_secret/${pid}`, this.options)
|
||||
return this.http.get(this.url + `/project/webhook_secret/${pid}`, this.options);
|
||||
}
|
||||
|
||||
setWebhookSecret(pid: number, secret: string) {
|
||||
return this.http.post(this.url + `/project/webhook_secret/${pid}`, {"webhook_secret": secret}, this.options)
|
||||
return this.http.post(this.url + `/project/webhook_secret/${pid}`, {'webhook_secret': secret}, this.options);
|
||||
}
|
||||
|
||||
resetFailedTasks(pid: number) {
|
||||
return this.http.post(this.url + `/project/reset_failed_tasks/${pid}`, null, this.options)
|
||||
return this.http.post(this.url + `/project/reset_failed_tasks/${pid}`, null, this.options);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,34 +1,34 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {NavigationEnd, NavigationStart, Router, RouterModule, Routes} from '@angular/router';
|
||||
import {LogsComponent} from "./logs/logs.component";
|
||||
import {ProjectDashboardComponent} from "./project-dashboard/project-dashboard.component";
|
||||
import {ProjectListComponent} from "./project-list/project-list.component";
|
||||
import {CreateProjectComponent} from "./create-project/create-project.component";
|
||||
import {UpdateProjectComponent} from "./update-project/update-project.component";
|
||||
import {Title} from "@angular/platform-browser";
|
||||
import {filter} from "rxjs/operators";
|
||||
import {TranslateService} from "@ngx-translate/core";
|
||||
import {LoginComponent} from "./login/login.component";
|
||||
import {AccountDetailsComponent} from "./account-details/account-details.component";
|
||||
import {WorkerDashboardComponent} from "./worker-dashboard/worker-dashboard.component";
|
||||
import {ProjectPermsComponent} from "./project-perms/project-perms.component";
|
||||
import {ManagerListComponent} from "./manager-list/manager-list.component";
|
||||
import {IndexComponent} from "./index/index.component";
|
||||
import {ProjectSecretComponent} from "./project-secret/project-secret.component";
|
||||
import {LogsComponent} from './logs/logs.component';
|
||||
import {ProjectDashboardComponent} from './project-dashboard/project-dashboard.component';
|
||||
import {ProjectListComponent} from './project-list/project-list.component';
|
||||
import {CreateProjectComponent} from './create-project/create-project.component';
|
||||
import {UpdateProjectComponent} from './update-project/update-project.component';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
import {filter} from 'rxjs/operators';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {LoginComponent} from './login/login.component';
|
||||
import {AccountDetailsComponent} from './account-details/account-details.component';
|
||||
import {WorkerDashboardComponent} from './worker-dashboard/worker-dashboard.component';
|
||||
import {ProjectPermsComponent} from './project-perms/project-perms.component';
|
||||
import {ManagerListComponent} from './manager-list/manager-list.component';
|
||||
import {IndexComponent} from './index/index.component';
|
||||
import {ProjectSecretComponent} from './project-secret/project-secret.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{path: "", component: IndexComponent},
|
||||
{path: "log", component: LogsComponent},
|
||||
{path: "login", component: LoginComponent},
|
||||
{path: "account", component: AccountDetailsComponent},
|
||||
{path: "projects", component: ProjectListComponent},
|
||||
{path: "project/:id", component: ProjectDashboardComponent},
|
||||
{path: "project/:id/update", component: UpdateProjectComponent},
|
||||
{path: "project/:id/perms", component: ProjectPermsComponent},
|
||||
{path: "project/:id/secret", component: ProjectSecretComponent},
|
||||
{path: "new_project", component: CreateProjectComponent},
|
||||
{path: "workers", component: WorkerDashboardComponent},
|
||||
{path: "manager_list", component: ManagerListComponent},
|
||||
{path: '', component: IndexComponent},
|
||||
{path: 'log', component: LogsComponent},
|
||||
{path: 'login', component: LoginComponent},
|
||||
{path: 'account', component: AccountDetailsComponent},
|
||||
{path: 'projects', component: ProjectListComponent},
|
||||
{path: 'project/:id', component: ProjectDashboardComponent},
|
||||
{path: 'project/:id/update', component: UpdateProjectComponent},
|
||||
{path: 'project/:id/perms', component: ProjectPermsComponent},
|
||||
{path: 'project/:id/secret', component: ProjectSecretComponent},
|
||||
{path: 'new_project', component: CreateProjectComponent},
|
||||
{path: 'workers', component: WorkerDashboardComponent},
|
||||
{path: 'manager_list', component: ManagerListComponent},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
@ -41,19 +41,19 @@ export class AppRoutingModule {
|
||||
router.events
|
||||
.pipe(filter(event => event instanceof NavigationEnd))
|
||||
.subscribe((event: NavigationStart) => {
|
||||
this.updateTitle(translate, title, event.url)
|
||||
this.updateTitle(translate, title, event.url);
|
||||
}
|
||||
);
|
||||
|
||||
translate.onLangChange.subscribe(() =>
|
||||
this.updateTitle(translate, title, router.url)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
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("/")))
|
||||
.subscribe((t) => title.setTitle(t))
|
||||
tr.get('title.' + url.substring(0, url.indexOf('/') == -1 ? url.length : url.indexOf('/')))
|
||||
.subscribe((t) => title.setTitle(t));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {TranslateService} from "@ngx-translate/core";
|
||||
import {AuthService} from "./auth.service";
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {AuthService} from './auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@ -10,25 +10,25 @@ import {AuthService} from "./auth.service";
|
||||
})
|
||||
export class AppComponent {
|
||||
|
||||
langChange(lang: any) {
|
||||
this.translate.use(lang.lang)
|
||||
}
|
||||
|
||||
langList: any[] = [
|
||||
{lang: "fr", display: "Français"},
|
||||
{lang: "en", display: "English"},
|
||||
];
|
||||
|
||||
constructor(private translate: TranslateService,
|
||||
public router: Router,
|
||||
public authService: AuthService) {
|
||||
|
||||
translate.addLangs([
|
||||
"en",
|
||||
"fr"
|
||||
'en',
|
||||
'fr'
|
||||
]);
|
||||
|
||||
translate.setDefaultLang("en");
|
||||
translate.setDefaultLang('en');
|
||||
}
|
||||
|
||||
langList: any[] = [
|
||||
{lang: 'fr', display: 'Français'},
|
||||
{lang: 'en', display: 'English'},
|
||||
];
|
||||
|
||||
langChange(lang: any) {
|
||||
this.translate.use(lang.lang);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,19 +33,19 @@ import {
|
||||
MatTabsModule,
|
||||
MatToolbarModule,
|
||||
MatTreeModule
|
||||
} from "@angular/material";
|
||||
import {ApiService} from "./api.service";
|
||||
import {MessengerService} from "./messenger.service";
|
||||
import {HttpClient, HttpClientModule} from "@angular/common/http";
|
||||
} from '@angular/material';
|
||||
import {ApiService} from './api.service';
|
||||
import {MessengerService} from './messenger.service';
|
||||
import {HttpClient, HttpClientModule} from '@angular/common/http';
|
||||
import {ProjectDashboardComponent} from './project-dashboard/project-dashboard.component';
|
||||
import {ProjectListComponent} from './project-list/project-list.component';
|
||||
import {CreateProjectComponent} from './create-project/create-project.component';
|
||||
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
|
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {UpdateProjectComponent} from './update-project/update-project.component';
|
||||
import {SnackBarComponent} from "./messenger/snack-bar.component";
|
||||
import {TranslateLoader, TranslateModule, TranslateService} from "@ngx-translate/core";
|
||||
import {TranslateHttpLoader} from "@ngx-translate/http-loader";
|
||||
import {TranslatedPaginator} from "./TranslatedPaginatorConfiguration";
|
||||
import {SnackBarComponent} from './messenger/snack-bar.component';
|
||||
import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core';
|
||||
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
|
||||
import {TranslatedPaginator} from './TranslatedPaginatorConfiguration';
|
||||
import {LoginComponent} from './login/login.component';
|
||||
import {AccountDetailsComponent} from './account-details/account-details.component';
|
||||
import {WorkerDashboardComponent} from './worker-dashboard/worker-dashboard.component';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {MatDialogRef} from "@angular/material";
|
||||
import {MatDialogRef} from '@angular/material';
|
||||
|
||||
@Component({
|
||||
selector: 'app-are-you-sure',
|
||||
@ -16,10 +16,10 @@ export class AreYouSureComponent implements OnInit {
|
||||
}
|
||||
|
||||
onNoClick() {
|
||||
this.dialogRef.close(false)
|
||||
this.dialogRef.close(false);
|
||||
}
|
||||
|
||||
onYesClick() {
|
||||
this.dialogRef.close(true)
|
||||
this.dialogRef.close(true);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ApiService} from "./api.service";
|
||||
import {Credentials} from "./models/credentials";
|
||||
import {MessengerService} from "./messenger.service";
|
||||
import {Router} from "@angular/router";
|
||||
import {Manager} from "./models/manager";
|
||||
import {ApiService} from './api.service';
|
||||
import {Credentials} from './models/credentials';
|
||||
import {MessengerService} from './messenger.service';
|
||||
import {Router} from '@angular/router';
|
||||
import {Manager} from './models/manager';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -20,7 +20,7 @@ export class AuthService {
|
||||
.subscribe((data: any) => {
|
||||
this.account = data.content.manager;
|
||||
this.logged = data.content.logged_in;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
public login(credentials: Credentials) {
|
||||
@ -31,14 +31,14 @@ export class AuthService {
|
||||
.subscribe((data: any) => {
|
||||
this.account = data.content.manager;
|
||||
this.logged = true;
|
||||
this.router.navigateByUrl("/account");
|
||||
})
|
||||
this.router.navigateByUrl('/account');
|
||||
});
|
||||
},
|
||||
error => {
|
||||
console.log(error);
|
||||
this.messengerService.show(error.error.message);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public logout() {
|
||||
@ -47,13 +47,13 @@ export class AuthService {
|
||||
() => {
|
||||
this.account = null;
|
||||
this.logged = false;
|
||||
this.router.navigateByUrl("login");
|
||||
this.router.navigateByUrl('login');
|
||||
},
|
||||
error => {
|
||||
console.log(error);
|
||||
this.messengerService.show(error.error.message);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public register(credentials: Credentials) {
|
||||
@ -63,12 +63,12 @@ export class AuthService {
|
||||
.subscribe((data: any) => {
|
||||
this.logged = true;
|
||||
this.account = data.content.manager;
|
||||
this.router.navigateByUrl("/account");
|
||||
this.router.navigateByUrl('/account');
|
||||
}),
|
||||
error => {
|
||||
console.log(error);
|
||||
this.messengerService.show(error.error.message);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Project} from "../models/project";
|
||||
import {ApiService} from "../api.service";
|
||||
import {MessengerService} from "../messenger.service";
|
||||
import {Router} from "@angular/router";
|
||||
import {AuthService} from "../auth.service";
|
||||
import {Project} from '../models/project';
|
||||
import {ApiService} from '../api.service';
|
||||
import {MessengerService} from '../messenger.service';
|
||||
import {Router} from '@angular/router';
|
||||
import {AuthService} from '../auth.service';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -26,10 +26,10 @@ export class CreateProjectComponent implements OnInit {
|
||||
}
|
||||
|
||||
cloneUrlChange() {
|
||||
let tokens = this.project.clone_url.split("/");
|
||||
const tokens = this.project.clone_url.split('/');
|
||||
|
||||
if (tokens.length > 2) {
|
||||
this.project.git_repo = tokens[tokens.length - 2] + "/" + tokens[tokens.length - 1]
|
||||
this.project.git_repo = tokens[tokens.length - 2] + '/' + tokens[tokens.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,13 +38,13 @@ export class CreateProjectComponent implements OnInit {
|
||||
|
||||
this.apiService.createProject(this.project).subscribe(
|
||||
data => {
|
||||
this.router.navigateByUrl("/project/" + data["content"]["id"]);
|
||||
this.router.navigateByUrl('/project/' + data['content']['id']);
|
||||
},
|
||||
error => {
|
||||
console.log(error.error.message);
|
||||
this.messengerService.show(error.error.message);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {ApiService} from "../api.service";
|
||||
import {ApiService} from '../api.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-index',
|
||||
|
@ -1,9 +1,9 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Credentials} from "../models/credentials";
|
||||
import {ApiService} from "../api.service";
|
||||
import {MessengerService} from "../messenger.service";
|
||||
import {Router} from "@angular/router";
|
||||
import {AuthService} from "../auth.service";
|
||||
import {Credentials} from '../models/credentials';
|
||||
import {ApiService} from '../api.service';
|
||||
import {MessengerService} from '../messenger.service';
|
||||
import {Router} from '@angular/router';
|
||||
import {AuthService} from '../auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
@ -24,15 +24,15 @@ export class LoginComponent implements OnInit {
|
||||
}
|
||||
|
||||
login() {
|
||||
this.authService.login(this.credentials)
|
||||
this.authService.login(this.credentials);
|
||||
}
|
||||
|
||||
register() {
|
||||
this.authService.register(this.credentials)
|
||||
this.authService.register(this.credentials);
|
||||
}
|
||||
|
||||
canCreate(): boolean {
|
||||
return this.credentials.username && this.credentials.username != "" &&
|
||||
this.credentials.password == this.credentials.repeatPassword
|
||||
return this.credentials.username && this.credentials.username != '' &&
|
||||
this.credentials.password == this.credentials.repeatPassword;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import {ApiService} from "../api.service";
|
||||
import {getLogLevel, LogEntry} from "../models/logentry";
|
||||
import {ApiService} from '../api.service';
|
||||
import {getLogLevel, LogEntry} from '../models/logentry';
|
||||
|
||||
import _ from "lodash"
|
||||
import * as moment from "moment";
|
||||
import {MatButtonToggleChange, MatPaginator, MatSort, MatTableDataSource} from "@angular/material";
|
||||
import _ from 'lodash';
|
||||
import * as moment from 'moment';
|
||||
import {MatButtonToggleChange, MatPaginator, MatSort, MatTableDataSource} from '@angular/material';
|
||||
|
||||
@Component({
|
||||
selector: 'app-logs',
|
||||
@ -15,14 +15,14 @@ export class LogsComponent implements OnInit {
|
||||
|
||||
logs: LogEntry[] = [];
|
||||
data: MatTableDataSource<LogEntry>;
|
||||
filterLevel: number = 1;
|
||||
logsCols: string[] = ["level", "timestamp", "message", "data"];
|
||||
filterLevel = 1;
|
||||
logsCols: string[] = ['level', 'timestamp', 'message', 'data'];
|
||||
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
constructor(private apiService: ApiService) {
|
||||
this.data = new MatTableDataSource<LogEntry>(this.logs)
|
||||
this.data = new MatTableDataSource<LogEntry>(this.logs);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@ -36,26 +36,26 @@ export class LogsComponent implements OnInit {
|
||||
|
||||
filterLevelChange(event: MatButtonToggleChange) {
|
||||
this.filterLevel = Number(event.value);
|
||||
this.getLogs(Number(event.value))
|
||||
this.getLogs(Number(event.value));
|
||||
}
|
||||
|
||||
public refresh() {
|
||||
this.getLogs(this.filterLevel)
|
||||
this.getLogs(this.filterLevel);
|
||||
}
|
||||
|
||||
private getLogs(level: number) {
|
||||
this.apiService.getLogs(level).subscribe(
|
||||
data => {
|
||||
this.data.data = _.map(data["content"]["logs"], (entry) => {
|
||||
this.data.data = _.map(data['content']['logs'], (entry) => {
|
||||
return <LogEntry>{
|
||||
message: entry.message,
|
||||
timestamp: moment.unix(entry.timestamp).format("YYYY-MM-DD HH:mm:ss"),
|
||||
timestamp: moment.unix(entry.timestamp).format('YYYY-MM-DD HH:mm:ss'),
|
||||
data: JSON.stringify(JSON.parse(entry.data), null, 2),
|
||||
level: getLogLevel(entry.level),
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import {ApiService} from "../api.service";
|
||||
import {MessengerService} from "../messenger.service";
|
||||
import {TranslateService} from "@ngx-translate/core";
|
||||
import {MatPaginator, MatSort, MatTableDataSource} from "@angular/material";
|
||||
import {ApiService} from '../api.service';
|
||||
import {MessengerService} from '../messenger.service';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {MatPaginator, MatSort, MatTableDataSource} from '@angular/material';
|
||||
|
||||
import * as moment from "moment"
|
||||
import {AuthService} from "../auth.service";
|
||||
import {Manager} from "../models/manager";
|
||||
import * as moment from 'moment';
|
||||
import {AuthService} from '../auth.service';
|
||||
import {Manager} from '../models/manager';
|
||||
|
||||
@Component({
|
||||
selector: 'app-manager-list',
|
||||
@ -28,7 +28,7 @@ export class ManagerListComponent implements OnInit {
|
||||
private translate: TranslateService,
|
||||
private authService: AuthService
|
||||
) {
|
||||
this.data = new MatTableDataSource<Manager>()
|
||||
this.data = new MatTableDataSource<Manager>();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@ -38,34 +38,34 @@ export class ManagerListComponent implements OnInit {
|
||||
}
|
||||
|
||||
canPromote(manager: Manager) {
|
||||
return !manager.tracker_admin
|
||||
return !manager.tracker_admin;
|
||||
}
|
||||
|
||||
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) {
|
||||
this.apiService.promote(manager.id)
|
||||
.subscribe(() => this.getManagers())
|
||||
.subscribe(() => this.getManagers());
|
||||
}
|
||||
|
||||
public demote(manager: Manager) {
|
||||
this.apiService.demote(manager.id)
|
||||
.subscribe(() => this.getManagers())
|
||||
.subscribe(() => this.getManagers());
|
||||
}
|
||||
|
||||
private getManagers() {
|
||||
this.apiService.getManagerList()
|
||||
.subscribe(data => {
|
||||
this.data.data = data["content"]["managers"]
|
||||
this.data.data = data['content']['managers'];
|
||||
},
|
||||
error => {
|
||||
if (error && (error.status == 401 || error.status == 403)) {
|
||||
console.log(error.error.message);
|
||||
this.translate.get("manager_list.unauthorized")
|
||||
this.translate.get('manager_list.unauthorized')
|
||||
.subscribe(t => this.messengerService.show(t));
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
|
||||
import {ApiService} from "../api.service";
|
||||
import {Manager} from "../models/manager";
|
||||
import {ApiService} from '../api.service';
|
||||
import {Manager} from '../models/manager';
|
||||
|
||||
@Component({
|
||||
selector: 'manager-select',
|
||||
@ -23,7 +23,7 @@ export class ManagerSelectComponent implements OnInit {
|
||||
|
||||
loadManagerList() {
|
||||
this.apiService.getManagerList()
|
||||
.subscribe(data => this.managerList = data["content"]["managers"])
|
||||
.subscribe(data => this.managerList = data['content']['managers']);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Subject} from "rxjs";
|
||||
import {MessengerState} from "./messenger/messenger";
|
||||
import {Subject} from 'rxjs';
|
||||
import {MessengerState} from './messenger/messenger';
|
||||
|
||||
@Injectable()
|
||||
export class MessengerService {
|
||||
@ -11,12 +11,12 @@ export class MessengerService {
|
||||
this.messengerSubject.next({
|
||||
message: message,
|
||||
hidden: false,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
hide() {
|
||||
this.messengerSubject.next({
|
||||
hidden: true,
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {MessengerService} from "../messenger.service";
|
||||
import {MessengerState} from "./messenger";
|
||||
import {Subscription} from "rxjs";
|
||||
import {MatSnackBar, MatSnackBarConfig} from "@angular/material";
|
||||
import {TranslateService} from "@ngx-translate/core";
|
||||
import {MessengerService} from '../messenger.service';
|
||||
import {MessengerState} from './messenger';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {MatSnackBar, MatSnackBarConfig} from '@angular/material';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
|
||||
@Component({
|
||||
selector: 'messenger-snack-bar',
|
||||
@ -27,11 +27,11 @@ export class SnackBarComponent implements OnInit {
|
||||
if (state.hidden) {
|
||||
this.snackBar.dismiss();
|
||||
} else {
|
||||
this.translate.get("messenger.close")
|
||||
this.translate.get('messenger.close')
|
||||
.subscribe(t =>
|
||||
this.snackBar.open(state.message, t, <MatSnackBarConfig>{
|
||||
duration: 10 * 1000,
|
||||
}))
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
export interface Credentials {
|
||||
username: string,
|
||||
password: string,
|
||||
repeatPassword: string,
|
||||
username: string;
|
||||
password: string;
|
||||
repeatPassword: string;
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
export interface LogEntry {
|
||||
level: string,
|
||||
message: string,
|
||||
data: any,
|
||||
timestamp: string,
|
||||
level: string;
|
||||
message: string;
|
||||
data: any;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
export enum LogLevel {
|
||||
FATAL = "fatal",
|
||||
PANIC = "panic",
|
||||
ERROR = "error",
|
||||
WARN = "warn",
|
||||
INFO = "info",
|
||||
DEBUG = "debug",
|
||||
TRACE = "trace",
|
||||
FATAL = 'fatal',
|
||||
PANIC = 'panic',
|
||||
ERROR = 'error',
|
||||
WARN = 'warn',
|
||||
INFO = 'info',
|
||||
DEBUG = 'debug',
|
||||
TRACE = 'trace',
|
||||
}
|
||||
|
||||
export function getLogLevel(level: number): string {
|
||||
|
@ -1,8 +1,8 @@
|
||||
export interface Manager {
|
||||
id: number;
|
||||
username: string
|
||||
tracker_admin: boolean
|
||||
register_time: number
|
||||
username: string;
|
||||
tracker_admin: boolean;
|
||||
register_time: number;
|
||||
}
|
||||
|
||||
export class ManagerRoleOnProject {
|
||||
@ -10,57 +10,57 @@ export class ManagerRoleOnProject {
|
||||
role: number;
|
||||
|
||||
public static fromEntity(data: { role: number, manager: Manager }): ManagerRoleOnProject {
|
||||
let m = new ManagerRoleOnProject();
|
||||
const m = new ManagerRoleOnProject();
|
||||
m.role = data.role;
|
||||
m.manager = data.manager;
|
||||
return m;
|
||||
}
|
||||
|
||||
get readRole(): boolean {
|
||||
return (this.role & 1) != 0
|
||||
return (this.role & 1) != 0;
|
||||
}
|
||||
|
||||
set readRole(role: boolean) {
|
||||
if (role) {
|
||||
this.role |= 1
|
||||
this.role |= 1;
|
||||
} else {
|
||||
this.role &= ~1
|
||||
this.role &= ~1;
|
||||
}
|
||||
}
|
||||
|
||||
get editRole(): boolean {
|
||||
return (this.role & 2) != 0
|
||||
return (this.role & 2) != 0;
|
||||
}
|
||||
|
||||
set editRole(role: boolean) {
|
||||
if (role) {
|
||||
this.role |= 2
|
||||
this.role |= 2;
|
||||
} else {
|
||||
this.role &= ~2
|
||||
this.role &= ~2;
|
||||
}
|
||||
}
|
||||
|
||||
get manageRole(): boolean {
|
||||
return (this.role & 4) != 0
|
||||
return (this.role & 4) != 0;
|
||||
}
|
||||
|
||||
set manageRole(role: boolean) {
|
||||
if (role) {
|
||||
this.role |= 4
|
||||
this.role |= 4;
|
||||
} else {
|
||||
this.role &= ~4
|
||||
this.role &= ~4;
|
||||
}
|
||||
}
|
||||
|
||||
get secretRole(): boolean {
|
||||
return (this.role & 8) != 0
|
||||
return (this.role & 8) != 0;
|
||||
}
|
||||
|
||||
set secretRole(role: boolean) {
|
||||
if (role) {
|
||||
this.role |= 8
|
||||
this.role |= 8;
|
||||
} else {
|
||||
this.role &= ~8
|
||||
this.role &= ~8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
export interface MonitoringSnapshot {
|
||||
new_task_count: number
|
||||
failed_task_count: number
|
||||
closed_task_count: number
|
||||
awaiting_verification_count: number
|
||||
time_stamp: number
|
||||
new_task_count: number;
|
||||
failed_task_count: number;
|
||||
closed_task_count: number;
|
||||
awaiting_verification_count: number;
|
||||
time_stamp: number;
|
||||
}
|
||||
|
||||
export interface AssignedTasks {
|
||||
assignee: string
|
||||
task_count: number
|
||||
assignee: string;
|
||||
task_count: number;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import {Worker} from "./worker"
|
||||
import {Worker} from './worker';
|
||||
|
||||
export interface WorkerAccess {
|
||||
submit: boolean
|
||||
assign: boolean
|
||||
request: boolean
|
||||
worker: Worker
|
||||
project: number
|
||||
submit: boolean;
|
||||
assign: boolean;
|
||||
request: boolean;
|
||||
worker: Worker;
|
||||
project: number;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
export interface Worker {
|
||||
id: number
|
||||
alias: string
|
||||
created: number
|
||||
secret: string
|
||||
id: number;
|
||||
alias: string;
|
||||
created: number;
|
||||
secret: string;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {Project} from "../models/project";
|
||||
import {Project} from '../models/project';
|
||||
|
||||
@Component({
|
||||
selector: 'project-icon',
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {ApiService} from "../api.service";
|
||||
import {Project} from "../models/project";
|
||||
import {AuthService} from "../auth.service";
|
||||
import {ApiService} from '../api.service';
|
||||
import {Project} from '../models/project';
|
||||
import {AuthService} from '../auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-project-list',
|
||||
@ -17,7 +17,7 @@ export class ProjectListComponent implements OnInit {
|
||||
projects: Project[];
|
||||
|
||||
ngOnInit() {
|
||||
this.getProjects()
|
||||
this.getProjects();
|
||||
}
|
||||
|
||||
refresh() {
|
||||
@ -26,7 +26,7 @@ export class ProjectListComponent implements OnInit {
|
||||
|
||||
getProjects() {
|
||||
this.apiService.getProjects().subscribe(data =>
|
||||
this.projects = data["content"]["projects"]);
|
||||
this.projects = data['content']['projects']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {ApiService} from "../api.service";
|
||||
import {Project} from "../models/project";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
import {ApiService} from '../api.service';
|
||||
import {Project} from '../models/project';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
|
||||
import * as moment from "moment"
|
||||
import {WorkerAccess} from "../models/worker-access";
|
||||
import {AuthService} from "../auth.service";
|
||||
import {Manager, ManagerRoleOnProject} from "../models/manager";
|
||||
import {MessengerService} from "../messenger.service";
|
||||
import {TranslateService} from "@ngx-translate/core";
|
||||
import * as moment from 'moment';
|
||||
import {WorkerAccess} from '../models/worker-access';
|
||||
import {AuthService} from '../auth.service';
|
||||
import {Manager, ManagerRoleOnProject} from '../models/manager';
|
||||
import {MessengerService} from '../messenger.service';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-project-perms',
|
||||
@ -28,58 +28,58 @@ export class ProjectPermsComponent implements OnInit {
|
||||
private projectId: number;
|
||||
accesses: WorkerAccess[];
|
||||
managerRoles: ManagerRoleOnProject;
|
||||
unauthorized: boolean = false;
|
||||
unauthorized = false;
|
||||
moment = moment;
|
||||
|
||||
ngOnInit() {
|
||||
this.route.params.subscribe(params => {
|
||||
this.projectId = params["id"];
|
||||
this.projectId = params['id'];
|
||||
this.getProject();
|
||||
this.getProjectAccesses();
|
||||
this.getProjectManagers();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
public acceptRequest(wa: WorkerAccess) {
|
||||
this.apiService.acceptWorkerAccessRequest(wa.worker.id, this.projectId)
|
||||
.subscribe(() => {
|
||||
this.getProjectAccesses();
|
||||
this.translate.get("perms.set").subscribe(t => this.messenger.show(t));
|
||||
})
|
||||
this.translate.get('perms.set').subscribe(t => this.messenger.show(t));
|
||||
});
|
||||
}
|
||||
|
||||
public rejectRequest(wa: WorkerAccess) {
|
||||
this.apiService.rejectWorkerAccessRequest(wa.worker.id, this.projectId)
|
||||
.subscribe(() => {
|
||||
this.getProjectAccesses();
|
||||
this.translate.get("perms.set").subscribe(t => this.messenger.show(t));
|
||||
})
|
||||
this.translate.get('perms.set').subscribe(t => this.messenger.show(t));
|
||||
});
|
||||
}
|
||||
|
||||
private getProject() {
|
||||
this.apiService.getProject(this.projectId).subscribe(data => {
|
||||
this.project = data["content"]["project"]
|
||||
})
|
||||
this.project = data['content']['project'];
|
||||
});
|
||||
}
|
||||
|
||||
private getProjectAccesses() {
|
||||
this.apiService.getProjectAccess(this.projectId).subscribe(
|
||||
data => {
|
||||
this.accesses = data["content"]["accesses"]
|
||||
this.accesses = data['content']['accesses'];
|
||||
},
|
||||
error => {
|
||||
if (error && (error.status == 401 || error.status == 403)) {
|
||||
this.unauthorized = true;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
private getProjectManagers() {
|
||||
this.apiService.getManagerListWithRoleOn(this.projectId)
|
||||
.subscribe(data => {
|
||||
this.managerRoles = data["content"]["managers"].map(d =>
|
||||
ManagerRoleOnProject.fromEntity(d))
|
||||
})
|
||||
this.managerRoles = data['content']['managers'].map(d =>
|
||||
ManagerRoleOnProject.fromEntity(d));
|
||||
});
|
||||
}
|
||||
|
||||
public refresh() {
|
||||
@ -90,7 +90,7 @@ export class ProjectPermsComponent implements OnInit {
|
||||
public onSelectManager(manager: Manager) {
|
||||
if (manager.id != this.auth.account.id) {
|
||||
this.apiService.setManagerRoleOnProject(this.projectId, 1, manager.id)
|
||||
.subscribe(() => this.refresh())
|
||||
.subscribe(() => this.refresh());
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ export class ProjectPermsComponent implements OnInit {
|
||||
this.apiService.setManagerRoleOnProject(this.projectId, manager.role, manager.manager.id)
|
||||
.subscribe(() => {
|
||||
this.refresh();
|
||||
this.translate.get("perms.set").subscribe(t => this.messenger.show(t));
|
||||
})
|
||||
this.translate.get('perms.set').subscribe(t => this.messenger.show(t));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {AuthService} from "../auth.service";
|
||||
import {ApiService} from "../api.service";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
import {TranslateService} from "@ngx-translate/core";
|
||||
import {MessengerService} from "../messenger.service";
|
||||
import {AuthService} from '../auth.service';
|
||||
import {ApiService} from '../api.service';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {MessengerService} from '../messenger.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-project-secret',
|
||||
@ -25,7 +25,7 @@ export class ProjectSecretComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.route.params.subscribe(params => {
|
||||
this.projectId = params["id"];
|
||||
this.projectId = params['id'];
|
||||
this.getSecret();
|
||||
this.getWebhookSecret();
|
||||
});
|
||||
@ -33,30 +33,30 @@ export class ProjectSecretComponent implements OnInit {
|
||||
|
||||
getSecret() {
|
||||
this.apiService.getSecret(this.projectId).subscribe(data => {
|
||||
this.secret = data["content"]["secret"]
|
||||
this.secret = data['content']['secret'];
|
||||
}, error => {
|
||||
this.translate.get("messenger.unauthorized").subscribe(t => this.messenger.show(t))
|
||||
})
|
||||
this.translate.get('messenger.unauthorized').subscribe(t => this.messenger.show(t));
|
||||
});
|
||||
}
|
||||
|
||||
getWebhookSecret() {
|
||||
this.apiService.getWebhookSecret(this.projectId).subscribe(data => {
|
||||
this.webhookSecret = data["content"]["webhook_secret"]
|
||||
this.webhookSecret = data['content']['webhook_secret'];
|
||||
}, error => {
|
||||
this.translate.get("messenger.unauthorized").subscribe(t => this.messenger.show(t))
|
||||
})
|
||||
this.translate.get('messenger.unauthorized').subscribe(t => this.messenger.show(t));
|
||||
});
|
||||
}
|
||||
|
||||
onUpdate() {
|
||||
this.apiService.setSecret(this.projectId, this.secret).subscribe(data => {
|
||||
this.translate.get("secret.ok").subscribe(t => this.messenger.show(t))
|
||||
})
|
||||
this.translate.get('secret.ok').subscribe(t => this.messenger.show(t));
|
||||
});
|
||||
}
|
||||
|
||||
onWebhookUpdate() {
|
||||
this.apiService.setWebhookSecret(this.projectId, this.webhookSecret).subscribe(data => {
|
||||
this.translate.get("secret.ok").subscribe(t => this.messenger.show(t))
|
||||
})
|
||||
this.translate.get('secret.ok').subscribe(t => this.messenger.show(t));
|
||||
});
|
||||
}
|
||||
|
||||
refresh() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||
import {ApiService} from "../api.service";
|
||||
import {Project} from "../models/project";
|
||||
import {ApiService} from '../api.service';
|
||||
import {Project} from '../models/project';
|
||||
|
||||
@Component({
|
||||
selector: 'project-select',
|
||||
@ -22,7 +22,7 @@ export class ProjectSelectComponent implements OnInit {
|
||||
|
||||
loadProjectList() {
|
||||
this.apiService.getProjects().subscribe(data => {
|
||||
this.projectList = data["content"]["projects"]
|
||||
})
|
||||
this.projectList = data['content']['projects'];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Project} from "../models/project";
|
||||
import {ApiService} from "../api.service";
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {MessengerService} from "../messenger.service";
|
||||
import {Project} from '../models/project';
|
||||
import {ApiService} from '../api.service';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {MessengerService} from '../messenger.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-update-project',
|
||||
@ -23,29 +23,29 @@ export class UpdateProjectComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.route.params.subscribe(params => {
|
||||
this.projectId = params["id"];
|
||||
this.projectId = params['id'];
|
||||
this.getProject();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
private getProject() {
|
||||
this.apiService.getProject(this.projectId).subscribe(data => {
|
||||
this.project = data["content"]["project"];
|
||||
this.selectedProject = <Project>{id: this.project.chain}
|
||||
})
|
||||
this.project = data['content']['project'];
|
||||
this.selectedProject = <Project>{id: this.project.chain};
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.project.chain = this.selectedProject ? this.selectedProject.id : 0;
|
||||
this.apiService.updateProject(this.project).subscribe(
|
||||
data => {
|
||||
this.router.navigateByUrl("/project/" + this.project.id);
|
||||
this.router.navigateByUrl('/project/' + this.project.id);
|
||||
},
|
||||
error => {
|
||||
console.log(error.error.message);
|
||||
this.messengerService.show(error.error.message);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {ApiService} from "../api.service";
|
||||
import {ApiService} from '../api.service';
|
||||
|
||||
import {Chart} from "chart.js";
|
||||
import {Chart} from 'chart.js';
|
||||
|
||||
@Component({
|
||||
selector: 'app-worker-dashboard',
|
||||
@ -17,24 +17,24 @@ export class WorkerDashboardComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.setupChart();
|
||||
this.refresh()
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
public refresh() {
|
||||
this.apiService.getWorkerStats()
|
||||
.subscribe(data => {
|
||||
this.updateChart(data["content"]["stats"])
|
||||
this.updateChart(data['content']['stats']);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private setupChart() {
|
||||
|
||||
let elem = document.getElementById("worker-stats") as any;
|
||||
let ctx = elem.getContext("2d");
|
||||
const elem = document.getElementById('worker-stats') as any;
|
||||
const ctx = elem.getContext('2d');
|
||||
|
||||
this.chart = new Chart(ctx, {
|
||||
type: "bar",
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: [],
|
||||
datasets: [],
|
||||
@ -51,7 +51,7 @@ export class WorkerDashboardComponent implements OnInit {
|
||||
},
|
||||
responsive: true
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
private updateChart(data) {
|
||||
@ -59,7 +59,7 @@ export class WorkerDashboardComponent implements OnInit {
|
||||
this.chart.data.labels = data.map(w => w.alias);
|
||||
this.chart.data.datasets = [{
|
||||
data: data.map(w => w.closed_task_count),
|
||||
backgroundColor: "#FF3D00"
|
||||
backgroundColor: '#FF3D00'
|
||||
}];
|
||||
this.chart.update();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user