-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5390cdc
commit 01fac85
Showing
8 changed files
with
199 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<app-page id="scriptsViewConfig" title="View Configuration" transition-class="hideTop"> | ||
<template slot="bar-right"> | ||
<button v-on:click="app.back()" title="Close"><i class="fa fa-window-close"></i></button> | ||
</template> | ||
<page-article> | ||
<json :name="'Configuration'" :obj="config" :schema="schema"></json> | ||
<button v-on:click="onSave()"><i class="far fa-save"></i> Save</button> | ||
</page-article> | ||
</app-page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
define(['./config.json', './view.xml'], function(config, viewXml) { | ||
|
||
var viewTemplate = [ | ||
'<app-page id="' + config.id + '" title="' + config.title + '">', | ||
viewXml, | ||
'</app-page>' | ||
].join('\n'); | ||
|
||
var viewVue = new Vue({ | ||
template: viewTemplate, | ||
data: { | ||
property: {} | ||
}, | ||
methods: { | ||
onShow: function() { | ||
this.onDataChange(); | ||
}, | ||
onDataChange: function() { | ||
Promise.all([ | ||
app.getThings(), | ||
app.getPropertiesByThingId() | ||
]).then(apply(this, function(things, properties) { | ||
this.refreshProperties(things, properties); | ||
})); | ||
}, | ||
refreshProperties: function(things, properties) { | ||
var propertyMap = {}; | ||
for (var i = 0; i < config.properties.length; i++) { | ||
var cfgProp = config.properties[i]; | ||
var parts = cfgProp.path.split('/', 2); | ||
var thingId = parts[0]; | ||
var propName = parts[1]; | ||
var props = properties[thingId]; | ||
var value; | ||
if (props) { | ||
value = props[propName]; | ||
if (value !== undefined) { | ||
propertyMap[cfgProp.name] = value; | ||
continue; | ||
} | ||
} | ||
var thing = things[thingId]; | ||
if (thing) { | ||
var thgProp = thing.properties[propName]; | ||
if (thgProp) { | ||
var propType = thgProp['@type']; | ||
switch (propType) { | ||
case 'integer': | ||
case 'number': | ||
value = 0; | ||
break; | ||
case 'string': | ||
value = ''; | ||
break; | ||
case 'boolean': | ||
value = false; | ||
break; | ||
} | ||
propertyMap[cfgProp.name] = value; | ||
} | ||
} | ||
} | ||
this.property = propertyMap; | ||
} | ||
} | ||
}); | ||
|
||
addPageComponent(viewVue, config.icon); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"title": "Id", | ||
"type": "string", | ||
"default": "view", | ||
"required": true | ||
}, | ||
"title": { | ||
"title": "Title", | ||
"type": "string", | ||
"default": "View", | ||
"required": true | ||
}, | ||
"icon": { | ||
"title": "Icon", | ||
"description": "The fontawesome icon to use for the view tile and menu entry, such as 'house'", | ||
"type": "string" | ||
}, | ||
"properties": { | ||
"title": "Properties", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"title": "Name", | ||
"type": "string", | ||
"required": true | ||
}, | ||
"path": { | ||
"title": "Property", | ||
"type": "string", | ||
"enumVar": "readablePropertyPaths" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local extension = ... | ||
local loader = require('jls.lang.loader') | ||
local coreExtPath = extension:getEngine().lhaExtensionsDir:getPath() | ||
local webBaseAddons = loader.load('web-base.addons', coreExtPath) | ||
webBaseAddons.registerAddonExtension(extension, 'init.js') |
Oops, something went wrong.