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

Commit

Permalink
first attempt to speed up control rendering
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 Jun 23, 2017
1 parent 2ae569e commit ee9cd61
Showing 1 changed file with 13 additions and 14 deletions.
@@ -1,5 +1,5 @@
angular.module('PaperUI.controllers.control', []) //
.controller('ControlPageController', function($scope, $routeParams, $location, $timeout, itemRepository, thingTypeRepository, thingService, thingTypeService, channelTypeService, thingConfigService, imageService, util) {
.controller('ControlPageController', function($scope, $routeParams, $location, $timeout, itemRepository, thingTypeRepository, thingService, thingTypeService, channelTypeService, thingConfigService, imageService, util, thingRepository) {
$scope.items = [];
$scope.selectedIndex = 0;
$scope.tabs = [];
Expand Down Expand Up @@ -37,29 +37,28 @@ angular.module('PaperUI.controllers.control', []) //
var thingList;
function getThings() {
$scope.things = [];
thingService.getAll().$promise.then(function(things) {
thingRepository.getAll().then(function(things) {
thingList = things;
$scope.isLoadComplete = false;
thingTypeService.getAll().$promise.then(function(thingTypes) {
thingTypeRepository.getAll().then(function(thingTypes) {
$scope.thingTypes = thingTypes;
channelTypeService.getAll().$promise.then(function(channels) {
$scope.channelTypes = channels;
var thingTypesUsed = getUsedThingTypesUIDs(thingList);
for (var i = 0; i < thingTypesUsed.length; i++) {
thingTypeService.getByUid({
thingTypeUID : thingTypesUsed[i]
angular.forEach(thingTypesUsed, function(thingTypeUsed) {
thingTypeRepository.getOne(function(element) {
return element.UID === thingTypeUsed;
}, function(thingType) {
thingTypes.push(thingType);
for (var t_i = 0; t_i < thingList.length; t_i++) {
if (thingList[t_i].thingTypeUID === thingType.UID) {
renderThing(thingList[t_i], thingType, $scope.channelTypes);
angular.forEach(thingList, function(thing) {
if (thing.thingTypeUID === thingType.UID) {
renderThing(thing, thingType, $scope.channelTypes);
}
if (i == thingTypesUsed.length && t_i == thingList.length - 1) {
getTabs();
}
}
})
});
}
});
}).then(function() {
getTabs();
});
});

Expand Down

0 comments on commit ee9cd61

Please sign in to comment.