Commit b620de07 authored by Tifenn Guillas's avatar Tifenn Guillas

Add comments for core module => DONE

parent 11c7843c
......@@ -19,6 +19,10 @@ import { environment } from '../../../environments/environment'
styleUrls: [ 'nav.component.css' ],
changeDetection: ChangeDetectionStrategy.OnPush
})
/**
* @class
* @classdesc Core nav component.
*/
export class NavComponent {
@Input() isAuthenticated: boolean;
@Input() userProfile: UserProfile;
......@@ -26,8 +30,14 @@ export class NavComponent {
@Output() login: EventEmitter<any> = new EventEmitter();
@Output() logout: EventEmitter<any> = new EventEmitter();
@Output() openEditProfile: EventEmitter<any> = new EventEmitter();
baseHref: string = environment.baseHref;
/**
* Checks if search link is allowed.
*
* @return boolean
*/
isSearchAllowed(): boolean {
if (this.instance && this.instance.config.search) {
return this.instance.config.search;
......@@ -35,6 +45,11 @@ export class NavComponent {
return false;
}
/**
* Checks if search multiple link is allowed.
*
* @return boolean
*/
isSearchMultipleAllowed(): boolean {
if (this.instance && this.instance.config.search_multiple) {
return this.instance.config.search_multiple.allowed;
......@@ -42,6 +57,11 @@ export class NavComponent {
return false;
}
/**
* Checks if documentation link is allowed.
*
* @return boolean
*/
isDocumentationAllowed(): boolean {
if (this.instance && this.instance.config.documentation) {
return this.instance.config.documentation;
......@@ -49,15 +69,30 @@ export class NavComponent {
return false;
}
emitLogin() {
/**
* Emits event to log in.
*
* @fires EventEmitter<any>
*/
emitLogin(): void {
this.login.emit();
}
emitLogout() {
/**
* Emits event to log out.
*
* @return EventEmitter<any>
*/
emitLogout(): void {
this.logout.emit();
}
emitOpenEditProfile() {
/**
* Emits event to go to edit profile page.
*
* @return EventEmitter<any>
*/
emitOpenEditProfile(): void {
this.openEditProfile.emit();
}
}
......@@ -22,6 +22,11 @@ import { UserProfile } from '../../auth/store/user-profile.model';
import { Instance } from '../../metamodel/model';
import { VERSIONS } from '../../../settings/settings';
/**
* Interface for store state.
*
* @interface StoreState
*/
interface StoreState {
auth: fromAuth.State;
metamodel: fromMetamodel.State;
......@@ -33,6 +38,12 @@ interface StoreState {
styleUrls: [ './app.component.css' ],
encapsulation: ViewEncapsulation.None
})
/**
* @class
* @classdesc App container.
*
* @implements OnInit
*/
export class AppComponent implements OnInit {
public anisClientVersion: string = VERSIONS.anisClient;
public year = (new Date()).getFullYear();
......@@ -50,14 +61,23 @@ export class AppComponent implements OnInit {
this.store.dispatch(new instanceActions.LoadInstanceMetaAction());
}
/**
* Dispatches action to log in.
*/
login(): void {
this.store.dispatch(new authActions.LoginAction());
}
/**
* Dispatches action to log out.
*/
logout(): void {
this.store.dispatch(new authActions.LogoutAction());
}
/**
* Dispatches action to open edit profile page.
*/
openEditProfile(): void {
this.store.dispatch(new authActions.OpenEditProfileAction());
}
......
......@@ -13,4 +13,8 @@ import { Component } from '@angular/core';
selector: 'app-not-found-page',
templateUrl: 'not-found-page.component.html'
})
/**
* @class
* @classdesc Not found page container.
*/
export class NotFoundPageComponent { }
......@@ -19,6 +19,12 @@ import * as fromMetamodel from '../metamodel/reducers';
@Injectable({
providedIn: 'root'
})
/**
* @class
* @classdesc Navigation guard.
*
* @implements CanActivate
*/
export class NavigationGuard implements CanActivate {
constructor(private store$: Store<{ metamodel: fromMetamodel.State }>) { }
......@@ -36,6 +42,13 @@ export class NavigationGuard implements CanActivate {
return this.isModuleAllowed(module);
}
/**
* Checks if the given module is allowed.
*
* @param {string} module - The module.
*
* @return Observable<boolean>
*/
isModuleAllowed(module: string): Observable<boolean> {
return this.store$.select(state => state.metamodel.instance.instance)
.pipe(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment