mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-04-19 20:09:14 +03:00
Create a 'save this zone' button
This commit is contained in:
parent
3e2f45e596
commit
45ed135591
4 changed files with 51 additions and 4 deletions
|
@ -68,9 +68,16 @@ input[type="submit"] {
|
||||||
margin: 0 0 50px;
|
margin: 0 0 50px;
|
||||||
}
|
}
|
||||||
img.list {
|
img.list {
|
||||||
|
opacity: .4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clickme {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clickme:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
/* overrides jtable.css */
|
/* overrides jtable.css */
|
||||||
div.jtable-main-container > div.jtable-title {
|
div.jtable-main-container > div.jtable-title {
|
||||||
background-color: #FFFFFF;
|
background-color: #FFFFFF;
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 727 B After Width: | Height: | Size: 437 B |
33
index.php
33
index.php
|
@ -149,7 +149,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
function displayDnssecIcon(zone) {
|
function displayDnssecIcon(zone) {
|
||||||
if (zone.record.dnssec == true) {
|
if (zone.record.dnssec == true) {
|
||||||
var $img = $('<img class="list" src="img/lock.png" title="DNSSec Info" />');
|
var $img = $('<img class="clickme" src="img/lock.png" title="DNSSec Info" />');
|
||||||
$img.click(function () {
|
$img.click(function () {
|
||||||
$("#dnssecinfo").html("");
|
$("#dnssecinfo").html("");
|
||||||
$.each(zone.record.keyinfo, function ( i, val) {
|
$.each(zone.record.keyinfo, function ( i, val) {
|
||||||
|
@ -170,10 +170,23 @@ function displayDnssecIcon(zone) {
|
||||||
});
|
});
|
||||||
return $img;
|
return $img;
|
||||||
} else {
|
} else {
|
||||||
return '<img src="img/lock_open.png" title="DNSSec Disabled" />';
|
return '<img class="list" src="img/lock_open.png" title="DNSSec Disabled" />';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function displayExportIcon(zone) {
|
||||||
|
var $img = $('<img class="list clickme" src="img/export.png" title="Export zone" />');
|
||||||
|
$img.click(function () {
|
||||||
|
var $zexport = $.getJSON("zones.php?zone="+zone.record.name+"&action=export", function(data) {
|
||||||
|
var dl = document.createElement('a');
|
||||||
|
dl.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(data.Record.zone));
|
||||||
|
dl.setAttribute('download', zone.record.name+'.txt');
|
||||||
|
dl.click();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return $img;
|
||||||
|
}
|
||||||
|
|
||||||
function displayContent(fieldName) {
|
function displayContent(fieldName) {
|
||||||
return function(data) {
|
return function(data) {
|
||||||
var value = data.record[fieldName];
|
var value = data.record[fieldName];
|
||||||
|
@ -331,6 +344,14 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
return $img;
|
return $img;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
exportzone: {
|
||||||
|
title: '',
|
||||||
|
width: '1%',
|
||||||
|
create: false,
|
||||||
|
edit: false,
|
||||||
|
display: displayExportIcon,
|
||||||
|
listClass: 'exportzone'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -564,6 +585,14 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
return $img;
|
return $img;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
exportzone: {
|
||||||
|
title: '',
|
||||||
|
width: '1%',
|
||||||
|
create: false,
|
||||||
|
edit: false,
|
||||||
|
display: displayExportIcon,
|
||||||
|
listClass: 'exportzone'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
15
zones.php
15
zones.php
|
@ -28,9 +28,11 @@ function api_request($path, $opts = null, $type = null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$headers = array();
|
||||||
|
array_push($headers, 'Accept: application/json');
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
if ($authmethod == "xapikey") {
|
if ($authmethod == "xapikey") {
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-API-Key: '.$apipass));
|
array_push($headers, 'X-API-Key: '.$apipass);
|
||||||
} else {
|
} else {
|
||||||
curl_setopt($ch, CURLOPT_USERPWD, "$apiuser:$apipass");
|
curl_setopt($ch, CURLOPT_USERPWD, "$apiuser:$apipass");
|
||||||
}
|
}
|
||||||
|
@ -41,10 +43,11 @@ function api_request($path, $opts = null, $type = null) {
|
||||||
$type = 'POST';
|
$type = 'POST';
|
||||||
}
|
}
|
||||||
$postdata = json_encode($opts);
|
$postdata = json_encode($opts);
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
array_push($headers, 'Content-Type: application/json');
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'DELETE':
|
case 'DELETE':
|
||||||
case 'PATCH':
|
case 'PATCH':
|
||||||
|
@ -55,6 +58,7 @@ function api_request($path, $opts = null, $type = null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
$return = curl_exec($ch);
|
$return = curl_exec($ch);
|
||||||
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
$json = json_decode($return, 1);
|
$json = json_decode($return, 1);
|
||||||
|
@ -622,6 +626,13 @@ case "deleterecord":
|
||||||
jtable_respond(null, 'delete');
|
jtable_respond(null, 'delete');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "export":
|
||||||
|
$zone = $_GET['zone'];
|
||||||
|
$export = api_request("/servers/${apisid}/zones/${zone}/export");
|
||||||
|
|
||||||
|
jtable_respond($export, 'single');
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
jtable_respond(null, 'error', 'No such action');
|
jtable_respond(null, 'error', 'No such action');
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue