Add refresh and auto-refresh buttons to template list

Change-Id: Ifb92f76a88c3b3ac1c1ed6c8ae1304f0c97380f8
This commit is contained in:
Niv Oppenhaim 2018-08-19 10:43:06 +00:00
parent bc980af7bf
commit 343355df3f
2 changed files with 54 additions and 5 deletions

View File

@ -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){

View File

@ -1,14 +1,30 @@
<div class="template-list" ng-controller="TemplateListController as templateList">
<div class="add-btn">
<div class="add-btn" >
<button class="btn btn-primary"
type="file"
id="add-template"
ngf-select="templateList.uploadFile($file, $invalidFiles)"
ngf-max-height="1000"
accept="*"
accept=".yaml,.yml"
data-toggle="tooltip"
title="File type: YAML Max Size: 2MB"
ngf-max-size="1MB">
Add Template
</button>
<button class="btn btn-primary fa fa-refresh"
ng-click="templateList.refreshTemplates()"
ngf-max-height="1000"
data-toggle="tooltip"
title="Refresh template list"
>
</button>
<div class="themable-checkbox btn" style="float: right">
<input type="checkbox" ng-model="templateList.checkboxAutoRefresh" id="themable-checkbox" ng-change="alarmList.autoRefreshChanged()">
<label for="themable-checkbox" translate>Auto Refresh</label>
</div>
</div>
<div class="panel panel-default">