This commit is contained in:
2019-11-08 18:51:36 +00:00
parent c168a00e1a
commit ef219df726
3 changed files with 11 additions and 87 deletions

View File

@@ -45,19 +45,19 @@ TODO:
///////////
//ERROR
window.$gz.eventBus.$on("notify-error", function handleNotifyWarn(msg) {
vm.$root.$gznotify({ message: msg, type: "error", timeout: 2000 });
vm.$root.$gznotify({ message: msg, type: "error", timeout: 5000 });
});
///////////
//WARNING
window.$gz.eventBus.$on("notify-warning", function handleNotifyWarn(msg) {
vm.$root.$gznotify({ message: msg, type: "warning", timeout: 2000 });
vm.$root.$gznotify({ message: msg, type: "warning", timeout: 4000 });
});
///////////
//INFO
window.$gz.eventBus.$on("notify-info", function handleNotifyWarn(msg) {
vm.$root.$gznotify({ message: msg, type: "info", timeout: 2000 });
vm.$root.$gznotify({ message: msg, type: "info", timeout: 3000 });
});
///////////

View File

@@ -148,29 +148,11 @@ export default function initialize() {
//for now just show the message
window.$gz.eventBus.$emit(
"notify-info",
"1111 Time zone offset for your account is set to " +
"Time zone offset for your account is set to " +
res.data.timeZoneOffset +
" which doesn't match the local timezone offset of " +
localOffset
);
window.$gz.eventBus.$emit(
"notify-warning",
"2222 this is a warning test"
);
window.$gz.eventBus.$emit(
"notify-error",
"3333 this is an error test"
);
window.$gz.eventBus.$emit(
"notify-success",
"4444 this is a success test"
);
window.$gz.eventBus.$emit(
"notify-info",
"5555 this is the FINAL (info) test"
);
}
//Store offset in locale data

View File

@@ -10,9 +10,7 @@
</template>
<script>
/* eslint-disable */
//todo: modify this to MD standards so it can display multiple notifications sequentially but one at a time only
//and no new one will overwrite an old one until the old one has had at least 2 seconds to show or some good default maybe based on how much text is on it?
/* Xeslint-disable */
const DEFAULT_NOTIFY_OPTIONS = { type: "info", timeout: 3000 };
export default {
@@ -28,9 +26,7 @@ export default {
}),
methods: {
addNotification(options) {
if (!options.message) {
console.log("addNotification: No message, skipping this one");
return;
}
if (!options.type) {
@@ -41,88 +37,34 @@ export default {
}
//add it to the queue
this.notificationQueue.push(options);
console.log(
"addNotification just added: " +
"msg:" +
options.message +
"timeout:" +
options.timeout +
"type:" +
options.type +
" queue length is now: " +
this.notificationQueue.length
);
//trigger the notification queue handler if it isn't already in action
if (!this.processing) {
console.log("addNotification: NOT processing so calling this.handleNotifcations now...");
this.handleNotifications();
}
// //if it's not currently displaying anything then just show it immediately
// if (!this.isVisible) {
// this.message = message;
// this.options = Object.assign(this.options, options);
// this.isVisible = true;
// } else {
// //it *is* showing something so give it maximum 2 seconds then show the new one
// setTimeout(() => {
// this.message = message;
// this.options = Object.assign(this.options, options);
// this.isVisible = true;
// }, 2000);
// }
},
handleNotifications() {
console.log("TOP OF handleNotifications");
this.processing = true;
//Process the queue
if (this.notificationQueue.length > 0) {
console.log(
"handleNotification, just shown currentNotification deets: " +
"msg:" +
this.currentNotification.message +
"timeout:" +
this.currentNotification.timeout +
"type:" +
this.currentNotification.type +
" queue length is now: " +
this.notificationQueue.length
);
//Move the next item into the current slot
this.currentNotification = this.notificationQueue.shift();
// this.isVisible = true;
this.$nextTick(() => { this.isVisible = true })
//If don't use nextTick then don't get all visible when multiple in sequence
this.$nextTick(() => {
this.isVisible = true;
});
//Show it for the designated time before moving on to the next
setTimeout(() => {
console.log("Timeout-recursing now");
this.isVisible = false;
//recurse
this.handleNotifications();
}, this.currentNotification.timeout);
} else {
this.processing = false;
console.log("QUEUE EMPTY, stopping processing");
return;
}
// this.processing = true;
// //Keep doing this as long as there are items in the queue
// while (this.notificationQueue.length > 0) {
// console.log("TOP OF LOOP");
// //Move the first item into the current slot
// this.currentNotification = this.notificationQueue.shift();
// this.isVisible = true;
// //Show it for the designated time before moving on to the next
// setTimeout(() => {
// this.isVisible = false;
// }, this.currentNotification.timeout);
// console.log("AFTER TIMEOUT");
// }
// this.processing = false;
}
}
};