- remove auth-wrapper and tenant-box components from account package

- configure route providers
pull/9395/head
muhammedaltug 4 years ago
parent 50f91f7f56
commit e915a9132c

@ -0,0 +1,62 @@
<nav
class="navbar navbar-expand-lg navbar-dark bg-dark shadow-sm flex-column flex-md-row mb-4"
id="main-navbar"
style="min-height: 4rem"
>
<div class="container">
<abp-logo *abpReplaceableTemplate="{ componentKey: service.logoComponentKey }"></abp-logo>
<button
class="navbar-toggler"
type="button"
[attr.aria-expanded]="!service.isCollapsed"
(click)="service.isCollapsed = !service.isCollapsed"
>
<span class="navbar-toggler-icon"></span>
</button>
<div
class="navbar-collapse"
[class.overflow-hidden]="service.smallScreen"
id="main-navbar-collapse"
>
<ng-container *ngTemplateOutlet="!service.smallScreen ? navigations : null"></ng-container>
<div
*ngIf="service.smallScreen"
[@collapseWithMargin]="service.isCollapsed ? 'collapsed' : 'expanded'"
>
<ng-container *ngTemplateOutlet="navigations"></ng-container>
</div>
<ng-template #navigations>
<abp-routes
*abpReplaceableTemplate="{
componentKey: service.routesComponentKey,
inputs: {
smallScreen: { value: service.smallScreen }
}
}"
class="mx-auto"
[smallScreen]="service.smallScreen"
></abp-routes>
<abp-nav-items
*abpReplaceableTemplate="{
componentKey: service.navItemsComponentKey
}"
></abp-nav-items>
</ng-template>
</div>
</div>
</nav>
<!-- [@slideFromBottom]="outlet.isActivated && outlet.activatedRoute?.routeConfig?.path" TODO: throws ExpressionChangedAfterItHasBeenCheck when animation is active. It should be fixed -->
<div class="container">
<abp-page-alert-container></abp-page-alert-container>
<abp-auth-wrapper
*abpReplaceableTemplate="{
componentKey: authWrapperKey
}"
>
<router-outlet #outlet="outlet"></router-outlet>
</abp-auth-wrapper>
</div>

@ -1,14 +1,22 @@
import { Component } from '@angular/core'; import { AfterViewInit, Component } from '@angular/core';
import { eLayoutType } from '@abp/ng.core'; import { eLayoutType, SubscriptionService } from '@abp/ng.core';
import { LayoutService } from '../../services/layout.service';
@Component({ @Component({
selector: 'abp-layout-account', selector: 'abp-layout-account',
template: ` templateUrl: './account-layout.component.html',
<router-outlet></router-outlet> providers: [LayoutService, SubscriptionService],
<abp-confirmation></abp-confirmation>
`,
}) })
export class AccountLayoutComponent { export class AccountLayoutComponent implements AfterViewInit {
// required for dynamic component // required for dynamic component
static type = eLayoutType.account; static type = eLayoutType.account;
authWrapperKey = 'Account.AuthWrapperComponent';
constructor(public service: LayoutService) {}
ngAfterViewInit() {
this.service.subscribeWindowSize();
}
} }

@ -1,16 +1,18 @@
<div class="row"> <div class="row">
<div class="mx-auto col col-md-5"> <div class="mx-auto col col-md-5">
<ng-container *ngIf="(isMultiTenancyEnabled$ | async) && isTenantBoxVisible"> <ng-container *ngIf="(service.isMultiTenancyEnabled$ | async) && service.isTenantBoxVisible">
<abp-tenant-box *abpReplaceableTemplate="{ componentKey: tenantBoxKey }"></abp-tenant-box> <abp-tenant-box
*abpReplaceableTemplate="{ componentKey: service.tenantBoxKey }"
></abp-tenant-box>
</ng-container> </ng-container>
<div class="abp-account-container"> <div class="abp-account-container">
<div <div
*ngIf="enableLocalLogin$ | async; else disableLocalLoginTemplate" *ngIf="service.enableLocalLogin$ | async; else disableLocalLoginTemplate"
class="card mt-3 shadow-sm rounded" class="card mt-3 shadow-sm rounded"
> >
<div class="card-body p-5"> <div class="card-body p-5">
<router-outlet></router-outlet> <ng-content></ng-content>
</div> </div>
</div> </div>
</div> </div>

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AuthWrapperComponent } from './auth-wrapper.component';
describe('AuthWrapperComponent', () => {
let component: AuthWrapperComponent;
let fixture: ComponentFixture<AuthWrapperComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AuthWrapperComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AuthWrapperComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,13 @@
import { Component, OnInit } from '@angular/core';
import { AuthWrapperService } from '@abp/ng.account-core';
@Component({
selector: 'abp-auth-wrapper',
templateUrl: './auth-wrapper.component.html',
providers: [AuthWrapperService],
})
export class AuthWrapperComponent implements OnInit {
constructor(public service: AuthWrapperService) {}
ngOnInit(): void {}
}

@ -1,4 +1,4 @@
<ng-container *ngIf="(currentTenant$ | async) || {} as currentTenant"> <ng-container *ngIf="(service.currentTenant$ | async) || {} as currentTenant">
<div class="card shadow-sm rounded mb-3"> <div class="card shadow-sm rounded mb-3">
<div class="card-body px-5"> <div class="card-body px-5">
<div class="row"> <div class="row">
@ -16,7 +16,7 @@
id="AbpTenantSwitchLink" id="AbpTenantSwitchLink"
href="javascript:void(0);" href="javascript:void(0);"
class="btn btn-sm mt-3 btn-outline-primary" class="btn btn-sm mt-3 btn-outline-primary"
(click)="onSwitch()" (click)="service.onSwitch()"
>{{ 'AbpUiMultiTenancy::Switch' | abpLocalization }}</a >{{ 'AbpUiMultiTenancy::Switch' | abpLocalization }}</a
> >
</div> </div>
@ -24,17 +24,17 @@
</div> </div>
</div> </div>
<abp-modal size="md" [(visible)]="isModalVisible" [busy]="modalBusy"> <abp-modal size="md" [(visible)]="service.isModalVisible" [busy]="service.modalBusy">
<ng-template #abpHeader> <ng-template #abpHeader>
<h5>Switch Tenant</h5> <h5>Switch Tenant</h5>
</ng-template> </ng-template>
<ng-template #abpBody> <ng-template #abpBody>
<form (ngSubmit)="save()"> <form (ngSubmit)="service.save()">
<div class="mt-2"> <div class="mt-2">
<div class="form-group"> <div class="form-group">
<label for="name">{{ 'AbpUiMultiTenancy::Name' | abpLocalization }}</label> <label for="name">{{ 'AbpUiMultiTenancy::Name' | abpLocalization }}</label>
<input <input
[(ngModel)]="name" [(ngModel)]="service.name"
type="text" type="text"
id="name" id="name"
name="tenant" name="tenant"
@ -53,8 +53,8 @@
<abp-button <abp-button
type="abp-button" type="abp-button"
iconClass="fa fa-check" iconClass="fa fa-check"
(click)="save()" (click)="service.save()"
[disabled]="currentTenant?.name === name" [disabled]="currentTenant?.name === service.name"
> >
<span>{{ 'AbpTenantManagement::Save' | abpLocalization }}</span> <span>{{ 'AbpTenantManagement::Save' | abpLocalization }}</span>
</abp-button> </abp-button>

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TenantBoxComponent } from './tenant-box.component';
describe('TenantBoxComponent', () => {
let component: TenantBoxComponent;
let fixture: ComponentFixture<TenantBoxComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ TenantBoxComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(TenantBoxComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,13 @@
import { Component, OnInit } from '@angular/core';
import { TenantBoxService } from '@abp/ng.account-core';
@Component({
selector: 'abp-tenant-box',
templateUrl: './tenant-box.component.html',
providers: [TenantBoxService],
})
export class TenantBoxComponent implements OnInit {
constructor(public service: TenantBoxService) {}
ngOnInit(): void {}
}

@ -4,37 +4,37 @@
style="min-height: 4rem" style="min-height: 4rem"
> >
<div class="container"> <div class="container">
<abp-logo *abpReplaceableTemplate="{ componentKey: logoComponentKey }"></abp-logo> <abp-logo *abpReplaceableTemplate="{ componentKey: service.logoComponentKey }"></abp-logo>
<button <button
class="navbar-toggler" class="navbar-toggler"
type="button" type="button"
[attr.aria-expanded]="!isCollapsed" [attr.aria-expanded]="!service.isCollapsed"
(click)="isCollapsed = !isCollapsed" (click)="service.isCollapsed = !service.isCollapsed"
> >
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="navbar-collapse" [class.overflow-hidden]="smallScreen" id="main-navbar-collapse"> <div class="navbar-collapse" [class.overflow-hidden]="service.smallScreen" id="main-navbar-collapse">
<ng-container *ngTemplateOutlet="!smallScreen ? navigations : null"></ng-container> <ng-container *ngTemplateOutlet="!service.smallScreen ? navigations : null"></ng-container>
<div *ngIf="smallScreen" [@collapseWithMargin]="isCollapsed ? 'collapsed' : 'expanded'"> <div *ngIf="service.smallScreen" [@collapseWithMargin]="service.isCollapsed ? 'collapsed' : 'expanded'">
<ng-container *ngTemplateOutlet="navigations"></ng-container> <ng-container *ngTemplateOutlet="navigations"></ng-container>
</div> </div>
<ng-template #navigations> <ng-template #navigations>
<abp-routes <abp-routes
*abpReplaceableTemplate="{ *abpReplaceableTemplate="{
componentKey: routesComponentKey, componentKey: service.routesComponentKey,
inputs: { inputs: {
smallScreen: { value: smallScreen } smallScreen: { value: service.smallScreen }
} }
}" }"
class="mx-auto" class="mx-auto"
[smallScreen]="smallScreen" [smallScreen]="service.smallScreen"
></abp-routes> ></abp-routes>
<abp-nav-items <abp-nav-items
*abpReplaceableTemplate="{ *abpReplaceableTemplate="{
componentKey: navItemsComponentKey componentKey: service.navItemsComponentKey
}" }"
></abp-nav-items> ></abp-nav-items>
</ng-template> </ng-template>

@ -1,54 +1,21 @@
import { eLayoutType, SubscriptionService } from '@abp/ng.core'; import { eLayoutType, SubscriptionService } from '@abp/ng.core';
import { collapseWithMargin, slideFromBottom } from '@abp/ng.theme.shared'; import { collapseWithMargin, slideFromBottom } from '@abp/ng.theme.shared';
import { AfterViewInit, Component, OnDestroy } from '@angular/core'; import { AfterViewInit, Component } from '@angular/core';
import { fromEvent } from 'rxjs'; import { LayoutService } from '../../services/layout.service';
import { debounceTime } from 'rxjs/operators';
import { eThemeBasicComponents } from '../../enums/components';
@Component({ @Component({
selector: 'abp-layout-application', selector: 'abp-layout-application',
templateUrl: './application-layout.component.html', templateUrl: './application-layout.component.html',
animations: [slideFromBottom, collapseWithMargin], animations: [slideFromBottom, collapseWithMargin],
providers: [SubscriptionService], providers: [LayoutService, SubscriptionService],
}) })
export class ApplicationLayoutComponent implements AfterViewInit, OnDestroy { export class ApplicationLayoutComponent implements AfterViewInit {
// required for dynamic component // required for dynamic component
static type = eLayoutType.application; static type = eLayoutType.application;
isCollapsed = true; constructor(public service: LayoutService) {}
smallScreen: boolean; // do not set true or false
logoComponentKey = eThemeBasicComponents.Logo;
routesComponentKey = eThemeBasicComponents.Routes;
navItemsComponentKey = eThemeBasicComponents.NavItems;
constructor(private subscription: SubscriptionService) {}
private checkWindowWidth() {
setTimeout(() => {
if (window.innerWidth < 992) {
if (this.smallScreen === false) {
this.isCollapsed = false;
setTimeout(() => {
this.isCollapsed = true;
}, 100);
}
this.smallScreen = true;
} else {
this.smallScreen = false;
}
}, 0);
}
ngAfterViewInit() { ngAfterViewInit() {
this.checkWindowWidth(); this.service.subscribeWindowSize();
const resize$ = fromEvent(window, 'resize').pipe(debounceTime(150));
this.subscription.addOne(resize$, () => this.checkWindowWidth());
} }
ngOnDestroy() {}
} }

@ -1,4 +1,6 @@
export * from './account-layout/account-layout.component'; export * from './account-layout/account-layout.component';
export * from './account-layout/auth-wrapper/auth-wrapper.component';
export * from './account-layout/tenant-box/tenant-box.component';
export * from './application-layout/application-layout.component'; export * from './application-layout/application-layout.component';
export * from './empty-layout/empty-layout.component'; export * from './empty-layout/empty-layout.component';
export * from './logo/logo.component'; export * from './logo/logo.component';

@ -0,0 +1,43 @@
import { Injectable } from '@angular/core';
import { eThemeBasicComponents } from '../enums';
import { SubscriptionService } from '@abp/ng.core';
import { fromEvent } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
@Injectable()
export class LayoutService {
isCollapsed = true;
smallScreen: boolean; // do not set true or false
logoComponentKey = eThemeBasicComponents.Logo;
routesComponentKey = eThemeBasicComponents.Routes;
navItemsComponentKey = eThemeBasicComponents.NavItems;
constructor(private subscription: SubscriptionService) {}
private checkWindowWidth() {
setTimeout(() => {
if (window.innerWidth < 992) {
if (this.smallScreen === false) {
this.isCollapsed = false;
setTimeout(() => {
this.isCollapsed = true;
}, 100);
}
this.smallScreen = true;
} else {
this.smallScreen = false;
}
}, 0);
}
subscribeWindowSize() {
this.checkWindowWidth();
const resize$ = fromEvent(window, 'resize').pipe(debounceTime(150));
this.subscription.addOne(resize$, () => this.checkWindowWidth());
}
}

@ -20,6 +20,8 @@ import { ValidationErrorComponent } from './components/validation-error/validati
import { BASIC_THEME_NAV_ITEM_PROVIDERS } from './providers/nav-item.provider'; import { BASIC_THEME_NAV_ITEM_PROVIDERS } from './providers/nav-item.provider';
import { BASIC_THEME_STYLES_PROVIDERS } from './providers/styles.provider'; import { BASIC_THEME_STYLES_PROVIDERS } from './providers/styles.provider';
import { PageAlertContainerComponent } from './components/page-alert-container/page-alert-container.component'; import { PageAlertContainerComponent } from './components/page-alert-container/page-alert-container.component';
import { TenantBoxComponent } from './components/account-layout/tenant-box/tenant-box.component';
import { AuthWrapperComponent } from './components/account-layout/auth-wrapper/auth-wrapper.component';
export const LAYOUTS = [ApplicationLayoutComponent, AccountLayoutComponent, EmptyLayoutComponent]; export const LAYOUTS = [ApplicationLayoutComponent, AccountLayoutComponent, EmptyLayoutComponent];
@ -33,6 +35,8 @@ export const LAYOUTS = [ApplicationLayoutComponent, AccountLayoutComponent, Empt
CurrentUserComponent, CurrentUserComponent,
LanguagesComponent, LanguagesComponent,
PageAlertContainerComponent, PageAlertContainerComponent,
TenantBoxComponent,
AuthWrapperComponent,
], ],
exports: [ exports: [
...LAYOUTS, ...LAYOUTS,

Loading…
Cancel
Save