Login form with Tenant dropdown menu
This commit is contained in:
@@ -21,6 +21,7 @@ import { NotificationsTrayComponent } from './notifications-tray/notifications-t
|
||||
import { SearchToolComponent } from './search-tool/search-tool.component';
|
||||
import { KeyboardShortcutsDialogComponent } from './keyboard-shortcuts-dialog/keyboard-shortcuts-dialog.component';
|
||||
import { ServerSelectorComponent } from './server-selector/server-selector.component';
|
||||
import { TenantSelectorComponent } from './tenant-selector/tenant-selector.component';
|
||||
|
||||
/** Custom Modules */
|
||||
import { IconsModule } from './icons.module';
|
||||
@@ -57,7 +58,8 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
ErrorDialogComponent,
|
||||
NotificationsTrayComponent,
|
||||
SearchToolComponent,
|
||||
ServerSelectorComponent
|
||||
ServerSelectorComponent,
|
||||
TenantSelectorComponent
|
||||
],
|
||||
exports: [
|
||||
FileUploadComponent,
|
||||
@@ -73,7 +75,8 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
MaterialModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
TranslateModule
|
||||
TranslateModule,
|
||||
TenantSelectorComponent
|
||||
]
|
||||
})
|
||||
export class SharedModule { }
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<mat-form-field fxFlexAlign="center" id="tenant-selector">
|
||||
<span matPrefix class="m-r-10">
|
||||
<fa-icon icon="building" size="lg"></fa-icon>
|
||||
</span>
|
||||
<mat-label>{{ 'labels.inputs.Tenant' | translate }}</mat-label>
|
||||
<mat-select [disabled]="!allowSelection()" [formControl]="tenantSelector" (selectionChange)="setTenantIdentifier()" class="tenantselector">
|
||||
<mat-option *ngFor="let tenant of tenants" [value]="tenant">
|
||||
{{ tenant }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
@@ -0,0 +1,5 @@
|
||||
#tenant-selector,
|
||||
.tenantselector {
|
||||
width: 14rem;
|
||||
margin-bottom: 0.6rem;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TenantSelectorComponent } from './tenant-selector.component';
|
||||
|
||||
describe('TenantSelectorComponent', () => {
|
||||
let component: TenantSelectorComponent;
|
||||
let fixture: ComponentFixture<TenantSelectorComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ TenantSelectorComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TenantSelectorComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-tenant-selector',
|
||||
templateUrl: './tenant-selector.component.html',
|
||||
styleUrls: ['./tenant-selector.component.scss']
|
||||
})
|
||||
export class TenantSelectorComponent implements OnInit {
|
||||
|
||||
/** Tenant selector form control. */
|
||||
tenantSelector = new FormControl();
|
||||
|
||||
/**
|
||||
* Sets the Tenant Identifier of the application in the selector on initial setup.
|
||||
* @param {SettingsService} settingsService Settings Service.
|
||||
*/
|
||||
constructor(private settingsService: SettingsService) {
|
||||
this.tenantSelector.setValue(this.settingsService.tenantIdentifier);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the languages supported by the application.
|
||||
* @return {string[]} Supported languages.
|
||||
*/
|
||||
get tenants(): string[] {
|
||||
return this.settingsService.tenantIdentifiers || [];
|
||||
}
|
||||
|
||||
setTenantIdentifier(): void {
|
||||
this.settingsService.setTenantIdentifier(this.tenantSelector.value);
|
||||
}
|
||||
|
||||
allowSelection(): boolean {
|
||||
return (this.tenants.length > 1);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user