Noam Bloom 92cd660345 Add template show to templates list
Change-Id: I30d8ebb47f9845afa7fd2b8106aeae00333e6eb7
2016-10-18 14:02:43 +00:00

70 lines
1.9 KiB
JavaScript

(function () {
'use strict';
angular
.module('horizon.dashboard.project.vitrage')
.controller('TemplateListController', TemplateListController);
TemplateListController.$inject = ['$scope', '$modal', 'vitrageTopologySrv','$interval'];
function TemplateListController($scope, $modal, vitrageTopologySrv,$interval) {
var templateList = this;
templateList.templates = [];
templateList.itemplates = [];
templateList.$interval = $interval;
templateList.checkboxAutoRefresh = true;
$scope.STATIC_URL = STATIC_URL;
templateList.templates = [];
templateList.templateInterval;
getData();
startCollectData();
function startCollectData() {
if (angular.isDefined(templateList.templateInterval)) return;
templateList.templateInterval = templateList.$interval(getData,10000);
}
function stopCollectData() {
if (angular.isDefined(templateList.templateInterval)) {
templateList.$interval.cancel(templateList.templateInterval);
templateList.templateInterval = undefined;
}
}
$scope.$on('$destroy',function(){
templateList.stopCollectData();
})
templateList.autoRefreshChanged = function(){
if (templateList.checkboxAutoRefresh){
getData();
startCollectData();
}else{
stopCollectData();
}
}
function getData() {
vitrageTopologySrv.getTemplates('all').then(function(result){
templateList.templates = result.data;
});
templateList.onShowClick = function(template) {
var modalOptions = {
animation: true,
templateUrl: STATIC_URL + 'dashboard/project/components/template/templateContainer.html',
controller: 'TemplateContainerController',
windowClass: 'app-modal-window',
resolve: {template: function() {
return template;
}}
};
$modal.open(modalOptions);
}
}
}
})();