dashboard #1

Merged
andi merged 118 commits from dashboard into master 2024-09-29 06:47:35 +00:00
4 changed files with 28 additions and 3 deletions
Showing only changes of commit 02c748c286 - Show all commits

View File

@@ -75,7 +75,7 @@
<div cdkDragHandle class="handle"></div>
<app-text-widget
*ngIf="isTextWidget(id)"
[data]="getTextWidget(id)!"></app-text-widget>
[data]="getTextWidget(id)!" (deleted)="delete($event)"></app-text-widget>
<app-plot-widget
*ngIf="isPlotWidget(id)"
[data]="getPlotWidget(id)!"></app-plot-widget>

View File

@@ -208,4 +208,10 @@ export class DashboardComponent implements OnInit {
);
}
}
delete(dashboardId: string) {
this.dashboard!.arrangement[0] = this.dashboard!.arrangement[0].filter(a => a != dashboardId);
this.dashboard!.plots = this.dashboard!.plots.filter(p => p.id != dashboardId);
this.dashboard!.texts = this.dashboard!.texts.filter(t => t.id != dashboardId);
}
}

View File

@@ -25,6 +25,9 @@
}
</style>
<div class="text-widget">
<button mat-icon-button (click)="edit()" class="editable-hovered"><img src="/assets/img/edit-outline.svg"/></button>
<div class="actions editable-hovered">
<button mat-icon-button (click)="edit()"><img src="/assets/img/edit-outline.svg"/></button>
<button mat-icon-button (click)="delete()"><img src="/assets/img/recycle-bin-line.svg"/></button>
</div>
<p *ngFor="let line of lines()">{{line}}</p>
</div>

View File

@@ -1,5 +1,6 @@
import { Component, Input } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ConfirmationDialogComponent } from 'src/app/confirmation-dialog/confirmation-dialog.component';
import { TextWidget } from 'src/app/dashboard.service';
import { AddTextDialogComponent } from '../add-text-dialog/add-text-dialog.component';
@@ -11,11 +12,26 @@ export class TextWidgetComponent {
@Input()
data! : TextWidget;
@Output()
deleted : EventEmitter<string> = new EventEmitter<string>();
constructor(private dialog: MatDialog){}
lines(): string[]{
return typeof this.data.text == 'string' ? this.data.text.split(/\r?\n/) : [];
}
delete() {
this.dialog
.open(ConfirmationDialogComponent, {
data: {title: "", text: "Delete text?", btnOkLabel: "Delete", btnCancelLabel: "Cancel"}
})
.afterClosed()
.subscribe((result: boolean) => {
if (result === true) {
this.deleted.emit(this.data.id);
}
});
}
edit() {
this.dialog.open(AddTextDialogComponent,{