Skip to content
Snippets Groups Projects
Commit b620de07 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Add comments for core module => DONE

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