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

34 lines
972 B
JavaScript
Raw Normal View History

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