From a47bf22050177a6f429e03a6d676452773676845 Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Sun, 18 Jun 2023 18:04:50 +0200 Subject: [PATCH] intermediate save for notifications component --- .../notifications/notifications.vue | 36 +++++ .../src/components/notifications/popups.vue | 0 .../src/components/seatplan/editor/window.vue | 130 +++++++++++++----- 3 files changed, 132 insertions(+), 34 deletions(-) create mode 100644 src/webapp/src/components/notifications/notifications.vue create mode 100644 src/webapp/src/components/notifications/popups.vue diff --git a/src/webapp/src/components/notifications/notifications.vue b/src/webapp/src/components/notifications/notifications.vue new file mode 100644 index 0000000..6706d04 --- /dev/null +++ b/src/webapp/src/components/notifications/notifications.vue @@ -0,0 +1,36 @@ + + + \ No newline at end of file diff --git a/src/webapp/src/components/notifications/popups.vue b/src/webapp/src/components/notifications/popups.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/webapp/src/components/seatplan/editor/window.vue b/src/webapp/src/components/seatplan/editor/window.vue index 77ac319..408660b 100644 --- a/src/webapp/src/components/seatplan/editor/window.vue +++ b/src/webapp/src/components/seatplan/editor/window.vue @@ -27,7 +27,7 @@
- + @@ -35,12 +35,16 @@ - -
- -
Saved!
+ + +
+
+
+ done + close + progress_activity +

{{ message }}

-
@@ -77,7 +81,8 @@ zoomFactor: 1, historyPos: 0, generalSettings: { 'namingScheme': 'numeric' }, - saved: false, + message: 'Test message', + messageType: 'hide', } }, methods: { @@ -107,7 +112,7 @@ self.deleteSelected(); } else if ( event.ctrlKey && event.key === 's' ) { event.preventDefault(); - self.save(); + self.saveDraft(); } else if ( ( event.ctrlKey && event.key === 'y' ) ) { event.preventDefault(); self.historyOp( 'redo' ); @@ -259,10 +264,28 @@ }, save () { sessionStorage.setItem( 'seatplan', JSON.stringify( this.scaleDown( this.draggables ) ) ); - this.saved = true; + }, + saveDraft () { + sessionStorage.setItem( 'seatplan', JSON.stringify( this.scaleDown( this.draggables ) ) ); + // TODO: Save to server + this.message = 'Saved as draft'; + this.messageType = 'ok'; setTimeout( () => { - this.saved = false; - }, 5000 ) + this.messageType = 'hide'; + }, 5000 ); + }, + deploy () { + // TODO: Save to server + this.message = 'Deploying...'; + this.messageType = 'progress'; + setTimeout( () => { + this.messageType = 'ok'; + this.message = 'Deployed successfully'; + }, 5000 ); + setTimeout( () => { + this.messageType = 'hide'; + this.message = ''; + }, 10000 ); }, addNewElement () { this.draggables[ Object.keys( this.draggables ).length + 1 ] = { 'x': 100, 'y':100, 'h': 100, 'w': 250, 'active': false, 'draggable': true, 'resizable': true, 'id': Object.keys( this.draggables ).length + 1, 'origin': 1, 'shape':'rectangular', 'type': 'seat', 'startingRow': 1, 'seatCountingStartingPoint': 0 }; @@ -292,9 +315,17 @@ } else { if ( ( this.zoomFactor < 0.3 && scale < 0 ) || ( this.zoomFactor > 2.9 && scale > 0 ) ) { if ( this.zoomFactor < 0.3 ) { - alert( 'Minimum zoom factor reached' ); + this.message = 'Minimum zoom factor reached'; + this.messageType = 'error'; + setTimeout( () => { + this.messageType = 'hide'; + }, 5000 ); } else { - alert( 'Maximum zoom factor reached' ); + this.message = 'Maximum zoom factor reached'; + this.messageType = 'error'; + setTimeout( () => { + this.messageType = 'hide'; + }, 5000 ); } } else { this.zoomFactor += scale; @@ -371,33 +402,64 @@ cursor: default; } - .save-wrapper { - position: relative; + .message-box { + position: fixed; + left: 0.5%; + z-index: 5; + top: 3%; + color: white; + height: 10vh; + width: 15vw; + opacity: 1; + transition: all 0.5s; } - .saved { - transition: all 0.5s; - position: absolute; - top: 20%; - left: 150%; - width: 7vw; - height: 3vh; + .message-container { display: flex; justify-content: center; align-items: center; - background-color: var( --accent-background ); - color: white; - border-radius: 5px; + height: 100%; + width: 100%; } - .saved::before { - content: " "; - position: absolute; - bottom: 13%; - left: -10%; - margin-left: -5px; - border-width: 10px; - border-style: solid; - border-color: transparent var( --accent-background ) transparent transparent; + .types { + color: white; + border-radius: 100%; + margin-right: auto; + margin-left: 5%; + font-size: 200%; + } + + .message { + margin-right: 5%; + } + + .ok { + background-color: rgb(1, 71, 1); + } + + .error { + background-color: rgb(114, 1, 1); + } + + .hide { + opacity: 0; + } + + .progress { + background-color: rgb(0, 0, 99); + } + + .progress-spinner { + animation: spin 2s infinite linear; + } + + @keyframes spin { + from { + transform: rotate( 0deg ); + } + to { + transform: rotate( 720deg ); + } }