UNPKG

consumerportal

Version:

mydna Custimised for you

132 lines (105 loc) 3.69 kB
/// <reference path="../../includes.ts" /> module acctMgmtSignInDetailsCtrl { interface IAcctMgmtSignInDetailsController { passwordStrengthMeter(): any; createAccount(): any; } interface IAcctMgmtSignInDetailsScope extends angular.IScope { myForm: IFormController, snd: any; Username: any; } interface IFormController extends angular.IFormController{ Username: any; } class AcctMgmtSignInDetailsController implements IAcctMgmtSignInDetailsController { static $inject = [ '$rootScope', 'passwordStrengthSrvc', '$scope', 'scrollerSrvc', 'locationSrvc', 'apiSrvc', 'appMemorySrvc', 'mydnaApis', 'errorHandlerSrvc' ]; frm: any; tabIndexValue: any; showErrors: any; strengthClassName: string; strengthUserText: string; UsernameAlreadyExists: boolean; constructor( private $rootScope: angular.IRootScopeService, private passwordStrengthSrvc: passwordStrengthSrvc.IPasswordStrengthService, private $scope: IAcctMgmtSignInDetailsScope, private scrollerSrvc: scrollerSrvc.IScrollerService, private locationSrvc: locationSrvc.ILocationService, private apiSrvc: apiSrvc.IApiService, private appMemorySrvc: appMemorySrvc.IAppMemoryService, private mydnaApis: ImyDNAApis, private errorHandlerSrvc: errorHandlerSrvc.IErrorHandlerService ) { var vm = this; vm.UsernameAlreadyExists = false; vm.frm = {}; vm.frm.Password = ""; vm.frm.Confirm = false; vm.showErrors = false; vm.strengthClassName = ""; vm.strengthUserText = ""; $rootScope.$on("resetTabIndexValue", (event, message) => { vm.tabIndexValue = "0"; }); $rootScope.$on("setTabIndexValue", (event, message) => { vm.tabIndexValue = "-1"; }); if (vm.appMemorySrvc.getGenericFlag() == false) { vm.locationSrvc.goto('acctmgmt/findpatient', ''); } } passwordStrengthMeter() { var strength = this.passwordStrengthSrvc.checkStrength(this.frm.Password); this.strengthClassName = strength.className this.strengthUserText = strength.userText } createAccount() { this.scrollerSrvc.TopScroll(); var RegistrationObj = this.appMemorySrvc.getRegistrationUserinfo(); RegistrationObj.Username = this.frm.Username; RegistrationObj.Password = this.frm.Password; RegistrationObj.ConfirmPassword = this.frm.ConfirmPassword; this.showErrors = this.showErrors == true ? false : ""; if (this.$scope.myForm.$valid) { this.$scope.$emit("disable-on-save-on"); this.apiSrvc.registration_requests( this.mydnaApis.RegisterLoginDetails , RegistrationObj, true, "POST", "JSON").then(data => { this.frm = data.data; this.$scope.$emit("disable-on-save-off"); this.appMemorySrvc.setLoginPageMessage({ status: true, sourceRoute: 'acctmgmt/signindetails', description: 'Signin had been successful', body: "Please check your email for a confirmation of registration. You can login now using the form below, or <a href='#acctmgmt/findpatient'>register</a> another person." }); this.locationSrvc.goto('acctmgmt/login', ''); }, err => { if(err.status == 409){ this.showErrors = true; this.UsernameAlreadyExists = true; } else{ this.errorHandlerSrvc.errorHandler(err, 'debug', ''); } this.$scope.$emit("disable-on-save-off"); }); } else { this.showErrors = true; } } } angular.module('app').controller('acctMgmtSignInDetailsCtrl', AcctMgmtSignInDetailsController); }