adding dashbord
This commit is contained in:
55
pdb-js/src/app/dashboard.service.ts
Normal file
55
pdb-js/src/app/dashboard.service.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DashboardService {
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
createDashboard(data: DashboardCreationData): Observable<Dashboard>{
|
||||
return this.http.post<Dashboard>('//'+window.location.hostname+':'+window.location.port+'/api/dashboards/', data);
|
||||
}
|
||||
|
||||
getDashboards(): Observable<DashboardList>{
|
||||
return this.http.get<DashboardList>('//'+window.location.hostname+':'+window.location.port+'/api/dashboards/');
|
||||
}
|
||||
|
||||
getDashboard(id: string): Observable<Dashboard>{
|
||||
return this.http.get<Dashboard>('//'+window.location.hostname+':'+window.location.port+'/api/dashboards/'+id);
|
||||
}
|
||||
|
||||
saveDashboard(dashboard: Dashboard): Observable<Dashboard>{
|
||||
return this.http.put<Dashboard>('//'+window.location.hostname+':'+window.location.port+'/api/dashboards/'+dashboard.id, dashboard);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class DashboardCreationData{
|
||||
constructor(public name: string, public description: string){}
|
||||
}
|
||||
|
||||
export class Dashboard{
|
||||
constructor(public id: string, public name: string, public description: string, public texts: [TextWidget]){}
|
||||
}
|
||||
|
||||
export class DashboardList{
|
||||
constructor(public dashboards: [Dashboard]){}
|
||||
}
|
||||
|
||||
export abstract class BaseWidget {
|
||||
constructor(public type: 'TEXT'|'PLOT', public size: 'SMALL'|'MEDIUM'|'LARGE') {}
|
||||
}
|
||||
|
||||
export class TextWidget extends BaseWidget {
|
||||
constructor(override size: 'SMALL'|'MEDIUM'|'LARGE', public text: string) {
|
||||
super('TEXT', size);
|
||||
}
|
||||
}
|
||||
export class PlotWidget extends BaseWidget {
|
||||
constructor(override size: 'SMALL'|'MEDIUM'|'LARGE') {
|
||||
super('PLOT', size);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user