From 264a16c9bf666d1fc6724c83b10fc12a02ba04cb Mon Sep 17 00:00:00 2001 From: Argiro Kokogiannaki Date: Fri, 23 Oct 2020 13:58:16 +0000 Subject: [PATCH] [Monitor|Trunk] -remove isPublic/isActive and their funtionalities -add visibility -update stakeholder and indicator cards -add beta version of stats tool git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@59675 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/app.component.ts | 31 +- .../manageStakeholders.component.html | 254 ++++------ .../manageStakeholders.component.ts | 42 +- .../manageStakeholders.module.ts | 10 +- src/app/monitor/monitor.component.html | 12 +- src/app/monitor/monitor.component.ts | 42 +- .../stakeholder/stakeholder.component.html | 16 +- src/app/stakeholder/stakeholder.component.ts | 28 +- src/app/topic/indicators.component.html | 274 ++++------- src/app/topic/indicators.component.ts | 89 ++-- src/app/topic/topic.component.html | 254 +++------- src/app/topic/topic.component.ts | 111 ++--- src/app/topic/topic.module.ts | 8 +- src/app/utils/entities/stakeholderCreator.ts | 437 ------------------ src/app/utils/indicator-utils.ts | 18 +- src/app/utils/services/statistics.service.ts | 4 +- src/assets/new.css | 23 + src/assets/theme-assets/css/error_page.css | 2 +- src/environments/environment.beta.ts | 2 +- src/environments/environment.ts | 2 +- 20 files changed, 444 insertions(+), 1215 deletions(-) delete mode 100644 src/app/utils/entities/stakeholderCreator.ts diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 8c59105..60d8126 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -8,9 +8,10 @@ import {StakeholderService} from "./openaireLibrary/monitor/services/stakeholder import {BehaviorSubject, Subscriber} from "rxjs"; import {LayoutService} from "./openaireLibrary/dashboard/sharedComponents/sidebar/layout.service"; import {MenuItem, RootMenuItem} from "./openaireLibrary/sharedComponents/menu"; -import {Stakeholder, Topic} from "./openaireLibrary/monitor/entities/stakeholder"; +import {Stakeholder, Topic, Visibility} from "./openaireLibrary/monitor/entities/stakeholder"; import {LinksResolver} from "./search/links-resolver"; import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component"; +import {arrow_left} from "./openaireLibrary/utils/icons/icons"; @Component({ @@ -107,9 +108,9 @@ export class AppComponent implements OnInit, OnDestroy { if (isSearch) { this.activeTopic = null; } else if (params && params['topic'] && !this.activeTopic) { - this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.isPublic) && topic.isActive); + this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility)); } else { - this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.isPublic) && topic.isActive); + this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility)); } this.setSideBar(); } else { @@ -129,9 +130,9 @@ export class AppComponent implements OnInit, OnDestroy { if(isSearch) { this.activeTopic = null; } else if (params && params['topic']) { - this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.isPublic) && topic.isActive); + this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility)); } else { - this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.isPublic) && topic.isActive); + this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility)); } } @@ -145,7 +146,9 @@ export class AppComponent implements OnInit, OnDestroy { })); this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { this.user = user; - this.buildMenu(); + if(user){ + this.buildMenu(); + } }, error => { console.log("App couldn't fetch properties"); console.log(error); @@ -177,7 +180,7 @@ export class AppComponent implements OnInit, OnDestroy { private setSideBar() { let items: MenuItem[] = []; this.stakeholder.topics.forEach((topic) => { - if (this.isPublicOrIsMember(topic.isPublic) && topic.isActive) { + if (this.isPublicOrIsMember(topic.visibility)) { let topicItem: MenuItem = new MenuItem(topic.alias, topic.name, "", ( '/' + this.stakeholder.alias + '/' + topic.alias), null, [], [], {}); @@ -234,7 +237,7 @@ export class AppComponent implements OnInit, OnDestroy { this.adminMenuItems.push(new MenuItem("indicators", "Indicators", "", "/admin/"+this.stakeholder.alias + '/indicators', false, [], [], {}, "")); this.adminMenuItems.push(new MenuItem("users", "Users", "", "/admin/"+this.stakeholder.alias+"/users", false, [], [], {}, "")); this.specialSideBarMenuItem = new MenuItem("back", "Manage profiles", "", "/admin",false, [], null, {}); - this.specialSideBarMenuItem.icon = ''; + this.specialSideBarMenuItem.icon = '' + arrow_left.data + ''; // ''; } this.userMenuItems = []; @@ -246,7 +249,6 @@ export class AppComponent implements OnInit, OnDestroy { if (this.isAdmin()) { this.userMenuItems.push(new MenuItem("", "Manage profiles", "", "/admin", true, [], [], {})) - this.specialSideBarMenuItem = null; } if (this.user) { this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {})); @@ -282,14 +284,17 @@ export class AppComponent implements OnInit, OnDestroy { public isAdmin() { return this.user && (Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || Session.isMonitorCurator(this.user)); } - - public isPublicOrIsMember(isPublic: boolean): boolean { - if (isPublic) { + + public isPublicOrIsMember(visibility: Visibility): boolean { + if(visibility == "PRIVATE"){ + return false; + } + if (visibility == "PUBLIC") { return true; } else { if (this.isViewPublic) { // preview for not members return false; - } else if (this.isAdmin()) { + } else if(this.isAdmin()) { // if user is member, return true return true; } diff --git a/src/app/manageStakeholders/manageStakeholders.component.html b/src/app/manageStakeholders/manageStakeholders.component.html index 7e61bbd..a3b3ef9 100644 --- a/src/app/manageStakeholders/manageStakeholders.component.html +++ b/src/app/manageStakeholders/manageStakeholders.component.html @@ -2,15 +2,10 @@
-
-
-
+ type="select" [options]="[all].concat(stakeholderUtils.visibility)" + label="Visibility">
@@ -18,189 +13,110 @@ search
- -
- list -
-

Default Profiles

-
Default Profiles +
- - -
- -
-
-
- {{stakeholderUtils.isPublicIcon.get(stakeholder.isPublic)}} -
{{(stakeholder.isPublic) ? 'Public' : 'Private'}}
-
-
- {{stakeholderUtils.isActiveIcon}} -
{{(stakeholder.isActive) ? 'Active' : 'Inactive'}}
-
-
-
-
- + +
-
-
-
- - Create a default profile -
-
-
-
-
- Create a new default profile. -
-
- -
-
-
-
+

Profiles

-
- -
- -
-
-
- {{stakeholderUtils.isPublicIcon.get(stakeholder.isPublic)}} -
{{(stakeholder.isPublic) ? 'Public' : 'Private'}}
-
-
- {{stakeholderUtils.isActiveIcon}} -
{{(stakeholder.isActive) ? 'Active' : 'Inactive'}}
-
-
-
-
- +
-
-
-
- - Create a profile + +
+
+
+
+ + +
+
+
+
+ -
-
-
- Create a new profile by selecting the type (Funder, Organization, Research Initiative or Project) and - select indicators based on a default or a blank profile. -
-
- -
-
+
+
+ + +
+
+ +
+
+ + + +
+
+
+
+
+ {{text}} +
+
+
-
+
{ - this.onPrivacyChange(value); - })); this.subscriptions.push(this.filters.get('status').valueChanges.subscribe(value => { + console.debug(value); this.onStatusChange(value); })); this.subscriptions.push(this.filters.get('keyword').valueChanges.subscribe(value => { this.onKeywordChange(value); })); } - - onPrivacyChange(value) { - this.displayDefaultStakeholders = this.filterPrivacy(this.defaultStakeholders, value); - this.displayStakeholders = this.filterPrivacy(this.stakeholders, value); - } - + onStatusChange(value) { this.displayDefaultStakeholders = this.filterStatus(this.defaultStakeholders, value); this.displayStakeholders = this.filterStatus(this.stakeholders, value); @@ -136,21 +124,12 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy { this.displayDefaultStakeholders = this.filterByKeyword(this.defaultStakeholders, value); this.displayStakeholders = this.filterByKeyword(this.stakeholders, value); } - - - private filterPrivacy(stakeholders: Stakeholder[], value): Stakeholder[] { - if (value === 'all') { - return stakeholders; - } else { - return stakeholders.filter(stakeholder => stakeholder.isPublic === value); - } - } - + private filterStatus(stakeholders: Stakeholder[], value): Stakeholder[] { if (value === 'all') { return stakeholders; } else { - return stakeholders.filter(stakeholder => stakeholder.isActive === value); + return stakeholders.filter(stakeholder => stakeholder.visibility == value); } } @@ -227,7 +206,14 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy { } }); } - + changeStakeholderStatus(stakeholder: Stakeholder, visibility:Visibility) { + let path = [ + stakeholder._id + ]; + this.stakeholderService.toggleStatus(this.properties.monitorServiceAPIURL, path).subscribe(isActive => { + stakeholder.isActive = isActive; + }); + } toggleStakeholderStatus(stakeholder: Stakeholder) { let path = [ stakeholder._id diff --git a/src/app/manageStakeholders/manageStakeholders.module.ts b/src/app/manageStakeholders/manageStakeholders.module.ts index fc8fe72..d8a816a 100644 --- a/src/app/manageStakeholders/manageStakeholders.module.ts +++ b/src/app/manageStakeholders/manageStakeholders.module.ts @@ -10,6 +10,9 @@ import {AlertModalModule} from "../openaireLibrary/utils/modal/alertModal.module import {ReactiveFormsModule} from "@angular/forms"; import {AdminDashboardGuard} from "../utils/adminDashboard.guard"; import {EditStakeholderModule} from "../general/edit-stakeholder/edit-stakeholder.module"; +import {IconsModule} from "../openaireLibrary/utils/icons/icons.module"; +import {IconsService} from "../openaireLibrary/utils/icons/icons.service"; +import {bullet} from "../openaireLibrary/utils/icons/icons"; @NgModule({ declarations: [ManageStakeholdersComponent], @@ -21,7 +24,8 @@ import {EditStakeholderModule} from "../general/edit-stakeholder/edit-stakeholde LoadingModule, AlertModalModule, ReactiveFormsModule, - EditStakeholderModule + EditStakeholderModule, + IconsModule ], providers: [ AdminDashboardGuard, PreviousRouteRecorder, @@ -29,5 +33,7 @@ import {EditStakeholderModule} from "../general/edit-stakeholder/edit-stakeholde exports: [ManageStakeholdersComponent] }) export class ManageStakeholdersModule { - + constructor(private iconsService: IconsService) { + this.iconsService.registerIcons([ bullet]); + } } diff --git a/src/app/monitor/monitor.component.html b/src/app/monitor/monitor.component.html index 9d97080..0c9f83f 100644 --- a/src/app/monitor/monitor.component.html +++ b/src/app/monitor/monitor.component.html @@ -48,7 +48,9 @@