[Monitor Dashboard | Trunk]: Fix visibility issue
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@59749 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
63e5b51dcd
commit
95d2ba3475
|
@ -11,6 +11,8 @@ import {UtilitiesService} from "../../openaireLibrary/services/utilities.service
|
|||
import {User} from "../../openaireLibrary/login/utils/helper.class";
|
||||
import {UserManagementService} from "../../openaireLibrary/services/user-management.service";
|
||||
|
||||
declare var UIkit;
|
||||
|
||||
@Component({
|
||||
selector: 'edit-stakeholder',
|
||||
template: `
|
||||
|
@ -136,9 +138,6 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
this.isNew = isNew;
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
this.user = user;
|
||||
}, error => {
|
||||
console.log("App couldn't fetch properties");
|
||||
console.log(error);
|
||||
}));
|
||||
this.stakeholderFb = this.fb.group({
|
||||
_id: this.fb.control(this.stakeholder._id),
|
||||
|
@ -229,26 +228,26 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
});
|
||||
}
|
||||
|
||||
public save(callback: Function) {
|
||||
public save(callback: Function, errorCallback: Function = null) {
|
||||
if (this.file) {
|
||||
this.utilsService.uploadPhoto(this.properties.utilsService + "/upload/stakeholder/" + encodeURIComponent(this.stakeholderFb.value.alias), this.file).subscribe(res => {
|
||||
this.deletePhoto();
|
||||
this.removePhoto();
|
||||
this.stakeholderFb.get('logoUrl').setValue(res.filename);
|
||||
this.saveStakeholder(callback);
|
||||
this.saveStakeholder(callback, errorCallback);
|
||||
}, error => {
|
||||
this.uploadError = "An error has been occurred during upload your image. Try again later";
|
||||
this.saveStakeholder(callback);
|
||||
this.saveStakeholder(callback, errorCallback);
|
||||
});
|
||||
} else if (this.deleteCurrentPhoto) {
|
||||
this.deletePhoto();
|
||||
this.saveStakeholder(callback);
|
||||
this.saveStakeholder(callback, errorCallback);
|
||||
} else {
|
||||
this.saveStakeholder(callback);
|
||||
this.saveStakeholder(callback, errorCallback);
|
||||
}
|
||||
}
|
||||
|
||||
public saveStakeholder(callback: Function) {
|
||||
public saveStakeholder(callback: Function, errorCallback: Function = null) {
|
||||
if (this.isNew) {
|
||||
if (!this.stakeholderFb.value.isDefault) {
|
||||
let stakeholder = this.defaultStakeholders.find(value => value._id === this.stakeholderFb.value.defaultId);
|
||||
|
@ -258,13 +257,38 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
this.removePhoto();
|
||||
this.stakeholderService.buildStakeholder(this.properties.monitorServiceAPIURL,
|
||||
this.stakeholderFb.value).subscribe(stakeholder => {
|
||||
UIkit.notification(stakeholder.name+ '\'s has been successfully created', {
|
||||
status: 'success',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
callback(stakeholder);
|
||||
}, error => {
|
||||
UIkit.notification('An error has occurred. Please try again later', {
|
||||
status: 'danger',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
if(errorCallback) {
|
||||
errorCallback(error)
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.stakeholderFb.get('type').enable();
|
||||
this.stakeholderFb.get('alias').enable();
|
||||
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.stakeholderFb.value).subscribe(stakeholder => {
|
||||
UIkit.notification(stakeholder.name+ '\'s has been successfully saved', {
|
||||
status: 'success',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
callback(stakeholder);
|
||||
}, error => {
|
||||
UIkit.notification('An error has occurred. Please try again later', {
|
||||
status: 'danger',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ export class GeneralComponent implements OnInit, OnDestroy {
|
|||
this.stakeholder = stakeholder;
|
||||
this.reset();
|
||||
this.loading = false;
|
||||
}, (error) => {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import {Title} from "@angular/platform-browser";
|
|||
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
||||
import {Session} from "../openaireLibrary/login/utils/helper.class";
|
||||
import {EditStakeholderComponent} from "../general/edit-stakeholder/edit-stakeholder.component";
|
||||
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
|
||||
|
||||
declare var UIkit;
|
||||
|
||||
|
@ -204,11 +205,22 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
|
|||
this.index = (this.stakeholder) ? this.stakeholders.findIndex(value => value._id === this.stakeholder._id) : -1;
|
||||
}
|
||||
this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, [this.stakeholder._id]).subscribe(() => {
|
||||
UIkit.notification(this.stakeholder.name+ ' has been successfully deleted', {
|
||||
status: 'success',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
if (!this.stakeholder.defaultId) {
|
||||
this.defaultStakeholders.splice(this.index, 1);
|
||||
} else {
|
||||
this.stakeholders.splice(this.index, 1);
|
||||
}
|
||||
}, error => {
|
||||
UIkit.notification('An error has occurred. Please try again later', {
|
||||
status: 'danger',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -216,26 +228,19 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
|
|||
let path = [
|
||||
stakeholder._id
|
||||
];
|
||||
this.stakeholderService.toggleStatus(this.properties.monitorServiceAPIURL, path).subscribe(isActive => {
|
||||
stakeholder.isActive = isActive;
|
||||
});
|
||||
}
|
||||
|
||||
toggleStakeholderStatus(stakeholder: Stakeholder) {
|
||||
let path = [
|
||||
stakeholder._id
|
||||
];
|
||||
this.stakeholderService.toggleStatus(this.properties.monitorServiceAPIURL, path).subscribe(isActive => {
|
||||
stakeholder.isActive = isActive;
|
||||
});
|
||||
}
|
||||
|
||||
toggleStakeholderAccess(stakeholder: Stakeholder) {
|
||||
let path = [
|
||||
stakeholder._id
|
||||
];
|
||||
this.stakeholderService.toggleAccess(this.properties.monitorServiceAPIURL, path).subscribe(isPublic => {
|
||||
stakeholder.isPublic = isPublic;
|
||||
this.stakeholderService.changeVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => {
|
||||
stakeholder.visibility = visibility;
|
||||
UIkit.notification(stakeholder.name+ '\'s status has been successfully changed to ' + stakeholder.visibility.toLowerCase(), {
|
||||
status: 'success',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
}, error => {
|
||||
UIkit.notification('An error has occurred. Please try again later', {
|
||||
status: 'danger',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {RouterModule} from '@angular/router';
|
||||
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
|
||||
import {StakeholderComponent} from "./stakeholder.component";
|
||||
import {CanExitGuard} from "../openaireLibrary/utils/can-exit.guard";
|
||||
import {AdminDashboardGuard} from "../utils/adminDashboard.guard";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild([
|
||||
{
|
||||
path: '',
|
||||
component: StakeholderComponent,
|
||||
canActivate: [AdminDashboardGuard],
|
||||
canDeactivate: [PreviousRouteRecorder, CanExitGuard]
|
||||
}
|
||||
])
|
||||
]
|
||||
})
|
||||
export class StakeholderRoutingModule {
|
||||
}
|
|
@ -1,201 +0,0 @@
|
|||
<aside id="sidebar_main">
|
||||
<div id="sidebar_content">
|
||||
<div *ngIf="stakeholder" class="sidebar_main_header uk-margin-remove-bottom uk-text-center">
|
||||
<img *ngIf="properties.environment =='beta' || properties.environment =='development'" class="badge"
|
||||
[src]="'assets/common-assets/'+(properties.environment =='beta'?'beta_flag.svg':'prototype_flag.svg')"
|
||||
[alt]="properties.environment">
|
||||
<div class="uk-position-relative uk-margin-small-top">
|
||||
<!-- <div *ngIf="!stakeholder.defaultId" class="uk-badge default">Default</div>-->
|
||||
<!-- <img class="logo" *ngIf="stakeholder.logoUrl" [src]="stakeholder.logoUrl">-->
|
||||
<!-- <div class="uk-margin-top" *ngIf="!stakeholder.logoUrl" >{{stakeholder.name}}</div>-->
|
||||
<a [href]="properties.domain + properties.baseLink"><div class="portalLogo logo" ></div></a>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="stakeholder" class="menu_section">
|
||||
<ul class="uk-list">
|
||||
<li class="uk-margin-bottom md-bg-blue-900 uk-padding-small">
|
||||
<a [routerLink]="'../'" class="md-color-white">
|
||||
<span class="menu_icon"><i class="material-icons md-color-white">arrow_back</i></span>
|
||||
<div class="menu_title uk-width-expand uk-text-uppercase">
|
||||
Back
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li [class.current_section]="analysisOpen"
|
||||
[class.act_section]="analysisOpen"
|
||||
class="submenu_trigger">
|
||||
<a href="#" (click)="analysisOpen = !analysisOpen; $event.preventDefault()">
|
||||
<!-- <span class="menu_icon"><i class="material-icons">donut_large</i></span>-->
|
||||
<span class="menu_title uk-width-expand">Analysis Indicators</span>
|
||||
</a>
|
||||
<ul [style.display]="(analysisOpen?'block':'none')" class="uk-list">
|
||||
<ng-template ngFor [ngForOf]="stakeholder.topics" let-topic let-i="index">
|
||||
<li
|
||||
[title]="topic.name+': '+(topic.isActive?'Active':'Inactive')+', '+(topic.isPublic?'Public':'Private')"
|
||||
class="uk-margin-top uk-margin-small-right">
|
||||
<a [routerLink]="topic.alias" class="uk-flex">
|
||||
<span *ngIf="topic.icon" class="menu_icon">
|
||||
<span [innerHTML]="satinizeHTML(topic.icon)"></span>
|
||||
</span>
|
||||
<div class="menu_title uk-width-expand">
|
||||
{{topic.name}}
|
||||
<!--<i
|
||||
class="material-icons md-18 uk-margin-small-left">{{topic.visibility ? 'public' : 'lock'}}</i>
|
||||
<i class="material-icons md-18"
|
||||
[class.md-color-green-300]="topic.isActive">brightness_1</i>-->
|
||||
</div>
|
||||
<div class="menu_on_hover" (click)="$event.stopPropagation();$event.preventDefault()">
|
||||
<i class=" onHover" uk-icon="more-vertical"></i>
|
||||
<div #element uk-dropdown="mode: click; pos: bottom-right; offset: 5; delay-hide: 0; flip: false"
|
||||
class="uk-padding-remove-horizontal">
|
||||
<ul class="uk-nav uk-dropdown-nav uk-list">
|
||||
<li><a (click)="editTopicOpen(i); hide(element)">Edit</a></li>
|
||||
<!--<li><a (click)="toggleTopicStatus(topic); hide(element)">
|
||||
{{topic.isActive ? 'Inactive' : 'Active'}}</a>
|
||||
</li>
|
||||
<li><a (click)="toggleTopicStatus(topic); hide(element)">
|
||||
{{topic.isPublic?'Private':'Public'}}</a>
|
||||
</li>-->
|
||||
<hr *ngIf="!topic.defaultId" class="uk-nav-divider">
|
||||
<li *ngIf="!topic.defaultId"><a (click)="deleteTopicOpen(i, 'delete'); hide(element)">Delete</a>
|
||||
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
|
||||
<!-- <a (click)="deleteTopicOpen(i, 'delete'); hide(element)">Delete from all profiles</a>-->
|
||||
<!-- <a (click)="deleteTopicOpen(i, 'disconnect'); hide(element)">Delete and disconnect from all profiles</a>-->
|
||||
<!-- </ng-container>-->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
</ng-template>
|
||||
<li>
|
||||
<a href="#" (click)="editTopicOpen(); $event.preventDefault()">
|
||||
<span class="menu_icon"><i class="material-icons">add</i></span>
|
||||
<span class="menu_title">Create new Topic</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
<div id="page_content">
|
||||
<div id="page_content_inner" class="uk-padding-large">
|
||||
<h4 class="uk-text-bold uk-margin-top">
|
||||
Customise your Monitor Dashboard!
|
||||
</h4>
|
||||
<div class="uk-text-large uk-margin-bottom">
|
||||
<div>
|
||||
Modify or add new topics, categories and content.<br><br>
|
||||
Start your navigation through the <span class="md-color-blue-900">left side menu!</span>
|
||||
</div>
|
||||
<div class="uk-margin-small-top uk-margin-small-bottom uk-margin-large-left">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="88" viewBox="0 0 30 88">
|
||||
<g id="Group_749" data-name="Group 749" transform="translate(-872.168 -490.5)">
|
||||
<text class="fill_text" id="OR" transform="translate(872.168 540.271)" font-size="18"
|
||||
font-family="OpenSans-Bold, Open Sans" font-weight="900" opacity="0.8">
|
||||
<tspan x="0" y="0">OR</tspan>
|
||||
</text>
|
||||
<line class="stroke_line" id="Line_225" data-name="Line 225" y2="30" transform="translate(885.5 490.5)"
|
||||
fill="none" stroke="#000" stroke-width="1" opacity="0.2"></line>
|
||||
<line class="stroke_line" id="Line_226" data-name="Line 226" y2="30" transform="translate(885.5 548.5)"
|
||||
fill="none" stroke="#000" stroke-width="1" opacity="0.2"></line>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="uk-width-1-1">
|
||||
Select one of the <span class="md-color-blue-900">topics below</span>!
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="stakeholder" class="uk-child-width-1-3@m uk-child-width-1-1@s uk-grid-match uk-grid-medium" uk-grid>
|
||||
<ng-template ngFor [ngForOf]="stakeholder.topics" let-topic>
|
||||
<div>
|
||||
<a [routerLink]="topic.alias" class="uk-card uk-card-default">
|
||||
<div class="md-card-toolbar">
|
||||
<!--<div class="md-card-toolbar-actions" >
|
||||
|
||||
<div class="md-card-dropdown uk-inline">
|
||||
<i uk-icon="more-vertical" class="clickable"></i>
|
||||
<div #element uk-dropdown="mode: click; pos: bottom-right; delay-hide: 0; flip: false"
|
||||
class="uk-padding-remove-horizontal">
|
||||
<ul class="uk-nav uk-dropdown-nav">
|
||||
<li *ngIf="!editing"><a (click)="editChartIndicatorOpen(chart, indicator._id);hide(element)">Edit</a>
|
||||
</li>
|
||||
<li *ngIf="!editing"><a (click)="toggleIndicatorStatus(chart._id, indicator);hide(element)">
|
||||
{{indicator.isActive ? 'Inactive' : 'Active'}}</a>
|
||||
</li>
|
||||
<li *ngIf="!editing"><a (click)="toggleIndicatorAccess(chart._id, indicator);hide(element)">
|
||||
{{indicator.visibility ? 'Private' : 'Public'}}</a>
|
||||
</li>
|
||||
<hr *ngIf="!indicator.defaultId " class="uk-nav-divider">
|
||||
<li *ngIf="!editing && !indicator.defaultId "><a
|
||||
(click)="deleteIndicatorOpen(chart, indicator._id, 'chart', 'delete');hide(element)">
|
||||
Delete</a>
|
||||
<!– <a (click)="deleteIndicatorOpen(chart, indicator._id, 'chart', 'delete');hide(element)">Delete from all profiles</a>–>
|
||||
<!– <a (click)="deleteIndicatorOpen(chart, indicator._id, 'chart', 'disconnect');hide(element)">Delete and disconnect from all profiles</a>–>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="uk-card-header">
|
||||
{{topic.name}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-card-body uk-grid">
|
||||
<!-- <h6 class="uk-text-bold">{{topic.name}}</h6>-->
|
||||
<div class="uk-width-1-2 uk-text-center"
|
||||
title="{{topic.isPublic?'Visible to all users':'Visible to members'}}">
|
||||
<i class="material-icons md-24">
|
||||
{{indicatorUtils.isPublicIcon.get(topic.isPublic)}}
|
||||
</i>
|
||||
<div>{{(topic.isPublic) ? 'Public' : 'Private'}}</div>
|
||||
</div>
|
||||
<div class="uk-width-1-2 uk-text-center"
|
||||
title="{{topic.isActive?'Included in the indicators list':'Available only through administration dashboard'}}">
|
||||
<i class="material-icons md-24" [class.md-color-green-300]="topic.isActive">
|
||||
{{indicatorUtils.isActiveIcon}}
|
||||
</i>
|
||||
<div>{{(topic.isActive) ? 'Active' : 'Inactive'}}</div>
|
||||
</div>
|
||||
<div *ngIf="topic.description && topic.description.length > 0 " class="uk-text-secondary uk-margin-top">
|
||||
{{topic.description}}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<modal-alert #deleteModal (alertOutput)="deleteTopic()">
|
||||
You are about to delete <span class="uk-text-bold" *ngIf="index !== -1">"{{stakeholder.topics[index].name}}"</span> topic permanently.
|
||||
<div *ngIf="topicChildrenActionOnDelete == 'delete'" class="uk-text-bold">
|
||||
Topics of all profiles based on this default topic, will be deleted as well.
|
||||
</div>
|
||||
<!-- <span *ngIf="topicChildrenActionOnDelete == 'disconnect'" class="uk-text-bold">-->
|
||||
<!-- Topics of all profiles based on this default topic, will not be marked as copied from default anymore.-->
|
||||
<!-- </span>-->
|
||||
Are you sure you want to proceed?
|
||||
</modal-alert>
|
||||
<modal-alert #editModal (alertOutput)="saveTopic(index)">
|
||||
<div *ngIf="form" class="uk-padding-small" [formGroup]="form">
|
||||
<div dashboard-input class="uk-form-row" [formInput]="form.get('name')" label="Title"></div>
|
||||
<div dashboard-input class="uk-form-row" [formInput]="form.get('description')"
|
||||
label="Description" type="textarea">
|
||||
</div>
|
||||
<div dashboard-input class="uk-form-row" [formInput]="form.get('icon')"
|
||||
label="Icon(SVG)" type="textarea">
|
||||
</div>
|
||||
<div class="uk-form-row uk-flex uk-flex-middle">
|
||||
<div dashboard-input class="uk-width-small" [formInput]="form.get('visibility')"
|
||||
label="Accessibility" [options]="stakeholderUtils.visibility" type="select">
|
||||
</div>
|
||||
<div dashboard-input class="uk-margin-small-left uk-width-small" [formInput]="form.get('isActive')"
|
||||
label="Visibility" [options]="stakeholderUtils.isActive" type="select">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</modal-alert>
|
|
@ -1,251 +0,0 @@
|
|||
import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||
import {Location} from '@angular/common';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {DomSanitizer, Title} from '@angular/platform-browser';
|
||||
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../openaireLibrary/utils/errorMessages.component';
|
||||
import {Stakeholder, Topic, Visibility} from "../openaireLibrary/monitor/entities/stakeholder";
|
||||
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
|
||||
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
||||
import {AlertModal} from "../openaireLibrary/utils/modal/alert";
|
||||
import {Subscriber} from "rxjs";
|
||||
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
|
||||
import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
|
||||
import {IndicatorUtils, StakeholderUtils} from "../utils/indicator-utils";
|
||||
import {IDeactivateComponent} from "../openaireLibrary/utils/can-exit.guard";
|
||||
import {visit} from "@angular/compiler-cli/src/ngtsc/util/src/visitor";
|
||||
|
||||
declare var UIkit;
|
||||
|
||||
@Component({
|
||||
selector: 'stakeholder',
|
||||
templateUrl: './stakeholder.component.html',
|
||||
})
|
||||
export class StakeholderComponent implements OnInit, OnDestroy, IDeactivateComponent {
|
||||
public subscriptions: any[] = [];
|
||||
public loading: boolean = true;
|
||||
public errorCodes: ErrorCodes;
|
||||
public stakeholder: Stakeholder;
|
||||
public analysisOpen: boolean = true;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
public form: FormGroup;
|
||||
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
|
||||
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
|
||||
public index: number = -1;
|
||||
properties: EnvProperties;
|
||||
|
||||
@ViewChild('deleteModal') deleteModal: AlertModal;
|
||||
@ViewChild('editModal') editModal: AlertModal;
|
||||
public topicChildrenActionOnDelete: string;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private title: Title,
|
||||
private layoutService: LayoutService,
|
||||
private fb: FormBuilder,
|
||||
private stakeholderService: StakeholderService, private sanitizer: DomSanitizer, private _location: Location) {
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
||||
if (stakeholder) {
|
||||
this.stakeholder = HelperFunctions.copy(stakeholder);
|
||||
this.form = null;
|
||||
this.title.setTitle(stakeholder.name);
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
}
|
||||
|
||||
canExit():boolean {
|
||||
this.subscriptions.forEach(value => {
|
||||
if (value instanceof Subscriber) {
|
||||
value.unsubscribe();
|
||||
}
|
||||
});
|
||||
this.stakeholderService.setStakeholder(this.stakeholder);
|
||||
return true;
|
||||
}
|
||||
|
||||
hide(element: any) {
|
||||
UIkit.dropdown(element).hide();
|
||||
}
|
||||
|
||||
get open(): boolean {
|
||||
return this.layoutService.open;
|
||||
}
|
||||
|
||||
private buildTopic(topic: Topic) {
|
||||
let topics = this.stakeholder.topics.filter(element => element._id !== topic._id);
|
||||
this.form = this.fb.group({
|
||||
_id: this.fb.control(topic._id),
|
||||
name: this.fb.control(topic.name, Validators.required),
|
||||
description: this.fb.control(topic.description),
|
||||
alias: this.fb.control(topic.alias, [
|
||||
Validators.required,
|
||||
this.stakeholderUtils.aliasValidator(topics)
|
||||
]
|
||||
),
|
||||
visibility: this.fb.control(topic.visibility),
|
||||
defaultId: this.fb.control(topic.defaultId),
|
||||
categories: this.fb.control(topic.categories),
|
||||
icon: this.fb.control(topic.icon)
|
||||
});
|
||||
this.subscriptions.push(this.form.get('name').valueChanges.subscribe(value => {
|
||||
let i = 1;
|
||||
value = this.stakeholderUtils.generateAlias(value);
|
||||
this.form.controls['alias'].setValue(value);
|
||||
while (this.form.get('alias').invalid) {
|
||||
this.form.controls['alias'].setValue(value + i);
|
||||
i++;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public editTopicOpen(index = -1) {
|
||||
this.index = index;
|
||||
if (index === -1) {
|
||||
this.buildTopic(new Topic(null, null, null, "PUBLIC"));
|
||||
} else {
|
||||
this.buildTopic(this.stakeholder.topics[index]);
|
||||
}
|
||||
this.editModal.cancelButtonText = 'Cancel';
|
||||
this.editModal.okButtonLeft = false;
|
||||
this.editModal.alertMessage = false;
|
||||
if (index === -1) {
|
||||
this.editModal.alertTitle = 'Create a new topic';
|
||||
this.editModal.okButtonText = 'Create';
|
||||
} else {
|
||||
this.editModal.alertTitle = 'Edit topic\'s information ';
|
||||
this.editModal.okButtonText = 'Save';
|
||||
}
|
||||
this.editModal.open();
|
||||
}
|
||||
|
||||
public saveTopic(index = -1) {
|
||||
if (!this.form.invalid) {
|
||||
if (index === -1) {
|
||||
this.save('Topic has been successfully created');
|
||||
} else {
|
||||
this.save('Topic has been successfully saved', index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public deleteTopicOpen(index: number, childrenAction: string = null) {
|
||||
this.topicChildrenActionOnDelete = null;
|
||||
if(childrenAction == "delete") {
|
||||
this.topicChildrenActionOnDelete = childrenAction;
|
||||
} else if(childrenAction == "disconnect") {
|
||||
this.topicChildrenActionOnDelete = childrenAction;
|
||||
}
|
||||
|
||||
this.index = index;
|
||||
this.deleteModal.alertTitle = 'Delete topic';
|
||||
this.deleteModal.cancelButtonText = 'No';
|
||||
this.deleteModal.okButtonText = 'Yes';
|
||||
this.deleteModal.open();
|
||||
}
|
||||
|
||||
private save(message: string, index: number = -1) {
|
||||
let path = [this.stakeholder._id];
|
||||
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.form.value, path).subscribe(topic => {
|
||||
if (index === -1) {
|
||||
this.stakeholder.topics.push(topic);
|
||||
} else {
|
||||
this.stakeholder.topics[index] = topic;
|
||||
}
|
||||
UIkit.notification(message, {
|
||||
status: 'success',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
}, error => {
|
||||
UIkit.notification(error.error.message, {
|
||||
status: 'danger',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
deleteTopic() {
|
||||
let path = [
|
||||
this.stakeholder._id,
|
||||
this.stakeholder.topics[this.index]._id
|
||||
];
|
||||
this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path, this.topicChildrenActionOnDelete).subscribe(() => {
|
||||
this.stakeholder.topics.splice(this.index, 1);
|
||||
this.index = -1;
|
||||
UIkit.notification('Topic has been successfully deleted', {
|
||||
status: 'success',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
}, error => {
|
||||
UIkit.notification(error.error.message, {
|
||||
status: 'danger',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
toggleTopicStatus(topic: Topic, visibility:Visibility) {
|
||||
let path = [
|
||||
this.stakeholder._id,
|
||||
topic._id
|
||||
];
|
||||
this.stakeholderService.toggleVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => {
|
||||
topic.visibility = visibility;
|
||||
UIkit.notification('Topic has been successfully changed to ' + visibility.toLowerCase(), {
|
||||
status: 'success',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
}, error => {
|
||||
UIkit.notification(error.error.message, {
|
||||
status: 'danger',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/*toggleTopicAccess(topic: Topic) {
|
||||
let path = [
|
||||
this.stakeholder._id,
|
||||
topic._id
|
||||
];
|
||||
this.stakeholderService.toggleAccess(this.properties.monitorServiceAPIURL, path).subscribe(visibility => {
|
||||
topic.visibility = visibility;
|
||||
UIkit.notification('Topic has been successfully changed to ' + (visibility?'public':'private'), {
|
||||
status: 'success',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
}, error => {
|
||||
UIkit.notification(error.error.message, {
|
||||
status: 'danger',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
});
|
||||
}*/
|
||||
satinizeHTML(html){
|
||||
return this.sanitizer.bypassSecurityTrustHtml(html);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
|
||||
|
||||
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
||||
import {RouterModule} from "@angular/router";
|
||||
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
|
||||
import {AlertModalModule} from "../openaireLibrary/utils/modal/alertModal.module";
|
||||
import {StakeholderComponent} from "./stakeholder.component";
|
||||
import {StakeholderRoutingModule} from "./stakeholder-routing.module";
|
||||
import {InputModule} from "../openaireLibrary/dashboard/sharedComponents/input/input.module";
|
||||
import {ClickModule} from "../openaireLibrary/utils/click/click.module";
|
||||
import {AdminDashboardGuard} from "../utils/adminDashboard.guard";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, StakeholderRoutingModule, ClickModule, RouterModule, FormsModule, AlertModalModule, ReactiveFormsModule, InputModule
|
||||
],
|
||||
declarations: [
|
||||
StakeholderComponent
|
||||
],
|
||||
providers: [
|
||||
AdminDashboardGuard, PreviousRouteRecorder,
|
||||
PiwikService
|
||||
],
|
||||
exports: [
|
||||
StakeholderComponent
|
||||
]
|
||||
})
|
||||
export class StakeholderModule {
|
||||
}
|
|
@ -68,7 +68,7 @@
|
|||
[class.disable-sortable]="!canReorder"
|
||||
[class.uk-sortable-nodrag]="!canReorder">
|
||||
<div class="uk-card uk-card-default uk-card-body uk-position-relative" [class.uk-card-hover]="canReorder">
|
||||
<ng-container *ngTemplateOutlet="visibilityOptions; context:{indicator: indicator}"></ng-container>
|
||||
<ng-container *ngTemplateOutlet="visibilityOptions; context:{indicator: indicator, sectionId: number._id}"></ng-container>
|
||||
<div class="uk-position-top-right uk-margin-small-right uk-margin-small-top clickable">
|
||||
<i uk-icon="more-vertical" (click)="$event.stopPropagation();$event.preventDefault()"></i>
|
||||
<div #element uk-dropdown="mode: click; pos: bottom-right; delay-hide: 0; flip: false">
|
||||
|
@ -76,7 +76,7 @@
|
|||
<li *ngIf="isAdministrator && !indicator.defaultId && !editing"><a
|
||||
(click)="editNumberIndicatorOpen(number, indicator._id)">Edit</a></li>
|
||||
<ng-template ngFor [ngForOf]="stakeholderUtils.visibility" let-v>
|
||||
<li *ngIf="indicator.visibility != v.value"><a (click)="toggleIndicatorStatus(number._id,
|
||||
<li *ngIf="indicator.visibility != v.value"><a (click)="changeIndicatorStatus(number._id,
|
||||
indicator, v.value); hide(element)">
|
||||
{{'Make ' + v.label.toLowerCase()}}</a>
|
||||
</li>
|
||||
|
@ -175,7 +175,7 @@
|
|||
[class.disable-sortable]="!canReorder"
|
||||
[class.uk-sortable-nodrag]="!canReorder">
|
||||
<div class="uk-card uk-card-default uk-card-body uk-position-relative" [class.uk-card-hover]="canReorder">
|
||||
<ng-container *ngTemplateOutlet="visibilityOptions; context:{indicator: indicator}"></ng-container>
|
||||
<ng-container *ngTemplateOutlet="visibilityOptions; context:{indicator: indicator, sectionId: chart._id}"></ng-container>
|
||||
<div class="uk-position-top-right uk-margin-small-right uk-margin-small-top clickable">
|
||||
<i uk-icon="more-vertical" (click)="$event.stopPropagation();$event.preventDefault()"></i>
|
||||
<div #element uk-dropdown="mode: click; pos: bottom-right; delay-hide: 0; flip: false">
|
||||
|
@ -184,7 +184,7 @@
|
|||
(click)="editChartIndicatorOpen(chart, indicator._id);hide(element)">Edit</a>
|
||||
</li>
|
||||
<ng-template ngFor [ngForOf]="stakeholderUtils.visibility" let-v>
|
||||
<li *ngIf="indicator.visibility != v.value"><a (click)="toggleIndicatorStatus(chart._id,
|
||||
<li *ngIf="indicator.visibility != v.value"><a (click)="changeIndicatorStatus(chart._id,
|
||||
indicator, v.value); hide(element)">
|
||||
{{'Make ' + v.label.toLowerCase()}}</a>
|
||||
</li>
|
||||
|
@ -454,7 +454,7 @@
|
|||
You are about to delete this section and its indicators permanently.
|
||||
Are you sure you want to proceed?
|
||||
</modal-alert>-->
|
||||
<ng-template #visibilityOptions let-indicator="indicator">
|
||||
<ng-template #visibilityOptions let-indicator="indicator" let-sectionId="sectionId">
|
||||
<span class="uk-position-top-left uk-margin-small-left uk-margin-small-top clickable visibility">
|
||||
<span class="clickable color">
|
||||
<icon [name]="stakeholderUtils.visibilityIcon.get(indicator.visibility)"></icon>
|
||||
|
@ -463,7 +463,7 @@
|
|||
<ul class="uk-nav uk-dropdown-nav">
|
||||
<li *ngFor="let v of stakeholderUtils.visibility" class="uk-position-relative">
|
||||
<a *ngIf="indicator.visibility != v.value"
|
||||
(click)="$event.stopPropagation();toggleIndicatorStatus(indicator._id, indicator,v.value);hide(element);$event.preventDefault()">
|
||||
(click)="$event.stopPropagation();changeIndicatorStatus(sectionId, indicator,v.value);hide(element);$event.preventDefault()">
|
||||
<icon [name]="stakeholderUtils.visibilityIcon.get(v.value)" ratio="0.8"></icon>
|
||||
<span> {{v.label}}</span>
|
||||
</a>
|
||||
|
|
|
@ -802,7 +802,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
});
|
||||
}
|
||||
|
||||
toggleIndicatorStatus(sectionId: string, indicator: Indicator, visibility:Visibility) {
|
||||
changeIndicatorStatus(sectionId: string, indicator: Indicator, visibility:Visibility) {
|
||||
this.editing = true;
|
||||
let path = [
|
||||
this.stakeholder._id,
|
||||
|
@ -812,16 +812,16 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
sectionId,
|
||||
indicator._id
|
||||
];
|
||||
this.stakeholderService.toggleVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => {
|
||||
this.stakeholderService.changeVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => {
|
||||
indicator.visibility = visibility;
|
||||
UIkit.notification('Indicator has been successfully changed to ' + visibility.toLowerCase, {
|
||||
UIkit.notification('Indicator has been successfully changed to ' + indicator.visibility.toLowerCase(), {
|
||||
status: 'success',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
});
|
||||
this.editing = false;
|
||||
}, error => {
|
||||
UIkit.notification(error.error.message, {
|
||||
UIkit.notification('An error has been occurred. Try again later', {
|
||||
status: 'danger',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<ul class="uk-nav uk-dropdown-nav uk-list">
|
||||
<li><a (click)="editTopicOpen(i); hide(element)">Edit</a></li>
|
||||
<ng-template ngFor [ngForOf]="stakeholderUtils.visibility" let-v>
|
||||
<li *ngIf="topic.visibility != v.value"><a (click)="toggleTopicStatus(i, v.value);
|
||||
<li *ngIf="topic.visibility != v.value"><a (click)="changeTopicStatus(i, v.value);
|
||||
hide(element)">
|
||||
{{'Make ' + v.label.toLowerCase()}}</a>
|
||||
</li>
|
||||
|
@ -91,7 +91,7 @@
|
|||
<ul class="uk-nav uk-dropdown-nav">
|
||||
<li><a (click)="editCategoryOpen(i); hide(element)">Edit</a></li>
|
||||
<ng-template ngFor [ngForOf]="stakeholderUtils.visibility" let-v>
|
||||
<li *ngIf="category.visibility != v.value"><a (click)="toggleCategoryStatus(i, v.value);
|
||||
<li *ngIf="category.visibility != v.value"><a (click)="changeCategoryStatus(i, v.value);
|
||||
hide(element)">
|
||||
{{'Make ' + v.label.toLowerCase()}}</a>
|
||||
</li>
|
||||
|
@ -139,7 +139,7 @@
|
|||
<ul class="uk-nav uk-dropdown-nav">
|
||||
<li><a (click)="editSubCategoryOpen(i); hide(element)">Edit</a></li>
|
||||
<ng-template ngFor [ngForOf]="stakeholderUtils.visibility" let-v>
|
||||
<li *ngIf="subCategory.visibility != v.value"><a (click)="toggleSubcategoryStatus(i, v.value);
|
||||
<li *ngIf="subCategory.visibility != v.value"><a (click)="changeSubcategoryStatus(i, v.value);
|
||||
hide(element)">
|
||||
{{'Make ' + v.label.toLowerCase()}}</a>
|
||||
</li>
|
||||
|
|
|
@ -211,14 +211,13 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
|
|||
}
|
||||
}
|
||||
|
||||
public toggleTopicStatus(index=this.topicIndex, visibility:Visibility) {
|
||||
public changeTopicStatus(index: number, visibility:Visibility) {
|
||||
this.type = 'topic';
|
||||
let path = [
|
||||
this.stakeholder._id,
|
||||
this.stakeholder.topics[index]._id
|
||||
];
|
||||
console.log('here')
|
||||
this.toggleStatus(this.stakeholder.topics[index], path, visibility);
|
||||
this.changeStatus(this.stakeholder.topics[index], path, visibility);
|
||||
}
|
||||
|
||||
|
||||
|
@ -304,7 +303,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
|
|||
}
|
||||
}
|
||||
|
||||
public toggleCategoryStatus(index: number, visibility:Visibility) {
|
||||
public changeCategoryStatus(index: number, visibility:Visibility) {
|
||||
this.index = index;
|
||||
this.type = 'category';
|
||||
let path = [
|
||||
|
@ -312,7 +311,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
|
|||
this.stakeholder.topics[this.topicIndex]._id,
|
||||
this.stakeholder.topics[this.topicIndex].categories[this.index]._id
|
||||
];
|
||||
this.toggleStatus(this.stakeholder.topics[this.topicIndex].categories[this.index], path, visibility);
|
||||
this.changeStatus(this.stakeholder.topics[this.topicIndex].categories[this.index], path, visibility);
|
||||
}
|
||||
|
||||
|
||||
|
@ -395,7 +394,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
|
|||
}
|
||||
}
|
||||
|
||||
public toggleSubcategoryStatus(index: number, visibility:Visibility) {
|
||||
public changeSubcategoryStatus(index: number, visibility:Visibility) {
|
||||
this.index = index;
|
||||
this.type = 'subcategory';
|
||||
let path = [
|
||||
|
@ -404,7 +403,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
|
|||
this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex]._id,
|
||||
this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex].subCategories[this.index]._id
|
||||
];
|
||||
this.toggleStatus(this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex].subCategories[this.index], path, visibility);
|
||||
this.changeStatus(this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex].subCategories[this.index], path, visibility);
|
||||
}
|
||||
|
||||
|
||||
|
@ -509,19 +508,20 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
|
|||
|
||||
public toggleStatusByIndex(index: number, visibility:Visibility, type) {
|
||||
if(type == "sub"){
|
||||
this.toggleSubcategoryStatus(index,visibility);
|
||||
this.changeSubcategoryStatus(index,visibility);
|
||||
}else if(type == "cat"){
|
||||
this.toggleCategoryStatus(index,visibility);
|
||||
this.changeCategoryStatus(index,visibility);
|
||||
}
|
||||
else if(type == "topic") {
|
||||
this.toggleTopicStatus(index,visibility);
|
||||
this.changeTopicStatus(index,visibility);
|
||||
}
|
||||
}
|
||||
private toggleStatus(element: Topic | Category | SubCategory, path: string[], visibility:Visibility) {
|
||||
this.stakeholderService.toggleVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => {
|
||||
|
||||
private changeStatus(element: Topic | Category | SubCategory, path: string[], visibility:Visibility) {
|
||||
this.stakeholderService.changeVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => {
|
||||
element.visibility = visibility;
|
||||
this.stakeholderService.setStakeholder(this.stakeholder);
|
||||
UIkit.notification(StringUtils.capitalize(this.type) + ' has been successfully changed to ' + visibility.toLowerCase, {
|
||||
UIkit.notification(StringUtils.capitalize(this.type) + ' has been successfully changed to ' + element.visibility.toLowerCase(), {
|
||||
status: 'success',
|
||||
timeout: 3000,
|
||||
pos: 'top-left'
|
||||
|
|
Loading…
Reference in New Issue