Skip to content

Commit

Permalink
Things Explorer - Initial contribution (#49)
Browse files Browse the repository at this point in the history
Added icons and quick reference to thing's binding docs

Show Thing in Paper UI - WIP

Generating Items from Things channels and more!

Things Explorer is completed!

Signed-off-by: Kuba Wolanin <hi@kubawolanin.com>
  • Loading branch information
kubawolanin authored Nov 12, 2017
1 parent b9b9868 commit a59a957
Show file tree
Hide file tree
Showing 24 changed files with 563 additions and 55 deletions.
24 changes: 21 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 70 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
"onCommand:openhab.searchDocs",
"onCommand:openhab.searchCommunity",
"onCommand:openhab.basicUI",
"onCommand:openhab.command.items.refreshEntry",
"onCommand:openhab.command.items.showInPaperUI",
"onCommand:openhab.command.items.copyName",
"onCommand:openhab.command.refreshEntry",
"onCommand:openhab.command.showInPaperUI",
"onCommand:openhab.command.copyName",
"onCommand:openhab.command.items.copyState",
"onCommand:openhab.command.items.addRule",
"onCommand:openhab.command.items.addToSitemap",
"onCommand:openhab.command.things.docs",
"onCommand:openhab.command.things.copyUID",
"onCommand:openhab.command.things.addItems",
"onLanguage:openhab"
],
"main": "./out/src/extension",
Expand All @@ -42,20 +45,33 @@
],
"view/title": [
{
"command": "openhab.command.items.refreshEntry",
"command": "openhab.command.refreshEntry",
"when": "view == openhabItems",
"group": "navigation"
},
{
"command": "openhab.command.refreshEntry",
"when": "view == openhabThings",
"group": "navigation"
}
],
"view/item/context": [
{
"command": "openhab.command.items.showInPaperUI",
"command": "openhab.command.showInPaperUI",
"when": "view == openhabItems"
},
{
"command": "openhab.command.items.copyName",
"command": "openhab.command.showInPaperUI",
"when": "view == openhabThings && viewItem == thing"
},
{
"command": "openhab.command.copyName",
"when": "view == openhabItems"
},
{
"command": "openhab.command.copyName",
"when": "view == openhabThings"
},
{
"command": "openhab.command.items.copyState",
"when": "view == openhabItems && viewItem != statelessItem && viewItem != statelessGroup"
Expand All @@ -64,9 +80,21 @@
"command": "openhab.command.items.addToSitemap",
"when": "view == openhabItems"
},
{
"command": "openhab.command.things.addItems",
"when": "view == openhabThings"
},
{
"command": "openhab.command.items.addRule",
"when": "view == openhabItems"
},
{
"command": "openhab.command.things.copyUID",
"when": "view == openhabThings"
},
{
"command": "openhab.command.things.docs",
"when": "view == openhabThings && viewItem == thing"
}
]
},
Expand All @@ -93,7 +121,7 @@
"title": "openHAB: Search in Community Forum"
},
{
"command": "openhab.command.items.showInPaperUI",
"command": "openhab.command.showInPaperUI",
"title": "Show in Paper UI"
},
{
Expand All @@ -105,15 +133,27 @@
"title": "Insert into Sitemap"
},
{
"command": "openhab.command.items.copyName",
"command": "openhab.command.copyName",
"title": "Copy Name"
},
{
"command": "openhab.command.items.copyState",
"title": "Copy State"
},
{
"command": "openhab.command.items.refreshEntry",
"command": "openhab.command.things.copyUID",
"title": "Copy UID"
},
{
"command": "openhab.command.things.addItems",
"title": "Create Items from Channels"
},
{
"command": "openhab.command.things.docs",
"title": "Binding documentation"
},
{
"command": "openhab.command.refreshEntry",
"title": "Refresh",
"icon": {
"light": "resources/light/refresh.svg",
Expand Down Expand Up @@ -174,6 +214,20 @@
],
"default": "",
"description": "(optional) Specifies the Basic Auth password for accessing the openHAB preview/REST API"
},
"openhab.paperPath": {
"type": [
"string"
],
"default": "paperui",
"description": "(optional) If you're using openHAB2 build from before 9th Jan 2017, change this parameter to 'ui'"
},
"openhab.paperInBrowser": {
"type": [
"boolean"
],
"default": false,
"description": "(optional) Makes 'Show in Paper UI' option open a target URL in external browser"
}
}
},
Expand Down Expand Up @@ -207,6 +261,11 @@
"id": "openhabItems",
"name": "openHAB Items",
"when": "resourceLangId == openhab"
},
{
"id": "openhabThings",
"name": "openHAB Things",
"when": "resourceLangId == openhab"
}
]
},
Expand Down Expand Up @@ -246,10 +305,12 @@
"@types/lodash": "^4.14.77",
"@types/request": "^2.0.6",
"@types/request-promise-native": "^1.0.5",
"ascii-table": "0.0.9",
"copy-paste": "^1.3.0",
"lodash": "^4.17.4",
"request": "^2.83.0",
"request-promise-native": "^1.0.5",
"underscore.string": "^3.3.4",
"vscode-languageclient": "^2.6.3"
}
}
3 changes: 3 additions & 0 deletions resources/dark/empty-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/dark/empty-gray-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/dark/full-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/dark/gray-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/dark/green-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/light/empty-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/light/empty-gray-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/light/full-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/light/gray-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/light/green-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/ItemsExplorer/ItemsExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class ItemsExplorer implements TreeDataProvider<Item> {
label: item.name + (item.state ? ' (' + item.state + ')' : ''),
collapsibleState: item.isGroup ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None,
command: item.isGroup ? void 0 : {
command: 'openhab.command.items.showInPaperUI',
command: 'openhab.command.showInPaperUI',
arguments: [item.name],
title: 'Show in Paper UI'
},
Expand Down
19 changes: 3 additions & 16 deletions src/ItemsExplorer/ItemsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
workspace
} from 'vscode'
import { Item } from './Item'
import { handleRequestError } from '../Utils'

import * as _ from 'lodash'
import * as request from 'request-promise-native'
Expand Down Expand Up @@ -63,22 +64,8 @@ export class ItemsModel {
.then(function (response: Item[] | Item) {
resolve(this.sort(transform(response)))
}.bind(this))
.catch(async err => {
let config = workspace.getConfiguration('openhab')
const setHost = 'Set openHAB host'
const disableRest = 'Disable REST API'
const result = await window.showErrorMessage('Error while connecting to openHAB REST API. ', setHost, disableRest)
switch (result) {
case setHost:
config.update('host', 'localhost')
commands.executeCommand('workbench.action.openWorkspaceSettings')
break
case disableRest:
config.update('useRestApi', false)
break
default:
break
}
.catch(err => {
handleRequestError(err)
reject()
})
})
Expand Down
41 changes: 41 additions & 0 deletions src/ThingsExplorer/Channel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { IChannel } from './IChannel'
import * as _ from 'lodash'

export class Channel {

constructor(private channel: IChannel) {
}

public get treeItemType(): string {
return 'channel';
}

public get label(): string {
return this.channel.label ? this.channel.label : this.id;
}

public get id(): string {
return this.channel.id;
}

public get itemType(): string {
return this.channel.itemType;
}

public get uid(): string {
return this.channel.uid;
}

public get kind(): string {
return this.channel.kind;
}

public get binding(): string {
return this.uid.split(':')[0];
}

public get linkedItems(): string[] {
return this.channel.linkedItems;
}

}
25 changes: 25 additions & 0 deletions src/ThingsExplorer/IChannel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export interface IChannel {

linkedItems?: any[];

uid?: string;

id?: string;

channelTypeUID?: string;

itemType?: string;

kind?: string;

label?: string;

description?: string;

defaultTags?: string[];

properties?: object;

configuration?: object;

}
Loading

0 comments on commit a59a957

Please sign in to comment.