From 9ddfd86b4f54ba3f178fde9f8cb959baa02da718 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 22 Mar 2018 02:15:07 +0100 Subject: Commit diverse av Ole Mathias sitt template-greier --- web/api/read/distro-management | 2 +- web/api/read/networks | 0 web/api/write/network-add | 0 web/api/write/network-update | 0 web/index.html | 10 +++--- web/js/nms-template.js | 76 ++++++++++++++++++++++++++---------------- web/templates/HOWTO.txt | 2 +- 7 files changed, 54 insertions(+), 36 deletions(-) mode change 100644 => 100755 web/api/read/networks mode change 100644 => 100755 web/api/write/network-add mode change 100644 => 100755 web/api/write/network-update (limited to 'web') 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 old mode 100644 new mode 100755 diff --git a/web/api/write/network-add b/web/api/write/network-add old mode 100644 new mode 100755 diff --git a/web/api/write/network-update b/web/api/write/network-update old mode 100644 new mode 100755 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 @@
-
- - - -
+
+ +
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($("").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. -- cgit v1.2.3