import { ConfigGetAppConfiguration, ConfigState, DynamicLayoutComponent, CoreModule } from '@abp/ng.core';
import { Component, Optional, Inject, NgModule, ViewChild, InjectionToken } from '@angular/core';
import { Router, RouterModule } from '@angular/router';
import { Validators, FormBuilder } from '@angular/forms';
import { Navigate } from '@ngxs/router-plugin';
import { Store } from '@ngxs/store';
import { OAuthService } from 'angular-oauth2-oidc';
import { from } from 'rxjs';
import { validatePassword, NgxValidateCoreModule } from '@ngx-validate/core';
import { ThemeSharedModule } from '@abp/ng.theme.shared';
import { NgbModal, NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
import { __assign } from 'tslib';
import { TableModule } from 'primeng/table';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var maxLength = Validators.maxLength, minLength = Validators.minLength, required = Validators.required;
var LoginComponent = /** @class */ (function () {
function LoginComponent(fb, oauthService, store, options) {
this.fb = fb;
this.oauthService = oauthService;
this.store = store;
this.options = options;
this.oauthService.configure(this.store.selectSnapshot(ConfigState.getOne('environment')).oAuthConfig);
this.oauthService.loadDiscoveryDocument();
this.form = this.fb.group({
username: ['', [required, maxLength(255)]],
password: ['', [required, maxLength(32)]],
remember: [false],
});
}
/**
* @return {?}
*/
LoginComponent.prototype.onSubmit = /**
* @return {?}
*/
function () {
var _this = this;
if (this.form.invalid)
return;
this.oauthService.setStorage(this.form.value.remember ? localStorage : sessionStorage);
from(this.oauthService.fetchTokenUsingPasswordFlow(this.form.get('username').value, this.form.get('password').value)).subscribe({
next: (/**
* @return {?}
*/
function () {
/** @type {?} */
var redirectUrl = window.history.state.redirectUrl || _this.options.redirectUrl;
_this.store
.dispatch(new ConfigGetAppConfiguration())
.subscribe((/**
* @return {?}
*/
function () { return _this.store.dispatch(new Navigate([redirectUrl || '/'])); }));
}),
error: (/**
* @return {?}
*/
function () { return console.error('an error occured'); }),
});
};
LoginComponent.decorators = [
{ type: Component, args: [{
selector: 'abp-login',
template: "
\n
\n
\n\n
\n
{{ 'AbpAccount::Login' | abpLocalization }}
\n
\n
\n
\n
\n
\n"
}] }
];
/** @nocollapse */
LoginComponent.ctorParameters = function () { return [
{ type: FormBuilder },
{ type: OAuthService },
{ type: Store },
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: ['ACCOUNT_OPTIONS',] }] }
]; };
return LoginComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var maxLength$1 = Validators.maxLength, minLength$1 = Validators.minLength, required$1 = Validators.required, email = Validators.email;
var RegisterComponent = /** @class */ (function () {
function RegisterComponent(fb, oauthService, router) {
this.fb = fb;
this.oauthService = oauthService;
this.router = router;
this.form = this.fb.group({
username: ['', [required$1, maxLength$1(255)]],
password: [
'',
[required$1, maxLength$1(32), minLength$1(6), validatePassword(['small', 'capital', 'number', 'special'])],
],
email: ['', [required$1, email]],
});
}
/**
* @return {?}
*/
RegisterComponent.prototype.onSubmit = /**
* @return {?}
*/
function () {
if (this.form.invalid)
return;
};
RegisterComponent.decorators = [
{ type: Component, args: [{
selector: 'abp-register',
template: "\n"
}] }
];
/** @nocollapse */
RegisterComponent.ctorParameters = function () { return [
{ type: FormBuilder },
{ type: OAuthService },
{ type: Router }
]; };
return RegisterComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var routes = [
{ path: '', pathMatch: 'full', redirectTo: 'login' },
{
path: '',
component: DynamicLayoutComponent,
children: [{ path: 'login', component: LoginComponent }, { path: 'register', component: RegisterComponent }],
},
];
var AccountRoutingModule = /** @class */ (function () {
function AccountRoutingModule() {
}
AccountRoutingModule.decorators = [
{ type: NgModule, args: [{
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
},] }
];
return AccountRoutingModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var TenantBoxComponent = /** @class */ (function () {
function TenantBoxComponent(modalService, fb) {
this.modalService = modalService;
this.fb = fb;
}
/**
* @return {?}
*/
TenantBoxComponent.prototype.createForm = /**
* @return {?}
*/
function () {
this.form = this.fb.group({
name: [this.selected.name],
});
};
/**
* @return {?}
*/
TenantBoxComponent.prototype.openModal = /**
* @return {?}
*/
function () {
this.createForm();
this.modalService.open(this.modalContent);
};
/**
* @return {?}
*/
TenantBoxComponent.prototype.onSwitch = /**
* @return {?}
*/
function () {
this.selected = (/** @type {?} */ ({}));
this.openModal();
};
/**
* @return {?}
*/
TenantBoxComponent.prototype.save = /**
* @return {?}
*/
function () {
this.selected = this.form.value;
this.modalService.dismissAll();
};
TenantBoxComponent.decorators = [
{ type: Component, args: [{
selector: 'abp-tenant-box',
template: "\n\n\n \n \n\n"
}] }
];
/** @nocollapse */
TenantBoxComponent.ctorParameters = function () { return [
{ type: NgbModal },
{ type: FormBuilder }
]; };
TenantBoxComponent.propDecorators = {
modalContent: [{ type: ViewChild, args: ['modalContent', { static: false },] }]
};
return TenantBoxComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} options
* @return {?}
*/
function optionsFactory(options) {
return __assign({ redirectUrl: '/' }, options);
}
/** @type {?} */
var ACCOUNT_OPTIONS = new InjectionToken('ACCOUNT_OPTIONS');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var AccountModule = /** @class */ (function () {
function AccountModule() {
}
/**
* @param {?=} options
* @return {?}
*/
AccountModule.forRoot = /**
* @param {?=} options
* @return {?}
*/
function (options) {
if (options === void 0) { options = (/** @type {?} */ ({})); }
return {
ngModule: AccountModule,
providers: [
{ provide: ACCOUNT_OPTIONS, useValue: options },
{
provide: 'ACCOUNT_OPTIONS',
useFactory: optionsFactory,
deps: [ACCOUNT_OPTIONS],
},
],
};
};
AccountModule.decorators = [
{ type: NgModule, args: [{
declarations: [LoginComponent, RegisterComponent, TenantBoxComponent],
imports: [CoreModule, AccountRoutingModule, ThemeSharedModule, TableModule, NgbDropdownModule, NgxValidateCoreModule],
exports: [],
},] }
];
return AccountModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var ACCOUNT_ROUTES = (/** @type {?} */ ([
{
name: 'Account',
path: 'account',
invisible: true,
layout: "application" /* application */,
children: [{ path: 'login', name: 'Login', order: 1 }, { path: 'register', name: 'Register', order: 2 }],
},
]));
export { ACCOUNT_OPTIONS, ACCOUNT_ROUTES, AccountModule, LoginComponent, RegisterComponent, optionsFactory, LoginComponent as ɵa, RegisterComponent as ɵc, TenantBoxComponent as ɵd, AccountRoutingModule as ɵe, optionsFactory as ɵf, ACCOUNT_OPTIONS as ɵg };
//# sourceMappingURL=abp-ng.account.js.map