-
François Agneray authoredFrançois Agneray authored
admin.component.ts 2.70 KiB
/**
* This file is part of Anis Client.
*
* @copyright Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
import { UserProfile } from 'src/app/auth/user-profile.model';
import * as authActions from 'src/app/auth/auth.actions';
import * as authSelector from 'src/app/auth/auth.selector';
import * as surveyActions from 'src/app/metamodel/actions/survey.actions';
import * as databaseActions from 'src/app/metamodel/actions/database.actions';
import * as selectActions from 'src/app/metamodel/actions/select.actions';
import * as optionActions from 'src/app/metamodel/actions/select-option.actions';
import { AppConfigService } from 'src/app/app-config.service';
@Component({
selector: 'app-admin',
templateUrl: 'admin.component.html'
})
/**
* @class
* @classdesc Portal home container.
*
* @implements OnInit
*/
export class AdminComponent implements OnInit {
public links = [
{ label: 'Instances', icon: 'fas fa-object-group', routerLink: 'instance-list' },
{ label: 'Surveys', icon: 'fas fa-table', routerLink: 'survey-list'},
{ label: 'Databases', icon: 'fas fa-database', routerLink: 'database-list'},
{ label: 'Settings', icon: 'fas fa-wrench', routerLink: 'settings'}
];
public isAuthenticated: Observable<boolean>;
public userProfile: Observable<UserProfile>;
public userRoles: Observable<string[]>;
constructor(private store: Store<{ }>, private config: AppConfigService) {
this.isAuthenticated = store.select(authSelector.selectIsAuthenticated);
this.userProfile = store.select(authSelector.selectUserProfile);
this.userRoles = store.select(authSelector.selectUserRoles);
}
ngOnInit() {
Promise.resolve(null).then(() => this.store.dispatch(surveyActions.loadSurveyList()));
Promise.resolve(null).then(() => this.store.dispatch(databaseActions.loadDatabaseList()));
Promise.resolve(null).then(() => this.store.dispatch(selectActions.loadSelectList()));
Promise.resolve(null).then(() => this.store.dispatch(optionActions.loadSelectOptionList()));
}
getBaseHref() {
return this.config.baseHref;
}
getAuthenticationEnabled() {
return this.config.authenticationEnabled;
}
login(): void {
this.store.dispatch(authActions.login());
}
logout(): void {
this.store.dispatch(authActions.logout());
}
openEditProfile(): void {
this.store.dispatch(authActions.openEditProfile());
}
}