aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rwxr-xr-xweb/api/read/distro-management2
-rwxr-xr-x[-rw-r--r--]web/api/read/networks0
-rwxr-xr-x[-rw-r--r--]web/api/write/network-add0
-rwxr-xr-x[-rw-r--r--]web/api/write/network-update0
-rw-r--r--web/index.html10
-rw-r--r--web/js/nms-template.js76
-rw-r--r--web/templates/HOWTO.txt2
7 files changed, 54 insertions, 36 deletions
diff --git a/web/api/read/distro-management b/web/api/read/distro-management
index 7fbebef..55ca07e 100755
--- a/web/api/read/distro-management
+++ b/web/api/read/distro-management
@@ -19,7 +19,7 @@ my $q2;
$nms::web::cc{'max-age'} = "5";
$nms::web::cc{'stale-while-revalidate'} = "30";
-$q2 = $nms::web::dbh->prepare('SELECT distro_name,sysname,subnet4,subnet6,traffic_vlan,distro_phy_port FROM switches WHERE placement is not null AND distro_name is not null AND distro_phy_port is not null and deleted = false');
+$q2 = $nms::web::dbh->prepare('SELECT distro_name,sysname,distro_phy_port FROM switches WHERE placement is not null AND distro_name is not null AND distro_phy_port is not null and deleted = false');
$q2->execute();
while (my $ref = $q2->fetchrow_hashref()) {
diff --git a/web/api/read/networks b/web/api/read/networks
index 870ae8c..870ae8c 100644..100755
--- a/web/api/read/networks
+++ b/web/api/read/networks
diff --git a/web/api/write/network-add b/web/api/write/network-add
index d1aab4e..d1aab4e 100644..100755
--- a/web/api/write/network-add
+++ b/web/api/write/network-add
diff --git a/web/api/write/network-update b/web/api/write/network-update
index f6684c5..f6684c5 100644..100755
--- a/web/api/write/network-update
+++ b/web/api/write/network-update
diff --git a/web/index.html b/web/index.html
index d8f2a60..2fee54f 100644
--- a/web/index.html
+++ b/web/index.html
@@ -143,11 +143,11 @@
<div class="span3 col-lg-6">
<textarea id="template-input" class="form-control" cols="80" rows="25"></textarea>
<div class="form-inline">
- <div class="form-group">
- <button onclick="nmsTemplate.fromFile('HOWTO.txt')" class="btn btn-info">Load HOWTO.txt</button>
- <button onclick="nmsTemplate.fromFile('switches.txt')" class="btn btn-info">Load switches.txt</button>
- <button onclick="nmsTemplate.fromFile('switch.txt')" class="btn btn-info">Load switch.txt</button>
- </div>
+ <div class="form-group">
+ <select onchange="nmsTemplate.fromFile(this.value)" class="form-control" id="nmsTemplate-select">
+ <option value="">Select template</option>
+ </select>
+ </div>
<div class="form-group">
<label for="template-query-params">Query parameters</label>
<input type="text" class="form-control" id="template-query-params" value="?switch=e13-1&foo=bar" />
diff --git a/web/js/nms-template.js b/web/js/nms-template.js
index c34ef34..6159f5b 100644
--- a/web/js/nms-template.js
+++ b/web/js/nms-template.js
@@ -4,36 +4,54 @@ var nmsTemplate = nmsTemplate || {
}
nmsTemplate.test = function() {
- var input = document.getElementById("template-input");
- var output = document.getElementById("template-output");
- var qp = document.getElementById("template-query-params");
- $.ajax({
- type: "POST",
- url: "/api/templates/test" + qp.value,
- async: false,
- data: input.value,
- dataType: "text",
- success: function (indata, textStatus, jqXHR) {
- var output = document.getElementById("template-output");
- output.value = jqXHR.responseText;
- },
- error: function (jqXHR, textStatus) {
- var output = document.getElementById("template-output");
- output.value = jqXHR.responseText;
- }
- });
+ var input = document.getElementById("template-input");
+ var output = document.getElementById("template-output");
+ var qp = document.getElementById("template-query-params");
+ $.ajax({
+ type: "POST",
+ url: "/api/templates/test" + qp.value,
+ async: false,
+ data: input.value,
+ dataType: "text",
+ success: function (indata, textStatus, jqXHR) {
+ var output = document.getElementById("template-output");
+ output.value = jqXHR.responseText;
+ },
+ error: function (jqXHR, textStatus) {
+ var output = document.getElementById("template-output");
+ output.value = jqXHR.responseText;
+ }
+ });
}
nmsTemplate.fromFile = function(template) {
- $.ajax({
- type: "GET",
- url: "/templates/" + template,
- async: false,
- dataType: "text",
- success: function (indata, textStatus, jqXHR) {
- var output = document.getElementById("template-input");
- output.value = indata;
- }
- });
- nmsTemplate.test();
+ if(template == '') { return; }
+ $.ajax({
+ type: "GET",
+ url: "/templates/" + template,
+ async: false,
+ dataType: "text",
+ success: function (indata, textStatus, jqXHR) {
+ var output = document.getElementById("template-input");
+ output.value = indata;
+ }
+ });
+ nmsTemplate.test();
}
+
+nmsTemplate.getTemplates = function() {
+ $.ajax({
+ type: "GET",
+ url: "/api/read/template-list",
+ async: false,
+ dataType: "json",
+ success: function (indata, textStatus, jqXHR) {
+ console.log(indata['templates']);
+ $.each( indata['templates'], function( value ) {
+ $('#nmsTemplate-select').append($("<option></option>").attr("value",indata['templates'][value]['file']).text(indata['templates'][value]['file']));
+ });
+ }
+ });
+}
+
+nmsTemplate.getTemplates();
diff --git a/web/templates/HOWTO.txt b/web/templates/HOWTO.txt
index ed47926..641878e 100644
--- a/web/templates/HOWTO.txt
+++ b/web/templates/HOWTO.txt
@@ -8,7 +8,7 @@ We utilize Jinja2 templates.
-#}
{% set url = "localhost" -%}
-{% set example_switch = "distro0" -%}
+{% set example_switch = "r1.tele" -%}
See http://jinja.pocoo.org/ for the full documentation of the templating
language.