{
const originalFlow$ = this.flowsCallService.getFlowById(flowId);
const newFlow$ = this.flowsCallService.createNewFlow();
diff --git a/src/app/shared/title-toolbar/title-toolbar.css b/src/app/shared/title-toolbar/title-toolbar.css
index e69de29..281738c 100644
--- a/src/app/shared/title-toolbar/title-toolbar.css
+++ b/src/app/shared/title-toolbar/title-toolbar.css
@@ -0,0 +1,17 @@
+.save-snackbar {
+ position: fixed;
+ right: 24px;
+ bottom: 24px;
+ z-index: 2000;
+ padding: 10px 14px;
+ border-radius: 8px;
+ background: #15803d;
+ color: #ffffff;
+ font-size: 13px;
+ font-weight: 500;
+ box-shadow: 0 10px 20px rgba(15, 23, 42, 0.22);
+}
+
+.save-snackbar-error {
+ background: #b91c1c;
+}
diff --git a/src/app/shared/title-toolbar/title-toolbar.html b/src/app/shared/title-toolbar/title-toolbar.html
index e59458f..213d9aa 100644
--- a/src/app/shared/title-toolbar/title-toolbar.html
+++ b/src/app/shared/title-toolbar/title-toolbar.html
@@ -69,3 +69,9 @@
}
}
+
+@if (snackbarMessage()) {
+
+ {{ snackbarMessage() }}
+
+}
diff --git a/src/app/shared/title-toolbar/title-toolbar.ts b/src/app/shared/title-toolbar/title-toolbar.ts
index 3a351d3..fea324a 100644
--- a/src/app/shared/title-toolbar/title-toolbar.ts
+++ b/src/app/shared/title-toolbar/title-toolbar.ts
@@ -1,5 +1,6 @@
import { CommonModule } from '@angular/common';
-import { Component, computed, ElementRef, inject, ViewChild } from '@angular/core';
+import { Component, computed, ElementRef, inject, signal, ViewChild } from '@angular/core';
+import { take } from 'rxjs';
import { EditorStateHolder } from '@stores/flow-editor';
@Component({
@@ -9,6 +10,7 @@ import { EditorStateHolder } from '@stores/flow-editor';
styleUrl: './title-toolbar.css',
})
export class TitleToolbar {
+ private snackTimeout: ReturnType | null = null;
@ViewChild('titleInput') myInputRef!: ElementRef;
@@ -20,6 +22,8 @@ export class TitleToolbar {
});
notSaved = computed(() => this.editorState.isDirty());
+ snackbarMessage = signal(null);
+ snackbarType = signal<'success' | 'error'>('success');
changeTitle(value: string) {
@@ -35,9 +39,18 @@ export class TitleToolbar {
save() {
if (!this.notSaved()) return;
- this.editorState.save().subscribe(
- err => console.error('Save failed', err)
- );
+ this.editorState.save().pipe(
+ take(1)
+ ).subscribe({
+ next: () => {
+ console.log('Flow saved');
+ this.showSnackbar('Flow saved', 'success');
+ },
+ error: err => {
+ console.error('Save failed', err);
+ this.showSnackbar('Errore durante il salvataggio', 'error');
+ }
+ });
}
undo() {
@@ -46,5 +59,19 @@ export class TitleToolbar {
redo() {
this.editorState.redo();
- }
+ }
+
+ private showSnackbar(message: string, type: 'success' | 'error') {
+ this.snackbarMessage.set(message);
+ this.snackbarType.set(type);
+
+ if (this.snackTimeout) {
+ clearTimeout(this.snackTimeout);
+ }
+
+ this.snackTimeout = setTimeout(() => {
+ this.snackbarMessage.set(null);
+ this.snackTimeout = null;
+ }, 2500);
+ }
}