You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
4.1 KiB
111 lines
4.1 KiB
import { NotificationService } from "./NotificationService";
|
|
// @ts-ignore
|
|
import * as alertify from "alertifyjs";
|
|
import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel";
|
|
import log = require("loglevel");
|
|
import bootbox = require("bootbox")
|
|
export class AlertifyNotificationService implements NotificationService {
|
|
|
|
private readonly _alertify = alertify;
|
|
constructor() {
|
|
this._alertify.set('notifier', 'position', 'top-center');
|
|
}
|
|
success(message: string): void {
|
|
this._alertify.success(message)
|
|
}
|
|
error(message: string): void {
|
|
this._alertify.error(message);
|
|
}
|
|
errorWithDelay(message: string, delay: number): void {
|
|
const _delay = this._alertify.get('notifier', 'delay');
|
|
this._alertify.set('notifier', 'delay', delay);
|
|
this._alertify.error(message);
|
|
this._alertify.set('notifier', 'delay', _delay);
|
|
}
|
|
warning(message: string): void {
|
|
this._alertify.warning(message);
|
|
}
|
|
message(message: string): void {
|
|
this._alertify.message(message);
|
|
}
|
|
passphrasePrompt(vm: ActiveUserViewModel, vms: ActiveUserViewModel[], cb1: (contactName: string, passphrase: string,
|
|
lastMessageTime: string | null, op: string) => void,
|
|
cb2: () => any): void {
|
|
|
|
// alertify.myprompt || alertify.dialog('myprompt', function () {
|
|
|
|
// // document.getElementById('passphraseFormNew')!.addEventListener('submit', function (e: Event) {
|
|
// // e.preventDefault();
|
|
// // log.debug(this.querySelectorAll('input'))
|
|
// // Array.from(this.querySelectorAll('input')).map((el) => {
|
|
// // const el2 = el as HTMLInputElement;
|
|
// // vm.passphrase = el2.value;
|
|
// // vm.unlocked = true;
|
|
// // cb1(vm.userName!, vm.passphrase, null, "new");
|
|
// // cb2();
|
|
// // alertify.myprompt().close();
|
|
// // })
|
|
// // log.debug(vm)
|
|
|
|
// // })
|
|
|
|
// return {
|
|
// main: function (content: HTMLElement) {
|
|
// log.debug(vm)
|
|
|
|
// // @ts-ignore
|
|
// this.setContent(content);
|
|
// },
|
|
|
|
// setup: function () {
|
|
// return {
|
|
// focus: {
|
|
// // @ts-ignore
|
|
// element: function () {
|
|
// // @ts-ignore
|
|
// return this.elements.body.querySelector(this.get('selector'));
|
|
// },
|
|
// select: true
|
|
// },
|
|
// options: {
|
|
// title: 'Enter Passphrase',
|
|
// basic: true,
|
|
// maximizable: false,
|
|
// resizable: false,
|
|
// padding: false
|
|
// }
|
|
// };
|
|
// },
|
|
// settings: {
|
|
// // @ts-ignore
|
|
// selector: undefined
|
|
// },
|
|
// }
|
|
|
|
|
|
// })
|
|
|
|
// alertify.myprompt(document.getElementById('passphraseFormNew')).set('selector', 'input[type="password"]');
|
|
|
|
if (vm.passphrase == null) {
|
|
bootbox.prompt({
|
|
title: "Please enter the passphrase",
|
|
inputType: 'password',
|
|
callback: function (result) {
|
|
if (result) {
|
|
log.debug(result);
|
|
cb1(vm.userName!, result, null, "new");
|
|
vm.unlocked = true
|
|
vms.filter(v => v.userName == vm.userName).map(v => { v.passphrase = result; v.unlocked = true })
|
|
cb2();
|
|
log.debug(vm)
|
|
log.debug(vms)
|
|
}
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
cb1(vm.userName!, vm.passphrase, null, "new");
|
|
}
|
|
}
|
|
}
|