[Monitor Dashboard]: Merge create and edit modals. Rename SidebarService to LayoutService and add hasSidebar on it
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@57706 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
228ebb8e11
commit
bd82b388ef
|
@ -1,6 +1,6 @@
|
||||||
<!--disable_transitions -->
|
<!--disable_transitions -->
|
||||||
<div class="sidebar_main_swipe" [class.sidebar_main_active]="open && hasSidebar">
|
<div class="sidebar_main_swipe" [class.sidebar_main_active]="open && hasSidebar">
|
||||||
<div id="header_main"[class.header_full]="!hasSidebar">
|
<div *ngIf="hasHeader" id="header_main" [class.header_full]="!hasSidebar">
|
||||||
<div class="uk-light">
|
<div class="uk-light">
|
||||||
<a *ngIf="hasSidebar" id="sidebar_main_toggle" (click)="toggleOpen()" class="sSwitch sSwitch_left">
|
<a *ngIf="hasSidebar" id="sidebar_main_toggle" (click)="toggleOpen()" class="sSwitch sSwitch_left">
|
||||||
<span class="sSwitchIcon"></span>
|
<span class="sSwitchIcon"></span>
|
||||||
|
|
|
@ -5,9 +5,9 @@ import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
||||||
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
||||||
import {User} from './openaireLibrary/login/utils/helper.class';
|
import {User} from './openaireLibrary/login/utils/helper.class';
|
||||||
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
||||||
import {SideBarService} from "./library/sharedComponents/sidebar/sideBar.service";
|
|
||||||
import {StakeholderService} from "./services/stakeholder.service";
|
import {StakeholderService} from "./services/stakeholder.service";
|
||||||
import {Subscriber} from "rxjs";
|
import {Subscriber} from "rxjs";
|
||||||
|
import {LayoutService} from "./library/sharedComponents/sidebar/layout.service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -19,13 +19,14 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
user: User;
|
user: User;
|
||||||
loginCheck: boolean = false;
|
loginCheck: boolean = false;
|
||||||
hasSidebar: boolean = false;
|
hasSidebar: boolean = false;
|
||||||
|
hasHeader: boolean = false;
|
||||||
private subscriptions: any[] = [];
|
private subscriptions: any[] = [];
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private propertiesService: EnvironmentSpecificService,
|
private propertiesService: EnvironmentSpecificService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private userManagementService: UserManagementService,
|
private userManagementService: UserManagementService,
|
||||||
private sidebarService: SideBarService,
|
private layoutService: LayoutService,
|
||||||
private stakeholderService: StakeholderService,
|
private stakeholderService: StakeholderService,
|
||||||
private cdr: ChangeDetectorRef) {
|
private cdr: ChangeDetectorRef) {
|
||||||
}
|
}
|
||||||
|
@ -46,8 +47,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
this.stakeholderService.stakeholder.alias !== params['stakeholder']) {
|
this.stakeholderService.stakeholder.alias !== params['stakeholder']) {
|
||||||
this.stakeholderService.getStakeholder(this.properties.monitorServiceAPIURL, params['stakeholder']).subscribe(stakeholder => {
|
this.stakeholderService.getStakeholder(this.properties.monitorServiceAPIURL, params['stakeholder']).subscribe(stakeholder => {
|
||||||
this.stakeholderService.setStakeholder(stakeholder);
|
this.stakeholderService.setStakeholder(stakeholder);
|
||||||
console.log(stakeholder);
|
this.layoutService.setOpen(true);
|
||||||
this.sidebarService.setOpen(true);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,10 +64,15 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.subscriptions.push(this.sidebarService.hasSidebar.subscribe(hasSidebar => {
|
this.subscriptions.push(this.layoutService.hasSidebar.subscribe(hasSidebar => {
|
||||||
this.hasSidebar = hasSidebar;
|
this.hasSidebar = hasSidebar;
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
}));
|
}));
|
||||||
|
this.subscriptions.push(this.layoutService.hasHeader.subscribe(hasHeader => {
|
||||||
|
this.hasHeader = hasHeader;
|
||||||
|
console.log(this.hasHeader);
|
||||||
|
this.cdr.detectChanges();
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
|
@ -79,14 +84,14 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public get open() {
|
public get open() {
|
||||||
return this.sidebarService.open;
|
return this.layoutService.open;
|
||||||
}
|
}
|
||||||
|
|
||||||
public toggleOpen(event = null) {
|
public toggleOpen(event = null) {
|
||||||
if (!event) {
|
if (!event) {
|
||||||
this.sidebarService.setOpen(!this.open);
|
this.layoutService.setOpen(!this.open);
|
||||||
} else if (event && event['value'] === true) {
|
} else if (event && event['value'] === true) {
|
||||||
this.sidebarService.setOpen(false);
|
this.layoutService.setOpen(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,12 @@ import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'
|
||||||
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
|
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
|
||||||
import {ErrorMessagesComponent} from '../openaireLibrary/utils/errorMessages.component';
|
import {ErrorMessagesComponent} from '../openaireLibrary/utils/errorMessages.component';
|
||||||
import {Stakeholder, Topic} from "../utils/entities/stakeholder";
|
import {Stakeholder, Topic} from "../utils/entities/stakeholder";
|
||||||
import {SideBarService} from "../library/sharedComponents/sidebar/sideBar.service";
|
|
||||||
import {StakeholderService} from "../services/stakeholder.service";
|
import {StakeholderService} from "../services/stakeholder.service";
|
||||||
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
||||||
import {AlertModal} from "../openaireLibrary/utils/modal/alert";
|
import {AlertModal} from "../openaireLibrary/utils/modal/alert";
|
||||||
import {Subscriber} from "rxjs";
|
import {Subscriber} from "rxjs";
|
||||||
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
|
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
|
||||||
|
import {LayoutService} from "../library/sharedComponents/sidebar/layout.service";
|
||||||
|
|
||||||
declare var UIkit;
|
declare var UIkit;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private title: Title,
|
private title: Title,
|
||||||
private sideBarService: SideBarService,
|
private layoutService: LayoutService,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private stakeholderService: StakeholderService) {
|
private stakeholderService: StakeholderService) {
|
||||||
this.errorCodes = new ErrorCodes();
|
this.errorCodes = new ErrorCodes();
|
||||||
|
@ -75,14 +75,14 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
get open(): boolean {
|
get open(): boolean {
|
||||||
return this.sideBarService.open;
|
return this.layoutService.open;
|
||||||
}
|
}
|
||||||
|
|
||||||
public toggleOpen(event = null) {
|
public toggleOpen(event = null) {
|
||||||
if (!event) {
|
if (!event) {
|
||||||
this.sideBarService.setOpen(!this.open);
|
this.layoutService.setOpen(!this.open);
|
||||||
} else if (event && event['value'] === true) {
|
} else if (event && event['value'] === true) {
|
||||||
this.sideBarService.setOpen(false);
|
this.layoutService.setOpen(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {ActivationStart, Router} from "@angular/router";
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class SideBarService {
|
export class LayoutService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set this to true when sidebar items are ready.
|
* Set this to true when sidebar items are ready.
|
||||||
|
@ -17,6 +17,11 @@ export class SideBarService {
|
||||||
*/
|
*/
|
||||||
private hasSidebarSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
|
private hasSidebarSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add hasHeader: false on data of route config, if header is not needed.
|
||||||
|
*/
|
||||||
|
private hasHeaderSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
|
||||||
|
|
||||||
constructor(private router: Router) {
|
constructor(private router: Router) {
|
||||||
this.router.events.subscribe(event => {
|
this.router.events.subscribe(event => {
|
||||||
if (event instanceof ActivationStart) {
|
if (event instanceof ActivationStart) {
|
||||||
|
@ -28,6 +33,13 @@ export class SideBarService {
|
||||||
} else if (this.hasSidebarSubject.value === false) {
|
} else if (this.hasSidebarSubject.value === false) {
|
||||||
this.setHasSidebar(true);
|
this.setHasSidebar(true);
|
||||||
}
|
}
|
||||||
|
if (this.hasHeaderSubject.value === true &&
|
||||||
|
data['hasHeader'] !== undefined &&
|
||||||
|
data['hasHeader'] === false) {
|
||||||
|
this.setHasHeader(false);
|
||||||
|
} else if (this.hasHeaderSubject.value === false) {
|
||||||
|
this.setHasHeader(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -47,4 +59,12 @@ export class SideBarService {
|
||||||
setHasSidebar(value: boolean) {
|
setHasSidebar(value: boolean) {
|
||||||
this.hasSidebarSubject.next(value);
|
this.hasSidebarSubject.next(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get hasHeader(): Observable<boolean> {
|
||||||
|
return this.hasHeaderSubject.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
setHasHeader(value: boolean) {
|
||||||
|
this.hasHeaderSubject.next(value);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -12,25 +12,29 @@ import {MonitorComponent} from "./monitor.component";
|
||||||
path: ':stakeholder',
|
path: ':stakeholder',
|
||||||
component: MonitorComponent,
|
component: MonitorComponent,
|
||||||
canActivate: [FreeGuard],
|
canActivate: [FreeGuard],
|
||||||
canDeactivate: [PreviousRouteRecorder]
|
canDeactivate: [PreviousRouteRecorder],
|
||||||
|
data: {hasHeader: false}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':stakeholder/:topic',
|
path: ':stakeholder/:topic',
|
||||||
component: MonitorComponent,
|
component: MonitorComponent,
|
||||||
canActivate: [FreeGuard],
|
canActivate: [FreeGuard],
|
||||||
canDeactivate: [PreviousRouteRecorder]
|
canDeactivate: [PreviousRouteRecorder],
|
||||||
|
data: {hasHeader: false}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':stakeholder/:topic/:category',
|
path: ':stakeholder/:topic/:category',
|
||||||
component: MonitorComponent,
|
component: MonitorComponent,
|
||||||
canActivate: [FreeGuard],
|
canActivate: [FreeGuard],
|
||||||
canDeactivate: [PreviousRouteRecorder]
|
canDeactivate: [PreviousRouteRecorder],
|
||||||
|
data: {hasHeader: false}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':stakeholder/:topic/:category/:subCategory',
|
path: ':stakeholder/:topic/:category/:subCategory',
|
||||||
component: MonitorComponent,
|
component: MonitorComponent,
|
||||||
canActivate: [FreeGuard],
|
canActivate: [FreeGuard],
|
||||||
canDeactivate: [PreviousRouteRecorder]
|
canDeactivate: [PreviousRouteRecorder],
|
||||||
|
data: {hasHeader: false}
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
|
|
@ -14,8 +14,8 @@ import {StakeholderService} from "../services/stakeholder.service";
|
||||||
import {Category, ChartHelper, IndicatorPath, Stakeholder, SubCategory, Topic} from "../utils/entities/stakeholder";
|
import {Category, ChartHelper, IndicatorPath, Stakeholder, SubCategory, Topic} from "../utils/entities/stakeholder";
|
||||||
import {StatisticsService} from "../utils/services/statistics.service";
|
import {StatisticsService} from "../utils/services/statistics.service";
|
||||||
import {Item, Sidebar} from "../utils/entities/sidebar";
|
import {Item, Sidebar} from "../utils/entities/sidebar";
|
||||||
import {SideBarService} from "../library/sharedComponents/sidebar/sideBar.service";
|
|
||||||
import {IndicatorUtils} from "../utils/indicator-utils";
|
import {IndicatorUtils} from "../utils/indicator-utils";
|
||||||
|
import {LayoutService} from "../library/sharedComponents/sidebar/layout.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'monitor',
|
selector: 'monitor',
|
||||||
|
@ -51,7 +51,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
|
||||||
private helper: HelperService,
|
private helper: HelperService,
|
||||||
private stakeholderService: StakeholderService,
|
private stakeholderService: StakeholderService,
|
||||||
private statisticsService: StatisticsService,
|
private statisticsService: StatisticsService,
|
||||||
private sideBarService: SideBarService,
|
private layoutService: LayoutService,
|
||||||
private seoService: SEOService,
|
private seoService: SEOService,
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
private sanitizer: DomSanitizer) {
|
private sanitizer: DomSanitizer) {
|
||||||
|
@ -100,14 +100,14 @@ export class MonitorComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public get open() {
|
public get open() {
|
||||||
return this.sideBarService.open;
|
return this.layoutService.open;
|
||||||
}
|
}
|
||||||
|
|
||||||
public toggleOpen(event = null) {
|
public toggleOpen(event = null) {
|
||||||
if(!event) {
|
if(!event) {
|
||||||
this.sideBarService.setOpen(!this.open);
|
this.layoutService.setOpen(!this.open);
|
||||||
} else if(event && event['value'] === true) {
|
} else if(event && event['value'] === true) {
|
||||||
this.sideBarService.setOpen(false);
|
this.layoutService.setOpen(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,41 +207,34 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<modal-alert #createIndicatorModal
|
|
||||||
(alertOutput)="createIndicator()"
|
|
||||||
[okDisabled]="indicatorFb && indicatorFb.invalid">
|
|
||||||
<div *ngIf="indicatorFb" class="uk-form-stacked" [formGroup]="indicatorFb">
|
|
||||||
<div dashboard-input class="uk-form-row" [formInput]="indicatorFb.get('name')" label="Title"></div>
|
|
||||||
<div dashboard-input class="uk-form-row" [formInput]="indicatorFb.get('description')"
|
|
||||||
label="Description" type="textarea"></div>
|
|
||||||
<div dashboard-input class="uk-form-row" *ngFor="let chartUrl of urls.controls;"
|
|
||||||
[formInput]="chartUrl"
|
|
||||||
label="Chart Url"></div>
|
|
||||||
</div>
|
|
||||||
</modal-alert>
|
|
||||||
<modal-alert #editIndicatorModal
|
<modal-alert #editIndicatorModal
|
||||||
[classBody]="'large-modal'"
|
[classBody]="'large-modal'"
|
||||||
(alertOutput)="saveIndicator()"
|
(alertOutput)="saveIndicator()"
|
||||||
[okDisabled]="editIndicatorFb && (editIndicatorFb.invalid ||(!editIndicatorFb.dirty && index !==-1))">
|
[okDisabled]="indicatorFb && (indicatorFb.invalid ||(!indicatorFb.dirty && index !==-1))">
|
||||||
<div *ngIf="editIndicatorFb" class="uk-padding-small" [formGroup]="editIndicatorFb">
|
<div *ngIf="indicatorFb" class="uk-padding-small" [formGroup]="indicatorFb">
|
||||||
<div dashboard-input class="uk-form-row" [formInput]="editIndicatorFb.get('name')" label="Title"></div>
|
<div dashboard-input class="uk-form-row" [formInput]="indicatorFb.get('name')" label="Title"></div>
|
||||||
<div dashboard-input class="uk-form-row" [formInput]="editIndicatorFb.get('description')"
|
<div dashboard-input class="uk-form-row" [formInput]="indicatorFb.get('description')"
|
||||||
label="Description" type="textarea">
|
label="Description" type="textarea">
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-form-row uk-flex uk-flex-middle">
|
<div class="uk-form-row uk-flex uk-flex-middle">
|
||||||
<div dashboard-input class="uk-width-small" [formInput]="editIndicatorFb.get('isPublic')"
|
<div dashboard-input class="uk-width-small" [formInput]="indicatorFb.get('isPublic')"
|
||||||
label="Accessibility" [options]="indicatorUtils.isPublic" type="select">
|
label="Accessibility" [options]="indicatorUtils.isPublic" type="select">
|
||||||
</div>
|
</div>
|
||||||
<div dashboard-input class="uk-margin-small-left uk-width-small" [formInput]="editIndicatorFb.get('isActive')"
|
<div dashboard-input class="uk-margin-small-left uk-width-small" [formInput]="indicatorFb.get('isActive')"
|
||||||
label="Visibility" [options]="indicatorUtils.isActive" type="select">
|
label="Visibility" [options]="indicatorUtils.isActive" type="select">
|
||||||
</div>
|
</div>
|
||||||
<div dashboard-input class="uk-margin-small-left uk-width-small" [formInput]="editIndicatorFb.get('width')"
|
<div dashboard-input class="uk-margin-small-left uk-width-small" [formInput]="indicatorFb.get('width')"
|
||||||
type="select" [options]="indicatorUtils.chartSizes"
|
type="select" [options]="indicatorUtils.chartSizes"
|
||||||
label="Chart Size">
|
label="Chart Size">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr class="uk-margin-large-top uk-margin-large-bottom">
|
<hr class="uk-margin-large-top uk-margin-large-bottom">
|
||||||
<div formArrayName="indicatorPaths">
|
<div *ngIf="urls" formArrayName="urls">
|
||||||
|
<div dashboard-input class="uk-form-row" *ngFor="let chartUrl of urls.controls;"
|
||||||
|
[formInput]="chartUrl"
|
||||||
|
label="Chart Url"></div>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="indicatorPaths" formArrayName="indicatorPaths">
|
||||||
<div *ngFor="let indicatorPath of indicatorPaths.controls; let i=index"
|
<div *ngFor="let indicatorPath of indicatorPaths.controls; let i=index"
|
||||||
[formGroup]="indicatorPath">
|
[formGroup]="indicatorPath">
|
||||||
<div formArrayName="parameters">
|
<div formArrayName="parameters">
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import {AfterViewInit, Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild} from "@angular/core";
|
import {AfterViewInit, Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild} from "@angular/core";
|
||||||
import {SideBarService} from "../library/sharedComponents/sidebar/sideBar.service";
|
|
||||||
import {Indicator, IndicatorPath, Stakeholder} from "../utils/entities/stakeholder";
|
import {Indicator, IndicatorPath, Stakeholder} from "../utils/entities/stakeholder";
|
||||||
import {IndicatorUtils, Option} from "../utils/indicator-utils";
|
import {IndicatorUtils, Option} from "../utils/indicator-utils";
|
||||||
import {FormArray, FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms";
|
import {FormArray, FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms";
|
||||||
|
@ -10,6 +9,7 @@ import {DomSanitizer} from "@angular/platform-browser";
|
||||||
import {StakeholderService} from "../services/stakeholder.service";
|
import {StakeholderService} from "../services/stakeholder.service";
|
||||||
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
|
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
|
||||||
import {Subscriber} from "rxjs";
|
import {Subscriber} from "rxjs";
|
||||||
|
import {LayoutService} from "../library/sharedComponents/sidebar/layout.service";
|
||||||
|
|
||||||
declare var UIkit;
|
declare var UIkit;
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
public stakeholder: Stakeholder = null;
|
public stakeholder: Stakeholder = null;
|
||||||
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
|
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
|
||||||
public indicatorFb: FormGroup;
|
public indicatorFb: FormGroup;
|
||||||
public editIndicatorFb: FormGroup;
|
|
||||||
/**
|
/**
|
||||||
* Editable indicator
|
* Editable indicator
|
||||||
*/
|
*/
|
||||||
|
@ -55,12 +54,10 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
*/
|
*/
|
||||||
public grid: boolean = true;
|
public grid: boolean = true;
|
||||||
private subscriptions: any[] = [];
|
private subscriptions: any[] = [];
|
||||||
|
|
||||||
@ViewChild('createIndicatorModal') createIndicatorModal: AlertModal;
|
|
||||||
@ViewChild('editIndicatorModal') editIndicatorModal: AlertModal;
|
@ViewChild('editIndicatorModal') editIndicatorModal: AlertModal;
|
||||||
@ViewChild('deleteIndicatorModal') deleteIndicatorModal: AlertModal;
|
@ViewChild('deleteIndicatorModal') deleteIndicatorModal: AlertModal;
|
||||||
|
|
||||||
constructor(private sideBarService: SideBarService,
|
constructor(private layoutService: LayoutService,
|
||||||
private stakeholderService: StakeholderService,
|
private stakeholderService: StakeholderService,
|
||||||
private statisticsService: StatisticsService,
|
private statisticsService: StatisticsService,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
|
@ -108,9 +105,9 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
|
|
||||||
public toggleOpen(event = null) {
|
public toggleOpen(event = null) {
|
||||||
if (!event) {
|
if (!event) {
|
||||||
this.sideBarService.setOpen(!this.open);
|
this.layoutService.setOpen(!this.open);
|
||||||
} else if (event && event['value'] === true) {
|
} else if (event && event['value'] === true) {
|
||||||
this.sideBarService.setOpen(false);
|
this.layoutService.setOpen(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +223,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
|
|
||||||
get open(): boolean {
|
get open(): boolean {
|
||||||
return this.sideBarService.open;
|
return this.layoutService.open;
|
||||||
}
|
}
|
||||||
|
|
||||||
get canNumbersReorder(): boolean {
|
get canNumbersReorder(): boolean {
|
||||||
|
@ -249,7 +246,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
|
|
||||||
public get indicatorPaths(): FormArray {
|
public get indicatorPaths(): FormArray {
|
||||||
return this.editIndicatorFb.get('indicatorPaths') as FormArray;
|
return this.indicatorFb.get('indicatorPaths') as FormArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getParameters(index: number): FormArray {
|
public getParameters(index: number): FormArray {
|
||||||
|
@ -274,19 +271,24 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
|
|
||||||
public createIndicatorOpen() {
|
public createIndicatorOpen() {
|
||||||
|
this.indicator = null;
|
||||||
this.indicatorFb = this.fb.group({
|
this.indicatorFb = this.fb.group({
|
||||||
|
id: this.fb.control(null),
|
||||||
name: this.fb.control('', Validators.required),
|
name: this.fb.control('', Validators.required),
|
||||||
description: this.fb.control(''),
|
description: this.fb.control(''),
|
||||||
width: this.fb.control('small', Validators.required),
|
isPublic: this.fb.control(false),
|
||||||
|
isActive: this.fb.control(false),
|
||||||
urls: this.fb.array([]),
|
urls: this.fb.array([]),
|
||||||
|
width: this.fb.control('small', Validators.required),
|
||||||
});
|
});
|
||||||
this.addUrl();
|
this.addUrl();
|
||||||
this.createIndicatorModal.alertTitle = 'Create a new chart Indicator';
|
this.editIndicatorModal.alertTitle = 'Create a new chart Indicator';
|
||||||
this.createIndicatorModal.cancelButtonText = 'Cancel';
|
this.editIndicatorModal.cancelButtonText = 'Cancel';
|
||||||
this.createIndicatorModal.okButtonText = 'Create';
|
this.editIndicatorModal.okButtonText = 'Create';
|
||||||
this.createIndicatorModal.okButtonLeft = false;
|
this.editIndicatorModal.okButtonLeft = false;
|
||||||
this.createIndicatorModal.alertMessage = false;
|
this.editIndicatorModal.alertMessage = false;
|
||||||
this.createIndicatorModal.open();
|
this.editIndicatorModal.stayOpen = true;
|
||||||
|
this.editIndicatorModal.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public createIndicator() {
|
public createIndicator() {
|
||||||
|
@ -295,8 +297,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.indicatorFb.value.description,
|
this.indicatorFb.value.description,
|
||||||
'chart',
|
'chart',
|
||||||
this.indicatorFb.value.width,
|
this.indicatorFb.value.width,
|
||||||
false,
|
this.indicatorFb.value.isActive,
|
||||||
false,
|
this.indicatorFb.value.isPublic,
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
this.indicatorFb.value.urls.forEach(url => {
|
this.indicatorFb.value.urls.forEach(url => {
|
||||||
|
@ -335,7 +337,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
parameters: parameters
|
parameters: parameters
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
this.editIndicatorFb = this.fb.group({
|
this.indicatorFb = this.fb.group({
|
||||||
id: this.fb.control(this.indicator._id),
|
id: this.fb.control(this.indicator._id),
|
||||||
name: this.fb.control(this.indicator.name, Validators.required),
|
name: this.fb.control(this.indicator.name, Validators.required),
|
||||||
description: this.fb.control(this.indicator.description),
|
description: this.fb.control(this.indicator.description),
|
||||||
|
@ -344,35 +346,45 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
indicatorPaths: indicatorPaths,
|
indicatorPaths: indicatorPaths,
|
||||||
width: this.fb.control(this.indicator.width, Validators.required),
|
width: this.fb.control(this.indicator.width, Validators.required),
|
||||||
});
|
});
|
||||||
this.editIndicatorModal.cancelButtonText = 'Cancel';
|
if(index === -1) {
|
||||||
this.editIndicatorModal.okButtonText = 'Save Changes';
|
this.editIndicatorModal.okButtonText = 'Save';
|
||||||
this.editIndicatorModal.okButtonLeft = false;
|
this.editIndicatorModal.stayOpen = false;
|
||||||
this.editIndicatorModal.alertMessage = false;
|
} else {
|
||||||
this.editIndicatorModal.open();
|
this.editIndicatorModal.cancelButtonText = 'Cancel';
|
||||||
setTimeout(() => {
|
this.editIndicatorModal.okButtonText = 'Save Changes';
|
||||||
this.indicator.indicatorPaths.forEach(indicatorPath => {
|
this.editIndicatorModal.okButtonLeft = false;
|
||||||
indicatorPath.safeResourceUrl = this.getUrlByStakeHolder(indicatorPath)
|
this.editIndicatorModal.alertMessage = false;
|
||||||
});
|
this.editIndicatorModal.open();
|
||||||
}, (index === -1)?500:0);
|
}
|
||||||
|
this.indicator.indicatorPaths.forEach(indicatorPath => {
|
||||||
|
indicatorPath.safeResourceUrl = this.getUrlByStakeHolder(indicatorPath)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
saveIndicator() {
|
saveIndicator() {
|
||||||
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.editIndicatorFb.value, this.indicator.indicatorPaths);
|
if(this.indicator) {
|
||||||
let path = [
|
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.indicatorFb.value, this.indicator.indicatorPaths);
|
||||||
this.stakeholder._id,
|
let path = [
|
||||||
this.stakeholder.topics[this.topicIndex]._id,
|
this.stakeholder._id,
|
||||||
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]._id,
|
this.stakeholder.topics[this.topicIndex]._id,
|
||||||
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id
|
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]._id,
|
||||||
];
|
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id
|
||||||
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.indicator, path).subscribe(indicator => {
|
];
|
||||||
if (this.index !== -1) {
|
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.indicator, path).subscribe(indicator => {
|
||||||
this.charts[this.index] = indicator;
|
if (this.index !== -1) {
|
||||||
} else {
|
this.charts[this.index] = indicator;
|
||||||
this.charts.push(indicator);
|
} else {
|
||||||
}
|
this.charts.push(indicator);
|
||||||
this.filterCharts();
|
}
|
||||||
this.stakeholderService.setStakeholder(this.stakeholder);
|
this.filterCharts();
|
||||||
});
|
this.stakeholderService.setStakeholder(this.stakeholder);
|
||||||
|
this.indicatorFb = null;
|
||||||
|
}, error => {
|
||||||
|
this.indicatorFb = null;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.createIndicator();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reorderIndicators(type: string, indicatorIds: string[]) {
|
reorderIndicators(type: string, indicatorIds: string[]) {
|
||||||
|
@ -395,7 +407,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshIndicator(index: number) {
|
refreshIndicator(index: number) {
|
||||||
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.editIndicatorFb.value, this.indicator.indicatorPaths);
|
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.indicatorFb.value, this.indicator.indicatorPaths);
|
||||||
this.indicator.indicatorPaths.forEach(indicatorPath => {
|
this.indicator.indicatorPaths.forEach(indicatorPath => {
|
||||||
indicatorPath.safeResourceUrl = this.getUrlByStakeHolder(indicatorPath)
|
indicatorPath.safeResourceUrl = this.getUrlByStakeHolder(indicatorPath)
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,6 @@ import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {Title} from '@angular/platform-browser';
|
import {Title} from '@angular/platform-browser';
|
||||||
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
||||||
import {Category, Stakeholder, SubCategory, Topic} from "../utils/entities/stakeholder";
|
import {Category, Stakeholder, SubCategory, Topic} from "../utils/entities/stakeholder";
|
||||||
import {SideBarService} from "../library/sharedComponents/sidebar/sideBar.service";
|
|
||||||
import {StakeholderService} from "../services/stakeholder.service";
|
import {StakeholderService} from "../services/stakeholder.service";
|
||||||
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
||||||
import {AlertModal} from "../openaireLibrary/utils/modal/alert";
|
import {AlertModal} from "../openaireLibrary/utils/modal/alert";
|
||||||
|
@ -57,7 +56,6 @@ export class TopicComponent implements OnInit, OnDestroy {
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private title: Title,
|
private title: Title,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private sideBarService: SideBarService,
|
|
||||||
private stakeholderService: StakeholderService) {
|
private stakeholderService: StakeholderService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue