Added templates list view to vitrage dashboard
Change-Id: Iae2a4b09f20d1e26d664b0bd76197a3c302798cd
This commit is contained in:
parent
9eac15598f
commit
b1523c6485
@ -15,4 +15,7 @@ recursive-include vitragealarms/static *
|
||||
recursive-include vitragealarms/templates *
|
||||
|
||||
recursive-include vitrageentities/static *
|
||||
recursive-include vitrageentities/templates *
|
||||
recursive-include vitrageentities/templates *
|
||||
|
||||
recursive-include vitragetemplates/static *
|
||||
recursive-include vitragetemplates/templates *
|
@ -23,6 +23,7 @@ classifier =
|
||||
packages =
|
||||
vitrageentities
|
||||
vitragealarms
|
||||
vitragetemplates
|
||||
vitragedashboard
|
||||
|
||||
|
||||
|
@ -97,3 +97,23 @@ class Rca(generic.View):
|
||||
"""
|
||||
|
||||
return api.vitrage.rca(request, alarm_id)
|
||||
|
||||
|
||||
@urls.register
|
||||
class Templates(generic.View):
|
||||
"""API for vitrage templates."""
|
||||
|
||||
url_regex = r'vitrage/template/'
|
||||
|
||||
@rest_utils.ajax()
|
||||
def get(self, request):
|
||||
"""Get a single template with the vitrage id.
|
||||
|
||||
The following get template may be passed in the GET
|
||||
|
||||
:param template_id the id of the vitrage template
|
||||
|
||||
The result is a template object.
|
||||
"""
|
||||
|
||||
return api.vitrage.templates(request)
|
||||
|
@ -41,3 +41,7 @@ def alarms(request, vitrage_id='all'):
|
||||
|
||||
def rca(request, alarm_id):
|
||||
return vitrageclient(request).rca.get(alarm_id=alarm_id)
|
||||
|
||||
|
||||
def templates(request):
|
||||
return vitrageclient(request).template.list()
|
||||
|
@ -0,0 +1,27 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# The name of the panel to be added to HORIZON_CONFIG. Required.
|
||||
PANEL = 'templates_vitrage_panel'
|
||||
# The name of the dashboard the PANEL associated with. Required.
|
||||
PANEL_DASHBOARD = 'project'
|
||||
# The name of the panel group the PANEL is associated with.
|
||||
PANEL_GROUP = 'vitrage_panel_group'
|
||||
|
||||
# Python panel class of the PANEL to be added.
|
||||
ADD_PANEL = 'vitragetemplates.panel.TemplatesVitrage'
|
||||
|
||||
ADD_INSTALLED_APPS = ['vitragetemplates']
|
||||
|
||||
ADD_ANGULAR_MODULES = ['horizon.dashboard.project.vitrage']
|
||||
|
||||
AUTO_DISCOVER_STATIC_FILES = True
|
@ -16,7 +16,8 @@
|
||||
var service = {
|
||||
getTopology: getTopology,
|
||||
getAlarms: getAlarms,
|
||||
getRca: getRca
|
||||
getRca: getRca,
|
||||
getTemplates: getTemplates
|
||||
};
|
||||
|
||||
return service;
|
||||
@ -55,6 +56,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
function getTemplates() {
|
||||
return apiService.get('/api/vitrage/template/')
|
||||
.error(function () {
|
||||
toastService.add('error', gettext('Unable to fetch the Vitrage Templates service.'));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}());
|
||||
|
@ -42,6 +42,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
function getTemplates() {
|
||||
|
||||
if (vitrageAPI) {
|
||||
return vitrageAPI.getTemplates()
|
||||
.success(function(data) {
|
||||
return data;
|
||||
})
|
||||
.error(function(err) {
|
||||
console.error(err);
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getRootCauseAnalysis(alarm_id) {
|
||||
if (vitrageAPI) {
|
||||
@ -59,7 +73,8 @@
|
||||
return {
|
||||
getTopology: getTopology,
|
||||
getAlarms: getAlarms,
|
||||
getRootCauseAnalysis: getRootCauseAnalysis
|
||||
getRootCauseAnalysis: getRootCauseAnalysis,
|
||||
getTemplates: getTemplates
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
@ -0,0 +1,55 @@
|
||||
(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().then(function(result){
|
||||
templateList.templates = result.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
@ -0,0 +1,34 @@
|
||||
<div class="template-list" ng-controller="TemplateListController as templateList">
|
||||
<div class="themable-checkbox refreshBtn">
|
||||
<input type="checkbox" ng-model="templateList.checkboxAutoRefresh" id="themable-checkbox" ng-change="templateList.autoRefreshChanged()">
|
||||
<label for="themable-checkbox" translate>Auto Refresh</label>
|
||||
</div>
|
||||
<div class="panel panel-default" >
|
||||
|
||||
<table st-table='templateList.itemplates' st-safe-src="templateList.templates" class="table-striped table-rsp table-detail modern" hz-table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th st-sort="name" style="padding-left: 15px;">{$ 'Name' | translate $}</th>
|
||||
<th st-sort="status">{$ 'Status' | translate $}</th>
|
||||
<th st-sort="details">{$ 'Details' | translate $}</th>
|
||||
<th st-sort="timestamp">{$ 'Timestamp' | translate $}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="4">
|
||||
<hz-search-bar group-classes="input-group-sm"
|
||||
icon-classes="fa-search">
|
||||
</hz-search-bar>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="template in templateList.itemplates track by $index">
|
||||
<td style="padding-left: 15px;">{$template.name$}</td>
|
||||
<td>{$template.status$}</td>
|
||||
<td>{$template["status details"]$}</td>
|
||||
<td><i class="fa fa-clock-o"></i> {$template.date | date:"yyyy-MM-dd hh:mm:ss"$} </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,10 @@
|
||||
.template-list {
|
||||
.refreshBtn{
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.first-column {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
@import 'layout/main/compute/compute';
|
||||
@import "alarmList/alarmList.scss";
|
||||
@import 'alarmList/alarmList.scss';
|
||||
@import 'components/sunburst/sunburst';
|
||||
@import 'components/alarms/alarms.scss';
|
||||
@import 'components/rca/rootCauseAnalysisGraph.scss';
|
||||
@ -12,6 +12,7 @@
|
||||
@import 'entities/info/entities-info.scss';
|
||||
@import 'entities/toolbox/entities-toolbox.scss';
|
||||
@import 'entities/entities.scss';
|
||||
@import 'templateList/templateList.scss';
|
||||
|
||||
.red {
|
||||
color: #FA3C3C;
|
||||
|
19
vitragetemplates/__init__.py
Normal file
19
vitragetemplates/__init__.py
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import pbr.version
|
||||
|
||||
|
||||
__version__ = pbr.version.VersionInfo(
|
||||
'vitrage-dashboard').version_string()
|
22
vitragetemplates/panel.py
Normal file
22
vitragetemplates/panel.py
Normal file
@ -0,0 +1,22 @@
|
||||
# Copyright 2015 IBM Corp.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
|
||||
|
||||
class TemplatesVitrage(horizon.Panel):
|
||||
name = _("Templates")
|
||||
slug = "vitragetemplates"
|
16
vitragetemplates/templates/templates/index.html
Normal file
16
vitragetemplates/templates/templates/index.html
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Templates List" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Templates List") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<div ng-cloak ng-init='init({{ TOPOLOGY_VITRAGE_SETTINGS }})'>
|
||||
<ng-include src="'{{STATIC_URL}}dashboard/project/templateList/templateList.html'"></ng-include>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
22
vitragetemplates/urls.py
Normal file
22
vitragetemplates/urls.py
Normal file
@ -0,0 +1,22 @@
|
||||
# Copyright 2015 IBM Corp.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from django.conf import urls
|
||||
|
||||
from vitragetemplates import views
|
||||
|
||||
urlpatterns = urls.patterns(
|
||||
'',
|
||||
urls.url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
)
|
15
vitragetemplates/version.py
Normal file
15
vitragetemplates/version.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import pbr.version
|
||||
|
||||
version_info = pbr.version.VersionInfo('vitrage_templates_ui')
|
32
vitragetemplates/views.py
Normal file
32
vitragetemplates/views.py
Normal file
@ -0,0 +1,32 @@
|
||||
# Copyright 2012 Alcatel-Lucent, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from horizon import views
|
||||
|
||||
import json
|
||||
|
||||
|
||||
class IndexView(views.APIView):
|
||||
# A very simple class-based view...
|
||||
template_name = 'templates/index.html'
|
||||
|
||||
def get_data(self, request, context, *args, **kwargs):
|
||||
topology_settings = {
|
||||
'VITRAGE_VERSION': {
|
||||
'VER': 1,
|
||||
'REL': 1
|
||||
}
|
||||
}
|
||||
context['TOPOLOGY_VITRAGE_SETTINGS'] = json.dumps(topology_settings)
|
||||
return context
|
Loading…
x
Reference in New Issue
Block a user