mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-03-12 01:32:12 +00:00
refactor(menu): refactor main manu
This commit is contained in:
@@ -13,6 +13,17 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component} from '@angular/core';
|
||||
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
||||
import {
|
||||
SCAppConfigurationMenuCategory,
|
||||
SCThing,
|
||||
SCThingTranslator,
|
||||
SCTranslations,
|
||||
} from '@openstapps/core';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {ConfigProvider} from '../../config/config.provider';
|
||||
|
||||
const logger = new Logger();
|
||||
|
||||
/**
|
||||
* Generated class for the MenuPage page.
|
||||
@@ -20,22 +31,28 @@ import {Component} from '@angular/core';
|
||||
* See https://ionicframework.com/docs/components/#navigation for more info on
|
||||
* Ionic pages and navigation.
|
||||
*/
|
||||
|
||||
@Component({
|
||||
selector: 'stapps-navigation',
|
||||
styleUrls: ['navigation.scss'],
|
||||
templateUrl: 'navigation.html',
|
||||
})
|
||||
export class NavigationComponent {
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
public pages = [
|
||||
{title: 'Search', url: '/search', icon: 'search'},
|
||||
{title: 'Settings', url: '/settings', icon: 'settings'},
|
||||
];
|
||||
language: keyof SCTranslations<SCThing> = 'en';
|
||||
menu: SCAppConfigurationMenuCategory[];
|
||||
translator: SCThingTranslator;
|
||||
|
||||
constructor() {
|
||||
// Nothing yet.
|
||||
constructor(private configProvider: ConfigProvider,
|
||||
public translateService: TranslateService) {
|
||||
this.loadMenuEntries().then(() =>
|
||||
logger.log('menuEntries loaded from config: ' + JSON.stringify(this.menu))).catch((error) => {
|
||||
logger.error(error);
|
||||
|
||||
});
|
||||
translateService.onLangChange.subscribe((event: LangChangeEvent) => {
|
||||
this.language = event.lang as keyof SCTranslations<any>;
|
||||
this.translator = new SCThingTranslator(this.language, 'en');
|
||||
});
|
||||
this.translator = new SCThingTranslator('en', 'en');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,6 +63,10 @@ export class NavigationComponent {
|
||||
// console.log('ionViewDidLoad MenuPage');
|
||||
}
|
||||
|
||||
async loadMenuEntries() {
|
||||
this.menu = await this.configProvider.getValue('menus') as SCAppConfigurationMenuCategory[];
|
||||
}
|
||||
|
||||
// openPage(page) {
|
||||
// this.nav.setRoot(page.component);
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user