dashborad total counts from server

This commit is contained in:
annampak 2017-12-15 13:52:11 +02:00
parent 66447e29e9
commit d134efcb55
8 changed files with 70 additions and 18 deletions

View File

@ -104,12 +104,13 @@ import { SharedModule } from './shared/shared.module';
import { MaterialModule } from './shared/material/material.module';
import { AuthService } from './services/auth/auth.service';
import { ProjectListingComponent } from './projects/project-listing.component';
import { DashboardService } from './services/dashboard/dashboard.service';
import { BaseHttpService } from './utilities/cite-http-service-module/base-http.service';
import { DataManagementPlanListingComponent } from './dmps/dmp-listing.component';
import { ProjectEditorComponent } from './projects/editor/project-editor.component';
import { DataManagementPlanEditorComponent } from './dmps/editor/dmp-editor.component';
import { FigurecardComponent } from './figurecard/figurecard.component';
import { FigurecardComponent } from './shared/components/figurecard/figurecard.component';
@ -195,7 +196,7 @@ import { FigurecardComponent } from './figurecard/figurecard.component';
},
ServerService, VisibilityRulesService, PaginationService, GlobalVariables, AuthGuard, TokenService,
LocalStorageService, RestBase, EestoreService, NativeLoginService, PDFService,
AuthService,
AuthService,DashboardService,
BaseHttpService
],
bootstrap: [AppComponent]

View File

@ -21,7 +21,7 @@
<div class="icon">
<i class="material-icons">list</i>
</div>
<h3 class="card-title">52</h3>
<h3 class="card-title">{{dashboardStatisticsData.totalProjectCount}}</h3>
<p class="card-description text-center">
This is good if your company size is between 2 and 10 Persons.
</p>
@ -34,7 +34,7 @@
<div class="icon">
<i class="material-icons">mode_edit</i>
</div>
<h3 class="card-title">33</h3>
<h3 class="card-title">{{dashboardStatisticsData.totalDataManagementPlanCount}}</h3>
<p class="card-description text-center">
This is good if your company size is between 2 and 10 Persons.
</p>
@ -47,7 +47,7 @@
<div class="icon">
<i class="material-icons">subject</i>
</div>
<h3 class="card-title">3</h3>
<h3 class="card-title">{{dashboardStatisticsData.totalDataSetCount}}</h3>
<p class="card-description text-center">
This is good if your company size is between 2 and 10 Persons.
</p>
@ -64,7 +64,7 @@
<div class="row" style="margin-top: 30px">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 col-md-offset-1">
<app-figurecard
title="184"
title={{dashboardStatisticsData.totalProjectCount}}
headerIcon="list"
category="Projects"
footContent="open projects"
@ -75,7 +75,7 @@
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<app-figurecard
title="75.521"
title={{dashboardStatisticsData.totalDataManagementPlanCount}}
headerIcon="mode_edit"
category="DMPs"
footContent="open DMPs"
@ -86,7 +86,7 @@
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<app-figurecard
title="+245"
title={{dashboardStatisticsData.totalDataSetCount}}
headerIcon="subject"
category="Datasets"
footContent="open datasets"

View File

@ -1,7 +1,9 @@
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { ServerService } from '../../app/services/server.service';
import { RestBase } from '../../app/services/rest-base';
import { DashboardService } from '../../app/services/dashboard/dashboard.service';
import { DashboardStatisticsModel } from '../models/dashboard/DashboardStatisticsModel';
import { JsonSerializer } from '../utilities/JsonSerializer';
@Component({
selector: 'homepage',
@ -12,9 +14,12 @@ import { RestBase } from '../../app/services/rest-base';
export class HomepageComponent implements OnInit{
private userInfo: any;
private dashboardStatisticsData:DashboardStatisticsModel = new DashboardStatisticsModel();
constructor(private serverService: ServerService, private route: ActivatedRoute, private router: Router, private restbase: RestBase){
constructor(private serverService: ServerService, private route: ActivatedRoute, private router: Router, private dashBoardService: DashboardService){
this.dashboardStatisticsData.totalDataManagementPlanCount = 0;
this.dashboardStatisticsData.totalDataSetCount = 0;
this.dashboardStatisticsData.totalProjectCount = 0;
}
@ -24,14 +29,14 @@ export class HomepageComponent implements OnInit{
this.userInfo = userInfo;
},
error => {
}
);
}
this.dashBoardService.getStatistics().subscribe(data =>{
debugger;
this.dashboardStatisticsData = new JsonSerializer<DashboardStatisticsModel>().fromJSONObject(data,DashboardStatisticsModel);
})
getStatistics(){
return this.restbase.get("datasetprofile/getAll");
}
}

View File

@ -0,0 +1,15 @@
import { Serializable } from "../Serializable";
export class DashboardStatisticsModel implements Serializable<DashboardStatisticsModel>{
public totalDataManagementPlanCount: number;
public totalProjectCount: number;
public totalDataSetCount: number;
fromJSONObject(item: any): DashboardStatisticsModel {
this.totalDataManagementPlanCount = item.totalDataManagementPlanCount;
this.totalProjectCount = item.totalProjectCount;
this.totalDataSetCount = item.totalDataSetCount;
return this;
}
}

View File

@ -0,0 +1,31 @@
import 'rxjs/add/operator/map';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { HostConfiguration } from './../../app.constants';
import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service';
import { Observable } from 'rxjs/Observable';
import { DashboardStatisticsModel } from '../../models/dashboard/DashboardStatisticsModel';
@Injectable()
export class DashboardService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
this.actionUrl = HostConfiguration.Server + 'dashboard/';
this.headers = new HttpHeaders();
this.headers = this.headers.set('Content-Type', 'application/json');
this.headers = this.headers.set('Accept', 'application/json');
}
getStatistics(): Observable<DashboardStatisticsModel> {
return this.http.get<DashboardStatisticsModel>(this.actionUrl + 'getStatistics', { headers: this.headers });
}
}