From 83f0bb781a4d2f0c87b14095ebe92f65fa929a93 Mon Sep 17 00:00:00 2001
From: Key Networks <34238649+key-networks@users.noreply.github.com>
Date: Wed, 31 Jan 2018 11:14:49 +0800
Subject: [PATCH] Setting of activeBridge
---
src/controllers/networkController.js | 23 +++++++++++++++++++----
src/package.json | 2 +-
src/routes/zt_controller.js | 1 -
src/views/index.pug | 5 +++--
src/views/members.pug | 18 +++++++++++++-----
src/views/not_implemented.pug | 8 +++++++-
6 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/src/controllers/networkController.js b/src/controllers/networkController.js
index 65e0634..48e4eb3 100644
--- a/src/controllers/networkController.js
+++ b/src/controllers/networkController.js
@@ -587,6 +587,25 @@ exports.members = async function(req, res) {
throw err;
}
}
+ } else if (req.body.activeBridge) {
+ req.checkBody('activeBridge', 'activeBridge state must be boolean').isBoolean();
+ req.sanitize('activeBridge').trim();
+ req.sanitize('activeBridge').escape();
+
+ errors = req.validationErrors();
+
+ if (!errors) {
+ const activeBridge =
+ {
+ activeBridge: req.body.activeBridge
+ };
+
+ try {
+ const mem = await zt.member_object(req.params.nwid, req.body.id, activeBridge);
+ } catch (err) {
+ throw err;
+ }
+ }
} else if (req.body.name) {
req.sanitize('name').trim();
req.sanitize('name').escape();
@@ -709,16 +728,12 @@ exports.assign_ip = async function(req, res) {
let ipAddressInManagedRoute = false;
network.routes.forEach(function(item) {
let ipv4 = new ipaddr.Address4(value);
- console.log('ipv4 = ' + JSON.stringify(ipv4));
let target4 = new ipaddr.Address4(item.target);
- console.log('target4 = ' + JSON.stringify(target4));
if (ipv4.isValid() && target4.isValid()) {
if (ipv4.isInSubnet(target4)) ipAddressInManagedRoute = true;
}
let ipv6 = new ipaddr.Address6(value);
- console.log('ipv6 = ' + JSON.stringify(ipv6));
let target6 = new ipaddr.Address6(item.target);
- console.log('target6 = ' + JSON.stringify(target6));
if (ipv6.isValid() && target6.isValid()) {
if (ipv6.isInSubnet(target6)) ipAddressInManagedRoute = true;
}
diff --git a/src/package.json b/src/package.json
index 7d22d7f..304c58b 100644
--- a/src/package.json
+++ b/src/package.json
@@ -1,6 +1,6 @@
{
"name": "ztncui",
- "version": "0.4.0",
+ "version": "0.4.1",
"private": true,
"scripts": {
"start": "node ./bin/www",
diff --git a/src/routes/zt_controller.js b/src/routes/zt_controller.js
index f015545..aa541e5 100644
--- a/src/routes/zt_controller.js
+++ b/src/routes/zt_controller.js
@@ -83,7 +83,6 @@ router.get('/network/:nwid/member/:id/ipAssignments/:index/delete', restrict, ne
router.post('/network/:nwid/member/:id/ipAssignments', restrict, networkController.assign_ip);
-
// GET request for any network object
router.get('/network/:nwid/:object', restrict, networkController.network_object);
diff --git a/src/views/index.pug b/src/views/index.pug
index 02588ff..e87c6de 100644
--- a/src/views/index.pug
+++ b/src/views/index.pug
@@ -17,6 +17,7 @@ block content
if error
b #{error}
else
- p This network controller has a ZeroTier address of #{zt_address}
+ h4 This network controller has a ZeroTier address of #{zt_address}
- a(href='/controller/networks') List all networks on this network controller
+ h4
+ a(href='/controller/networks') List all networks on this network controller
diff --git a/src/views/members.pug b/src/views/members.pug
index d6d7519..92ca2bb 100644
--- a/src/views/members.pug
+++ b/src/views/members.pug
@@ -8,11 +8,17 @@ extends network_layout
block net_content
script.
$(function() {
- $('.checkbox').on('click', function() {
+ $('#authCheckBox').on('click', function() {
$.post('', {id: this.value, auth: this.checked});
});
});
+ $(function() {
+ $('#activeBridgeCheckBox').on('click', function() {
+ $.post('', {id: this.value, activeBridge: this.checked});
+ });
+ });
+
$(function() {
$('.text').on('change', function() {
$.post('', {id: this.name, name: this.value});
@@ -30,7 +36,9 @@ block net_content
| Member ID
td(width='10%')
| Authorized
- td(width='57%')
+ td(width='10%')
+ | Active bridge
+ td(width='47%')
| IP assignment
each member in members
tr
@@ -43,7 +51,9 @@ block net_content
td
a(href=url) #{member.id}
td
- input.checkbox(type='checkbox' name='authCheckBox' value=member.id checked=(member.authorized? true : false))
+ input.checkbox(type='checkbox' id='authCheckBox' value=member.id checked=(member.authorized? true : false))
+ td
+ input.checkbox(type='checkbox' id='activeBridgeCheckBox' value=member.id checked=(member.activeBridge? true : false))
td
each ipAssignment in member.ipAssignments
a(href='/controller/network/' + network.nwid + '/member/' + member.id + '/ipAssignments')
@@ -58,8 +68,6 @@ block net_content
.alert.alert-info
strong There are no members on this network - invite users to join #{network.nwid}
- a.btn.btn-default(href='/controller/networks' name='networks' role='button') Networks
- = ' '
a.btn.btn-default(href='' name='refresh' role='button') Refresh
if errors
diff --git a/src/views/not_implemented.pug b/src/views/not_implemented.pug
index a4e0a2b..e6997c7 100644
--- a/src/views/not_implemented.pug
+++ b/src/views/not_implemented.pug
@@ -11,4 +11,10 @@ block net_content
a(href='../' + member.address) #{member.address}
h4 Editing of
b #{title}
- | has not been implemented
+ | has not been implemented.
+
+ h4
+ | Note that you may be able to edit some properties on the
+ strong
+ a(href='/controller/network/' + network.nwid + '/members') Members
+ | page.