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

Added edit dashboard name, description and note

parent 07566dd1
Branches
No related tags found
No related merge requests found
Showing with 167 additions and 14 deletions
<nb-card>
<nb-card-header>
<h4>
{{ "dashboardPage.edit_dashboard_infos" | translate }}
</h4>
</nb-card-header>
<nb-card-body>
<div [formGroup]="page" class="step-container">
<div class="row">
<nb-form-field class="col-12 mb-1 mt-1">
<div class="d-flex flex-column">
<label for="name" class="label mr-2">
{{ "dashboardPage.name" | translate }} *
</label>
<input #name type="text" nbInput fullWidth fieldSize="small"
placeholder="{{ 'dashboardPage.name' | translate }}" name="name" formControlName="name"
nbTooltip="{{ 'general.mandatory_field' | translate }}" [(value)] = "dashboardPage.name"/>
</div>
</nb-form-field>
<nb-form-field class="col-12 mb-1 mt-1">
<div class="d-flex flex-column">
<label for="description" class="label mr-2">
{{ "dashboardPage.description" | translate }}
</label>
<input #description type="text" nbInput fullWidth fieldSize="small"
placeholder="{{ 'dashboardPage.description' | translate }}" description="name"
formControlName="description" [(value)]="dashboardPage.description" />
</div>
</nb-form-field>
</div>
<div class="row">
<nb-form-field class="col-12 mb-1 mt-1">
<div class="d-flex flex-column">
<label for="note" class="label mr-2">
{{ "dashboardPage.note" | translate }}
</label>
<textarea #note nbInput fullWidth rows="3" type="text" fieldSize="small"
placeholder="{{ 'dashboardPage.note' | translate }}" name="note"
formControlName="note" [(value)]= "dashboardPage.note"></textarea>
</div>
</nb-form-field>
</div>
</div>
</nb-card-body>
<nb-card-footer>
<button type="submit" nbButton status="primary" (click)="saveDashboard(name.value, description.value, note.value)" size="small">
<nb-icon icon="save"></nb-icon>{{'general.save'|translate}}
</button>
</nb-card-footer>
</nb-card>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DashboardInfoComponent } from './dashboard-info.component';
describe('DashboardInfoComponent', () => {
let component: DashboardInfoComponent;
let fixture: ComponentFixture<DashboardInfoComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ DashboardInfoComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(DashboardInfoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { not } from '@angular/compiler/src/output/output_ast';
import { Component, OnInit, Input, Inject } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { NbDialogRef, NbToastrService } from '@nebular/theme';
import { TranslateService } from '@ngx-translate/core';
import { GridsterItem } from 'angular-gridster2';
import { DashboardPage, IDashboardPage } from '../../../model/dashboard-page.model';
import { DashboardPageCrudService } from '../services/dashboard-page-crud.service';
import { FormManagerService } from '../services/form-manager.service';
@Component({
selector: 'ngx-dashboard-info',
templateUrl: './dashboard-info.component.html',
styleUrls: ['./dashboard-info.component.scss']
})
export class DashboardInfoComponent implements OnInit {
public items:Array<GridsterItem>;
dashboardPage: IDashboardPage | any = "";
@Input() pageId: number;
@Input() page: FormGroup = new FormGroup({});
constructor(protected dialogRef: NbDialogRef<DashboardInfoComponent>, public dashboardPageService: DashboardPageCrudService, private formService: FormManagerService,
private toastrService: NbToastrService,
private translateService: TranslateService,
) {
}
ngOnInit(): void {
if(this.pageId !== undefined){
this.page = this.formService.pageFormCreator(new DashboardPage());
this.dashboardPageService.getPageById(this.pageId.toString()).subscribe((data) => {
this.dashboardPage = data;
console.log("IN WINDOW MODAL")
console.log(data);
});
}
}
saveDashboard(name, description, note){
this.dashboardPage.name = name;
this.dashboardPage.description = description;
this.dashboardPage.note = note;
this.dashboardPage.content = JSON.stringify(this.items);
this.dashboardPageService.updatePageById(this.dashboardPage).subscribe((res) => {
// console.log('## Saved Dashboard with id:' + this.dashboardPage.id);
this.toastrService.success(this.translateService.instant('dashboardPage.updated'), this.translateService.instant('general.success'));
this.dialogRef.close();
},err => {
// console.log(err);
this.toastrService.danger(this.translateService.instant('dashboardPage.operation_failed'), this.translateService.instant('general.error'));
});
}
}
......@@ -31,6 +31,7 @@ import { DashboardCloneWizardComponent } from './dashboard-clone-wizard/dashboar
import { ChartViewComponent } from './chart-view/chart-view.component';
import {MatDialogModule} from '@angular/material/dialog';
import { DashboardCardViewComponent } from './dashboard-card-view/dashboard-card-view.component';
import { DashboardInfoComponent } from './dashboard-info/dashboard-info.component';
@NgModule({
......@@ -95,6 +96,7 @@ import { DashboardCardViewComponent } from './dashboard-card-view/dashboard-card
DashboardCloneWizardComponent,
ChartViewComponent,
DashboardCardViewComponent,
DashboardInfoComponent,
],
})
......
......@@ -322,14 +322,14 @@ export class DashboardPageComponent implements OnInit {
console.log("CURRENT changeCurrentSharedType");
console.log(this.currentShared);
}
// editPage(page: DashboardPage) {
// this.page = this.formService.pageFormCreator(page);
// this.pageName = page.name;
// this.menuItemService.getByPageId(this.pageId).subscribe(
// (data) => { this.disabledTarget = data!=null && data.length>0 ? data[0].type != MenuType.SHARED : true; },
// error => (this.showError(error))
// );
// }
editPage(page: DashboardPage) {
this.page = this.formService.pageFormCreator(page);
this.pageName = page.name;
this.menuItemService.getByPageId(this.pageId).subscribe(
(data) => { this.disabledTarget = data!=null && data.length>0 ? data[0].type != MenuType.SHARED : true; },
error => (this.showError(error))
);
}
// isShared(): boolean{
// if(this.selected == "SHARED"){
......
......@@ -10,6 +10,8 @@ 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 { DashboardComponentDialogComponent } from '../dashboard-component-dialog/dashboard-component-dialog.component';
import { DashboardInfoComponent } from '../dashboard-info/dashboard-info.component';
import { DashboardPageCrudService } from '../services/dashboard-page-crud.service';
@Component({
......@@ -136,7 +138,10 @@ export class ManageDashboardPageComponent implements OnInit {
{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:'clone', enabled:true, status:"alert", icon:"copy", tooltip:this.translateService.instant('dashboardClone.action_clone')},
{action:'preview', enabled:true, status:"alert", icon:"eye-outline", tooltip:this.translateService.instant('dashboardClone.action_preview')}
{action:'preview', enabled:true, status:"alert", icon:"eye-outline", tooltip:this.translateService.instant('dashboardClone.action_preview')},
{action:'edit_sharing', enabled:true, status:"alert", icon:"share-outline", tooltip:this.translateService.instant('dashboardPage.edit_sharing')},
{action:'editDashboard', enabled:true, status:"alert", icon:"edit", tooltip:this.translateService.instant('general.editContent')}
];
},
renderComponent: TableActionsComponent,
......@@ -152,17 +157,26 @@ export class ManageDashboardPageComponent implements OnInit {
add: false,
edit: false,
delete: false,
clone: false
clone: false,
edit_sharing: false
},
};
}
onCustom(event, data) {
if (event == 'edit') {
this.router.navigate(['/pages/dashboard-management/edit-dashboard-page/' + data.id])
};
const dialogRef = this.dialogService
.open(DashboardInfoComponent,
{ context: { pageId: data.id }})
.onClose.subscribe((res) => {
console.log("RES SHOULD BE TRUE")
console.log(res)
this.fetchTableData();
},err => {
// console.log(err);
});
}
if (event == 'editDashboard') {
this.router.navigate(['/pages/dashboard-management/edit-dashboard-page-content/' + data.id])
......@@ -202,7 +216,7 @@ export class ManageDashboardPageComponent implements OnInit {
});
};
}
}
}
......@@ -49,6 +49,7 @@
"notFound": "No Dashboard Pages found",
"createLabel": "Create a new Dashboard Page",
"createOrEditLabel": "Create or edit a Dashboard Page",
"edit_dashboard_infos": "Edit Dashboard's info",
"id": "ID",
"type":"Type",
"name": "Name",
......@@ -56,6 +57,7 @@
"content": "Content",
"note": "Note",
"shared": "Shared",
"edit_sharing": "Edit sharing",
"createdDate": "Created Date",
"createdBy": "Created By",
"dashboardComponent": "Dashboard Component",
......
......@@ -49,6 +49,7 @@
"notFound": "No Dashboard Pages found",
"createLabel": "Create a new Dashboard Page",
"createOrEditLabel": "Create or edit a Dashboard Page",
"edit_dashboard_infos": "Edit Dashboard's info",
"id": "ID",
"name": "Name",
"type":"Type",
......@@ -56,6 +57,7 @@
"content": "Content",
"note": "Note",
"shared": "Published",
"edit_sharing": "Edit sharing",
"createdDate": "Created Date",
"createdBy": "Created By",
"dashboardComponent": "Dashboard Component",
......
......@@ -49,12 +49,14 @@
"notFound": "Dashboard non trovata",
"createLabel": "Crea una nuova Dashboard",
"createOrEditLabel": "Crea oppure modifica una Dashboard",
"edit_dashboard_infos": "Modifica informazioni della Dashboard",
"id": "ID",
"name": "Nome",
"description": "Descrizione",
"content": "Contenuto",
"note": "Note",
"type":"Tipo",
"edit_sharing": "Modifica condivisione",
"shared": "Pubblicata",
"createdDate": "Data di creazione",
"createdBy": "Creato da",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment