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 //ERROR
window.$gz.eventBus.$on("notify-error", function handleNotifyWarn(msg) { 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 //WARNING
window.$gz.eventBus.$on("notify-warning", function handleNotifyWarn(msg) { 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 //INFO
window.$gz.eventBus.$on("notify-info", function handleNotifyWarn(msg) { 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 //for now just show the message
window.$gz.eventBus.$emit( window.$gz.eventBus.$emit(
"notify-info", "notify-info",
"1111 Time zone offset for your account is set to " + "Time zone offset for your account is set to " +
res.data.timeZoneOffset + res.data.timeZoneOffset +
" which doesn't match the local timezone offset of " + " which doesn't match the local timezone offset of " +
localOffset 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 //Store offset in locale data

View File

@@ -10,9 +10,7 @@
</template> </template>
<script> <script>
/* eslint-disable */ /* Xeslint-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?
const DEFAULT_NOTIFY_OPTIONS = { type: "info", timeout: 3000 }; const DEFAULT_NOTIFY_OPTIONS = { type: "info", timeout: 3000 };
export default { export default {
@@ -28,9 +26,7 @@ export default {
}), }),
methods: { methods: {
addNotification(options) { addNotification(options) {
if (!options.message) { if (!options.message) {
console.log("addNotification: No message, skipping this one");
return; return;
} }
if (!options.type) { if (!options.type) {
@@ -42,87 +38,33 @@ export default {
//add it to the queue //add it to the queue
this.notificationQueue.push(options); 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 //trigger the notification queue handler if it isn't already in action
if (!this.processing) { if (!this.processing) {
console.log("addNotification: NOT processing so calling this.handleNotifcations now...");
this.handleNotifications(); 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() { handleNotifications() {
console.log("TOP OF handleNotifications");
this.processing = true; this.processing = true;
//Process the queue //Process the queue
if (this.notificationQueue.length > 0) { 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 //Move the next item into the current slot
this.currentNotification = this.notificationQueue.shift(); 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 //Show it for the designated time before moving on to the next
setTimeout(() => { setTimeout(() => {
console.log("Timeout-recursing now");
this.isVisible = false; this.isVisible = false;
//recurse //recurse
this.handleNotifications(); this.handleNotifications();
}, this.currentNotification.timeout); }, this.currentNotification.timeout);
} else { } else {
this.processing = false; this.processing = false;
console.log("QUEUE EMPTY, stopping processing");
return; 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;
} }
} }
}; };