From f1cc59da348300d5ea6d964218c0654b75163406 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Mon, 1 Feb 2021 19:17:55 +0000 Subject: [PATCH] [Library | Trunk]: Admin tools pages add loading and notifications git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60331 d315682c-612b-4755-9ff5-7f18f6832af3 --- dashboard/divId/divIds.component.html | 11 +-- dashboard/divId/divIds.component.ts | 26 ++++++- dashboard/divId/divIds.module.ts | 3 +- dashboard/entity/entities.component.html | 10 +-- dashboard/entity/entities.component.ts | 27 ++++++- dashboard/entity/entities.module.ts | 3 +- dashboard/page/pages.component.html | 10 +-- dashboard/page/pages.component.ts | 47 +++++++---- dashboard/page/pages.module.ts | 3 +- dashboard/portal/portals.component.html | 99 +++++++++++------------- dashboard/portal/portals.component.ts | 42 ++++++---- dashboard/portal/portals.module.ts | 3 +- 12 files changed, 174 insertions(+), 110 deletions(-) diff --git a/dashboard/divId/divIds.component.html b/dashboard/divId/divIds.component.html index ef46784d..b319873e 100644 --- a/dashboard/divId/divIds.component.html +++ b/dashboard/divId/divIds.component.html @@ -40,19 +40,15 @@
-
-
+ +
{{updateErrorMessage}}
- - -
+
@@ -103,7 +99,6 @@
-
{ this.deleteDivIdsFromArray(this.selectedDivIds); + UIkit.notification('Classes have been successfully deleted', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); this.showLoading = false; }, error => this.handleUpdateError('System error deleting the selected classes', error) @@ -233,6 +240,7 @@ export class DivIdsComponent implements OnInit { } public divIdSaveConfirmed(data: any) { + this.showLoading = true; if (!Session.isLoggedIn()) { this._router.navigate(['/user-info'], { queryParams: { @@ -246,6 +254,11 @@ export class DivIdsComponent implements OnInit { this.subscriptions.push(this._helpContentService.saveDivId(this.classForm.value, this.properties.adminToolsAPIURL).subscribe( divId => { this.divIdSavedSuccessfully(divId); + UIkit.notification('Class ' + divId.name + ' has been successfully created', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); }, error => this.handleUpdateError("System error creating class", error) )); @@ -254,6 +267,11 @@ export class DivIdsComponent implements OnInit { this.subscriptions.push(this._helpContentService.updateDivId(this.classForm.value, this.properties.adminToolsAPIURL).subscribe( divId => { this.divIdUpdatedSuccessfully(divId); + UIkit.notification('Class ' + divId.name + ' has been successfully updated', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); }, error => this.handleUpdateError("System error updating class", error) )); @@ -266,12 +284,14 @@ export class DivIdsComponent implements OnInit { this.divIds.push(divId); this.applyFilters(); this.applyCheck(false); + this.showLoading = false; } public divIdUpdatedSuccessfully(divId: DivId) { this.divIds[this.index] = divId; this.applyFilters(); this.applyCheck(false); + this.showLoading = false; } public applyFilters() { @@ -298,7 +318,11 @@ export class DivIdsComponent implements OnInit { this.updateErrorMessage = message; console.log('Server responded: ' + error); } - + UIkit.notification('An error has occurred. Please try again later', { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); this.showLoading = false; } diff --git a/dashboard/divId/divIds.module.ts b/dashboard/divId/divIds.module.ts index a056bd53..3a7ded00 100644 --- a/dashboard/divId/divIds.module.ts +++ b/dashboard/divId/divIds.module.ts @@ -20,12 +20,13 @@ import {SearchInputModule} from "../../sharedComponents/search-input/search-inpu import {IconsModule} from "../../utils/icons/icons.module"; import {IconsService} from "../../utils/icons/icons.service"; import {add} from "../../utils/icons/icons"; +import {LoadingModule} from "../../utils/loading/loading.module"; @NgModule({ imports: [ CommonModule, RouterModule, FormsModule, AlertModalModule, ReactiveFormsModule, AdminToolServiceModule, InputModule, MatAutocompleteModule, MatFormFieldModule, MatChipsModule, - MatCheckboxModule, AdminTabsModule, PageContentModule, ClassesRoutingModule, SearchInputModule, IconsModule + MatCheckboxModule, AdminTabsModule, PageContentModule, ClassesRoutingModule, SearchInputModule, IconsModule, LoadingModule ], declarations: [DivIdsComponent], exports: [DivIdsComponent] diff --git a/dashboard/entity/entities.component.html b/dashboard/entity/entities.component.html index de701c5e..2a789e3b 100644 --- a/dashboard/entity/entities.component.html +++ b/dashboard/entity/entities.component.html @@ -48,7 +48,8 @@
-
+ +
@@ -67,12 +68,7 @@
- - - -
+
diff --git a/dashboard/entity/entities.component.ts b/dashboard/entity/entities.component.ts index f2bbaa50..5d2fe518 100644 --- a/dashboard/entity/entities.component.ts +++ b/dashboard/entity/entities.component.ts @@ -13,11 +13,12 @@ import {properties} from "../../../../environments/environment"; import {ConnectHelper} from "../../connect/connectHelper"; import {AlertModal} from "../../utils/modal/alert"; +declare var UIkit; + @Component({ selector: 'entities', templateUrl: './entities.component.html', }) - export class EntitiesComponent implements OnInit { @ViewChild('editModal') editModal: AlertModal; @@ -188,6 +189,11 @@ export class EntitiesComponent implements OnInit { this._helpContentService.deleteEntities(this.selectedEntities, this.properties.adminToolsAPIURL).subscribe( _ => { this.deleteEntitiesFromArray(this.selectedEntities); + UIkit.notification('Entities have been successfully deleted', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); this.showLoading = false; }, error => this.handleUpdateError('System error deleting the selected entities', error) @@ -232,6 +238,7 @@ export class EntitiesComponent implements OnInit { } public entitySaveConfirmed(data: any) { + this.showLoading = true; if (!Session.isLoggedIn()) { this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}}); @@ -242,6 +249,11 @@ export class EntitiesComponent implements OnInit { this.entityForm.value, this.properties.adminToolsAPIURL).subscribe( entity => { this.entityUpdatedSuccessfully(entity); + UIkit.notification('Entity ' + entity.name + ' has been successfully updated', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); }, error => this.handleUpdateError('System error updating entity', error) ); @@ -249,6 +261,11 @@ export class EntitiesComponent implements OnInit { this._helpContentService.saveEntity(this.entityForm.value, this.properties.adminToolsAPIURL).subscribe( entity => { this.entitySavedSuccessfully(entity); + UIkit.notification('Entity ' + entity.name + ' has been successfully created', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); }, error => this.handleUpdateError('System error creating entity', error) ); @@ -261,12 +278,14 @@ export class EntitiesComponent implements OnInit { this.entities.push(entity); this.applyFilters(); this.applyCheck(false); + this.showLoading = false; } public entityUpdatedSuccessfully(entity: Entity) { this.entities[this.index] = entity; this.applyFilters(); this.applyCheck(false); + this.showLoading = false; } public applyFilters() { @@ -306,7 +325,11 @@ export class EntitiesComponent implements OnInit { this.updateErrorMessage = message; console.log('Server responded: ' + error); } - + UIkit.notification('An error has occurred. Please try again later', { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); this.showLoading = false; } diff --git a/dashboard/entity/entities.module.ts b/dashboard/entity/entities.module.ts index 9e426d4f..9a84af29 100644 --- a/dashboard/entity/entities.module.ts +++ b/dashboard/entity/entities.module.ts @@ -14,11 +14,12 @@ import {SearchInputModule} from "../../sharedComponents/search-input/search-inpu import {IconsModule} from "../../utils/icons/icons.module"; import {IconsService} from "../../utils/icons/icons.service"; import {add} from "../../utils/icons/icons"; +import {LoadingModule} from "../../utils/loading/loading.module"; @NgModule({ imports: [ CommonModule, RouterModule, FormsModule, AdminToolServiceModule, - AlertModalModule, ReactiveFormsModule, MatSlideToggleModule, InputModule, PageContentModule, AdminTabsModule, EntitiesRoutingModule, SearchInputModule, IconsModule + AlertModalModule, ReactiveFormsModule, MatSlideToggleModule, InputModule, PageContentModule, AdminTabsModule, EntitiesRoutingModule, SearchInputModule, IconsModule, LoadingModule ], declarations: [EntitiesComponent], exports: [EntitiesComponent] diff --git a/dashboard/page/pages.component.html b/dashboard/page/pages.component.html index 956072b6..1dd11094 100644 --- a/dashboard/page/pages.component.html +++ b/dashboard/page/pages.component.html @@ -43,7 +43,8 @@
-
+ +
@@ -61,10 +62,7 @@
- -
+
    @@ -78,7 +76,7 @@
    {{check.page.name}}
    Entities: - {{check.page.entities.join(", ")}}
    + {{getEntitiesAsString(check.page)}}
Route: {{check.page.route}}
Type: {{check.page.type}}
diff --git a/dashboard/page/pages.component.ts b/dashboard/page/pages.component.ts index 3d73bf38..a5a86b78 100644 --- a/dashboard/page/pages.component.ts +++ b/dashboard/page/pages.component.ts @@ -1,29 +1,26 @@ import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {HelpContentService} from '../../services/help-content.service'; -import {FormArray, FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms'; +import {FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms'; import {CheckPage, Page} from '../../utils/entities/adminTool/page'; -import {Portal} from '../../utils/entities/adminTool/portal'; -import {CheckEntity, Entity} from '../../utils/entities/adminTool/entity'; +import {Entity} from '../../utils/entities/adminTool/entity'; import {EnvProperties} from '../../utils/properties/env-properties'; import {Session} from '../../login/utils/helper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; -import {HelperFunctions} from '../../utils/HelperFunctions.class'; import {UserManagementService} from '../../services/user-management.service'; -import {Observable, Subscriber} from "rxjs"; -import {map, startWith} from "rxjs/operators"; -import {MatAutocompleteSelectedEvent} from "@angular/material"; +import {Subscriber} from "rxjs"; import {PortalUtils} from "../portal/portalHelper"; import {properties} from "../../../../environments/environment"; import {ConnectHelper} from "../../connect/connectHelper"; import {Option} from "../../sharedComponents/input/input.component"; import {AlertModal} from "../../utils/modal/alert"; +declare var UIkit; + @Component({ selector: 'pages', templateUrl: './pages.component.html', }) - export class PagesComponent implements OnInit { @ViewChild('editModal') editModal: AlertModal; @@ -100,7 +97,6 @@ export class PagesComponent implements OnInit { this.isPortalAdministrator = Session.isPortalAdministrator(user) && !this.portal; })); })); - this.subscriptions.push(this._helpContentService.getEntities(this.properties.adminToolsAPIURL).subscribe( entities => { this.allEntities = []; @@ -110,7 +106,6 @@ export class PagesComponent implements OnInit { value: entity }); }); - this.showLoading = false; }, error => this.handleError('System error retrieving pages', error))); @@ -139,9 +134,7 @@ export class PagesComponent implements OnInit { this.showLoading = true; this.updateErrorMessage = ''; this.errorMessage = ''; - this.pageWithDivIds = []; - let parameters = ''; if (this.pagesType) { parameters = '?page_type=' + this.pagesType; @@ -279,6 +272,11 @@ export class PagesComponent implements OnInit { this.subscriptions.push(this._helpContentService.deletePages(this.selectedPages, this.properties.adminToolsAPIURL).subscribe( _ => { this.deletePagesFromArray(this.selectedPages); + UIkit.notification('Pages have been successfully deleted', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); this.showLoading = false; }, error => this.handleUpdateError('System error deleting the selected pages', error) @@ -352,6 +350,7 @@ export class PagesComponent implements OnInit { } public pageSaveConfirmed(data: any) { + this.showLoading = true; if (!Session.isLoggedIn()) { this._router.navigate(['/user-info'], { queryParams: { @@ -365,6 +364,11 @@ export class PagesComponent implements OnInit { this.subscriptions.push(this._helpContentService.savePage(this.pageForm.value, this.properties.adminToolsAPIURL).subscribe( page => { this.pageSavedSuccessfully(page, true); + UIkit.notification('Page ' + page.name + ' has been successfully created', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); }, error => this.handleUpdateError('System error creating page', error) )); @@ -373,6 +377,11 @@ export class PagesComponent implements OnInit { this.subscriptions.push(this._helpContentService.updatePage(this.pageForm.value, this.properties.adminToolsAPIURL).subscribe( page => { this.pageSavedSuccessfully(page, false); + UIkit.notification('Page ' + page.name + ' has been successfully updated', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); }, error => this.handleUpdateError('System error updating page', error) )); @@ -389,6 +398,7 @@ export class PagesComponent implements OnInit { } this.applyFilters(); this.applyCheck(false); + this.showLoading = false; } public applyFilters() { @@ -440,10 +450,21 @@ export class PagesComponent implements OnInit { this.updateErrorMessage = message;// + ' (Server responded: ' + error + ')'; console.log('Server responded: ' + error); } - + UIkit.notification('An error has occurred. Please try again later', { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); this.showLoading = false; } + public getEntitiesAsString(page: Page): string { + if(page.entities) { + return ( page.entities).map((page: Entity) => page.name).join(','); + } + return ''; + } + // public filterByPortal(event: any) { // this.portal = event.target.value; // this.applyPortalFilter(this.portal); diff --git a/dashboard/page/pages.module.ts b/dashboard/page/pages.module.ts index 8b023f69..c7dfdb92 100644 --- a/dashboard/page/pages.module.ts +++ b/dashboard/page/pages.module.ts @@ -14,11 +14,12 @@ import {SearchInputModule} from "../../sharedComponents/search-input/search-inpu import {IconsModule} from "../../utils/icons/icons.module"; import {IconsService} from "../../utils/icons/icons.service"; import {add} from "../../utils/icons/icons"; +import {LoadingModule} from "../../utils/loading/loading.module"; @NgModule({ imports: [ CommonModule, RouterModule, FormsModule, AlertModalModule, ReactiveFormsModule, MatSlideToggleModule, AdminToolServiceModule, InputModule, - MatAutocompleteModule, MatFormFieldModule, MatChipsModule, AdminTabsModule, PageContentModule, PagesRoutingModule, SearchInputModule, IconsModule + MatAutocompleteModule, MatFormFieldModule, MatChipsModule, AdminTabsModule, PageContentModule, PagesRoutingModule, SearchInputModule, IconsModule, LoadingModule ], declarations: [PagesComponent], exports: [PagesComponent] diff --git a/dashboard/portal/portals.component.html b/dashboard/portal/portals.component.html index b145fc4c..7e3e2ddf 100644 --- a/dashboard/portal/portals.component.html +++ b/dashboard/portal/portals.component.html @@ -40,62 +40,57 @@
-
- - {{updateErrorMessage}} -
- - - - -
- -
+ +
+
+ + {{updateErrorMessage}} +
+ +
-
- - - - - - - - - - - - - - +
NameTypeActions
- -
{{check.portal.name}}
-
-
{{check.portal.type}}
-
-
- - -
-
+ + + + + + + + + + + + + + - + - -
NameTypeActions
+ +
{{check.portal.name}}
+
+
{{check.portal.type}}
+
+
+ + +
+
-
-
No portals found
-
- -
+ +
diff --git a/dashboard/portal/portals.component.ts b/dashboard/portal/portals.component.ts index 9763d4bb..0e06cebd 100644 --- a/dashboard/portal/portals.component.ts +++ b/dashboard/portal/portals.component.ts @@ -13,6 +13,8 @@ import {PortalUtils} from "./portalHelper"; import {properties} from "../../../../environments/environment"; import {AlertModal} from "../../utils/modal/alert"; +declare var UIkit; + @Component({ selector: 'portals', templateUrl: './portals.component.html', @@ -164,6 +166,11 @@ export class PortalsComponent implements OnInit { this.subscriptions.push(this._helpContentService.deleteCommunities(this.selectedPortals, this.properties.adminToolsAPIURL).subscribe( _ => { this.deletePortalsFromArray(this.selectedPortals); + UIkit.notification('Portals have been successfully deleted', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); this.showLoading = false; }, error => this.handleUpdateError('System error deleting the selected communities', error) @@ -220,6 +227,7 @@ export class PortalsComponent implements OnInit { } public portalSaveConfirmed(data: any) { + this.showLoading = true; if (!Session.isLoggedIn()) { this._router.navigate(['/user-info'], { queryParams: { @@ -235,6 +243,11 @@ export class PortalsComponent implements OnInit { this.properties.adminToolsAPIURL).subscribe( portal => { this.portalUpdatedSuccessfully(portal); + UIkit.notification('Portal ' + portal.name + ' has been successfully updated', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); }, error => this.handleUpdateError('System error updating portal', error) )); @@ -243,6 +256,11 @@ export class PortalsComponent implements OnInit { this.properties.adminToolsAPIURL).subscribe( portal => { this.portalSavedSuccessfully(portal); + UIkit.notification('Portal ' + portal.name + ' has been successfully created', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); }, error => this.handleUpdateError('System error creating portal', error) )); @@ -250,33 +268,18 @@ export class PortalsComponent implements OnInit { } } - public portalUpdateConfirmed(data: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} - }); - } else { - this.portalForm.get('type').enable(); - this.subscriptions.push(this._helpContentService.updateCommunity(this.portalForm.value, - this.properties.adminToolsAPIURL).subscribe( - portal => { - this.portalUpdatedSuccessfully(portal); - }, - error => this.handleUpdateError('System error updating portal', error) - )); - } - } - public portalSavedSuccessfully(portal: Portal) { this.portals.push(portal); this.applyFilters(); this.applyCheck(false); + this.showLoading = false; } public portalUpdatedSuccessfully(portal: Portal) { this.portals[this.index] = portal; this.applyFilters(); this.applyCheck(false); + this.showLoading = false; } public applyFilters() { @@ -310,6 +313,11 @@ export class PortalsComponent implements OnInit { this.updateErrorMessage = message; console.log('Server responded: ' + error); } + UIkit.notification('An error has occurred. Please try again later', { + status: 'danger', + timeout: 6000, + pos: 'bottom-right' + }); this.showLoading = false; } diff --git a/dashboard/portal/portals.module.ts b/dashboard/portal/portals.module.ts index 9b967243..d578f9b4 100644 --- a/dashboard/portal/portals.module.ts +++ b/dashboard/portal/portals.module.ts @@ -13,12 +13,13 @@ import {IconsService} from "../../utils/icons/icons.service"; import {add} from "../../utils/icons/icons"; import {IconsModule} from "../../utils/icons/icons.module"; import {SearchInputModule} from "../../sharedComponents/search-input/search-input.module"; +import {LoadingModule} from "../../utils/loading/loading.module"; @NgModule({ imports: [ CommonModule, FormsModule, AlertModalModule, ReactiveFormsModule, - RouterModule, AdminToolServiceModule, InputModule, AdminTabsModule, PageContentModule, PortalsRoutingModule, IconsModule, SearchInputModule + RouterModule, AdminToolServiceModule, InputModule, AdminTabsModule, PageContentModule, PortalsRoutingModule, IconsModule, SearchInputModule, LoadingModule ], declarations: [PortalsComponent], exports: [PortalsComponent]