From 47629c9e2b9477b363630cf7259384a24adb9ce9 Mon Sep 17 00:00:00 2001 From: annampak Date: Fri, 2 Feb 2018 16:07:25 +0200 Subject: [PATCH] welcome page statistics --- dmp-frontend/src/app/app-routing.module.ts | 6 +++-- dmp-frontend/src/app/app.module.ts | 4 ++- .../src/app/homepage/homepage.component.ts | 23 ++++++++++++---- .../services/dashboard/dashboard.service.ts | 4 +++ .../navigation/navigation.component.css | 4 +++ .../navigation/navigation.component.html | 8 +++++- .../welcomepage/welcomepage.component.html | 1 + .../app/welcomepage/welcomepage.component.ts | 26 +++++++++++++++++++ 8 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 dmp-frontend/src/app/welcomepage/welcomepage.component.html create mode 100644 dmp-frontend/src/app/welcomepage/welcomepage.component.ts diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index 08f90cb8a..f70d29cdf 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -5,16 +5,18 @@ import { RouterModule, Routes } from '@angular/router'; import { HomepageComponent } from './homepage/homepage.component'; import { AuthGuard } from './guards/auth.guard'; import { LoginComponent } from './user-management/login/login.component'; +import { WelcomepageComponent } from '@app/welcomepage/welcomepage.component'; const appRoutes: Routes = [ { path: 'datasets', loadChildren: './datasets/dataset.module#DatasetModule' ,canActivate: [AuthGuard]}, { path: 'projects', loadChildren: './projects/projects.module#ProjectsModule',canActivate: [AuthGuard] }, { path: "dmps", loadChildren: './dmps/dmps.module#DataManagementPlanModule',canActivate: [AuthGuard] }, { path: 'form', loadChildren: './dataset-profile-form/dataset-profile.module#DatasetProfileModule', canActivate: [AuthGuard]}, - { path: 'welcome', component: HomepageComponent, canActivate: [AuthGuard] }, + { path: 'home', component: HomepageComponent, canActivate: [AuthGuard] }, { path: '', redirectTo: '/welcome', pathMatch: 'full' }, { path: "unauthorized", loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule' }, - { path: "users", loadChildren: './users/users.module#UsersModule' } + { path: "users", loadChildren: './users/users.module#UsersModule' }, + { path: "welcome", component: WelcomepageComponent } ]; @NgModule({ diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index beb768b5a..46d74de9d 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -31,13 +31,15 @@ import { PageNotFoundComponent } from './not-found.component'; import { AppComponent } from './app.component'; import { NgModule } from "@angular/core"; import { DatasetProfileModule } from './dataset-profile-form/dataset-profile.module'; +import { WelcomepageComponent } from '@app/welcomepage/welcomepage.component'; @NgModule({ declarations: [ AppComponent, PageNotFoundComponent, - HomepageComponent + HomepageComponent, + WelcomepageComponent ], imports: [ BrowserModule, diff --git a/dmp-frontend/src/app/homepage/homepage.component.ts b/dmp-frontend/src/app/homepage/homepage.component.ts index ccfb7b604..2aa54361b 100644 --- a/dmp-frontend/src/app/homepage/homepage.component.ts +++ b/dmp-frontend/src/app/homepage/homepage.component.ts @@ -3,6 +3,7 @@ import { Router, ActivatedRoute } from '@angular/router'; import { DashboardService } from '../../app/services/dashboard/dashboard.service'; import { DashboardStatisticsModel } from '../models/dashboard/DashboardStatisticsModel'; import { JsonSerializer } from '../utilities/JsonSerializer'; +import { AuthService } from '@app/services/auth/auth.service'; @Component({ selector: 'homepage', @@ -18,7 +19,8 @@ export class HomepageComponent implements OnInit { constructor( private route: ActivatedRoute, private router: Router, - private dashBoardService: DashboardService + private dashBoardService: DashboardService, + private authentication: AuthService ) { this.dashboardStatisticsData.totalDataManagementPlanCount = 0; this.dashboardStatisticsData.totalDataSetCount = 0; @@ -28,11 +30,22 @@ export class HomepageComponent implements OnInit { ngOnInit() { - this.dashBoardService.getStatistics().subscribe(results => { - //let data = results['payload']; - this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel); - }) + if(!this.isAuthenticated()){ + this.dashBoardService.getStatistics().subscribe(results => { + //let data = results['payload']; + this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel); + }) + }else{ + this.dashBoardService.getStatisticsSpecificuser().subscribe(results => { + this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel); + }) + } + } + public isAuthenticated(): boolean { + return !(!this.authentication.current()) + } + } \ No newline at end of file diff --git a/dmp-frontend/src/app/services/dashboard/dashboard.service.ts b/dmp-frontend/src/app/services/dashboard/dashboard.service.ts index 7556a37a8..d6c35a00b 100644 --- a/dmp-frontend/src/app/services/dashboard/dashboard.service.ts +++ b/dmp-frontend/src/app/services/dashboard/dashboard.service.ts @@ -28,4 +28,8 @@ export class DashboardService { return this.http.get(this.actionUrl + 'getStatistics', { headers: this.headers }); } + getStatisticsSpecificuser(): Observable { + return this.http.get(this.actionUrl + 'me/getStatistics', { headers: this.headers }); + } + } diff --git a/dmp-frontend/src/app/shared/components/navigation/navigation.component.css b/dmp-frontend/src/app/shared/components/navigation/navigation.component.css index b3396c2cc..762f55639 100644 --- a/dmp-frontend/src/app/shared/components/navigation/navigation.component.css +++ b/dmp-frontend/src/app/shared/components/navigation/navigation.component.css @@ -20,3 +20,7 @@ text-decoration: none; padding-right: 15px; } + +.login-label{ + font-size:14px; +} diff --git a/dmp-frontend/src/app/shared/components/navigation/navigation.component.html b/dmp-frontend/src/app/shared/components/navigation/navigation.component.html index 74c0c39ba..2d2045813 100644 --- a/dmp-frontend/src/app/shared/components/navigation/navigation.component.html +++ b/dmp-frontend/src/app/shared/components/navigation/navigation.component.html @@ -7,10 +7,16 @@ -
+
{{this.getPrincipalName()}}
+ + + + \ No newline at end of file diff --git a/dmp-frontend/src/app/welcomepage/welcomepage.component.html b/dmp-frontend/src/app/welcomepage/welcomepage.component.html new file mode 100644 index 000000000..be5bbfb10 --- /dev/null +++ b/dmp-frontend/src/app/welcomepage/welcomepage.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dmp-frontend/src/app/welcomepage/welcomepage.component.ts b/dmp-frontend/src/app/welcomepage/welcomepage.component.ts new file mode 100644 index 000000000..d67ebc8e9 --- /dev/null +++ b/dmp-frontend/src/app/welcomepage/welcomepage.component.ts @@ -0,0 +1,26 @@ +import { Component, OnInit } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; +import { DashboardService } from '../../app/services/dashboard/dashboard.service'; +import { DashboardStatisticsModel } from '../models/dashboard/DashboardStatisticsModel'; +import { JsonSerializer } from '../utilities/JsonSerializer'; +import { HomepageComponent } from '../homepage/homepage.component' + +@Component({ + selector: 'welcomepage', + templateUrl: './welcomepage.component.html', + // styleUrls: ['./homepage.component.css'], + providers: [DashboardService] +}) +export class WelcomepageComponent implements OnInit { + + private userInfo: any; + private dashboardStatisticsData: DashboardStatisticsModel = new DashboardStatisticsModel(); + + constructor( ) { + } + + ngOnInit() { + + } + +} \ No newline at end of file