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

Commit

Permalink
Further performance improvements, bug fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Henning Treu <henning.treu@telekom.de>
  • Loading branch information
Henning Treu committed Jul 5, 2017
1 parent b66b2dc commit 42c6d1a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 61 deletions.
@@ -1,5 +1,5 @@
angular.module('PaperUI.controllers.control', []) //
.controller('ControlPageController', function($scope, $routeParams, $location, $timeout, $filter, itemRepository, thingTypeRepository, thingConfigService, imageService, util, thingRepository, channelTypeRepository) {
.controller('ControlPageController', function($scope, $routeParams, $location, $timeout, $filter, itemRepository, thingTypeService, thingConfigService, imageService, util, thingRepository, channelTypeRepository) {
$scope.items = [];
$scope.selectedIndex = 0;
$scope.tabs = [];
Expand Down Expand Up @@ -40,37 +40,34 @@ angular.module('PaperUI.controllers.control', []) //
}

function getThings() {
var renderedThings = [];
thingRepository.getAll(null, true).then(function(things) {
thingTypeRepository.getAll(null, true).then(function(thingTypes) {
channelTypeRepository.getAll(null, true).then(function(channelTypes) {
var thingTypesUsed = getUsedThingTypesUIDs(things);
angular.forEach(thingTypesUsed, function(thingTypeUsed) {
var thingType = thingTypes.filter(function(element) {
return element.UID === thingTypeUsed;
})[0];
if (thingType == null) {
return;
}
angular.forEach(things, function(thing) {
if (thing.thingTypeUID === thingType.UID) {
var renderedThing = renderThing(thing, thingType, channelTypes);
if (renderedThing && renderedThings.indexOf(renderedThing) == -1) {
renderedThings.push(renderedThing);
}
$scope.tabs = getTabs(things);
channelTypeRepository.getAll(null, true).then(function(channelTypes) {
var thingTypesUsed = getUsedThingTypesUIDs(things);
angular.forEach(thingTypesUsed, function(thingTypeUID) {
thingTypeService.getByUid({
thingTypeUID : thingTypeUID
}, function(thingType) {
var matchingThings = things.filter(function(thing) {
return thingType.UID === thing.thingTypeUID;
});
angular.forEach(matchingThings, function(thing) {
var renderedThing = renderThing(thing, thingType, channelTypes);
if (renderedThing) {
$scope.things.push(renderedThing);
}
})

})
$scope.tabs = getTabs(renderedThings);
$scope.things = renderedThings;
})
})
});
}

function renderThing(thing, thingType, channelTypes) {
thing.thingChannels = thingConfigService.getThingChannels(thing, thingType, channelTypes, true);
angular.forEach(thing.thingChannels, function(value, key) {
thing.thingChannels[key].channels = $.grep(thing.thingChannels[key].channels, function(channel, i) {
angular.forEach(thing.thingChannels, function(thingChannel) {
thingChannel.channels = $.grep(thingChannel.channels, function(channel) {
return channel.linkedItems.length > 0;
});
});
Expand Down
Expand Up @@ -532,7 +532,7 @@ angular.module('PaperUI.services', [ 'PaperUI.services.repositories', 'PaperUI.c
includedChannels = includedChannels.concat(group.channels);
group.channels = advanced ? group.channels : this.filterAdvance(thingType, channelTypes, group.channels, false);
thingChannels.push(group);
})
}, this)

var group = {
"name" : "Others",
Expand Down Expand Up @@ -576,7 +576,7 @@ angular.module('PaperUI.services', [ 'PaperUI.services.repositories', 'PaperUI.c
if (thingType.channelGroups && thingType.channelGroups.length > 0) {
angular.forEach(thingType.channelGroups, function(channelGroup) {
if (channelGroup && channelGroup.channels) {
var result = cg.channels.filter(function(channel) {
var result = channelGroup.channels.filter(function(channel) {
return channel.typeUID === channelUID;
})
if (result.length > 0) {
Expand Down
Expand Up @@ -9,45 +9,45 @@
<button class="md-button" ng-click="$location.path('configuration/locations')">Add Location</button>
</p>
-->
<md-tabs md-stretch-tabs="always" class="section-tabs" md-selected="selectedIndex" ng-if="tabs.length > 0">
<md-tabs md-stretch-tabs="always" class="section-tabs" md-selected="selectedIndex">
<md-tab ng-repeat="tab in tabs track by tab.name" ng-disabled="tab.disabled" label="{{::tab.name}}" layout-fill>
<md-tab-content layout-fill="">
<p class="text-center" ng-show="getItem(tabs[selectedIndex].name).members.length == 0">
No Things available.
<button class="md-button" ng-click="$location.path('inbox/setup')">Add Thing</button>
</p>
<div ng-controller="ControlController" class="items row" md-swipe-left="next()" md-swipe-right="prev()" ng-if="tabs[selectedIndex] === tab" ng-attr-id="{{::'items-' + tabs.indexOf(tab)}}">
<div ng-controller="ControlController" class="items row" md-swipe-left="next()" md-swipe-right="prev()" ng-attr-id="{{::'items-' + tabs.indexOf(tab)}}">
<div class="col-lg-4 col-sm-6 col-xs-12 item-wrapper" ng-repeat="thing in getThingsForTab(tab.name) track by thing.UID" on-finish-render>
<div class="card item">
<div class="row">
<h3 class="clabel col-xs-9">{{thing.label}}</h3>
<h3 class="clabel col-xs-9">{{::thing.label}}</h3>
<i ng-click="navigateTo('configuration/things/view/'+thing.UID)" class="material-icons cursor-pointer col-xs-3 pull-right" style="color: black; background-color: transparent;">launch</i>
</div>
<div class="ibadge">
<span class="icon-x">
</div>
<div ng-repeat="group in thing.thingChannels">
<div ng-repeat="group in ::thing.thingChannels track by $index">
<div ng-if="!angular.isUndefined(group.name) && group.name.length > 0 && group.channels.length>0">
<h2>{{::group.name}}</h2>
</div>
<div class="" ng-repeat="channel in group.channels">
<div ng-if="channel.linkedItems.length>0">
<div ng-repeat="item in getItems(channel.linkedItems)">
<div ng-switch on="item.type" class="icontrol" ng-controller="ItemController">
<div ng-switch-when="Switch" ng-controller="SwitchItemController">
<div class="" ng-repeat="channel in ::group.channels track by channel.id">
<div ng-if="::(channel.linkedItems.length>0)">
<div ng-repeat="item in ::getItems(channel.linkedItems) track by item.name">
<div class="icontrol" ng-controller="ItemController">
<div ng-if="::(item.type === 'Switch')" ng-controller="SwitchItemController">
<div layout="row" layout-align="start center" class="dimmer-widget">
<div flex="40">
<p>
<i class="material-icons">{{::getIcon(item.category)}}</i>{{::getLabel(item.category, item.name, 'Switch')}}
</p>
</div>
<div flex="60" layout="row" layout-align="end center" class="switch-widget" ng-if="!isOptionList(item)">
<div flex="60" layout="row" layout-align="end center" class="switch-widget" ng-if="::!isOptionList(item)">
<md-switch class="md-default-theme" ng-disabled="isReadOnly(item)" ng-model="item.state" ng-change="setOn(item.state)" ng-true-value="'ON'" ng-false-value="'OFF'" aria-label={{item.label}}></md-switch>
</div>
</div>
<div layout="row" item-state-dropdown layout-align="end center" ng-if="isOptionList(item) && !isReadOnly(item)"></div>
<div layout="row" item-state-dropdown layout-align="end center" ng-if="::isOptionList(item) && !isReadOnly(item)"></div>
</div>
<div ng-switch-when="Dimmer" ng-controller="DimmerItemController">
<div ng-if="::(item.type === 'Dimmer')" ng-controller="DimmerItemController">
<div layout="row" layout-align="start center" class="dimmer-widget">
<div flex="40">
<p>
Expand All @@ -58,71 +58,71 @@ <h2>{{::group.name}}</h2>
<h2>{{item.stateText}}</h2>
</div>
</div>
<md-slider ng-if="!isOptionList(item) && !isReadOnly(item)" ng-class="{'left-padded' : showSwitch(item.category)}" class="md-default-theme" style="height: 40px;" flex min="0" max="100" ng-model="item.state" ng-change="setBrightness(item.state)" aria-label={{::item.label}}></md-slider>
<div layout="row" layout-align="start center" class="dimmer-widget" ng-if="showSwitch(item.category) && !isOptionList(item) && !isReadOnly(item)">
<md-slider ng-if="::(!isOptionList(item) && !isReadOnly(item))" ng-class="{'left-padded' : showSwitch(item.category)}" class="md-default-theme" style="height: 40px;" flex min="0" max="100" ng-model="item.state" ng-change="setBrightness(item.state)" aria-label={{::item.label}}></md-slider>
<div layout="row" layout-align="start center" class="dimmer-widget" ng-if="::(showSwitch(item.category) && !isOptionList(item) && !isReadOnly(item))">
<div flex="40">
<p class="no-icon-margin-left">Off/On</p>
</div>
<div flex="60" layout="row" layout-align="end center" class="dimmer-widget">
<md-switch class="md-default-theme" ng-model="on" ng-change="setOn(on)" ng-true-value="'ON'" ng-false-value="'OFF'" aria-label={{::item.label}}></md-switch>
</div>
</div>
<div layout="row" item-state-dropdown layout-align="end center" ng-if="isOptionList(item) && !isReadOnly(item)"></div>
<div layout="row" item-state-dropdown layout-align="end center" ng-if="::(isOptionList(item) && !isReadOnly(item))"></div>
</div>
<div ng-switch-when="Color" ng-controller="ColorItemController">
<div ng-if="::(item.type === 'Color')" ng-controller="ColorItemController">
<div layout="row" layout-align="start center" class="dimmer-widget">
<div flex="45">
<p>
<i class="material-icons">wb_incandescent</i>{{::getLabel(item.category, item.name, 'Color')}}
</p>
</div>
<div ng-if="!isOptionList(item) && !isReadOnly(item)" flex="55" layout="row" layout-align="end center" class="dimmer-widget">
<div ng-if="::(!isOptionList(item) && !isReadOnly(item))" flex="55" layout="row" layout-align="end center" class="dimmer-widget">

<md-slider class="hue md-default-theme" flex min="0" max="360" ng-model="hue" ng-change="setHue(hue)" aria-label="{{::item.label}} hue"></md-slider>
</div>
</div>
<div ng-if="!isOptionList(item) && !isReadOnly(item)" layout="row" layout-align="start center" class="dimmer-widget">
<div ng-if="::(!isOptionList(item) && !isReadOnly(item))" layout="row" layout-align="start center" class="dimmer-widget">
<div flex="45">
<p class="no-icon-margin-left">Brightness</p>
</div>
<div flex="55" layout="row" layout-align="end center" class="dimmer-widget">
<md-slider class="md-default-theme" flex min="0" max="100" ng-model="brightness" ng-change="setBrightness(brightness)" aria-label="{{::item.label}} brightness"></md-slider>
</div>
</div>
<div ng-if="!isOptionList(item) && !isReadOnly(item)" layout="row" layout-align="start center" class="dimmer-widget">
<div ng-if="::(!isOptionList(item) && !isReadOnly(item))" layout="row" layout-align="start center" class="dimmer-widget">
<div flex="45">
<p class="no-icon-margin-left">Saturation</p>
</div>
<div flex="55" layout="row" layout-align="end center" class="dimmer-widget">
<md-slider class="md-default-theme" flex min="0" max="100" ng-model="saturation" ng-change="setSaturation(saturation)" aria-label="{{::item.label}} saturation"></md-slider>
</div>
</div>
<div ng-if="isReadOnly(item)" flex="100" layout="row" layout-align="end center">
<div ng-if="::isReadOnly(item)" flex="100" layout="row" layout-align="end center">
<h2>{{item.stateText}}</h2>
</div>
<div layout="row" item-state-dropdown layout-align="end center" ng-if="isOptionList(item) && !isReadOnly(item)"></div>
<div layout="row" item-state-dropdown layout-align="end center" ng-if="::(isOptionList(item) && !isReadOnly(item))"></div>
</div>
<div ng-switch-when="Number" class="numberWidget">
<div ng-if="::(item.type === 'Number')" class="numberWidget">
<div layout="row" layout-align="start center">
<div flex="40" layout="row" layout-align="start center">
<p>
<i class="material-icons">{{::getIcon(item.category, 'trending_up')}}</i>{{::getLabel(item.category, item.name, 'Value')}}
</p>
</div>
<div flex="60" layout="row" layout-align="end center">
<div ng-show="isReadOnly(item)">
<h2 class="state" ng-if="isReadOnly(item)">{{::item.stateText}}</h2>
<div ng-show="::isReadOnly(item)">
<h2 class="state" ng-if="::isReadOnly(item)">{{item.stateText}}</h2>
</div>
<div layout="row" layout-align="end center" ng-if="!isReadOnly(item) && !isOptionList(item)">
<div layout="row" layout-align="end center" ng-if="::(!isReadOnly(item) && !isOptionList(item))">
<h2 class="state edit" ng-if="!editMode" ng-click="editState()">{{item.stateText}}</h2>
<md-input-container ng-show="editMode"> <input name="{{::item.name}}" ng-model="item.state" aria-label={{::item.label}} type="number" ng-min="item.stateDescription.minimum" ng-max="item.stateDescription.maximum"></input> </md-input-container>
<i class="md-button control-button material-icons" ng-disabled="controlForm[item.name].$invalid" ng-show="editMode" ng-click="controlForm[item.name].$invalid || updateState()">check</i>
</div>
</div>
</div>
<div layout="row" item-state-dropdown layout-align="start center" ng-if="isOptionList(item) && !isReadOnly(item)"></div>
<div layout="row" item-state-dropdown layout-align="start center" ng-if="::(isOptionList(item) && !isReadOnly(item))"></div>
</div>
<div ng-switch-when="Rollershutter" ng-controller="RollershutterItemController">
<div ng-if="::(item.type === 'Rollershutter')" ng-controller="RollershutterItemController">
<div layout="row" layout-align="start center" flex="100">
<div flex="40" layout="row" layout-align="start center">
<p>
Expand All @@ -140,17 +140,17 @@ <h2 class="state edit" ng-if="!editMode" ng-click="editState()">{{item.stateText
</div>
</div>
</div>
<div ng-if="!isOptionList(item) && !isReadOnly(item)" layout="row" layout-align="start center" flex="100">
<div ng-if="::(!isOptionList(item) && !isReadOnly(item))" layout="row" layout-align="start center" flex="100">
<div flex="40" layout="row" layout-align="start center">
<p>Control</p>
</div>
<div flex="60" layout="row" layout-align="end center">
<i class="md-button control-button material-icons" ng-click="sendCommand('DOWN')">vertical_align_bottom</i> <i class="md-button control-button material-icons" ng-click="sendCommand('STOP')">stop</i> <i class="md-button control-button material-icons" ng-click="sendCommand('UP')">vertical_align_top</i>
</div>
</div>
<div layout="row" item-state-dropdown layout-align="end center" ng-if="isOptionList(item) && !isReadOnly(item)"></div>
<div layout="row" item-state-dropdown layout-align="end center" ng-if="::(isOptionList(item) && !isReadOnly(item))"></div>
</div>
<div ng-switch-when="Player" ng-controller="PlayerItemController">
<div ng-if="::(item.type === 'Player')" ng-controller="PlayerItemController">
<div layout="row" layout-align="end center">
<div flex="40" layout="row" layout-align="start center">
<p>
Expand All @@ -172,7 +172,7 @@ <h2>{{item.stateText}}</h2>
</div>
</div>
</div>
<div ng-switch-when="Contact" ng-controller="DefaultItemController">
<div ng-if="::(item.type === 'Contact')" ng-controller="DefaultItemController">
<div layout="row" layout-align="start center">
<div flex="40" layout="row" layout-align="start center">
<p>
Expand All @@ -183,9 +183,9 @@ <h2>{{item.stateText}}</h2>
<h2 class="state">{{item.stateText}}</h2>
</div>
</div>
<div layout="row" item-state-dropdown layout-align="end center" ng-if="isOptionList(item) && !isReadOnly(item)"></div>
<div layout="row" item-state-dropdown layout-align="end center" ng-if="::(isOptionList(item) && !isReadOnly(item))"></div>
</div>
<div ng-switch-when="Location" ng-controller="LocationItemController">
<div ng-if="::(item.type === 'Location')" ng-controller="LocationItemController">
<div layout="row" layout-align="start center">
<p>
<i class="material-icons">place</i>{{::getLabel(item.category, item.name, 'Location')}}
Expand All @@ -206,9 +206,9 @@ <h2 class="state edit" ng-if="!editMode" ng-click="editState()">{{formattedState
<i class="md-button control-button material-icons" ng-show="editMode" ng-click="updateState()">check</i>
</div>
</div>
<div layout="row" item-state-dropdown layout-align="end center" ng-if="isOptionList(item) && !isReadOnly(item)"></div>
<div layout="row" item-state-dropdown layout-align="end center" ng-if="::(isOptionList(item) && !isReadOnly(item))"></div>
</div>
<div ng-switch-when="Image" ng-controller="ImageItemController">
<div ng-if="::(item.type === 'Image')" ng-controller="ImageItemController">
<div layout-align="start center" layout="row">
<div flex="60">
<p class="ng-binding">
Expand All @@ -228,7 +228,7 @@ <h2 class="state edit" ng-if="!editMode" ng-click="editState()">{{formattedState
</div>
</div>
</div>
<div class="textControl" ng-switch-default ng-controller="DefaultItemController">
<div class="textControl" ng-if="::(item.type === 'DateTime' || item.type === 'String')" ng-controller="DefaultItemController">
<div layout="row" layout-align="start center" style="height: 100%">
<p flex="40">
<i class="material-icons">{{::getIcon(item.category)}}</i>{{::getLabel(item.category, item.name, 'Value')}}
Expand All @@ -255,7 +255,7 @@ <h2 class="state edit" ng-if="!editMode" ng-click="editState()">{{formattedState
</div>
</div>
<!-- for option list selection -->
<div layout="row" layout-align="start center" ng-show="isOptionList(item) && !isReadOnly(item)" item-state-dropdown></div>
<div layout="row" layout-align="start center" ng-show="::(isOptionList(item) && !isReadOnly(item))" item-state-dropdown></div>
</div>
</div>
</div>
Expand Down

0 comments on commit 42c6d1a

Please sign in to comment.