[MonitorDashboard]: Add service of stakeholder. Move copy to Library. Change name of Tools to IndicatorUtils.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@57574 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
153912442d
commit
8210fe3e37
|
@ -8,7 +8,7 @@ import {ErrorMessagesComponent} from '../openaireLibrary/utils/errorMessages.com
|
|||
import {Stakeholder, Topic} from "../utils/entities/stakeholder";
|
||||
import {SideBarService} from "../library/sharedComponents/sidebar/sideBar.service";
|
||||
import {StakeholderService} from "../services/stakeholder.service";
|
||||
import {Tools} from "../utils/Tools";
|
||||
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
||||
|
||||
declare var UIkit;
|
||||
|
||||
|
@ -45,7 +45,7 @@ export class HomeComponent implements OnInit, OnDestroy {
|
|||
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
||||
if (stakeholder) {
|
||||
this.sideBarService.setHasSidebar(true);
|
||||
this.stakeholder = Tools.copy(stakeholder);
|
||||
this.stakeholder = HelperFunctions.copy(stakeholder);
|
||||
this.topic = null;
|
||||
this.title.setTitle(stakeholder.index_name);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {Injectable} from "@angular/core";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {BehaviorSubject, Observable} from "rxjs";
|
||||
import {Stakeholder} from "../utils/entities/stakeholder";
|
||||
import {Indicator, Stakeholder} from "../utils/entities/stakeholder";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root"
|
||||
|
@ -16,7 +16,33 @@ export class StakeholderService {
|
|||
|
||||
getStakeholder(url: string, alias:string): Observable<Stakeholder> {
|
||||
// return new BehaviorSubject<Stakeholder>(Stakeholder.createECStakeholder()).asObservable();
|
||||
return this.http.get<Stakeholder>(url + '/stakeholder/' + alias);
|
||||
return this.http.get<Stakeholder>(url + '/stakeholder/' + encodeURIComponent(alias));
|
||||
}
|
||||
|
||||
getAllStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
|
||||
return this.http.get<Stakeholder[]>(url + '/stakeholder/all' + (type)?('?type=' + type):'');
|
||||
}
|
||||
|
||||
getStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
|
||||
return this.http.get<Stakeholder[]>(url + '/stakeholder' + (type)?('?type=' + type):'');
|
||||
}
|
||||
|
||||
getDefaultStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
|
||||
return this.http.get<Stakeholder[]>(url + '/stakeholder/default' + (type)?('?type=' + type):'');
|
||||
}
|
||||
|
||||
saveStakeholder(url: string, stakeholder: Stakeholder): Observable<Stakeholder> {
|
||||
return this.http.post<Stakeholder>(url + '/stakeholder/save', stakeholder);
|
||||
}
|
||||
|
||||
saveIndicator(url: string, path: string[], indicator: Indicator): Observable<Indicator> {
|
||||
return this.http.post<Indicator>(url + '/' + path.join('/') +
|
||||
'/indicator/save', indicator);
|
||||
}
|
||||
|
||||
deleteIndicator(url: string, path: string[], indicatorId: string): Observable<boolean> {
|
||||
return this.http.delete<boolean>(url + '/' + path.join('/') +
|
||||
'/indicator/delete/' + encodeURIComponent(indicatorId));
|
||||
}
|
||||
|
||||
getStakeholderAsObservable(): Observable<Stakeholder> {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {Component, Input, OnChanges, OnInit, SimpleChanges} from "@angular/core";
|
||||
import {SideBarService} from "../library/sharedComponents/sidebar/sideBar.service";
|
||||
import {Indicator, Stakeholder} from "../utils/entities/stakeholder";
|
||||
import {IndicatorUtils} from "../utils/Tools";
|
||||
import {IndicatorUtils} from "../utils/indicator-utils";
|
||||
|
||||
@Component({
|
||||
selector: 'indicators',
|
||||
|
|
|
@ -5,7 +5,7 @@ import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'
|
|||
import {Category, Stakeholder, SubCategory, Topic} from "../utils/entities/stakeholder";
|
||||
import {SideBarService} from "../library/sharedComponents/sidebar/sideBar.service";
|
||||
import {StakeholderService} from "../services/stakeholder.service";
|
||||
import {Tools} from "../utils/Tools";
|
||||
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
||||
|
||||
declare var UIkit;
|
||||
|
||||
|
@ -44,7 +44,7 @@ export class TopicComponent implements OnInit, OnDestroy {
|
|||
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
||||
if (stakeholder) {
|
||||
this.sideBarService.setHasSidebar(true);
|
||||
this.stakeholder = Tools.copy(stakeholder);
|
||||
this.stakeholder = HelperFunctions.copy(stakeholder);
|
||||
this.topicIndex = this.stakeholder.topics.findIndex(topic => topic.alias === params['topic']);
|
||||
if(this.topicIndex === -1) {
|
||||
this.navigateToError();
|
||||
|
@ -90,7 +90,7 @@ export class TopicComponent implements OnInit, OnDestroy {
|
|||
if(element.className.indexOf('uk-open') !== -1) {
|
||||
this.hide(element);
|
||||
} else {
|
||||
this.copyCategory = Tools.copy(this.stakeholder.topics[this.topicIndex].categories[index]);
|
||||
this.copyCategory = HelperFunctions.copy(this.stakeholder.topics[this.topicIndex].categories[index]);
|
||||
this.show(element);
|
||||
this.valid = true;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ export class TopicComponent implements OnInit, OnDestroy {
|
|||
if(index === -1) {
|
||||
this.stakeholder.topics[this.topicIndex].categories.push(this.copyCategory);
|
||||
} else {
|
||||
this.stakeholder.topics[this.topicIndex].categories[index] = Tools.copy(this.copyCategory);
|
||||
this.stakeholder.topics[this.topicIndex].categories[index] = HelperFunctions.copy(this.copyCategory);
|
||||
}
|
||||
this.hide(element);
|
||||
} else {
|
||||
|
@ -118,7 +118,7 @@ export class TopicComponent implements OnInit, OnDestroy {
|
|||
if(element.className.indexOf('uk-open') !== -1) {
|
||||
this.hide(element);
|
||||
} else {
|
||||
this.copySubCategory = Tools.copy(this.stakeholder.topics[this.topicIndex].
|
||||
this.copySubCategory = HelperFunctions.copy(this.stakeholder.topics[this.topicIndex].
|
||||
categories[this.categoryIndex].subCategories[index]);
|
||||
this.show(element);
|
||||
this.valid = true;
|
||||
|
@ -134,7 +134,7 @@ export class TopicComponent implements OnInit, OnDestroy {
|
|||
subCategories.push(this.copySubCategory);
|
||||
} else {
|
||||
this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex].
|
||||
subCategories[index] = Tools.copy(this.copySubCategory);
|
||||
subCategories[index] = HelperFunctions.copy(this.copySubCategory);
|
||||
}
|
||||
this.hide(element);
|
||||
} else {
|
||||
|
@ -146,7 +146,7 @@ export class TopicComponent implements OnInit, OnDestroy {
|
|||
if(element.className.indexOf('uk-open') !== -1) {
|
||||
this.hide(element);
|
||||
} else {
|
||||
this.topic = Tools.copy(this.stakeholder.topics[this.topicIndex]);
|
||||
this.topic = HelperFunctions.copy(this.stakeholder.topics[this.topicIndex]);
|
||||
this.valid = true;
|
||||
this.show(element);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ export class TopicComponent implements OnInit, OnDestroy {
|
|||
public saveTopic(element) {
|
||||
if(this.topic.name && this.topic.name !== '') {
|
||||
this.topic.alias = this.topic.name.toLowerCase();
|
||||
this.stakeholder.topics[this.topicIndex] = Tools.copy(this.topic);
|
||||
this.stakeholder.topics[this.topicIndex] = HelperFunctions.copy(this.topic);
|
||||
this.hide(element);
|
||||
} else {
|
||||
this.valid = false;
|
||||
|
|
|
@ -16,10 +16,3 @@ export class IndicatorUtils {
|
|||
|
||||
isActiveIcon: string = 'brightness_1';
|
||||
}
|
||||
|
||||
export class Tools {
|
||||
|
||||
public static copy(element: any): any {
|
||||
return JSON.parse(JSON.stringify(element));
|
||||
}
|
||||
}
|
|
@ -49,7 +49,7 @@ li>a:hover .onHover {
|
|||
margin-left: var(--sidebar-width) !important;
|
||||
}
|
||||
}
|
||||
/* Custom width of sidebar, change var: sidebar-width*/
|
||||
/* Custom height of header, change var: header-height*/
|
||||
body {
|
||||
padding-top: var(--header-height) !important;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue