welcome page statistics
This commit is contained in:
parent
8653c06111
commit
47629c9e2b
|
@ -5,16 +5,18 @@ import { RouterModule, Routes } from '@angular/router';
|
||||||
import { HomepageComponent } from './homepage/homepage.component';
|
import { HomepageComponent } from './homepage/homepage.component';
|
||||||
import { AuthGuard } from './guards/auth.guard';
|
import { AuthGuard } from './guards/auth.guard';
|
||||||
import { LoginComponent } from './user-management/login/login.component';
|
import { LoginComponent } from './user-management/login/login.component';
|
||||||
|
import { WelcomepageComponent } from '@app/welcomepage/welcomepage.component';
|
||||||
|
|
||||||
const appRoutes: Routes = [
|
const appRoutes: Routes = [
|
||||||
{ path: 'datasets', loadChildren: './datasets/dataset.module#DatasetModule' ,canActivate: [AuthGuard]},
|
{ path: 'datasets', loadChildren: './datasets/dataset.module#DatasetModule' ,canActivate: [AuthGuard]},
|
||||||
{ path: 'projects', loadChildren: './projects/projects.module#ProjectsModule',canActivate: [AuthGuard] },
|
{ path: 'projects', loadChildren: './projects/projects.module#ProjectsModule',canActivate: [AuthGuard] },
|
||||||
{ path: "dmps", loadChildren: './dmps/dmps.module#DataManagementPlanModule',canActivate: [AuthGuard] },
|
{ path: "dmps", loadChildren: './dmps/dmps.module#DataManagementPlanModule',canActivate: [AuthGuard] },
|
||||||
{ path: 'form', loadChildren: './dataset-profile-form/dataset-profile.module#DatasetProfileModule', 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: '', redirectTo: '/welcome', pathMatch: 'full' },
|
||||||
{ path: "unauthorized", loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule' },
|
{ 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({
|
@NgModule({
|
||||||
|
|
|
@ -31,13 +31,15 @@ import { PageNotFoundComponent } from './not-found.component';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { NgModule } from "@angular/core";
|
import { NgModule } from "@angular/core";
|
||||||
import { DatasetProfileModule } from './dataset-profile-form/dataset-profile.module';
|
import { DatasetProfileModule } from './dataset-profile-form/dataset-profile.module';
|
||||||
|
import { WelcomepageComponent } from '@app/welcomepage/welcomepage.component';
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
PageNotFoundComponent,
|
PageNotFoundComponent,
|
||||||
HomepageComponent
|
HomepageComponent,
|
||||||
|
WelcomepageComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { Router, ActivatedRoute } from '@angular/router';
|
||||||
import { DashboardService } from '../../app/services/dashboard/dashboard.service';
|
import { DashboardService } from '../../app/services/dashboard/dashboard.service';
|
||||||
import { DashboardStatisticsModel } from '../models/dashboard/DashboardStatisticsModel';
|
import { DashboardStatisticsModel } from '../models/dashboard/DashboardStatisticsModel';
|
||||||
import { JsonSerializer } from '../utilities/JsonSerializer';
|
import { JsonSerializer } from '../utilities/JsonSerializer';
|
||||||
|
import { AuthService } from '@app/services/auth/auth.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'homepage',
|
selector: 'homepage',
|
||||||
|
@ -18,7 +19,8 @@ export class HomepageComponent implements OnInit {
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private dashBoardService: DashboardService
|
private dashBoardService: DashboardService,
|
||||||
|
private authentication: AuthService
|
||||||
) {
|
) {
|
||||||
this.dashboardStatisticsData.totalDataManagementPlanCount = 0;
|
this.dashboardStatisticsData.totalDataManagementPlanCount = 0;
|
||||||
this.dashboardStatisticsData.totalDataSetCount = 0;
|
this.dashboardStatisticsData.totalDataSetCount = 0;
|
||||||
|
@ -28,11 +30,22 @@ export class HomepageComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.dashBoardService.getStatistics().subscribe(results => {
|
if(!this.isAuthenticated()){
|
||||||
//let data = results['payload'];
|
this.dashBoardService.getStatistics().subscribe(results => {
|
||||||
this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel);
|
//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())
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -28,4 +28,8 @@ export class DashboardService {
|
||||||
return this.http.get<DashboardStatisticsModel>(this.actionUrl + 'getStatistics', { headers: this.headers });
|
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 });
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,3 +20,7 @@
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
padding-right: 15px;
|
padding-right: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.login-label{
|
||||||
|
font-size:14px;
|
||||||
|
}
|
||||||
|
|
|
@ -7,10 +7,16 @@
|
||||||
<button *ngIf="isAdmin()" mat-button class="navbar-button" routerLink="/users">{{'NAV-BAR.USERS' | translate}}</button>
|
<button *ngIf="isAdmin()" mat-button class="navbar-button" routerLink="/users">{{'NAV-BAR.USERS' | translate}}</button>
|
||||||
</div>
|
</div>
|
||||||
<span class="navbar-spacer"></span>
|
<span class="navbar-spacer"></span>
|
||||||
<div *ngIf="isAuthenticated()">
|
<div *ngIf="isAuthenticated();else loginoption">
|
||||||
<span class="user-label">{{this.getPrincipalName()}}</span>
|
<span class="user-label">{{this.getPrincipalName()}}</span>
|
||||||
<button mat-icon-button class="navbar-icon" (click)="logout()">
|
<button mat-icon-button class="navbar-icon" (click)="logout()">
|
||||||
<mat-icon class="navbar-icon">exit_to_app</mat-icon>
|
<mat-icon class="navbar-icon">exit_to_app</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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>
|
</mat-toolbar>
|
|
@ -0,0 +1 @@
|
||||||
|
<homepage></homepage>
|
|
@ -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() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue