-
Notifications
You must be signed in to change notification settings - Fork 22
/
appdashboardhelpernotifications.js
66 lines (61 loc) · 2.63 KB
/
appdashboardhelpernotifications.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { AppHelperBase } from "./v2/apphelperbase.js";
import { AppDashboard, ServerEventBus } from "./appdashboard.js";
import { EventBus } from "./v2/eventbus.js";
import { UtilDOM } from "./v2/utildom.js";
import { NotificationInfo } from "./v2/notification/notificationinfo.js";
class RequestNotificationInfo{}
class RequestResize{
constructor({width,height}){
this.width = width;
this.height = height;
}
}
class MouseLeave{}
class MouseEnter{}
/** @type {AppDashboard} */
let app = null
export class AppDashboardNotifications extends AppHelperBase{
constructor(appDashboard){
super(appDashboard);
app = appDashboard;
}
async load(){
EventBus.register(this);
const {ControlNotificationClickHandler} = await import("./v2/gcm/notificationclickhandler/controlnotificationclickhandler.js")
this.controlNotifications = new ControlNotificationClickHandler();
this.controlNotifications.hideFAB = true;
UtilDOM.setCssVariable("theme-background-color-panel","transparent");
this.controlNotifications.backgroundColor = "transparent";
await app.addElement(this.controlNotifications,app.rootElement)
ServerEventBus.post(new RequestNotificationInfo());
document.addEventListener("mouseleave", e=>ServerEventBus.post(new MouseLeave()))
document.addEventListener("mouseenter", e=>ServerEventBus.post(new MouseEnter()))
}
async onThemeApplied(){
UtilDOM.setCssVariable("theme-background-color-panel","transparent");
}
async onNotificationInfos(notificationInfos){
if(!this.controlNotifications) return;
const options = notificationInfos.options;
if(!options) return;
for(const optionsSingle of options){
optionsSingle.device = await app.getDevice(optionsSingle.senderId);
optionsSingle.canClose = true;
if(optionsSingle.hideText){
optionsSingle.text = "Hidden Text";
}
}
console.log("Got notification infos",options);
const {NotificationInfo} = await import("./v2/notification/notificationinfo.js")
this.controlNotifications.notifications = options.map(optionsSingle=>new NotificationInfo(optionsSingle,optionsSingle.device));
await this.controlNotifications.render();
await Util.sleep(50);
ServerEventBus.post(new RequestResize(this.controlNotifications.notificationsListSize));
}
async onRequestReplyMessage(request){
ServerEventBus.post(request);
}
async onRequestNotificationClose(request){
ServerEventBus.post(request);
}
}