From a227aea117a54fca01b97e7494d6432d2117fb2a Mon Sep 17 00:00:00 2001 From: Dirk Peter <67102395+dirk-peter-sag@users.noreply.github.com> Date: Wed, 12 Jun 2024 12:09:29 +0200 Subject: [PATCH] #10 indicator tooltip and visibility (#23) * #10: sets indicator tooltip * #10: improves indicator visibility * #10: moves update timer to service --------- Co-authored-by: Dirk Peter --- .../reminder-drawer.component.ts | 22 ----------- .../reminder-indicator.component.html | 3 +- .../reminder-indicator.component.less | 6 +-- .../reminder-indicator.component.ts | 32 +++++++++++++--- .../reminder-modal.component.html | 21 ++++++---- .../reminder-modal.component.ts | 13 +++---- plugin/reminder-plugin.module.ts | 4 +- plugin/services/reminder.service.ts | 38 ++++++++++++++++++- 8 files changed, 90 insertions(+), 49 deletions(-) diff --git a/plugin/components/reminder-drawer/reminder-drawer.component.ts b/plugin/components/reminder-drawer/reminder-drawer.component.ts index 0a87462..f433ca2 100644 --- a/plugin/components/reminder-drawer/reminder-drawer.component.ts +++ b/plugin/components/reminder-drawer/reminder-drawer.component.ts @@ -1,7 +1,5 @@ import { Component, OnDestroy } from '@angular/core'; import { AlertService, HeaderService } from '@c8y/ngx-components'; -import { filter, sortBy } from 'lodash'; -import moment from 'moment'; import { BsModalService } from 'ngx-bootstrap/modal'; import { BehaviorSubject, Subscription } from 'rxjs'; import { @@ -119,25 +117,5 @@ export class ReminderDrawerComponent implements OnDestroy { this.reminders = reminders; this.reminderGroups = this.reminderService.groupReminders(reminders); this.lastUpdate = new Date(); - this.setUpdateTimer(); - } - - private setUpdateTimer(): void { - // TODO update indicator - // - move update timer to service? - const now = moment(); - - clearTimeout(this.updateTimer); - - if (!this.reminders.length) return; - - const closestReminder = sortBy( - filter(this.reminders, (r) => r.status !== ReminderStatus.cleared && moment(r.time) > now), - 'time' - )[0]; - - if (!closestReminder) return; - - this.updateTimer = setTimeout(() => this.digestReminders(this.reminders), moment(closestReminder.time).diff(now)); } } diff --git a/plugin/components/reminder-indicator/reminder-indicator.component.html b/plugin/components/reminder-indicator/reminder-indicator.component.html index f8e6fba..43022a6 100644 --- a/plugin/components/reminder-indicator/reminder-indicator.component.html +++ b/plugin/components/reminder-indicator/reminder-indicator.component.html @@ -1,4 +1,5 @@ -