diff --git a/coderadar-ui/src/app/city-map/shared/effects.ts b/coderadar-ui/src/app/city-map/shared/effects.ts index 7f12bc052..7d93ace7f 100644 --- a/coderadar-ui/src/app/city-map/shared/effects.ts +++ b/coderadar-ui/src/app/city-map/shared/effects.ts @@ -13,17 +13,18 @@ import {INode} from '../interfaces/INode'; import {ICommitsGetErrorResponse} from '../interfaces/ICommitsGetErrorResponse'; import {Store} from '@ngrx/store'; import * as fromRoot from './reducers'; +import {Project} from '../../model/project'; @Injectable() export class AppEffects { - public currentProjectId: number; + public currentProject: Project; isLoaded = false; @Effect() loadCommitsEffects$ = this.actions$.pipe(ofType(LOAD_COMMITS), switchMap( - () => from(this.projectService.getCommits(this.currentProjectId, 'master')) + () => from(this.projectService.getCommits(this.currentProject.id, this.currentProject.defaultBranch)) .pipe( map((result: any) => { return actions.loadCommitsSuccess(result.body); @@ -38,7 +39,7 @@ export class AppEffects { @Effect() loadAvailableMetricsEffects$ = this.actions$.pipe(ofType(LOAD_AVAILABLE_METRICS), - switchMap(() => from(this.projectService.getAvailableMetrics(this.currentProjectId)) + switchMap(() => from(this.projectService.getAvailableMetrics(this.currentProject.id)) .pipe( mergeMap((result: any) => { const availableMetrics = result.body.map( @@ -74,7 +75,7 @@ export class AppEffects { map((action: IActionWithPayload) => action.payload), switchMap( (payload) => from(this.projectService.getDeltaTree(payload.leftCommit, payload.rightCommit, - payload.metricMapping, this.currentProjectId)) + payload.metricMapping, this.currentProject.id)) .pipe( mergeMap((result: HttpResponse) => { return [ diff --git a/coderadar-ui/src/app/levelized-structure-map/dependency-compare/dependency-compare.component.html b/coderadar-ui/src/app/levelized-structure-map/dependency-compare/dependency-compare.component.html index b47cfd491..919fc32aa 100644 --- a/coderadar-ui/src/app/levelized-structure-map/dependency-compare/dependency-compare.component.html +++ b/coderadar-ui/src/app/levelized-structure-map/dependency-compare/dependency-compare.component.html @@ -1,4 +1,6 @@ - + Show upward Dependencies Show downward Dependencies diff --git a/coderadar-ui/src/app/levelized-structure-map/dependency-root/dependency-root.component.html b/coderadar-ui/src/app/levelized-structure-map/dependency-root/dependency-root.component.html index cd714e631..34250d3a6 100644 --- a/coderadar-ui/src/app/levelized-structure-map/dependency-root/dependency-root.component.html +++ b/coderadar-ui/src/app/levelized-structure-map/dependency-root/dependency-root.component.html @@ -1,4 +1,6 @@ - + Show upward Dependencies Show downward Dependencies diff --git a/coderadar-ui/src/app/view/city-view/city-view-header/city-view-header.component.html b/coderadar-ui/src/app/view/city-view/city-view-header/city-view-header.component.html index c34eeba0f..f59f3d936 100644 --- a/coderadar-ui/src/app/view/city-view/city-view-header/city-view-header.component.html +++ b/coderadar-ui/src/app/view/city-view/city-view-header/city-view-header.component.html @@ -16,7 +16,7 @@
- + arrow_back_ios {{appComponent.trimProjectNameToLength(project.name, 16)}} diff --git a/coderadar-ui/src/app/view/city-view/city-view-header/city-view-header.component.ts b/coderadar-ui/src/app/view/city-view/city-view-header/city-view-header.component.ts index 0820efecb..da4dbbc77 100644 --- a/coderadar-ui/src/app/view/city-view/city-view-header/city-view-header.component.ts +++ b/coderadar-ui/src/app/view/city-view/city-view-header/city-view-header.component.ts @@ -24,28 +24,9 @@ export class CityViewHeaderComponent implements OnInit { } ngOnInit() { - this.projectId = this.appEffects.currentProjectId; - this.getProject(); + this.project = this.appEffects.currentProject; } - /** - * Gets the project from the service and saves it in this.project - */ - private getProject(): void { - this.projectService.getProject(this.projectId) - .then(response => { - this.project = new Project(response.body); - }) - .catch(error => { - if (error.status && error.status === FORBIDDEN) { - this.userService.refresh(() => this.getProject()); - } else if (error.status && error.status === NOT_FOUND) { - this.router.navigate(['/dashboard']); - } - }); - } - - logout(): void { this.userService.logout(); } diff --git a/coderadar-ui/src/app/view/city-view/city-view.component.ts b/coderadar-ui/src/app/view/city-view/city-view.component.ts index edc9bf7ef..dfadd9ec6 100644 --- a/coderadar-ui/src/app/view/city-view/city-view.component.ts +++ b/coderadar-ui/src/app/view/city-view/city-view.component.ts @@ -22,7 +22,6 @@ export class CityViewComponent implements OnInit { ngOnInit() { this.route.params.subscribe(params => { - this.cityEffects.currentProjectId = params.id; this.setTitle(params.id); }); } @@ -31,6 +30,7 @@ export class CityViewComponent implements OnInit { this.projectService.getProject(id) .then(response => { this.titleService.setTitle('Coderadar - ' + AppComponent.trimProjectName(response.body.name) + ' - 3D view'); + this.cityEffects.currentProject = new Project(response.body); }) .catch(error => { if (error.status && error.status === FORBIDDEN) { diff --git a/coderadar-ui/src/app/view/file-view/file-view.component.html b/coderadar-ui/src/app/view/file-view/file-view.component.html index d9b43e4d2..c05ab1b21 100644 --- a/coderadar-ui/src/app/view/file-view/file-view.component.html +++ b/coderadar-ui/src/app/view/file-view/file-view.component.html @@ -1,5 +1,5 @@
diff --git a/coderadar-ui/src/app/view/project-dashboard/list-view/list-view.component.ts b/coderadar-ui/src/app/view/project-dashboard/list-view/list-view.component.ts index 4227972dc..69058d4d6 100644 --- a/coderadar-ui/src/app/view/project-dashboard/list-view/list-view.component.ts +++ b/coderadar-ui/src/app/view/project-dashboard/list-view/list-view.component.ts @@ -76,7 +76,7 @@ export class ListViewComponent implements OnInit, OnChanges { this.route.params.subscribe(params => { this.projectId = params.id; this.selectedBranch = params.branch; - this.cityEffects.currentProjectId = this.projectId; + this.cityEffects.currentProject = this.project; this.showCommitsInRange(); }); } diff --git a/coderadar-ui/src/app/view/project-dashboard/project-dashboard.component.ts b/coderadar-ui/src/app/view/project-dashboard/project-dashboard.component.ts index 8594dee31..2d2d06ae7 100644 --- a/coderadar-ui/src/app/view/project-dashboard/project-dashboard.component.ts +++ b/coderadar-ui/src/app/view/project-dashboard/project-dashboard.component.ts @@ -69,7 +69,6 @@ export class ProjectDashboardComponent implements OnInit, OnDestroy { this.getCommits(true); } }); - this.cityEffects.currentProjectId = this.projectId; }); } @@ -125,6 +124,7 @@ export class ProjectDashboardComponent implements OnInit, OnDestroy { this.project = new Project(response.body.project); this.titleService.setTitle('Coderadar - ' + AppComponent.trimProjectName(this.project.name)); this.roles = response.body.roles; + this.cityEffects.currentProject = this.project; }) .catch(error => { if (error.status && error.status === FORBIDDEN) { diff --git a/coderadar-ui/src/app/view/view-commit/view-commit.component.html b/coderadar-ui/src/app/view/view-commit/view-commit.component.html index cf95cf50a..7972225a2 100644 --- a/coderadar-ui/src/app/view/view-commit/view-commit.component.html +++ b/coderadar-ui/src/app/view/view-commit/view-commit.component.html @@ -1,5 +1,5 @@