Skip to content
Snippets Groups Projects
Commit d82cb285 authored by digrazia2038's avatar digrazia2038
Browse files

Clone dashboard from table + minor changes

parent 0d025ce6
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
import { ChartModule } from 'angular2-chartjs'; import { ChartModule } from 'angular2-chartjs';
import 'chartjs-plugin-zoom'; import 'chartjs-plugin-zoom';
import { DashboardCloneWizardComponent } from './pages/dashboard-management/dashboard-clone-wizard/dashboard-clone-wizard.component';
export function configFactory(http: HttpClient): ConfigLoader { export function configFactory(http: HttpClient): ConfigLoader {
return new ConfigHttpLoader(http, './assets/config.json'); return new ConfigHttpLoader(http, './assets/config.json');
...@@ -91,7 +92,8 @@ ...@@ -91,7 +92,8 @@
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,
useClass: TokenInterceptor, useClass: TokenInterceptor,
multi: true multi: true
} },
DashboardCloneWizardComponent
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
}) })
......
...@@ -62,13 +62,13 @@ export class DashboardCloneWizardComponent implements OnInit { ...@@ -62,13 +62,13 @@ export class DashboardCloneWizardComponent implements OnInit {
this.fullListDashboardPagePersonal = this.fullListEditableDashboards.filter(x => x.type == MenuType.PRIVATE); this.fullListDashboardPagePersonal = this.fullListEditableDashboards.filter(x => x.type == MenuType.PRIVATE);
this.fullListDashboardPagePublic = this.fullListEditableDashboards.filter(x => x.type == MenuType.PUBLIC); this.fullListDashboardPagePublic = this.fullListEditableDashboards.filter(x => x.type == MenuType.PUBLIC);
this.route.queryParams.subscribe(params => { // this.route.queryParams.subscribe(params => {
if (params['parsedId'] != undefined && params['parsedId'] != null) { // if (params['parsedId'] != undefined && params['parsedId'] != null) {
this.parsedId = params['parsedId']; // this.parsedId = params['parsedId'];
this.foundDashboard = this.fullListEditableDashboards.find(x => x.id == this.parsedId); // this.foundDashboard = this.fullListEditableDashboards.find(x => x.id == this.parsedId);
this.selectedDashboardFormGroup.patchValue( { selectedDashboard: this.foundDashboard }); // this.selectedDashboardFormGroup.patchValue( { selectedDashboard: this.foundDashboard });
} // }
}); // });
}, },
error => (this.showError(error)) error => (this.showError(error))
); );
...@@ -84,7 +84,7 @@ export class DashboardCloneWizardComponent implements OnInit { ...@@ -84,7 +84,7 @@ export class DashboardCloneWizardComponent implements OnInit {
onSubmitFirst(selected : IDashboardPage){ onSubmitFirst(selected : IDashboardPage){
this.selectedDashboard = selected; 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){ onSubmitSecond(name: any , targets: any){
...@@ -95,7 +95,7 @@ export class DashboardCloneWizardComponent implements OnInit { ...@@ -95,7 +95,7 @@ export class DashboardCloneWizardComponent implements OnInit {
} }
/** Invoke API to clone the Dashboard */ /** Invoke API to clone the Dashboard */
executeClone(){ executeClone(): boolean {
//console.log("## selectedDashboard.id: "+ this.selectedDashboard.id + " selectedDashboard:" + this.selectedDashboard); //console.log("## selectedDashboard.id: "+ this.selectedDashboard.id + " selectedDashboard:" + this.selectedDashboard);
if (this.selectedDashboard.id == null || this.selectedDashboard.id == undefined){ if (this.selectedDashboard.id == null || this.selectedDashboard.id == undefined){
this.showError(this.translateService.instant('dashboardClone.clone_missing_parameter')); this.showError(this.translateService.instant('dashboardClone.clone_missing_parameter'));
...@@ -109,11 +109,12 @@ export class DashboardCloneWizardComponent implements OnInit { ...@@ -109,11 +109,12 @@ export class DashboardCloneWizardComponent implements OnInit {
console.log('## Dashboard has been succesfully cloned, (original) id: ' + this.createdDashboard.id); console.log('## Dashboard has been succesfully cloned, (original) id: ' + this.createdDashboard.id);
this.router.navigate(['/pages/dashboard-management/manage-dashboard-pages']); this.router.navigate(['/pages/dashboard-management/manage-dashboard-pages']);
this.showSuccess(); this.showSuccess();
return true;
},err => { },err => {
console.log("# Error during cloning due to e: " + err); console.log("# Error during cloning due to e: " + err);
this.showError(err); this.showError(err);
}); });
return false;
} }
showSuccess() { showSuccess() {
...@@ -137,4 +138,11 @@ export class DashboardCloneWizardComponent implements OnInit { ...@@ -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;
}
} }
...@@ -36,10 +36,14 @@ const routes: Routes = [ ...@@ -36,10 +36,14 @@ const routes: Routes = [
// path: 'edit-menu-block-page/:id', // path: 'edit-menu-block-page/:id',
// component: MenuBlocksPageComponent // component: MenuBlocksPageComponent
// }, // },
{
path: 'dashboard-clone-wizard',
component: DashboardCloneWizardComponent
}
// {
// path: 'dashboard-clone-wizard',
// component: DashboardCloneWizardComponent
// }
]; ];
@NgModule({ @NgModule({
......
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
<nb-select fullWidth formControlName="shared" size="small" name="shared" <nb-select fullWidth formControlName="shared" size="small" name="shared"
placeholder="{{'dashboardPage.shared'|translate}}" placeholder="{{'dashboardPage.shared'|translate}}"
[nbTooltip]="getMessageDisabledTarget()"> [nbTooltip]="getMessageDisabledTarget()" (selectedChange)="changeSelected($event)" >
<nb-option *ngFor="let k of sharedDomain" [value]="k.val" > <nb-option *ngFor="let k of sharedDomain" [value]="k.val" >
{{k.text}} {{k.text}}
</nb-option> </nb-option>
...@@ -152,7 +152,7 @@ ...@@ -152,7 +152,7 @@
</nb-form-field> </nb-form-field>
</div> </div>
<div class="row"> <div class="row" *ngIf="currentSelected">
<nb-form-field class="col-6 mb-1 mt-1"> <nb-form-field class="col-6 mb-1 mt-1">
<div class="d-flex flex-column"> <div class="d-flex flex-column">
<label for="shared" class="label mr-2"> <label for="shared" class="label mr-2">
......
...@@ -52,6 +52,8 @@ export class DashboardPageComponent implements OnInit { ...@@ -52,6 +52,8 @@ export class DashboardPageComponent implements OnInit {
private ENABLE_DELAY:boolean; private ENABLE_DELAY:boolean;
private DELAY:number; private DELAY:number;
currentSelected: string;
currentShared: string;
selected: string; selected: string;
...@@ -267,7 +269,17 @@ export class DashboardPageComponent implements OnInit { ...@@ -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) { // editPage(page: DashboardPage) {
// this.page = this.formService.pageFormCreator(page); // this.page = this.formService.pageFormCreator(page);
// this.pageName = page.name; // this.pageName = page.name;
......
...@@ -4,10 +4,12 @@ import { Router } from '@angular/router'; ...@@ -4,10 +4,12 @@ import { Router } from '@angular/router';
import { NbDialogService, NbToastrService } from '@nebular/theme'; import { NbDialogService, NbToastrService } from '@nebular/theme';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { LocalDataSource } from 'ng2-smart-table'; import { LocalDataSource } from 'ng2-smart-table';
import { OidcUserInformationService } from '../../../auth/services/oidc-user-information.service';
import { DashboardPage } from '../../../model/dashboard-page.model'; import { DashboardPage } from '../../../model/dashboard-page.model';
import { MenuType } from '../../../model/enumeration/menu-type.model'; import { MenuType } from '../../../model/enumeration/menu-type.model';
import { DialogComponent } from '../../shared/dialog/dialog.component'; import { DialogComponent } from '../../shared/dialog/dialog.component';
import { TableActionsComponent } from '../../shared/table-actions/table-actions.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'; import { DashboardPageCrudService } from '../services/dashboard-page-crud.service';
@Component({ @Component({
...@@ -25,7 +27,10 @@ export class ManageDashboardPageComponent implements OnInit { ...@@ -25,7 +27,10 @@ export class ManageDashboardPageComponent implements OnInit {
private datePipe: DatePipe, private datePipe: DatePipe,
private dialogService: NbDialogService, private dialogService: NbDialogService,
private translateService: TranslateService, private translateService: TranslateService,
private toastrService: NbToastrService) private toastrService: NbToastrService,
private userService: OidcUserInformationService,
private dashboardCloneService: DashboardCloneWizardComponent,
)
{ {
this.initTableSettings(); this.initTableSettings();
} }
...@@ -40,6 +45,8 @@ export class ManageDashboardPageComponent implements OnInit { ...@@ -40,6 +45,8 @@ export class ManageDashboardPageComponent implements OnInit {
(data) => { (data) => {
this.pages=data; this.pages=data;
this.source.load(data); this.source.load(data);
console.log("Fetching editable pages");
console.log(data)
}, },
error => (this.showError(error)) error => (this.showError(error))
); );
...@@ -70,14 +77,20 @@ export class ManageDashboardPageComponent implements OnInit { ...@@ -70,14 +77,20 @@ export class ManageDashboardPageComponent implements OnInit {
mode: 'external', mode: 'external',
columns: { columns: {
shared: { shared: {
title: this.translateService.instant('dashboardPage.shared'), title: this.translateService.instant('dashboardPage.status'),
filter: { valuePrepareFunction: (cell, row) => {
type: 'list', if (row.shared) {
config: { return this.translateService.instant('dashboardPage.published');
selectText: '',
list: sharedFilter
},
} }
return this.translateService.instant('dashboardPage.draft');
},
// filter: {
// type: 'list',
// config: {
// selectText: '',
// list: sharedFilter
// },
// }
}, },
type: { type: {
title: this.translateService.instant('dashboardPage.type'), title: this.translateService.instant('dashboardPage.type'),
...@@ -120,9 +133,9 @@ export class ManageDashboardPageComponent implements OnInit { ...@@ -120,9 +133,9 @@ export class ManageDashboardPageComponent implements OnInit {
type: 'custom', type: 'custom',
valuePrepareFunction: (cell, row) => { valuePrepareFunction: (cell, row) => {
return [ return [
{action:'edit', enabled:true, status:"info", icon:"edit-2", tooltip:this.translateService.instant('general.edit')}, {action:'edit', enabled:row.pageOwner, 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:'delete', enabled:row.pageOwner, 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:'cloneDashboard', enabled:true, status:"alert", icon:"copy", tooltip:this.translateService.instant('dashboardClone.action_clone')}
]; ];
}, },
renderComponent: TableActionsComponent, renderComponent: TableActionsComponent,
...@@ -138,6 +151,7 @@ export class ManageDashboardPageComponent implements OnInit { ...@@ -138,6 +151,7 @@ export class ManageDashboardPageComponent implements OnInit {
add: false, add: false,
edit: false, edit: false,
delete: false, delete: false,
cloneDashboard: false
}, },
}; };
...@@ -153,6 +167,10 @@ export class ManageDashboardPageComponent implements OnInit { ...@@ -153,6 +167,10 @@ export class ManageDashboardPageComponent implements OnInit {
this.router.navigate(['/pages/dashboard-management/edit-dashboard-page-content/' + data.id]) this.router.navigate(['/pages/dashboard-management/edit-dashboard-page-content/' + data.id])
} }
if (event == 'cloneDashboard') {
this.dashboardCloneService.cloneFromExternal(data);
}
if (event == 'delete') { 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 => { 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 => {
......
...@@ -161,13 +161,13 @@ export const MENU_ITEMS: NbMenuItem[] = [ ...@@ -161,13 +161,13 @@ export const MENU_ITEMS: NbMenuItem[] = [
// name: 'dashboard-menu-blocks' // name: 'dashboard-menu-blocks'
// } // }
// }, // },
{ // {
title: 'Clone Dashboard', // title: 'Clone Dashboard',
link: '/pages/dashboard-management/dashboard-clone-wizard', // link: '/pages/dashboard-management/dashboard-clone-wizard',
data: { // data: {
name: 'dashboard-clone' // name: 'dashboard-clone'
} // }
} // }
/*, /*,
{ {
title: 'Manage Dashboard Target', title: 'Manage Dashboard Target',
......
...@@ -69,10 +69,16 @@ export class PagesComponent implements OnInit { ...@@ -69,10 +69,16 @@ export class PagesComponent implements OnInit {
/** JMA - Add SHARED Menu to the Dashboard */ /** JMA - Add SHARED Menu to the Dashboard */
this.menuBlockService.getAll().subscribe((response: Array<IMenuBlock>) => { this.menuBlockService.getAll().subscribe((response: Array<IMenuBlock>) => {
// console.log('block response: ', JSON.stringify(response)); // console.log('block response: ', JSON.stringify(response));
if (response !== undefined && response !== null){ if (response !== undefined && response !== null && response){
try{ try{
console.log(response) 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) { } catch(e) {
console.log("# Error in menu content loading due to " + e); console.log("# Error in menu content loading due to " + e);
} }
......
...@@ -79,7 +79,11 @@ ...@@ -79,7 +79,11 @@
"back_modal": "Are you sure you want to go back without saving the dashboard?", "back_modal": "Are you sure you want to go back without saving the dashboard?",
"catch_error": "Error loading the dashboard page, please try again.", "catch_error": "Error loading the dashboard page, please try again.",
"wait_for_components": "Please wait for components to load.", "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": { "dashboardComponent": {
"list": "Dashboard Components", "list": "Dashboard Components",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment