From d134efcb55d2350884f4386bc6a27842fdcec9f9 Mon Sep 17 00:00:00 2001 From: annampak Date: Fri, 15 Dec 2017 13:52:11 +0200 Subject: [PATCH] dashborad total counts from server --- dmp-frontend/src/app/app.module.ts | 5 +-- .../src/app/homepage/homepage.component.html | 12 +++---- .../src/app/homepage/homepage.component.ts | 25 +++++++++------ .../dashboard/DashboardStatisticsModel.ts | 15 +++++++++ .../services/dashboard/dashboard.service.ts | 31 +++++++++++++++++++ .../figurecard/figurecard.component.css | 0 .../figurecard/figurecard.component.html | 0 .../figurecard/figurecard.component.ts | 0 8 files changed, 70 insertions(+), 18 deletions(-) create mode 100644 dmp-frontend/src/app/models/dashboard/DashboardStatisticsModel.ts create mode 100644 dmp-frontend/src/app/services/dashboard/dashboard.service.ts rename dmp-frontend/src/app/{ => shared/components}/figurecard/figurecard.component.css (100%) rename dmp-frontend/src/app/{ => shared/components}/figurecard/figurecard.component.html (100%) rename dmp-frontend/src/app/{ => shared/components}/figurecard/figurecard.component.ts (100%) diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index f4daaffcb..5b219e249 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -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] diff --git a/dmp-frontend/src/app/homepage/homepage.component.html b/dmp-frontend/src/app/homepage/homepage.component.html index 0e28568e7..a056b7540 100644 --- a/dmp-frontend/src/app/homepage/homepage.component.html +++ b/dmp-frontend/src/app/homepage/homepage.component.html @@ -21,7 +21,7 @@
list
-

52

+

{{dashboardStatisticsData.totalProjectCount}}

This is good if your company size is between 2 and 10 Persons.

@@ -34,7 +34,7 @@
mode_edit
-

33

+

{{dashboardStatisticsData.totalDataManagementPlanCount}}

This is good if your company size is between 2 and 10 Persons.

@@ -47,7 +47,7 @@
subject
-

3

+

{{dashboardStatisticsData.totalDataSetCount}}

This is good if your company size is between 2 and 10 Persons.

@@ -64,7 +64,7 @@
{ - } - ); + ); + + this.dashBoardService.getStatistics().subscribe(data =>{ + debugger; + this.dashboardStatisticsData = new JsonSerializer().fromJSONObject(data,DashboardStatisticsModel); + }) } - getStatistics(){ - return this.restbase.get("datasetprofile/getAll"); - } - } \ No newline at end of file diff --git a/dmp-frontend/src/app/models/dashboard/DashboardStatisticsModel.ts b/dmp-frontend/src/app/models/dashboard/DashboardStatisticsModel.ts new file mode 100644 index 000000000..2af2dd294 --- /dev/null +++ b/dmp-frontend/src/app/models/dashboard/DashboardStatisticsModel.ts @@ -0,0 +1,15 @@ +import { Serializable } from "../Serializable"; + +export class DashboardStatisticsModel implements Serializable{ + 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; + } + +} \ 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 new file mode 100644 index 000000000..7556a37a8 --- /dev/null +++ b/dmp-frontend/src/app/services/dashboard/dashboard.service.ts @@ -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 { + return this.http.get(this.actionUrl + 'getStatistics', { headers: this.headers }); + } + +} diff --git a/dmp-frontend/src/app/figurecard/figurecard.component.css b/dmp-frontend/src/app/shared/components/figurecard/figurecard.component.css similarity index 100% rename from dmp-frontend/src/app/figurecard/figurecard.component.css rename to dmp-frontend/src/app/shared/components/figurecard/figurecard.component.css diff --git a/dmp-frontend/src/app/figurecard/figurecard.component.html b/dmp-frontend/src/app/shared/components/figurecard/figurecard.component.html similarity index 100% rename from dmp-frontend/src/app/figurecard/figurecard.component.html rename to dmp-frontend/src/app/shared/components/figurecard/figurecard.component.html diff --git a/dmp-frontend/src/app/figurecard/figurecard.component.ts b/dmp-frontend/src/app/shared/components/figurecard/figurecard.component.ts similarity index 100% rename from dmp-frontend/src/app/figurecard/figurecard.component.ts rename to dmp-frontend/src/app/shared/components/figurecard/figurecard.component.ts