Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
feat(Things): Add search capability to item link dialog
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <chris@cd-jackson.com>
  • Loading branch information
cdjackson committed May 27, 2016
1 parent f2dfe24 commit b1a8477
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/app/configuration/itemLink.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ <h3 class="modal-title" i18n="item.LinkTitle"></h3>
<ui-select id="inputItem"
ng-model="result.name"
theme="bootstrap"
search-enabled="true"
>
search-enabled="true">
<ui-select-match i18n-attr="{placeholder: 'item.SelectName'}">
<habmin-icon class="fa fa-fw" category="{{$select.selected.category}}"></habmin-icon>
<span>{{$select.selected.name}}</span>
</ui-select-match>
<ui-select-choices repeat="item.name as item in items | orderBy: 'name'">
<ui-select-choices repeat="item.name as item in items | orderBy: 'name' | filter: $select.search">
<habmin-icon class="fa fa-fw" category="{{item.category}}"></habmin-icon>
<span>{{item.label}}</span><br>
<span class="small">{{item.name}}</span>
Expand All @@ -28,7 +27,8 @@ <h3 class="modal-title" i18n="item.LinkTitle"></h3>

</form>
</div>

<div class="modal-footer">
<button type="button" class="btn btn-primary" ng-click="ok()" i18n="common.save"></button>
<button type="button" ng-disabled="choiceSelected" class="btn btn-primary" ng-click="ok()" i18n="common.save"></button>
<button type="button" class="btn btn-warning" ng-click="cancel()" i18n="common.cancel"></button>
</div>
53 changes: 37 additions & 16 deletions src/app/configuration/thingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ angular.module('Config.Things', [
return true;
};

$scope.dec2hex = function(value, places) {
$scope.dec2hex = function (value, places) {
var template = "";
for(var c = 0; c < places; c++) {
for (var c = 0; c < places; c++) {
template += "0";
}
return (template + Number(value).toString(16)).substr(-places);
Expand Down Expand Up @@ -335,7 +335,7 @@ angular.module('Config.Things', [
$scope.panelDisplayed = 'PROPERTIES';

$scope.selectedThingHasProperties = false;
for(var key in thing.properties){
for (var key in thing.properties) {
$scope.selectedThingHasProperties = true;
break;
}
Expand Down Expand Up @@ -496,19 +496,26 @@ angular.module('Config.Things', [
function () {
growl.success(locale.getString("thing.UnlinkItemOk"));
},
function () {
growl.warning(locale.getString("thing.UnlinkItemFailed"));
function (response) {
var msg;
if (response != null && response.error != null) {
msg = response.error.message;
}
else {
msg = locale.getString("common.noResponse");
}
growl.warning(locale.getString("thing.UnlinkItemFailed", {message: msg}));
}
);
};

$scope.refreshChannelItems = function() {
$scope.refreshChannelItems = function () {
if ($scope.selectedThing == null || $scope.selectedThing.channels == null) {
return;
}

for (var c = 0; c < $scope.selectedThing.channels.length; c++) {
for(var i = 0; i < $scope.selectedThing.channels[c].linkedItems.length; i++) {
for (var i = 0; i < $scope.selectedThing.channels[c].linkedItems.length; i++) {
ItemModel.sendCommand($scope.selectedThing.channels[c].linkedItems[i], "REFRESH");
}
}
Expand Down Expand Up @@ -537,26 +544,40 @@ angular.module('Config.Things', [
function () {
growl.success(locale.getString("thing.DeleteItemOk"));
},
function () {
growl.warning(locale.getString("thing.DeleteItemFailed"));
function (response) {
var msg;
if (response != null && response.error != null) {
msg = response.error.message;
}
else {
msg = locale.getString("common.noResponse");
}
growl.warning(locale.getString("thing.DeleteItemFailed", {message: msg}));
}
);
},
function () {
growl.warning(locale.getString("thing.DeleteItemFailed"));
function (response) {
var msg;
if (response != null && response.error != null) {
msg = response.error.message;
}
else {
msg = locale.getString("common.noResponse");
}
growl.warning(locale.getString("thing.DeleteItemFailed", {message: msg}));
}
);
};

$scope.getValue = function(channel, value) {
if(value == "NULL") {
$scope.getValue = function (channel, value) {
if (value == "NULL") {
return "";
}
if(channel == null || channel.channelType == null || channel.channelType.stateDescription == null) {
if (channel == null || channel.channelType == null || channel.channelType.stateDescription == null) {
return value;
}
for(var state in channel.channelType.stateDescription.options) {
if(channel.channelType.stateDescription.options[state].value == value) {
for (var state in channel.channelType.stateDescription.options) {
if (channel.channelType.stateDescription.options[state].value == value) {
return channel.channelType.stateDescription.options[state].label;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/languages/en-GB/thing.lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
"WizardType": "Thing Type",
"WizardConfigure": "Configure",
"DeleteItemOk": "Item successfully deleted from channel",
"DeleteItemFailed": "Error deleting item from channel",
"DeleteItemFailed": "Error deleting item from channel: {message}",
"UID": "UID (Unique Identifier)",
"SelectUID": "Enter unique identifier...",
"SelectLabel": "Enter label...",
"Pending": "pending...",
"UnlinkItemOk": "Item successfully unlinked from channel",
"UnlinkItemFailed": "Error unlinking item from channel",
"UnlinkItemFailed": "Error unlinking item from channel: {message}",
"ChannelUnlinkTitle": "Unlink Item from Channel",
"ChannelUnlinkConfirm": "Are you sure you wish to unlink the item from the channel?<br>This will not delete the item, and you will be able to relink it later if you wish.",
"ChannelDeleteTitle": "Delete Item from Channel",
Expand Down

0 comments on commit b1a8477

Please sign in to comment.