diff --git a/src/app/core/components/nav.component.ts b/src/app/core/components/nav.component.ts index 37578341c2fd5262500d6986d4da7e3e3f97eb3b..0436c798a4b5b8b9d8a47a68d7982daf2f9bdc7c 100644 --- a/src/app/core/components/nav.component.ts +++ b/src/app/core/components/nav.component.ts @@ -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(); } } diff --git a/src/app/core/containers/app.component.ts b/src/app/core/containers/app.component.ts index c21f14ddf352c9c2714fa7e9a883f7d924d6392a..f70a37797db21a8eb5ebc1fea6305f579a8c1e9a 100644 --- a/src/app/core/containers/app.component.ts +++ b/src/app/core/containers/app.component.ts @@ -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()); } diff --git a/src/app/core/containers/not-found-page.component.ts b/src/app/core/containers/not-found-page.component.ts index a26a74ca0a98f6223597ef3b4a91e4c114e083c6..ffddb6ac578034e457491a59f3553741ca12cfd2 100644 --- a/src/app/core/containers/not-found-page.component.ts +++ b/src/app/core/containers/not-found-page.component.ts @@ -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 { } diff --git a/src/app/core/navigation.guard.ts b/src/app/core/navigation.guard.ts index 1072ebfc753d985a16224793ce7d3d229a2f8bd1..ef00ac1eb32c187cd9175ab0ffe4a3071b75172d 100644 --- a/src/app/core/navigation.guard.ts +++ b/src/app/core/navigation.guard.ts @@ -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(