feat: add auth support (default and paia)

This commit is contained in:
Michel Jonathan Schmitz
2022-01-24 18:43:00 +00:00
committed by Jovan Krunić
parent 046a95ba1d
commit b5f239ea4e
85 changed files with 3626 additions and 119 deletions

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Component} from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
import {
SCAppConfigurationMenuCategory,
@@ -20,8 +20,7 @@ import {
SCThingTranslator,
SCTranslations,
} from '@openstapps/core';
import {NGXLogger} from 'ngx-logger';
import {ConfigProvider} from '../../config/config.provider';
import {NavigationService} from './navigation.service';
/**
* Generated class for the MenuPage page.
@@ -34,7 +33,7 @@ import {ConfigProvider} from '../../config/config.provider';
styleUrls: ['navigation.scss'],
templateUrl: 'navigation.html',
})
export class NavigationComponent {
export class NavigationComponent implements OnInit {
/**
* Possible languages to be used for translation
*/
@@ -60,11 +59,9 @@ export class NavigationComponent {
translator: SCThingTranslator;
constructor(
private readonly configProvider: ConfigProvider,
public translateService: TranslateService,
private readonly logger: NGXLogger,
private navigationService: NavigationService,
) {
void this.loadMenuEntries();
translateService.onLangChange.subscribe((event: LangChangeEvent) => {
this.language = event.lang as keyof SCTranslations<SCLanguage>;
this.translator = new SCThingTranslator(this.language);
@@ -72,20 +69,7 @@ export class NavigationComponent {
this.translator = new SCThingTranslator('en');
}
/**
* Loads menu entries from configProvider
*/
async loadMenuEntries() {
try {
this.menu = (await this.configProvider.getValue(
'menus',
)) as SCAppConfigurationMenuCategory[];
} catch (error) {
this.logger.error(`error from loading menu entries: ${error}`);
}
async ngOnInit() {
this.menu = await this.navigationService.getMenu();
}
// openPage(page) {
// this.nav.setRoot(page.component);
// }
}

View File

@@ -0,0 +1,40 @@
import {Injectable} from '@angular/core';
import {SCAppConfigurationMenuCategory} from '@openstapps/core';
import {ConfigProvider} from '../../config/config.provider';
import {NGXLogger} from 'ngx-logger';
@Injectable({
providedIn: 'root',
})
export class NavigationService {
constructor(
private configProvider: ConfigProvider,
private logger: NGXLogger,
) {}
async getMenu() {
let menu: SCAppConfigurationMenuCategory[] = [];
try {
menu = (await this.configProvider.getValue(
'menus',
)) as SCAppConfigurationMenuCategory[];
} catch (error) {
this.logger.error(`error from loading menu entries: ${error}`);
}
// TODO: Load if from the backend (config)
menu[1].items.unshift({
icon: 'person',
route: '/profile',
title: 'profile',
translations: {
de: {
title: 'Profil',
},
en: {
title: 'profile',
},
},
});
return menu;
}
}