Performance improvements, refactoring, and package size reduction
This commit is contained in:
parent
8da3175402
commit
25ce5ac92a
@ -43,7 +43,7 @@
|
|||||||
"aot": true,
|
"aot": true,
|
||||||
"optimization": true,
|
"optimization": true,
|
||||||
"outputHashing": "all",
|
"outputHashing": "all",
|
||||||
"sourceMap": false,
|
"sourceMap": true,
|
||||||
"extractCss": true,
|
"extractCss": true,
|
||||||
"namedChunks": false,
|
"namedChunks": false,
|
||||||
"extractLicenses": true,
|
"extractLicenses": true,
|
||||||
|
@ -12,7 +12,7 @@ import { ApiInterceptor } from './app.api-http';
|
|||||||
import { LoginComponent } from './login/login.component';
|
import { LoginComponent } from './login/login.component';
|
||||||
import { BoardModule } from './board/board.module';
|
import { BoardModule } from './board/board.module';
|
||||||
import { FileModule } from './files/file-viewer.module';
|
import { FileModule } from './files/file-viewer.module';
|
||||||
import { DashboardModule } from './dashboard/dashboard.module';
|
// import { DashboardModule } from './dashboard/dashboard.module';
|
||||||
import { SettingsModule } from './settings/settings.module';
|
import { SettingsModule } from './settings/settings.module';
|
||||||
import { SharedModule } from './shared/shared.module';
|
import { SharedModule } from './shared/shared.module';
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ import { SharedModule } from './shared/shared.module';
|
|||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
BoardModule,
|
BoardModule,
|
||||||
FileModule,
|
FileModule,
|
||||||
DashboardModule,
|
// DashboardModule,
|
||||||
DragDropModule,
|
DragDropModule,
|
||||||
SettingsModule,
|
SettingsModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
|
@ -4,7 +4,7 @@ import { BoardDisplayComponent } from './board/board.component';
|
|||||||
import { FileViewerComponent } from './files/file-viewer.component';
|
import { FileViewerComponent } from './files/file-viewer.component';
|
||||||
import { LoginComponent } from './login/login.component';
|
import { LoginComponent } from './login/login.component';
|
||||||
import { SettingsComponent } from './settings/settings.component';
|
import { SettingsComponent } from './settings/settings.component';
|
||||||
import { DashboardComponent } from './dashboard/dashboard.component';
|
// import { DashboardComponent } from './dashboard/dashboard.component';
|
||||||
import { AuthGuard } from './shared/auth/auth.guard';
|
import { AuthGuard } from './shared/auth/auth.guard';
|
||||||
|
|
||||||
export const ROUTES: Routes = [
|
export const ROUTES: Routes = [
|
||||||
@ -27,11 +27,11 @@ export const ROUTES: Routes = [
|
|||||||
component: SettingsComponent,
|
component: SettingsComponent,
|
||||||
canActivate: [ AuthGuard ]
|
canActivate: [ AuthGuard ]
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
path: 'dashboard',
|
// path: 'dashboard',
|
||||||
component: DashboardComponent,
|
// component: DashboardComponent,
|
||||||
canActivate: [ AuthGuard ]
|
// canActivate: [ AuthGuard ]
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
path: 'files/:hash',
|
path: 'files/:hash',
|
||||||
component: FileViewerComponent,
|
component: FileViewerComponent,
|
||||||
|
@ -83,9 +83,11 @@
|
|||||||
<p></p>
|
<p></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="board" cdkDropListGroup *ngIf="activeBoard">
|
<div class="board" *ngIf="loading">
|
||||||
<div class="loading" *ngIf="loading">{{ strings['loading'] }}...</div>
|
<div class="loading">{{ strings['loading'] }}...</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="board" cdkDropListGroup *ngIf="activeBoard">
|
||||||
<tb-column class="column" [id]="column.id" [column]="column"
|
<tb-column class="column" [id]="column.id" [column]="column"
|
||||||
*ngFor="let column of activeBoard.columns"
|
*ngFor="let column of activeBoard.columns"
|
||||||
(on-update-boards)="updateBoards()"></tb-column>
|
(on-update-boards)="updateBoards()"></tb-column>
|
||||||
|
@ -74,18 +74,6 @@ export class BoardDisplayComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.updateBoards();
|
this.updateBoards();
|
||||||
|
|
||||||
sub = boardService.activeBoardChanged.subscribe((board: Board) => {
|
|
||||||
if (!board) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.activeBoard = board;
|
|
||||||
title.setTitle('TaskBoard - ' + board.name);
|
|
||||||
this.userFilter = null;
|
|
||||||
this.categoryFilter = null;
|
|
||||||
});
|
|
||||||
this.subs.push(sub);
|
|
||||||
|
|
||||||
sub = auth.userChanged.subscribe((user: User) => {
|
sub = auth.userChanged.subscribe((user: User) => {
|
||||||
this.updateActiveUser(user);
|
this.updateActiveUser(user);
|
||||||
});
|
});
|
||||||
@ -94,6 +82,7 @@ export class BoardDisplayComponent implements OnInit, OnDestroy {
|
|||||||
sub = active.params.subscribe(params => {
|
sub = active.params.subscribe(params => {
|
||||||
const id = +params.id;
|
const id = +params.id;
|
||||||
|
|
||||||
|
this.loading = true;
|
||||||
this.boardNavId = id ? id : null;
|
this.boardNavId = id ? id : null;
|
||||||
this.updateActiveBoard();
|
this.updateActiveBoard();
|
||||||
});
|
});
|
||||||
@ -167,38 +156,38 @@ export class BoardDisplayComponent implements OnInit, OnDestroy {
|
|||||||
if (response.data.length > 1) {
|
if (response.data.length > 1) {
|
||||||
this.updateBoardsList(response.data[1]);
|
this.updateBoardsList(response.data[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loading = false;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateBoardsList(boards: any[]): void {
|
private updateBoardsList(boards: any[]): void {
|
||||||
const activeBoards: Board[] = [];
|
const activeBoards: Board[] = [];
|
||||||
|
|
||||||
if (boards) {
|
boards.forEach((board: any) => {
|
||||||
boards.forEach((board: any) => {
|
if (board.is_active !== '1') {
|
||||||
const currentBoard = new Board(+board.id, board.name,
|
return;
|
||||||
board.is_active === '1',
|
}
|
||||||
board.ownColumn,
|
|
||||||
board.ownCategory,
|
const currentBoard = new Board(+board.id, board.name, true,
|
||||||
board.ownAutoAction,
|
board.ownColumn,
|
||||||
board.ownIssuetracker,
|
board.ownCategory,
|
||||||
board.sharedUser);
|
board.ownAutoAction,
|
||||||
if (currentBoard.is_active) {
|
board.ownIssuetracker,
|
||||||
activeBoards.push(currentBoard);
|
board.sharedUser);
|
||||||
}
|
activeBoards.push(currentBoard);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
this.boards = activeBoards;
|
this.boards = activeBoards;
|
||||||
|
this.loading = false;
|
||||||
|
|
||||||
|
this.sortColumns().then(() => { this.updateActiveBoard(); })
|
||||||
|
}
|
||||||
|
|
||||||
|
private async sortColumns() {
|
||||||
this.boards.forEach(board => {
|
this.boards.forEach(board => {
|
||||||
board.columns.sort((a: Column, b: Column) => {
|
board.columns.sort((a: Column, b: Column) => {
|
||||||
return +a.position - +b.position;
|
return +a.position - +b.position;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.updateActiveBoard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateActiveBoard(): void {
|
private updateActiveBoard(): void {
|
||||||
@ -213,9 +202,16 @@ export class BoardDisplayComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.userFilter = null;
|
||||||
|
this.categoryFilter = null;
|
||||||
|
|
||||||
this.activeBoard = board;
|
this.activeBoard = board;
|
||||||
this.boardService.updateActiveBoard(board);
|
|
||||||
this.pageName = board.name;
|
this.pageName = board.name;
|
||||||
|
|
||||||
|
this.boardService.updateActiveBoard(board);
|
||||||
|
this.title.setTitle('TaskBoard - ' + this.activeBoard.name);
|
||||||
|
|
||||||
|
this.loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateActiveUser(activeUser: User) {
|
private updateActiveUser(activeUser: User) {
|
||||||
|
@ -2,7 +2,13 @@ import { Injectable } from '@angular/core';
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
|
||||||
import * as marked from 'marked';
|
import * as marked from 'marked';
|
||||||
import * as hljs from 'highlight.js';
|
import hljs from 'node_modules/highlight.js/lib/core.js';
|
||||||
|
import javascript from 'node_modules/highlight.js/lib/languages/javascript.js';
|
||||||
|
import bash from 'node_modules/highlight.js/lib/languages/bash.js';
|
||||||
|
import css from 'node_modules/highlight.js/lib/languages/css.js';
|
||||||
|
import csharp from 'node_modules/highlight.js/lib/languages/csharp.js';
|
||||||
|
import php from 'node_modules/highlight.js/lib/languages/php.js';
|
||||||
|
|
||||||
import { BehaviorSubject, Observable, of } from 'rxjs';
|
import { BehaviorSubject, Observable, of } from 'rxjs';
|
||||||
import { map, catchError } from 'rxjs/operators';
|
import { map, catchError } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -32,6 +38,12 @@ export class BoardService {
|
|||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {
|
||||||
this.initMarked();
|
this.initMarked();
|
||||||
|
|
||||||
|
hljs.registerLanguage('javascript', javascript);
|
||||||
|
hljs.registerLanguage('bash', bash);
|
||||||
|
hljs.registerLanguage('css', css);
|
||||||
|
hljs.registerLanguage('csharp', csharp);
|
||||||
|
hljs.registerLanguage('php', php);
|
||||||
}
|
}
|
||||||
|
|
||||||
async convertMarkdown(markdown: string, callback = this.defaultCallback,
|
async convertMarkdown(markdown: string, callback = this.defaultCallback,
|
||||||
@ -55,8 +67,9 @@ export class BoardService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newBoard = this.convertBoardData(board);
|
this.convertBoardData(board).then(newBoard => {
|
||||||
this.activeBoard.next(newBoard);
|
this.activeBoard.next(newBoard);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getBoards(): Observable<ApiResponse> {
|
getBoards(): Observable<ApiResponse> {
|
||||||
@ -175,7 +188,7 @@ export class BoardService {
|
|||||||
this.http.post('api/refresh', {}).subscribe();
|
this.http.post('api/refresh', {}).subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
private convertBoardData(boardData: any): Board {
|
private async convertBoardData(boardData: any): Promise<Board> {
|
||||||
if (boardData instanceof Board) {
|
if (boardData instanceof Board) {
|
||||||
return boardData;
|
return boardData;
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ import {
|
|||||||
ElementRef,
|
ElementRef,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
Input,
|
Input,
|
||||||
OnInit,
|
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
Output
|
OnInit,
|
||||||
|
Output,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
import {
|
import {
|
||||||
@ -37,7 +37,7 @@ import { BoardService } from '../board.service';
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-column',
|
selector: 'tb-column',
|
||||||
templateUrl: './column.component.html'
|
templateUrl: './column.component.html',
|
||||||
})
|
})
|
||||||
export class ColumnDisplayComponent implements OnInit, OnDestroy {
|
export class ColumnDisplayComponent implements OnInit, OnDestroy {
|
||||||
public moveItemInArray: any;
|
public moveItemInArray: any;
|
||||||
@ -119,8 +119,8 @@ export class ColumnDisplayComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
this.subs.push(sub);
|
this.subs.push(sub);
|
||||||
|
|
||||||
sub = boardService.activeBoardChanged.subscribe((board: Board) => {
|
sub = boardService.activeBoardChanged.subscribe(newBoard => {
|
||||||
this.activeBoard = board;
|
this.activeBoard = newBoard;
|
||||||
});
|
});
|
||||||
this.subs.push(sub);
|
this.subs.push(sub);
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import {
|
import {
|
||||||
|
ChangeDetectionStrategy,
|
||||||
Component,
|
Component,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
Input,
|
Input,
|
||||||
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
Output
|
Output,
|
||||||
|
ChangeDetectorRef,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
|
|
||||||
@ -24,9 +27,12 @@ import { BoardService } from '../board.service';
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-task',
|
selector: 'tb-task',
|
||||||
templateUrl: './task.component.html'
|
templateUrl: './task.component.html',
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
export class TaskDisplayComponent implements OnInit {
|
export class TaskDisplayComponent implements OnInit, OnDestroy {
|
||||||
|
private subs: any[];
|
||||||
|
|
||||||
public isOverdue: boolean;
|
public isOverdue: boolean;
|
||||||
public isNearlyDue: boolean;
|
public isNearlyDue: boolean;
|
||||||
public strings: any;
|
public strings: any;
|
||||||
@ -56,21 +62,26 @@ export class TaskDisplayComponent implements OnInit {
|
|||||||
public boardService: BoardService,
|
public boardService: BoardService,
|
||||||
public modal: ModalService,
|
public modal: ModalService,
|
||||||
private notes: NotificationsService,
|
private notes: NotificationsService,
|
||||||
public stringsService: StringsService) {
|
public stringsService: StringsService,
|
||||||
|
private cdref: ChangeDetectorRef) {
|
||||||
this.onUpdateBoards = new EventEmitter<any>();
|
this.onUpdateBoards = new EventEmitter<any>();
|
||||||
this.percentComplete = 0;
|
this.percentComplete = 0;
|
||||||
|
this.subs = [];
|
||||||
|
|
||||||
stringsService.stringsChanged.subscribe(newStrings => {
|
let sub = stringsService.stringsChanged.subscribe(newStrings => {
|
||||||
this.strings = newStrings;
|
this.strings = newStrings;
|
||||||
});
|
});
|
||||||
|
this.subs.push(sub);
|
||||||
|
|
||||||
auth.userChanged.subscribe(() => {
|
sub = auth.userChanged.subscribe(() => {
|
||||||
this.userOptions = auth.userOptions;
|
this.userOptions = auth.userOptions;
|
||||||
});
|
});
|
||||||
|
this.subs.push(sub);
|
||||||
|
|
||||||
boardService.activeBoardChanged.subscribe((board: Board) => {
|
sub = boardService.activeBoardChanged.subscribe(newBoard => {
|
||||||
this.activeBoard = board;
|
this.activeBoard = newBoard;
|
||||||
});
|
});
|
||||||
|
this.subs.push(sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -78,6 +89,10 @@ export class TaskDisplayComponent implements OnInit {
|
|||||||
this.convertTaskDescription();
|
this.convertTaskDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.subs.forEach(sub => sub.unsubscribe());
|
||||||
|
}
|
||||||
|
|
||||||
getPercentStyle() {
|
getPercentStyle() {
|
||||||
return this.sanitizer.bypassSecurityTrustStyle(
|
return this.sanitizer.bypassSecurityTrustStyle(
|
||||||
'padding: 0; height: 5px; background-color: rgba(0, 0, 0, .4); ' +
|
'padding: 0; height: 5px; background-color: rgba(0, 0, 0, .4); ' +
|
||||||
|
@ -2,7 +2,6 @@ import { Component, OnDestroy } from '@angular/core';
|
|||||||
import {
|
import {
|
||||||
CdkDragDrop,
|
CdkDragDrop,
|
||||||
moveItemInArray,
|
moveItemInArray,
|
||||||
transferArrayItem
|
|
||||||
} from '@angular/cdk/drag-drop';
|
} from '@angular/cdk/drag-drop';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -26,19 +26,15 @@ export class Board {
|
|||||||
this.users = [];
|
this.users = [];
|
||||||
|
|
||||||
columnArray.forEach((column: any) => {
|
columnArray.forEach((column: any) => {
|
||||||
this.columns.push(new Column(+column.id,
|
this.convertColumn(column).then(col => {
|
||||||
column.name,
|
this.columns.push(col);
|
||||||
+column.position,
|
})
|
||||||
+column.board_id,
|
|
||||||
+column.task_limit,
|
|
||||||
column.ownTask));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
categoryArray.forEach((category: any) => {
|
categoryArray.forEach((category: any) => {
|
||||||
this.categories.push(new Category(+category.id,
|
this.convertCategory(category).then(cat => {
|
||||||
category.name,
|
this.categories.push(cat);
|
||||||
category.default_task_color,
|
});
|
||||||
+category.board_id));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
actionsArray.forEach((action: any) => {
|
actionsArray.forEach((action: any) => {
|
||||||
@ -81,5 +77,21 @@ export class Board {
|
|||||||
addIssueTracker(url: string, regex: string): void {
|
addIssueTracker(url: string, regex: string): void {
|
||||||
this.issue_trackers.push(new IssueTracker(0, url, regex));
|
this.issue_trackers.push(new IssueTracker(0, url, regex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async convertColumn(column: any): Promise<Column> {
|
||||||
|
const col = new Column(+column.id, column.name, +column.position,
|
||||||
|
+column.board_id, +column.task_limit,
|
||||||
|
column.ownTask);
|
||||||
|
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async convertCategory(category: any): Promise<Category> {
|
||||||
|
|
||||||
|
const cat = new Category(+category.id, category.name,
|
||||||
|
category.default_task_color, +category.board_id);
|
||||||
|
|
||||||
|
return cat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,10 +3,7 @@ import { Router } from '@angular/router';
|
|||||||
|
|
||||||
import { Notification } from '../models';
|
import { Notification } from '../models';
|
||||||
import { Constants } from '../constants';
|
import { Constants } from '../constants';
|
||||||
import {
|
import { AuthService, NotificationsService } from '../services';
|
||||||
AuthService,
|
|
||||||
NotificationsService,
|
|
||||||
} from '../services';
|
|
||||||
import { StringsService } from '../strings/strings.service';
|
import { StringsService } from '../strings/strings.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -46,10 +46,10 @@ describe('BoardService', () => {
|
|||||||
|
|
||||||
service.activeBoardChanged.subscribe(() => (changed = true));
|
service.activeBoardChanged.subscribe(() => (changed = true));
|
||||||
|
|
||||||
service.updateActiveBoard(<any>{});
|
service.updateActiveBoard({} as any);
|
||||||
|
|
||||||
expect(changed).toEqual(true);
|
expect(changed).toEqual(true);
|
||||||
});
|
})
|
||||||
|
|
||||||
it('gets all boards', () => {
|
it('gets all boards', () => {
|
||||||
service.getBoards().subscribe(response => {
|
service.getBoards().subscribe(response => {
|
||||||
|
Reference in New Issue
Block a user