46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import Vue from "vue";
|
|
import Component from "vue-class-component";
|
|
import { Modal, ModalHelper } from "./base-components"
|
|
|
|
import { Factory, MessageService, awaiter } from "src/_base";
|
|
import { LoginService } from "src/app.modules";
|
|
import { DataService } from '../services/dataService';
|
|
import iziToast, { IziToastSettings } from "izitoast";
|
|
|
|
@Component({ name: "login", components: { modal: Modal } })
|
|
export default class Login extends Vue {
|
|
|
|
public user: server.loginViewModel = { password: null, username: null };
|
|
public hasError: boolean = false;
|
|
|
|
public logginIn: boolean = false;
|
|
|
|
async doLogin() {
|
|
var service = Factory.Get(LoginService);
|
|
|
|
this.logginIn = true;
|
|
if (await awaiter(service.doLogin(this.user)).then(() => {
|
|
new DataService().GetUserSoftkeyFavorite();
|
|
ModalHelper.HideModal();
|
|
}).catch(() => {
|
|
this.logginIn = false;
|
|
this.hasError = !service.isAuthenticated;
|
|
}))
|
|
ModalHelper.HideModal();
|
|
}
|
|
|
|
mounted(){
|
|
Factory.Get(MessageService).subscribeToChannel("force-ui-update", args => {
|
|
this.$forceUpdate();
|
|
});
|
|
document.body.addEventListener('keydown', function(e) {
|
|
if (e.keyCode == 27) {
|
|
return false;
|
|
}
|
|
})
|
|
|
|
}
|
|
}
|
|
|
|
|