Skip to content

Commit c2f0565

Browse files
author
ticaki
committed
fix trigger fix navigation
1 parent 9cdc9b4 commit c2f0565

15 files changed

+227
-51
lines changed

build/lib/classes/navigation.js

+17-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/classes/navigation.js.map

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/controller/config-manager.js

+67-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/controller/config-manager.js.map

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/controller/states-controller.js

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/controller/states-controller.js.map

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/pages/pageItem.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/pages/pageItem.js.map

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

json/jsonTrash.json

Whitespace-only changes.

script/example_sendTo_script_iobroker

+15
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,20 @@ declare namespace ScriptConfig {
386386
method: EventMethod;
387387
};
388388

389+
export type NavigationItemConfig = {
390+
name: string;
391+
left?: {
392+
single?: string;
393+
double?: string;
394+
};
395+
right?: {
396+
single?: string;
397+
double?: string;
398+
};
399+
page: string;
400+
optional?: never;
401+
} | null;
402+
389403
export type SerialType = 'button' | 'light' | 'shutter' | 'text' | 'input_sel' | 'timer' | 'number' | 'fan';
390404

391405
/**
@@ -756,6 +770,7 @@ declare namespace ScriptConfig {
756770
* Native page items for the panel
757771
*/
758772
nativePageItems?: any;
773+
navigation?: NavigationItemConfig[];
759774
};
760775
export type leftScreensaverEntityType =
761776
| [ScreenSaverElementWithUndefined?, ScreenSaverElementWithUndefined?, ScreenSaverElementWithUndefined?]

src/lib/classes/navigation.ts

+20-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type NavigationItemConfig = {
1919
page: string;
2020
optional?: optionalActionsType;
2121
} | null;
22-
22+
export type NavigationItemConfigNonNull = NonNullable<NavigationItemConfig>;
2323
type NavigationItem = {
2424
left: {
2525
single?: number;
@@ -42,7 +42,7 @@ export interface NavigationConfig {
4242
export class Navigation extends BaseClass {
4343
panel: Panel;
4444
private database: NavigationItem[] = [];
45-
private navigationConfig: NavigationItemConfig[];
45+
private navigationConfig: NavigationItemConfigNonNull[];
4646
private mainPage = 'main';
4747
private doubleClickTimeout: ioBroker.Timeout | undefined;
4848
private _currentItem: number = 0;
@@ -67,20 +67,31 @@ export class Navigation extends BaseClass {
6767
constructor(config: NavigationConfig) {
6868
super(config.adapter, `${config.panel.name}-navigation`);
6969
this.panel = config.panel;
70-
this.navigationConfig = config.navigationConfig;
70+
this.navigationConfig = config.navigationConfig.filter(a => a !== null && a != null);
7171
}
7272

7373
init(): void {
7474
this.database = [];
75-
let b = 1;
7675
let serviceLeft = '';
7776
let serviceRight = '';
7877
let serviceID = -1;
78+
this.navigationConfig.sort((a, b) => {
79+
if (a.name === 'main') {
80+
return -1;
81+
}
82+
if (b.name === 'main') {
83+
return 1;
84+
}
85+
if (a.name > b.name) {
86+
return 1;
87+
}
88+
if (a.name < b.name) {
89+
return -1;
90+
}
91+
return 0;
92+
});
7993
for (let a = 0; a < this.navigationConfig.length; a++) {
8094
const c = this.navigationConfig[a];
81-
if (!c) {
82-
continue;
83-
}
8495
if (c.left && c.left.single === '///service') {
8596
serviceRight = c.name;
8697
}
@@ -91,8 +102,7 @@ export class Navigation extends BaseClass {
91102
serviceID = a;
92103
}
93104
const pageID = this.panel.getPagebyUniqueID(c.page);
94-
this.database[c.name === 'main' ? 0 : b++] =
95-
pageID !== null ? { page: pageID, left: {}, right: {}, index: a } : null;
105+
this.database[a] = pageID !== null ? { page: pageID, left: {}, right: {}, index: a } : null;
96106
}
97107
if (serviceID !== -1) {
98108
const c = this.navigationConfig[serviceID];
@@ -155,7 +165,7 @@ export class Navigation extends BaseClass {
155165
setMainPageByName(n: string): void {
156166
const index = this.navigationConfig.findIndex(a => a && a.name === n);
157167
if (index !== -1 && this.database[index]) {
158-
this.mainPage = this.navigationConfig[index]!.name;
168+
this.mainPage = this.navigationConfig[index].name;
159169
} else {
160170
this.log.warn(`Dont find navigation main page for ${n}`);
161171
}

0 commit comments

Comments
 (0)