welcome page statistics

This commit is contained in:
annampak 2018-02-02 16:07:25 +02:00
parent 8653c06111
commit 47629c9e2b
8 changed files with 67 additions and 9 deletions

View File

@ -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({

View File

@ -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,

View File

@ -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())
}
}

View File

@ -28,4 +28,8 @@ export class DashboardService {
return this.http.get<DashboardStatisticsModel>(this.actionUrl + 'getStatistics', { headers: this.headers });
}
getStatisticsSpecificuser(): Observable<DashboardStatisticsModel> {
return this.http.get<DashboardStatisticsModel>(this.actionUrl + 'me/getStatistics', { headers: this.headers });
}
}

View File

@ -20,3 +20,7 @@
text-decoration: none;
padding-right: 15px;
}
.login-label{
font-size:14px;
}

View File

@ -7,10 +7,16 @@
<button *ngIf="isAdmin()" mat-button class="navbar-button" routerLink="/users">{{'NAV-BAR.USERS' | translate}}</button>
</div>
<span class="navbar-spacer"></span>
<div *ngIf="isAuthenticated()">
<div *ngIf="isAuthenticated();else loginoption">
<span class="user-label">{{this.getPrincipalName()}}</span>
<button mat-icon-button class="navbar-icon" (click)="logout()">
<mat-icon class="navbar-icon">exit_to_app</mat-icon>
</button>
</div>
<ng-template #loginoption>
<span class="login-label">Log in</span>
<button mat-icon-button class="navbar-icon" [routerLink]=" ['/login'] ">
<mat-icon class="navbar-icon">input</mat-icon>
</button>
</ng-template>
</mat-toolbar>

View File

@ -0,0 +1 @@
<homepage></homepage>

View File

@ -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() {
}
}