Skip to content

Commit ce53cc3

Browse files
authored
Developer tools: Add Copy DSL definition for Items and Things (#3085)
Resolve openhab/openhab-core#4509. Signed-off-by: Jimmy Tanagra <[email protected]>
1 parent 6c88932 commit ce53cc3

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

bundles/org.openhab.ui/web/src/pages/developer/developer-tools.vue

+39-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
<f7-list-item media-item title="Block Libraries" footer="Develop custom extensions for Blockly scripts" link="blocks/">
2828
<f7-icon slot="media" f7="ticket" color="gray" />
2929
</f7-list-item>
30-
<f7-list-item media-item title="Add Items from Textual Definition" footer="Create or update items &amp; links in bulk" link="add-items-dsl">
30+
<f7-list-item media-item title="Copy DSL Definitions for All Things" footer="Copy all Things' DSL definitions to clipboard" link="#" @click="copyThingsDsl">
31+
<f7-icon slot="media" f7="lightbulb" color="gray" />
32+
</f7-list-item>
33+
<f7-list-item media-item title="Copy DSL Definitions for All Items" footer="Copy all Items' DSL definitions to clipboard" link="#" @click="copyItemsDsl">
34+
<f7-icon slot="media" f7="square_on_circle" color="gray" />
35+
</f7-list-item>
36+
<f7-list-item media-item title="Add Items from DSL Definition" footer="Create or update items &amp; links in bulk" link="add-items-dsl">
3137
<f7-icon slot="media" f7="text_badge_plus" color="gray" />
3238
</f7-list-item>
3339
</f7-list>
@@ -125,6 +131,10 @@
125131
</style>
126132

127133
<script>
134+
import Vue from 'vue'
135+
import Clipboard from 'v-clipboard'
136+
137+
Vue.use(Clipboard)
128138
129139
export default {
130140
components: {
@@ -167,6 +177,34 @@ export default {
167177
this.$oh.ws.close(this.wsClient)
168178
this.wsClient = null
169179
this.wsEvents = []
180+
},
181+
copyThingsDsl () {
182+
this.$oh.api.getPlain({
183+
url: '/rest/file-format/things',
184+
headers: { accept: 'text/vnd.openhab.dsl.thing' }
185+
}).then((definition) => {
186+
if (this.$clipboard(definition)) {
187+
this.$f7.toast.show({
188+
text: 'Things DSL definitions copied to clipboard',
189+
destroyOnClose: true,
190+
closeTimeout: 2000
191+
}).open()
192+
}
193+
})
194+
},
195+
copyItemsDsl () {
196+
this.$oh.api.getPlain({
197+
url: '/rest/file-format/items',
198+
headers: { accept: 'text/vnd.openhab.dsl.item' }
199+
}).then((definition) => {
200+
if (this.$clipboard(definition)) {
201+
this.$f7.toast.show({
202+
text: 'Items DSL definitions copied to clipboard',
203+
destroyOnClose: true,
204+
closeTimeout: 2000
205+
}).open()
206+
}
207+
})
170208
}
171209
},
172210
asyncComputed: {

0 commit comments

Comments
 (0)