|
|
|
@ -36,12 +36,7 @@ export class AppComponent implements OnInit {
|
|
|
|
|
actionMapping: {
|
|
|
|
|
mouse: {
|
|
|
|
|
dblClick: (tree, node, $event) => {
|
|
|
|
|
const id = node.data.id;
|
|
|
|
|
const nodeId = node.data.node_id;
|
|
|
|
|
if ( !node.data.virtual ) {
|
|
|
|
|
this.currentPageId = id;
|
|
|
|
|
this.router.navigate(['/editor', { id, ...(nodeId ? { node_id: nodeId } : {}) }]);
|
|
|
|
|
}
|
|
|
|
|
this.navigateEditorToNode(node);
|
|
|
|
|
},
|
|
|
|
|
click: (tree, node, $event) => {
|
|
|
|
|
TREE_ACTIONS.FOCUS(tree, node, $event);
|
|
|
|
@ -165,6 +160,19 @@ export class AppComponent implements OnInit {
|
|
|
|
|
this.hasSearchOpen = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public navigateEditorToNode(node: any) {
|
|
|
|
|
if ( !node.data ) {
|
|
|
|
|
node = { data: node };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const id = node.data.id;
|
|
|
|
|
const nodeId = node.data.node_id;
|
|
|
|
|
if ( !node.data.virtual ) {
|
|
|
|
|
this.currentPageId = id;
|
|
|
|
|
this.router.navigate(['/editor', { id, ...(nodeId ? { node_id: nodeId } : {}) }]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async onNodeMenuClick($event) {
|
|
|
|
|
let canManage = this.menuTarget.data.level === 'manage';
|
|
|
|
|
if ( !canManage ) {
|
|
|
|
@ -368,6 +376,7 @@ export class AppComponent implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async initializeApp() {
|
|
|
|
|
console.log('session', this);
|
|
|
|
|
this.loader = await this.loading.create({
|
|
|
|
|
message: 'Starting up...',
|
|
|
|
|
cssClass: 'noded-loading-mask',
|
|
|
|
@ -388,17 +397,46 @@ export class AppComponent implements OnInit {
|
|
|
|
|
this.session.systemBase = stat.system_base;
|
|
|
|
|
|
|
|
|
|
await this.session.initialize();
|
|
|
|
|
|
|
|
|
|
if ( this.session.get('user.preferences.dark_mode') ) {
|
|
|
|
|
this.toggleDark();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await this.statusBar.styleDefault();
|
|
|
|
|
await this.splashScreen.hide();
|
|
|
|
|
this.initialized$.next(true);
|
|
|
|
|
|
|
|
|
|
if ( this.session.get('user.preferences.default_page') ) {
|
|
|
|
|
const id = this.session.get('user.preferences.default_page');
|
|
|
|
|
const node = this.findNode(id);
|
|
|
|
|
if ( node ) {
|
|
|
|
|
this.navigateEditorToNode(node);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toggleDark() {
|
|
|
|
|
// const prefersDark = window.matchMedia('(prefers-color-scheme: dark)');
|
|
|
|
|
this.darkMode = !this.darkMode;
|
|
|
|
|
this.session.set('user.preferences.dark_mode', this.darkMode);
|
|
|
|
|
document.body.classList.toggle('dark', this.darkMode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
findNode(id: string, nodes = this.nodes) {
|
|
|
|
|
for ( const node of nodes ) {
|
|
|
|
|
if ( node.id === id ) {
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( node.children ) {
|
|
|
|
|
const foundNode = this.findNode(id, node.children);
|
|
|
|
|
if ( foundNode ) {
|
|
|
|
|
return foundNode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isDark() {
|
|
|
|
|
return !!this.darkMode;
|
|
|
|
|
}
|
|
|
|
|