diff --git a/src/components/panels/HistoryRemindersPanel.vue b/src/components/panels/HistoryRemindersPanel.vue
index 1e060b327..ef0b7db20 100644
--- a/src/components/panels/HistoryRemindersPanel.vue
+++ b/src/components/panels/HistoryRemindersPanel.vue
@@ -133,8 +133,7 @@
:rules="nameInputRules"
hide-details
outlined
- dense
- @update:error="isInvalidName = !isInvalidName">
+ dense>
@@ -144,8 +143,7 @@
:rules="hoursInputRules"
hide-details
outlined
- dense
- @update:error="isInvalidHours = !isInvalidHours">
+ dense>
@@ -172,8 +170,7 @@
:rules="nameInputRules"
hide-details
outlined
- dense
- @update:error="isInvalidName = !isInvalidName">
+ dense>
@@ -183,8 +180,7 @@
:rules="hoursInputRules"
hide-details
outlined
- dense
- @update:error="isInvalidHours = !isInvalidHours">
+ dense>
@@ -210,7 +206,7 @@ import {
mdiCloseThick,
mdiRepeatOnce,
} from '@mdi/js'
-import { Component, Mixins } from 'vue-property-decorator'
+import { Component, Mixins, Watch } from 'vue-property-decorator'
import { GuiRemindersStateReminder } from '@/store/gui/reminders/types'
import BaseMixin from '@/components/mixins/base'
import Panel from '@/components/ui/Panel.vue'
@@ -238,7 +234,7 @@ export default class HistoryRemindersPanel extends Mixins(BaseMixin) {
isInvalidName = false
// TODO: translate
- hoursInputRules = [(value: number) => value > 0 || 'Must be a postitive number']
+ hoursInputRules = [(value: number) => value > 0 || 'Must be a positive number']
isInvalidHours = false
sortBy = 'remaining_print_time'
@@ -416,6 +412,8 @@ export default class HistoryRemindersPanel extends Mixins(BaseMixin) {
start_total_print_time: 0,
time_delta: 0,
}
+ this.isInvalidHours = true
+ this.isInvalidName = true
}
createReminder() {
@@ -431,6 +429,8 @@ export default class HistoryRemindersPanel extends Mixins(BaseMixin) {
openEditReminderDialog(reminder: GuiRemindersStateReminder) {
this.editingReminder = { ...reminder }
this.editingReminder.time_delta = Math.round(this.editingReminder.time_delta / 3600)
+ this.isInvalidHours = false
+ this.isInvalidName = false
this.editReminderDialog = true
}
@@ -442,5 +442,25 @@ export default class HistoryRemindersPanel extends Mixins(BaseMixin) {
this.editReminderDialog = false
this.editingReminder = null
}
+
+ @Watch('editingDisplayName')
+ onEditingDisplayname(val: string) {
+ this.isInvalidName = !val
+ }
+
+ @Watch('editingPrintHours')
+ onEditingPrintHours(val: string) {
+ this.isInvalidHours = parseFloat(val) <= 0
+ }
+
+ @Watch('creatingDisplayName')
+ onCreatingDisplayName(val: string) {
+ this.isInvalidName = !val
+ }
+
+ @Watch('creatingPrintHours')
+ onCreatingPrintHours(val: string) {
+ this.isInvalidHours = parseFloat(val) <= 0
+ }
}
diff --git a/src/store/gui/notifications/getters.ts b/src/store/gui/notifications/getters.ts
index de456430d..500319054 100644
--- a/src/store/gui/notifications/getters.ts
+++ b/src/store/gui/notifications/getters.ts
@@ -5,6 +5,7 @@ import i18n from '@/plugins/i18n.js'
import { RootStateDependency } from '@/store/types'
import { sha256 } from 'js-sha256'
import { PrinterStateKlipperConfigWarning } from '@/store/printer/types'
+import { GuiRemindersStateReminder } from '../reminders/types'
export const getters: GetterTree = {
getNotifications: (state, getters) => {
@@ -28,6 +29,9 @@ export const getters: GetterTree = {
// klipper warnings
notifications = notifications.concat(getters['getNotificationsKlipperWarnings'])
+ // user-created reminders
+ notifications = notifications.concat(getters['getNotificationsOverdueReminders'])
+
const mapType = {
normal: 2,
high: 1,
@@ -270,6 +274,42 @@ export const getters: GetterTree = {
return notifications
},
+ getNotificationsOverdueReminders: (state, getters, rootState, rootGetters) => {
+ const notifications: GuiNotificationStateEntry[] = []
+ let reminders: GuiRemindersStateReminder[] = rootGetters['gui/reminders/getOverdueReminders']
+
+ const date = rootState.server.system_boot_at ?? new Date()
+
+ if (reminders.length) {
+ // get all dismissed reminders and convert it to a string[]
+ const remindersDismisses = rootGetters['gui/notifications/getDismissByCategory']('reminder').map(
+ (dismiss: GuiNotificationStateDismissEntry) => {
+ return dismiss.id
+ }
+ )
+
+ // filter all dismissed reminders
+ reminders = reminders.filter((reminder) => !remindersDismisses.includes(reminder.id))
+
+ reminders.forEach((reminder) => {
+ // TODO: translate
+ const title = 'User Created Reminder'
+ const description = reminder.name
+
+ notifications.push({
+ id: `reminder/${reminder.id}`,
+ priority: 'normal',
+ title: title,
+ description: description,
+ date,
+ dismissed: false,
+ })
+ })
+ }
+
+ return notifications
+ },
+
getDismiss: (state, getters, rootState) => {
const currentTime = new Date()
const systemBootAt = rootState.server.system_boot_at ?? new Date()
diff --git a/src/store/gui/reminders/getters.ts b/src/store/gui/reminders/getters.ts
index d4a4f7a2a..31595b6e2 100644
--- a/src/store/gui/reminders/getters.ts
+++ b/src/store/gui/reminders/getters.ts
@@ -18,4 +18,11 @@ export const getters: GetterTree = {
return reminders.find((reminder: GuiRemindersStateReminder) => reminder.id === id)
},
+
+ getOverdueReminders: (state, getters, rootState) => {
+ const currentTotalPrintTime = rootState.server.history.job_totals.total_print_time
+ return Object.values(state.reminders).filter(
+ (reminder) => reminder.time_delta - (currentTotalPrintTime - reminder.start_total_print_time) < 0
+ )
+ },
}