diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/transformations.js b/bundles/org.openhab.ui/web/src/assets/definitions/transformations.js new file mode 100644 index 0000000000..d89e305985 --- /dev/null +++ b/bundles/org.openhab.ui/web/src/assets/definitions/transformations.js @@ -0,0 +1,14 @@ +export default { + SNIPPETS: { + SCRIPT: { + 'application/vnd.openhab.dsl.rule': 'var returnValue = "String has " + input.length + " characters"\n\nreturnValue', + 'application/javascript': '(function(data) {\n var returnValue = "String has " + data.length + " characters"\n return returnValue\n})(input)', + 'application/javascript;version=ECMAScript-5.1': '(function(data) {\n var returnValue = "String has " + data.length + " characters"\n return returnValue\n})(input)', + 'application/x-ruby': '"String has #{input.length} characters"' + } + }, + EDITOR_MODES: { + MAP: 'text/x-properties', + SCALE: 'text/x-properties' + } +} diff --git a/bundles/org.openhab.ui/web/src/pages/settings/rules/script/blockly-editor.vue b/bundles/org.openhab.ui/web/src/components/config/controls/blockly-editor.vue similarity index 100% rename from bundles/org.openhab.ui/web/src/pages/settings/rules/script/blockly-editor.vue rename to bundles/org.openhab.ui/web/src/components/config/controls/blockly-editor.vue diff --git a/bundles/org.openhab.ui/web/src/components/config/controls/script-editor.vue b/bundles/org.openhab.ui/web/src/components/config/controls/script-editor.vue index d248f17f87..aa30d1ecfd 100644 --- a/bundles/org.openhab.ui/web/src/components/config/controls/script-editor.vue +++ b/bundles/org.openhab.ui/web/src/components/config/controls/script-editor.vue @@ -52,6 +52,7 @@ import 'codemirror/mode/groovy/groovy.js' import 'codemirror/mode/python/python.js' import 'codemirror/mode/ruby/ruby.js' import 'codemirror/mode/yaml/yaml.js' +import 'codemirror/mode/properties/properties.js' // theme css import 'codemirror/theme/gruvbox-dark.css' @@ -174,6 +175,7 @@ export default { if (this.mode && this.mode.indexOf('ruby') >= 0) return 'text/x-ruby' if (this.mode && this.mode.indexOf('groovy') >= 0) return 'text/x-groovy' if (this.mode && this.mode === 'rb') return 'text/x-ruby' + if (this.mode && this.mode === 'properties') return 'text/x-properties' return this.mode }, ternComplete (file, query) { diff --git a/bundles/org.openhab.ui/web/src/js/routes.js b/bundles/org.openhab.ui/web/src/js/routes.js index 705814125f..6cc46e350b 100644 --- a/bundles/org.openhab.ui/web/src/js/routes.js +++ b/bundles/org.openhab.ui/web/src/js/routes.js @@ -31,6 +31,9 @@ const AddThingPage = () => import(/* webpackChunkName: "admin-config" */ '../pag const InboxListPage = () => import(/* webpackChunkName: "admin-config" */ '../pages/settings/things/inbox/inbox-list.vue') +const TransformationsListPage = () => import(/* webpackChunkName: "admin-config" */ '../pages/settings/transformations/transformations-list.vue') +const TransformationsEditPage = () => import(/* webpackChunkName: "admin-rules" */ '../pages/settings/transformations/transformation-edit.vue') + const SemanticModelPage = () => import(/* webpackChunkName: "admin-config" */ '../pages/settings/model/model.vue') const PagesListPage = () => import(/* webpackChunkName: "admin-pages" */ '../pages/settings/pages/pages-list.vue') @@ -176,6 +179,17 @@ export default [ } ] }, + { + path: 'transformations/', + async: loadAsync(TransformationsListPage), + routes: [ + { + path: ':transformationId', + beforeLeave: checkDirtyBeforeLeave, + async: loadAsync(TransformationsEditPage, (routeTo) => (routeTo.params.transformationId === 'add') ? { createMode: true } : {}) + } + ] + }, { path: 'things/', beforeEnter: [enforceAdminForRoute], diff --git a/bundles/org.openhab.ui/web/src/pages/developer/blocks/blocks-edit.vue b/bundles/org.openhab.ui/web/src/pages/developer/blocks/blocks-edit.vue index 5d3623805f..b31ff45493 100644 --- a/bundles/org.openhab.ui/web/src/pages/developer/blocks/blocks-edit.vue +++ b/bundles/org.openhab.ui/web/src/pages/developer/blocks/blocks-edit.vue @@ -104,7 +104,7 @@ import YAML from 'yaml' import { strOptions } from 'yaml/types' -import BlocklyEditor from '@/pages/settings/rules/script/blockly-editor.vue' +import BlocklyEditor from '@/components/config/controls/blockly-editor.vue' import BlockPreview from './block-preview.vue' import ConfigSheet from '@/components/config/config-sheet.vue' import DirtyMixin from '@/pages/settings/dirty-mixin' @@ -115,7 +115,7 @@ export default { mixins: [DirtyMixin], components: { 'editor': () => import(/* webpackChunkName: "script-editor" */ '@/components/config/controls/script-editor.vue'), - BlocklyEditor, // 'blockly-editor': () => import(/* webpackChunkName: "blockly-editor" */ '@/pages/settings/rules/script/blockly-editor.vue'), + BlocklyEditor, // 'blockly-editor': () => import(/* webpackChunkName: "blockly-editor" */ '@/components/config/controls/blockly-editor.vue'), BlockPreview // 'block-preview': () => import(/* webpackChunkName: "blockly-editor" */ './block-preview.vue') }, props: ['uid', 'createMode'], diff --git a/bundles/org.openhab.ui/web/src/pages/settings/rules/script/script-edit.vue b/bundles/org.openhab.ui/web/src/pages/settings/rules/script/script-edit.vue index 04e5ee7671..66e5d93326 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/rules/script/script-edit.vue +++ b/bundles/org.openhab.ui/web/src/pages/settings/rules/script/script-edit.vue @@ -118,7 +118,7 @@ export default { components: { ScriptGeneralSettings, 'editor': () => import(/* webpackChunkName: "script-editor" */ '@/components/config/controls/script-editor.vue'), - 'blockly-editor': () => import(/* webpackChunkName: "blockly-editor" */ './blockly-editor.vue') + 'blockly-editor': () => import(/* webpackChunkName: "blockly-editor" */ '@/components/config/controls/blockly-editor.vue') }, props: ['ruleId', 'moduleId', 'createMode'], data () { diff --git a/bundles/org.openhab.ui/web/src/pages/settings/settings-menu.vue b/bundles/org.openhab.ui/web/src/pages/settings/settings-menu.vue index af5d5d0ac6..5920d7f837 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/settings-menu.vue +++ b/bundles/org.openhab.ui/web/src/pages/settings/settings-menu.vue @@ -60,6 +60,16 @@ :footer="objectsSubtitles.pages"> + + + Automation @@ -157,6 +167,7 @@ export default { model: 'The semantic model of your home', items: 'Manage the functional layer', pages: 'Design displays for user control & monitoring', + transform: 'Manage transformations', rules: 'Automate with triggers and actions', scenes: 'Store a set of desired states as a scene', scripts: 'Rules dedicated to running code', @@ -165,6 +176,7 @@ export default { inboxCount: '', thingsCount: '', itemsCount: '', + transformationsCount: '', sitemapsCount: 0 } }, @@ -199,6 +211,7 @@ export default { if (this.$store.getters.apiEndpoint('things')) this.$oh.api.get('/rest/things?summary=true').then((data) => { this.thingsCount = data.length.toString() }) if (this.$store.getters.apiEndpoint('items')) this.$oh.api.get('/rest/items').then((data) => { this.itemsCount = data.length.toString() }) if (this.$store.getters.apiEndpoint('ui')) this.$oh.api.get('/rest/ui/components/system:sitemap?summary=true').then((data) => { this.sitemapsCount = data.length }) + if (this.$store.getters.apiEndpoint('transformations')) this.$oh.api.get('/rest/transformations').then((data) => { this.transformationsCount = data.length }) }, navigateToStore (tab) { this.$f7.views.main.router.navigate('addons', { props: { initialTab: tab } }) diff --git a/bundles/org.openhab.ui/web/src/pages/settings/transformations/transformation-edit.vue b/bundles/org.openhab.ui/web/src/pages/settings/transformations/transformation-edit.vue new file mode 100644 index 0000000000..fcaef1e706 --- /dev/null +++ b/bundles/org.openhab.ui/web/src/pages/settings/transformations/transformation-edit.vue @@ -0,0 +1,298 @@ + + + + + diff --git a/bundles/org.openhab.ui/web/src/pages/settings/transformations/transformation-general-settings.vue b/bundles/org.openhab.ui/web/src/pages/settings/transformations/transformation-general-settings.vue new file mode 100644 index 0000000000..72232665f3 --- /dev/null +++ b/bundles/org.openhab.ui/web/src/pages/settings/transformations/transformation-general-settings.vue @@ -0,0 +1,56 @@ + + + diff --git a/bundles/org.openhab.ui/web/src/pages/settings/transformations/transformations-list.vue b/bundles/org.openhab.ui/web/src/pages/settings/transformations/transformations-list.vue new file mode 100644 index 0000000000..65d0471fc6 --- /dev/null +++ b/bundles/org.openhab.ui/web/src/pages/settings/transformations/transformations-list.vue @@ -0,0 +1,253 @@ + + +