From 343355df3f55fa73492e1668471ae10ba72987f5 Mon Sep 17 00:00:00 2001 From: Niv Oppenhaim Date: Sun, 19 Aug 2018 10:43:06 +0000 Subject: [PATCH] Add refresh and auto-refresh buttons to template list Change-Id: Ifb92f76a88c3b3ac1c1ed6c8ae1304f0c97380f8 --- .../templateList/templateList.controller.js | 39 +++++++++++++++++-- .../project/templateList/templateList.html | 20 +++++++++- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/vitrage_dashboard/dashboard/static/dashboard/project/templateList/templateList.controller.js b/vitrage_dashboard/dashboard/static/dashboard/project/templateList/templateList.controller.js index e973122..e525323 100644 --- a/vitrage_dashboard/dashboard/static/dashboard/project/templateList/templateList.controller.js +++ b/vitrage_dashboard/dashboard/static/dashboard/project/templateList/templateList.controller.js @@ -5,16 +5,49 @@ .module('horizon.dashboard.project.vitrage') .controller('TemplateListController', TemplateListController); - TemplateListController.$inject = ['$scope', 'modalSrv', 'vitrageTopologySrv']; + TemplateListController.$inject = ['$scope', '$interval', 'modalSrv', 'vitrageTopologySrv']; - function TemplateListController($scope, modalSrv, vitrageTopologySrv) + function TemplateListController($scope, $interval, modalSrv, vitrageTopologySrv) { var templateList = this; templateList.templates = []; templateList.itemplates = []; $scope.STATIC_URL = STATIC_URL; templateList.templates = []; + templateList.$interval = $interval; + templateList.checkboxAutoRefresh = true; + templateList.templateInterval; + getData(); + startCollectData(); + + function startCollectData() { + if (angular.isDefined(templateList.templateInterval)) return; + templateList.templateInterval = templateList.$interval(getData,5000); + } + + 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(); + } + }; + + templateList.refreshTemplates = function() { + getData(); + } templateList.closeModal = function() { if(templateList.file){ @@ -86,7 +119,7 @@ } } - getData(); + function getData() { vitrageTopologySrv.getTemplates('all').then(function(result){ diff --git a/vitrage_dashboard/dashboard/static/dashboard/project/templateList/templateList.html b/vitrage_dashboard/dashboard/static/dashboard/project/templateList/templateList.html index 5adabea..c967c70 100644 --- a/vitrage_dashboard/dashboard/static/dashboard/project/templateList/templateList.html +++ b/vitrage_dashboard/dashboard/static/dashboard/project/templateList/templateList.html @@ -1,14 +1,30 @@
-
+
+ + + +
+ + +
+