You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
frontend/src/app/service/navigation.service.ts

51 lines
1.8 KiB

import { Injectable } from '@angular/core';
import {BehaviorSubject} from 'rxjs';
import {debug} from '../utility';
import {DatabasePageComponent} from '../components/editor/database/database-page.component';
import {FileBoxPageComponent} from '../components/nodes/file-box/file-box-page.component';
import {ModalController} from '@ionic/angular';
import {ApiService} from './api.service';
export interface NavigationRequest {
pageId: string;
nodeId?: string;
}
@Injectable({
providedIn: 'root'
})
export class NavigationService {
protected refreshCount = 0;
public readonly sidebarRefresh$: BehaviorSubject<[number, boolean]> = new BehaviorSubject<[number, boolean]>([this.refreshCount, true]);
public readonly navigationRequest$: BehaviorSubject<NavigationRequest> = new BehaviorSubject<NavigationRequest>({
pageId: '',
});
public readonly initializationRequest$: BehaviorSubject<number> = new BehaviorSubject<number>(0);
public readonly initialized$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
constructor(
protected readonly ionModalController: ModalController,
protected readonly api: ApiService,
) { }
requestSidebarRefresh({ quiet = false }) {
this.refreshCount += 1;
this.sidebarRefresh$.next([this.refreshCount, quiet]);
}
requestNavigation(pageId: string, nodeId?: string) {
debug('Requesting page navigation:', pageId, nodeId);
debug('Page navigation trace', new Error());
this.navigationRequest$.next({
pageId,
nodeId
});
}
requestInitialization() {
debug('Requesting application initialization');
this.initializationRequest$.next(this.initializationRequest$.getValue() + 1);
}
}