diff --git a/src/app/app.module.ts b/src/app/app.module.ts index bfeec5ff8155288d44787165bfe8c0b116157b95..09e89b33aaa229dd3164cfb3646d5359c2fc2c31 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -32,6 +32,7 @@ import { ChartModule } from 'angular2-chartjs'; import 'chartjs-plugin-zoom'; +import { DashboardCloneWizardComponent } from './pages/dashboard-management/dashboard-clone-wizard/dashboard-clone-wizard.component'; export function configFactory(http: HttpClient): ConfigLoader { return new ConfigHttpLoader(http, './assets/config.json'); @@ -91,7 +92,8 @@ provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true - } + }, + DashboardCloneWizardComponent ], bootstrap: [AppComponent], }) diff --git a/src/app/pages/dashboard-management/dashboard-clone-wizard/dashboard-clone-wizard.component.ts b/src/app/pages/dashboard-management/dashboard-clone-wizard/dashboard-clone-wizard.component.ts index 653912927297da89f103523fe0d9631454833916..931b89df7ddd8b34005ce8f436e73d66c00a0fd2 100644 --- a/src/app/pages/dashboard-management/dashboard-clone-wizard/dashboard-clone-wizard.component.ts +++ b/src/app/pages/dashboard-management/dashboard-clone-wizard/dashboard-clone-wizard.component.ts @@ -62,13 +62,13 @@ export class DashboardCloneWizardComponent implements OnInit { this.fullListDashboardPagePersonal = this.fullListEditableDashboards.filter(x => x.type == MenuType.PRIVATE); this.fullListDashboardPagePublic = this.fullListEditableDashboards.filter(x => x.type == MenuType.PUBLIC); - this.route.queryParams.subscribe(params => { - if (params['parsedId'] != undefined && params['parsedId'] != null) { - this.parsedId = params['parsedId']; - this.foundDashboard = this.fullListEditableDashboards.find(x => x.id == this.parsedId); - this.selectedDashboardFormGroup.patchValue( { selectedDashboard: this.foundDashboard }); - } - }); + // this.route.queryParams.subscribe(params => { + // if (params['parsedId'] != undefined && params['parsedId'] != null) { + // this.parsedId = params['parsedId']; + // this.foundDashboard = this.fullListEditableDashboards.find(x => x.id == this.parsedId); + // this.selectedDashboardFormGroup.patchValue( { selectedDashboard: this.foundDashboard }); + // } + // }); }, error => (this.showError(error)) ); @@ -84,7 +84,7 @@ export class DashboardCloneWizardComponent implements OnInit { onSubmitFirst(selected : IDashboardPage){ this.selectedDashboard = selected; - this.createdDashboardFormGroup.patchValue( { createdDashboardName: (this.selectedDashboard.name + this.CLONED_SUFFIX) }); + // this.createdDashboardFormGroup.patchValue( { createdDashboardName: (this.selectedDashboard.name + this.CLONED_SUFFIX) }); } onSubmitSecond(name: any , targets: any){ @@ -95,7 +95,7 @@ export class DashboardCloneWizardComponent implements OnInit { } /** Invoke API to clone the Dashboard */ - executeClone(){ + executeClone(): boolean { //console.log("## selectedDashboard.id: "+ this.selectedDashboard.id + " selectedDashboard:" + this.selectedDashboard); if (this.selectedDashboard.id == null || this.selectedDashboard.id == undefined){ this.showError(this.translateService.instant('dashboardClone.clone_missing_parameter')); @@ -109,11 +109,12 @@ export class DashboardCloneWizardComponent implements OnInit { console.log('## Dashboard has been succesfully cloned, (original) id: ' + this.createdDashboard.id); this.router.navigate(['/pages/dashboard-management/manage-dashboard-pages']); this.showSuccess(); + return true; },err => { console.log("# Error during cloning due to e: " + err); this.showError(err); }); - + return false; } showSuccess() { @@ -137,4 +138,11 @@ export class DashboardCloneWizardComponent implements OnInit { } } + cloneFromExternal(selected : IDashboardPage): boolean{ + this.onSubmitFirst(selected); + this.onSubmitSecond(selected.name + "_CLONED", CloningOptionType.ALL); + this.executeClone(); + return true; + } + } diff --git a/src/app/pages/dashboard-management/dashboard-management-routing.module.ts b/src/app/pages/dashboard-management/dashboard-management-routing.module.ts index 53b3af830540ec5fdf5ed6544e1bf012bf5ec4de..fe6ec64b071dc9b37bd1a1ef1a37d9d2f818d80c 100644 --- a/src/app/pages/dashboard-management/dashboard-management-routing.module.ts +++ b/src/app/pages/dashboard-management/dashboard-management-routing.module.ts @@ -36,10 +36,14 @@ const routes: Routes = [ // path: 'edit-menu-block-page/:id', // component: MenuBlocksPageComponent // }, - { - path: 'dashboard-clone-wizard', - component: DashboardCloneWizardComponent - } + + + + + // { + // path: 'dashboard-clone-wizard', + // component: DashboardCloneWizardComponent + // } ]; @NgModule({ diff --git a/src/app/pages/dashboard-management/dashboard-page/dashboard-page.component.html b/src/app/pages/dashboard-management/dashboard-page/dashboard-page.component.html index 80638f7ca2eb6cb7863c3aa6cfb3cd3d551975b3..b86a0fd0ea9e42dfff3f28bc2eeba9eb791c4908 100644 --- a/src/app/pages/dashboard-management/dashboard-page/dashboard-page.component.html +++ b/src/app/pages/dashboard-management/dashboard-page/dashboard-page.component.html @@ -143,8 +143,8 @@ <nb-select fullWidth formControlName="shared" size="small" name="shared" placeholder="{{'dashboardPage.shared'|translate}}" - [nbTooltip]="getMessageDisabledTarget()"> - <nb-option *ngFor="let k of sharedDomain" [value]="k.val"> + [nbTooltip]="getMessageDisabledTarget()" (selectedChange)="changeSelected($event)" > + <nb-option *ngFor="let k of sharedDomain" [value]="k.val" > {{k.text}} </nb-option> </nb-select> @@ -152,7 +152,7 @@ </nb-form-field> </div> - <div class="row"> + <div class="row" *ngIf="currentSelected"> <nb-form-field class="col-6 mb-1 mt-1"> <div class="d-flex flex-column"> <label for="shared" class="label mr-2"> diff --git a/src/app/pages/dashboard-management/dashboard-page/dashboard-page.component.ts b/src/app/pages/dashboard-management/dashboard-page/dashboard-page.component.ts index 5a80674891176335d61dd166fc5ed5f57d99e82c..80cac0126964a3d7a958680cfe469c6e05a4584c 100644 --- a/src/app/pages/dashboard-management/dashboard-page/dashboard-page.component.ts +++ b/src/app/pages/dashboard-management/dashboard-page/dashboard-page.component.ts @@ -52,6 +52,8 @@ export class DashboardPageComponent implements OnInit { private ENABLE_DELAY:boolean; private DELAY:number; + currentSelected: string; + currentShared: string; selected: string; @@ -267,7 +269,17 @@ export class DashboardPageComponent implements OnInit { }); } + changeSelected(event){ + this.currentSelected=event; + console.log("CURRENT SELECTED"); + console.log(this.currentSelected); + } + changeCurrentSharedType(event){ + this.currentShared=event; + console.log("CURRENT changeCurrentSharedType"); + console.log(this.currentShared); + } // editPage(page: DashboardPage) { // this.page = this.formService.pageFormCreator(page); // this.pageName = page.name; diff --git a/src/app/pages/dashboard-management/manage-dashboard-page/manage-dashboard-page.component.ts b/src/app/pages/dashboard-management/manage-dashboard-page/manage-dashboard-page.component.ts index 6d0864dfc1f19cac7fdc4fdf6b2e31136d3dc931..9da76caa8254fd81d23f5a225a20cc91721b56da 100644 --- a/src/app/pages/dashboard-management/manage-dashboard-page/manage-dashboard-page.component.ts +++ b/src/app/pages/dashboard-management/manage-dashboard-page/manage-dashboard-page.component.ts @@ -4,10 +4,12 @@ import { Router } from '@angular/router'; import { NbDialogService, NbToastrService } from '@nebular/theme'; import { TranslateService } from '@ngx-translate/core'; import { LocalDataSource } from 'ng2-smart-table'; +import { OidcUserInformationService } from '../../../auth/services/oidc-user-information.service'; import { DashboardPage } from '../../../model/dashboard-page.model'; import { MenuType } from '../../../model/enumeration/menu-type.model'; import { DialogComponent } from '../../shared/dialog/dialog.component'; import { TableActionsComponent } from '../../shared/table-actions/table-actions.component'; +import { DashboardCloneWizardComponent } from '../dashboard-clone-wizard/dashboard-clone-wizard.component'; import { DashboardPageCrudService } from '../services/dashboard-page-crud.service'; @Component({ @@ -25,7 +27,10 @@ export class ManageDashboardPageComponent implements OnInit { private datePipe: DatePipe, private dialogService: NbDialogService, private translateService: TranslateService, - private toastrService: NbToastrService) + private toastrService: NbToastrService, + private userService: OidcUserInformationService, + private dashboardCloneService: DashboardCloneWizardComponent, + ) { this.initTableSettings(); } @@ -40,6 +45,8 @@ export class ManageDashboardPageComponent implements OnInit { (data) => { this.pages=data; this.source.load(data); + console.log("Fetching editable pages"); + console.log(data) }, error => (this.showError(error)) ); @@ -62,7 +69,7 @@ export class ManageDashboardPageComponent implements OnInit { let menuTypeFilter=[]; for(let mType of MenuType.values()){ - menuTypeFilter.push({ value: mType.enumVal, title: this.translateService.instant("MenuType."+mType.enumVal) }) + menuTypeFilter.push({ value: mType.enumVal, title: this.translateService.instant("MenuType."+mType.enumVal) }) } @@ -70,14 +77,20 @@ export class ManageDashboardPageComponent implements OnInit { mode: 'external', columns: { shared: { - title: this.translateService.instant('dashboardPage.shared'), - filter: { - type: 'list', - config: { - selectText: '', - list: sharedFilter - }, - } + title: this.translateService.instant('dashboardPage.status'), + valuePrepareFunction: (cell, row) => { + if (row.shared) { + return this.translateService.instant('dashboardPage.published'); + } + return this.translateService.instant('dashboardPage.draft'); + }, + // filter: { + // type: 'list', + // config: { + // selectText: '', + // list: sharedFilter + // }, + // } }, type: { title: this.translateService.instant('dashboardPage.type'), @@ -120,9 +133,9 @@ export class ManageDashboardPageComponent implements OnInit { type: 'custom', valuePrepareFunction: (cell, row) => { return [ - {action:'edit', enabled:true, status:"info", icon:"edit-2", tooltip:this.translateService.instant('general.edit')}, - {action:'delete', enabled:true, status:"danger", icon:"trash-2", tooltip:this.translateService.instant('general.delete')}, - {action:'editDashboard', enabled:true, status:"alert", icon:"edit", tooltip:this.translateService.instant('general.editContent')} + {action:'edit', enabled:row.pageOwner, status:"info", icon:"edit-2", tooltip:this.translateService.instant('general.edit')}, + {action:'delete', enabled:row.pageOwner, status:"danger", icon:"trash-2", tooltip:this.translateService.instant('general.delete')}, + {action:'cloneDashboard', enabled:true, status:"alert", icon:"copy", tooltip:this.translateService.instant('dashboardClone.action_clone')} ]; }, renderComponent: TableActionsComponent, @@ -138,6 +151,7 @@ export class ManageDashboardPageComponent implements OnInit { add: false, edit: false, delete: false, + cloneDashboard: false }, }; @@ -153,6 +167,10 @@ export class ManageDashboardPageComponent implements OnInit { this.router.navigate(['/pages/dashboard-management/edit-dashboard-page-content/' + data.id]) } + if (event == 'cloneDashboard') { + this.dashboardCloneService.cloneFromExternal(data); + } + if (event == 'delete') { this.dialogService.open(DialogComponent, { context: { title: this.translateService.instant('general.delete') + " " + this.translateService.instant('general.dashboard') , message: this.translateService.instant('general.deleteConfirm') } }).onClose.subscribe(res => { diff --git a/src/app/pages/pages-menu.ts b/src/app/pages/pages-menu.ts index 40b7792af05caeec7b2d94d3c27415ab0af3669b..20da94575f57325dcdaa0cd67d5f4f478e9f9bc8 100644 --- a/src/app/pages/pages-menu.ts +++ b/src/app/pages/pages-menu.ts @@ -161,13 +161,13 @@ export const MENU_ITEMS: NbMenuItem[] = [ // name: 'dashboard-menu-blocks' // } // }, - { - title: 'Clone Dashboard', - link: '/pages/dashboard-management/dashboard-clone-wizard', - data: { - name: 'dashboard-clone' - } - } + // { + // title: 'Clone Dashboard', + // link: '/pages/dashboard-management/dashboard-clone-wizard', + // data: { + // name: 'dashboard-clone' + // } + // } /*, { title: 'Manage Dashboard Target', diff --git a/src/app/pages/pages.component.ts b/src/app/pages/pages.component.ts index c635cd8c13e1a152afe14daf955c26be3894bb5b..b5043063b71f855bb509bcb7e18722412a42f61c 100644 --- a/src/app/pages/pages.component.ts +++ b/src/app/pages/pages.component.ts @@ -69,10 +69,16 @@ export class PagesComponent implements OnInit { /** JMA - Add SHARED Menu to the Dashboard */ this.menuBlockService.getAll().subscribe((response: Array<IMenuBlock>) => { // console.log('block response: ', JSON.stringify(response)); - if (response !== undefined && response !== null){ + if (response !== undefined && response !== null && response){ try{ console.log(response) - this.menu = this.menu.concat(response.map(item => this.menuMapperService.mapBlockToNbMenuItem(item))) ; + /**************** */ + for(let i = 0; i< response.length; i++){ + if(response[i].linkedItems != null){ + this.menu = this.menu.concat(this.menuMapperService.mapBlockToNbMenuItem(response[i])); + } + } + /**************** */ } catch(e) { console.log("# Error in menu content loading due to " + e); } diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index c5b087ad3314fd67d124621aa9d2f27b07165d51..f90372d624fc73db038ba067412e1aa5f6f82d8c 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -79,7 +79,11 @@ "back_modal": "Are you sure you want to go back without saving the dashboard?", "catch_error": "Error loading the dashboard page, please try again.", "wait_for_components": "Please wait for components to load.", - "visualization_catch_error": "Error in Dashboard page content during visualization. Please contact admin o try again." + "visualization_catch_error": "Error in Dashboard page content during visualization. Please contact admin o try again.", + "published": "Published", + "draft": "Draft", + "status": "Status" + }, "dashboardComponent": { "list": "Dashboard Components",