Skip to content

Commit

Permalink
Update page registration
Browse files Browse the repository at this point in the history
  • Loading branch information
javalikescript committed Feb 1, 2025
1 parent 336665e commit 9719559
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 36 deletions.
2 changes: 1 addition & 1 deletion extensions/hue-v2/hue-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ define(['./hue-v2.xml'], function(aPageTemplate) {
}
});

addPageComponent(aVue, true);
addPageComponent(aVue);

});
2 changes: 1 addition & 1 deletion extensions/owm/owm.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ define(['./owm.xml'], function(owmTemplate) {
}
});

addPageComponent(owmVue, 'umbrella');
addPageComponent(owmVue, 'umbrella', true);

});
2 changes: 1 addition & 1 deletion extensions/share/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ define(['./share.xml', 'engine/configuration/extensions/share/'], function(share
}
});

addPageComponent(shareVue, 'share');
addPageComponent(shareVue, 'share', true);

});
11 changes: 8 additions & 3 deletions extensions/web-base/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,19 @@
"title": "URL",
"type": "string"
},
"open": {
"title": "Open in a new tab",
"type": "boolean",
"default": false
},
"icon": {
"title": "Tile icon",
"type": "string",
"enumValues": [
{"const": "fa-link", "title": "Link"},
{"const": "fa-bookmark", "title": "Bookmark"}
{"const": "link", "title": "Link"},
{"const": "bookmark", "title": "Bookmark"}
],
"default": "fa-link"
"default": "link"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/web-base/www/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
<article class="tiles">
<div class="tile" v-for="tile in sortedTiles" v-on:click="onTile(tile)">
<span>{{ tile.name }}</span>
<p class="tile-value" v-if="tile.icon"><i :class="['fas', tile.icon]"></i></p>
<p class="tile-value" v-if="tile.icon"><i :class="['fas', 'fa-' + tile.icon]"></i></p>
</div>
</article>
</app-page>
Expand Down
39 changes: 22 additions & 17 deletions extensions/web-base/www/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,11 @@ var homePage = new Vue({
if (tile.id) {
app.toPage(tile.id);
} else if (tile.url) {
window.open(tile.url, '_blank');
if (tile.open) {
window.open(tile.url);
} else {
window.location.assign(tile.url);
}
}
}
},
Expand All @@ -527,9 +531,6 @@ var homePage = new Vue({
computed: {
sortedTiles: function() {
var tiles = [].concat(this.tiles);
if ((typeof webBaseConfig === 'object') && Array.isArray(webBaseConfig.links)) {
tiles = tiles.concat(webBaseConfig.links);
}
tiles.sort(compareByName);
return tiles;
}
Expand Down Expand Up @@ -652,25 +653,29 @@ new Vue({
el: '#pages'
});

function registerPageVue(vue, icon) {
function registerPageVue(vue, icon, showTile, showMenu) {
var page = getPageFromVue(vue);
if (page) {
menu.pages.push({
id: page.id,
name: page.title
});
homePage.tiles.push({
id: page.id,
name: page.title,
icon: icon
});
if (showTile) {
homePage.tiles.push({
id: page.id,
name: page.title,
icon: icon
});
}
if (showMenu) {
menu.pages.push({
id: page.id,
name: page.title
});
}
}
}

function addPageComponent(vue, menuIcon) {
function addPageComponent(vue, icon, showTile, showMenu) {
var component = vue.$mount();
document.getElementById('pages').appendChild(component.$el);
if (menuIcon) {
registerPageVue(vue, ((typeof menuIcon === 'string') && (menuIcon !== '')) ? 'fa-' + menuIcon : undefined);
if (icon !== undefined) {
registerPageVue(vue, icon, showTile, showMenu);
}
}
3 changes: 3 additions & 0 deletions extensions/web-base/www/app/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ Promise.all([
document.title = webBaseConfig.title;
homePage.title = webBaseConfig.title;
}
if (Array.isArray(webBaseConfig.links)) {
homePage.tiles = homePage.tiles.concat(webBaseConfig.links);
}
app.user = user;
if (Array.isArray(addons)) {
return Promise.all(addons.map(function(addon) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/web-base/www/app/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ registerPageVue(new Vue({
}
}
}
}), 'fa-plus-circle');
}), 'plus-circle', true, true);

function buildExtensionSchema(manifest, enumsById) {
if (manifest && manifest.schema) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/web-base/www/app/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ registerPageVue(new Vue({
}
}
}
}), 'fa-list');
}), 'list', true, true);
2 changes: 1 addition & 1 deletion extensions/web-base/www/app/things.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ registerPageVue(new Vue({
}
}
}
}), 'fa-circle');
}), 'circle', true, true);

new Vue({
el: '#thing',
Expand Down
2 changes: 1 addition & 1 deletion extensions/web-chart/web-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,6 @@ define(['./web-chart.xml'], function(pageXml) {
}
});

addPageComponent(vue, 'chart-line');
addPageComponent(vue, 'chart-line', true);

});
2 changes: 1 addition & 1 deletion extensions/web-dashboard/web-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,6 @@ define(['./web-dashboard.xml'], function(dashboardTemplate) {
}
});

addPageComponent(dashboardVue, 'columns');
addPageComponent(dashboardVue, 'columns', true);

});
2 changes: 1 addition & 1 deletion extensions/web-example/web-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ define(['./web-example.xml'], function(aPageTemplate) {
template: aPageTemplate
});

addPageComponent(aVue, true);
addPageComponent(aVue, 'flask', true);

});
2 changes: 1 addition & 1 deletion extensions/web-notes/web-notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ define(['./web-notes.xml', './web-note.xml', './web-draw.xml'], function(notesTe
}
});

addPageComponent(notesVue, 'sticky-note');
addPageComponent(notesVue, 'sticky-note', true, true);
addPageComponent(noteVue);
addPageComponent(drawVue);

Expand Down
2 changes: 1 addition & 1 deletion extensions/web-scripts/view-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ define(function() {
fn.call(this, options, config);
}
var vue = new Vue(options);
addPageComponent(vue, config.icon);
addPageComponent(vue, config.icon || undefined, config.tile, config.menu);
}

return {
Expand Down
13 changes: 12 additions & 1 deletion extensions/web-scripts/view-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,20 @@
},
"icon": {
"title": "Icon",
"description": "The fontawesome icon to use for the view tile and menu entry, such as 'home'",
"description": "The icon to use for the view tile, such as 'home'",
"default": "flask",
"type": "string"
},
"tile": {
"title": "Show in the tiles",
"type": "boolean",
"default": false
},
"menu": {
"title": "Show in the menu",
"type": "boolean",
"default": false
},
"properties": {
"title": "Properties",
"type": "array",
Expand Down
2 changes: 1 addition & 1 deletion extensions/web-scripts/web-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,6 @@ define(['./scripts.xml', './scripts-add.xml',
addPageComponent(scriptsViewVue);
addPageComponent(scriptsViewConfigVue);
addPageComponent(scriptsEditorVue);
addPageComponent(scriptsVue, 'scroll');
addPageComponent(scriptsVue, 'scroll', true, true);

});
2 changes: 1 addition & 1 deletion extensions/web-time/web-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ define(['./web-time.xml'], function(timeTemplate) {
}
});

addPageComponent(timeVue, 'clock');
addPageComponent(timeVue, 'clock', true);

});
2 changes: 1 addition & 1 deletion extensions/web-tools/web-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ define(['./web-tools.xml'], function(toolsTemplate) {
});

if (app.canAdminister) {
addPageComponent(toolsVue, 'tools');
addPageComponent(toolsVue, 'tools', true);
}

});

0 comments on commit 9719559

Please sign in to comment.