Notes/src/public/app/widgets/buttons/protected_session_status.js

30 lines
937 B
JavaScript
Raw Normal View History

2021-05-18 22:14:35 +02:00
import ButtonWidget from "./button_widget.js";
2021-05-24 22:29:49 +02:00
import protectedSessionHolder from "../../services/protected_session_holder.js";
2021-05-18 22:14:35 +02:00
export default class ProtectedSessionStatusWidget extends ButtonWidget {
doRender() {
2021-05-22 21:35:25 +02:00
this.updateSettings();
2021-05-18 22:14:35 +02:00
super.doRender();
}
2021-05-22 21:35:25 +02:00
updateSettings() {
this.settings.icon = protectedSessionHolder.isProtectedSessionAvailable()
2021-05-18 22:14:35 +02:00
? "bx-shield-quarter"
: "bx-log-in";
2021-05-22 21:35:25 +02:00
this.settings.title = protectedSessionHolder.isProtectedSessionAvailable()
2021-05-18 22:14:35 +02:00
? "Protected session is active. Click to leave protected session."
: "Click to enter protected session";
2021-05-22 21:35:25 +02:00
this.settings.command = protectedSessionHolder.isProtectedSessionAvailable()
2021-05-18 22:14:35 +02:00
? "leaveProtectedSession"
: "enterProtectedSession";
}
protectedSessionStartedEvent() {
2021-05-22 21:35:25 +02:00
this.updateSettings();
2021-05-18 22:14:35 +02:00
this.refreshIcon();
}
}