Merge "basic files of the plugin dashboard"

This commit is contained in:
Jenkins 2016-05-03 08:07:45 +00:00 committed by Gerrit Code Review
commit 39e9187ae1
6 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Mellanox Technologies, Ltd
#
# 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
import horizon_mellanox.api.rest
class MlnxDashboard(horizon.Dashboard):
name = _("Mellanox Technologies")
slug = "horizon_mellanox"
panels = ('settingspanel', 'neopanel', 'ufmpanel', 'aboutpanel') # Add your panels here.
default_panel = 'settingspanel' # Specify the slug of the dashboard's default panel.
horizon.register(MlnxDashboard)

View File

@ -0,0 +1,3 @@
"""
Stub file to work around django bug: https://code.djangoproject.com/ticket/7198
"""

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

View File

@ -0,0 +1,55 @@
horizon.horizon_mellanox = {
_getCookie: function(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
}
return "";
},
prepareNEOPanel: function(){
var val = this._getCookie("mellanox_neo_host");
if(val != ""){/*
// neo authentication
var xhttp = new XMLHttpRequest();
var url = "http://" + val + "/neo/login";
var user = this._getCookie("mellanox_neo_host_user");
var password = this._getCookie("mellanox_neo_host_password");
var data = "username=" + user + "&password=" + password;
xhttp.open("POST", url, true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.onreadystatechange = function() {
alert("on");
if (xhttp.readyState == 4 && xhttp.status == 200) {
alert("ready state");
//document.getElementById("neo_iframe").src = "http://" + val + "/neo";
}
};
xhttp.send(data);*/
document.getElementById("neo_iframe").src = "http://" + val + "/neo";
}else{
var msg = "<h5 style='margin:20px;'>NEO hostname/ip is not set, you can set it in Configurations panel</h5>";
document.getElementsByClassName("col-xs-12")[0].innerHTML = msg;
}
},
prepareUFMPanel: function(){
var val = this._getCookie("mellanox_ufm_host");
if(val != "")
document.getElementById("ufm_iframe").src = "http://" + val + "/ufmui";
else{
var msg = "<h5 style='margin:20px;'>UFM hostname/ip is not set, you can set it in Configurations panel</h5>";
document.getElementsByClassName("col-xs-12")[0].innerHTML = msg;
}
},
prepareSettingsPanel: function(){
document.getElementById("id_neo_host").value = this._getCookie("mellanox_neo_host");
document.getElementById("id_neo_host_user").value = this._getCookie("mellanox_neo_host_user");
document.getElementById("id_neo_host_password").value = this._getCookie("mellanox_neo_host_password");
document.getElementById("id_ufm_host").value = this._getCookie("mellanox_ufm_host");
}
};

View File

@ -0,0 +1,10 @@
{% extends 'base.html' %}
{% block sidebar %}
{% include 'horizon/common/_sidebar.html' %}
{% endblock %}
{% block main %}
{% include "horizon/_messages.html" %}
{% block neo_dashboard_main %}{% endblock %}
{% endblock %}