Archived
Allow setting a friendly name for the local node (fixes #65)
This commit is contained in:
1 parent
b6814241cc
commit
3a5b816125
5 files changed
+137
-65
No files matched your search
+1
-1
@@ -3,4 +3,4 @@ package auto
|
|||||||
|
|
||||||
import "github.com/cratonica/embed"
|
import "github.com/cratonica/embed"
|
||||||
|
|
||||||
var Resources embed.PackedResourceMap = embed.PackedResourceMap{0x1f, 0x8b, 0x8, 0x0, 0x0, 0x9, 0x6e, 0x88, 0x2, 0xff, 0xec, 0xbd, 0x6b, 0x8c, 0x24, 0xc9, 0x76, 0x1e, 0xd6, 0x97, 0xe2, 0xe5, 0x25, 0x9b, 0x6f, 0xd1, 0xb6, 0x24, 0xc3, 0x16, 0xaa, 0xf3, 0xf6, 0xed, 0xcd, 0xdc, 0xca, 0xae, 0xee, 0x9e, 0xdd, 0xbb, 0xbc, 0x37, 0xb3, 0x73, 0x8a, 0x3d, 0x3d, 0x3d, 0xaf, 0x9d, 0x9e, 0x99, 0xed, 0x9e, 0x99, 0x7d, 0x54, 0xd7, 0x2e, 0xf3, 0x55, 0x8f, 0xad, 0xaa, 0xac, 0x9a, 0xca, 0xaa, 0x7e, 0x4c, 0x77, 0x59, 0x80, 0x60, 0x41, 0xa6, 0x49, 0x2, 0x86, 0x2c, 0xd8, 0xb4, 0x4d, 0xc0, 0x36, 0x4d, 0xc3, 0x7f, 0xc, 0xca, 0x82, 0x5, 0xd8, 0x3f, 0x4c, 0x9, 0xb0, 0x65, 0xc2, 0xa0, 0x49, 0xe8, 0x87, 0xf5, 0x47, 0x4, 0x25, 0xeb, 0x61, 0xd9, 0xb0, 0x41, 0x58, 0x36, 0x6c, 0x43, 0x32, 0x6d, 0xd0, 0xfe, 0xce, 0x89, 0x88, 0xcc, 0xc8, 0xaa, 0xec, 0x9e, 0x99, 0xbd, 0x7b, 0xf9, 0xb0, 0xbb, 0x77, 0x63, 0x2a, 0x33, 0x32, 0x32, 0x22, 0xf2, 0xc4, 0x89, 0x13, 0xe7, 0x15, 0x27, 0x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0xcf, 0x98, 0xc4, 0xa7, 0x93, 0xf5, 0xc1, 0x74, 0x12, 0x47, 0x95, 0x76, 0xff, 0x6c, 0xd4, 0xe9, 0x86, 0xc3, 0x24, 0xbf, 0x5a, 0xf, 0x3b, 0xf1, 0xf1, 0x18, 0xbf, 0xd1, 0xf0, 0x24, 0x31, 0x6e, 0xbe, 0x49, 0x2b, 0xe7, 0xe7, 0xdd, 0x24, 0x18, 0xa5, 0x95, 0x8b, 0xca, 0x20, 0x9e, 0x8c, 0xbb, 0xe1, 0x6c, 0x86, 0xbb, 0xa5, 0xd7, 0xeb, 0x5b, 0xd2, 0x5e, 0x4f, 0x3b, 0xc3, 0x13, 0xcf, 0x48, 0x86, 0x51, 0xbc, 0xdb, 0x6a, 0xd7, 0x1e, 0xe1, 0xf7, 0xfe, 0xed, 0xca, 0x8a, 0x57, 0x19, 0x9c, 0xdd, 0xbf, 0x6d, 0x5c, 0xdd, 0x83, 0xed, 0x49, 0x54, 0x49, 0x27, 0x67, 0xfd, 0xd8, 0x33, 0x4e, 0xba, 0xd1, 0xa4, 0xe3, 0x6c, 0x6d, 0x7e, 0xc3, 0x28, 0x7c, 0xef, 0xb8, 0xdb, 0xee, 0x4c, 0xde, 0xb4, 0x96, 0x1b, 0xdf, 0xfc, 0x6, 0x41, 0x60, 0x12, 0xbd, 0xe9, 0x7b, 0x68, 0xfd, 0xe6, 0xf9, 0xf9, 0x71, 0x3c, 0x4Line truncated
|
var Resources embed.PackedResourceMap = embed.PackedResourceMap{0x1f, 0x8b, 0x8, 0x0, 0x0, 0x9, 0x6e, 0x88, 0x2, 0xff, 0xec, 0xbd, 0xb, 0x7c, 0x24, 0xd9, 0x59, 0x1f, 0xda, 0xbb, 0xf6, 0x7a, 0x6d, 0xed, 0x82, 0x1, 0x13, 0x8c, 0xe3, 0xe4, 0x47, 0xa9, 0x76, 0x56, 0x53, 0xb5, 0x2a, 0xb5, 0xa4, 0xd9, 0x97, 0xdd, 0xa5, 0x9a, 0xb6,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b, 0xb0, 0xbc, 0x64, 0x82, 0x59, 0xa5, 0x14, 0xf6, 0xad, 0x7b, 0x7a, 0x98, 0x7b, 0xda, 0xee, 0x84, 0x5b, 0xa7, 0xdd, 0x6e, 0x88, 0x27, 0x51, 0x6b, 0x3b, 0x9f, 0x21, 0x4a, 0xb5, 0x1b, 0xe0, 0x89, 0x81, 0x47, 0xf8, 0xb0, 0x24, 0x2c, 0xe5, 0x7e, 0x7e, 0x6e, 0x6e, 0x6e, 0x38, 0x34, 0x85, 0x73, 0x34, 0xa, 0x53, 0xc4, 0xa9, 0xa1, 0x7c, 0xe0,Line truncated
|
||||||
@@ -178,3 +178,25 @@ func clusterHash(nodes []NodeConfiguration) string {
|
|||||||
}
|
}
|
||||||
return fmt.Sprintf("%x", h.Sum(nil))
|
return fmt.Sprintf("%x", h.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cleanNodeList(nodes []NodeConfiguration, myID string) []NodeConfiguration {
|
||||||
|
var myIDExists bool
|
||||||
|
for _, node := range nodes {
|
||||||
|
if node.NodeID == myID {
|
||||||
|
myIDExists = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !myIDExists {
|
||||||
|
nodes = append(nodes, NodeConfiguration{
|
||||||
|
NodeID: myID,
|
||||||
|
Addresses: []string{"dynamic"},
|
||||||
|
Name: "",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Sort(NodeConfigurationList(nodes))
|
||||||
|
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
+104
-59
@@ -1,8 +1,13 @@
|
|||||||
|
/*jslint browser: true, continue: true, plusplus: true */
|
||||||
|
/*global $: false, angular: false */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
var syncthing = angular.module('syncthing', []);
|
var syncthing = angular.module('syncthing', []);
|
||||||
|
|
||||||
syncthing.controller('SyncthingCtrl', function ($scope, $http) {
|
syncthing.controller('SyncthingCtrl', function ($scope, $http) {
|
||||||
var prevDate = 0;
|
var prevDate = 0,
|
||||||
var modelGetOK = true;
|
modelGetOK = true;
|
||||||
|
|
||||||
$scope.connections = {};
|
$scope.connections = {};
|
||||||
$scope.config = {};
|
$scope.config = {};
|
||||||
@@ -11,7 +16,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
|
|||||||
|
|
||||||
// Strings before bools look better
|
// Strings before bools look better
|
||||||
$scope.settings = [
|
$scope.settings = [
|
||||||
{id: 'ListenStr', descr:"Sync Protocol Listen Addresses", type: 'string', restart: true},
|
{id: 'ListenStr', descr: "Sync Protocol Listen Addresses", type: 'string', restart: true},
|
||||||
{id: 'GUIAddress', descr: "GUI Listen Address", type: 'string', restart: true},
|
{id: 'GUIAddress', descr: "GUI Listen Address", type: 'string', restart: true},
|
||||||
{id: 'MaxSendKbps', descr: "Outgoing Rate Limit (KBps)", type: 'string', restart: true},
|
{id: 'MaxSendKbps', descr: "Outgoing Rate Limit (KBps)", type: 'string', restart: true},
|
||||||
{id: 'RescanIntervalS', descr: "Rescan Interval (s)", type: 'string', restart: true},
|
{id: 'RescanIntervalS', descr: "Rescan Interval (s)", type: 'string', restart: true},
|
||||||
@@ -40,6 +45,19 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function nodeCompare(a, b) {
|
||||||
|
if (a.NodeID === $scope.myID) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (b.NodeID === $scope.myID) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (a.NodeID < b.NodeID) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return a.NodeID > b.NodeID;
|
||||||
|
}
|
||||||
|
|
||||||
$http.get("/rest/version").success(function (data) {
|
$http.get("/rest/version").success(function (data) {
|
||||||
$scope.version = data;
|
$scope.version = data;
|
||||||
});
|
});
|
||||||
@@ -49,15 +67,10 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
|
|||||||
|
|
||||||
$http.get("/rest/config").success(function (data) {
|
$http.get("/rest/config").success(function (data) {
|
||||||
$scope.config = data;
|
$scope.config = data;
|
||||||
$scope.config.Options.ListenStr = $scope.config.Options.ListenAddress.join(", ")
|
$scope.config.Options.ListenStr = $scope.config.Options.ListenAddress.join(", ");
|
||||||
|
|
||||||
var nodes = $scope.config.Repositories[0].Nodes;
|
var nodes = $scope.config.Repositories[0].Nodes;
|
||||||
nodes = nodes.filter(function (x) { return x.NodeID != $scope.myID; });
|
nodes.sort(nodeCompare);
|
||||||
nodes.sort(function (a, b) {
|
|
||||||
if (a.NodeID < b.NodeID)
|
|
||||||
return -1;
|
|
||||||
return a.NodeID > b.NodeID;
|
|
||||||
})
|
|
||||||
$scope.nodes = nodes;
|
$scope.nodes = nodes;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -73,13 +86,18 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
|
|||||||
modelGetFailed();
|
modelGetFailed();
|
||||||
});
|
});
|
||||||
$http.get("/rest/connections").success(function (data) {
|
$http.get("/rest/connections").success(function (data) {
|
||||||
var now = Date.now();
|
var now = Date.now(),
|
||||||
var td = (now - prevDate) / 1000;
|
td = (now - prevDate) / 1000,
|
||||||
prevDate = now;
|
id;
|
||||||
|
|
||||||
$scope.inbps = 0
|
prevDate = now;
|
||||||
$scope.outbps = 0
|
$scope.inbps = 0;
|
||||||
for (var id in data) {
|
$scope.outbps = 0;
|
||||||
|
|
||||||
|
for (id in data) {
|
||||||
|
if (!data.hasOwnProperty(id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
data[id].inbps = Math.max(0, 8 * (data[id].InBytesTotal - $scope.connections[id].InBytesTotal) / td);
|
data[id].inbps = Math.max(0, 8 * (data[id].InBytesTotal - $scope.connections[id].InBytesTotal) / td);
|
||||||
data[id].outbps = Math.max(0, 8 * (data[id].OutBytesTotal - $scope.connections[id].OutBytesTotal) / td);
|
data[id].outbps = Math.max(0, 8 * (data[id].OutBytesTotal - $scope.connections[id].OutBytesTotal) / td);
|
||||||
@@ -96,7 +114,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
|
|||||||
var i, name;
|
var i, name;
|
||||||
for (i = 0; i < data.length; i++) {
|
for (i = 0; i < data.length; i++) {
|
||||||
name = data[i].Name.split("/");
|
name = data[i].Name.split("/");
|
||||||
data[i].ShortName = name[name.length-1];
|
data[i].ShortName = name[name.length - 1];
|
||||||
}
|
}
|
||||||
data.sort(function (a, b) {
|
data.sort(function (a, b) {
|
||||||
if (a.ShortName < b.ShortName) {
|
if (a.ShortName < b.ShortName) {
|
||||||
@@ -179,7 +197,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
|
|||||||
$scope.editNode = function (nodeCfg) {
|
$scope.editNode = function (nodeCfg) {
|
||||||
$scope.currentNode = nodeCfg;
|
$scope.currentNode = nodeCfg;
|
||||||
$scope.editingExisting = true;
|
$scope.editingExisting = true;
|
||||||
$scope.currentNode.AddressesStr = nodeCfg.Addresses.join(", ")
|
$scope.currentNode.AddressesStr = nodeCfg.Addresses.join(", ");
|
||||||
$('#editNode').modal({backdrop: 'static', keyboard: false});
|
$('#editNode').modal({backdrop: 'static', keyboard: false});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -190,50 +208,72 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.deleteNode = function () {
|
$scope.deleteNode = function () {
|
||||||
$('#editNode').modal('hide');
|
var newNodes = [], i;
|
||||||
if (!$scope.editingExisting)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var newNodes = [];
|
$('#editNode').modal('hide');
|
||||||
for (var i = 0; i < $scope.nodes.length; i++) {
|
if (!$scope.editingExisting) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < $scope.nodes.length; i++) {
|
||||||
if ($scope.nodes[i].NodeID !== $scope.currentNode.NodeID) {
|
if ($scope.nodes[i].NodeID !== $scope.currentNode.NodeID) {
|
||||||
newNodes.push($scope.nodes[i]);
|
newNodes.push($scope.nodes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.nodes = newNodes;
|
$scope.nodes = newNodes;
|
||||||
$scope.config.Repositories[0].Nodes = newNodes;
|
$scope.config.Repositories[0].Nodes = newNodes;
|
||||||
|
|
||||||
$http.post('/rest/config', JSON.stringify($scope.config), {headers: {'Content-Type': 'application/json'}})
|
$http.post('/rest/config', JSON.stringify($scope.config), {headers: {'Content-Type': 'application/json'}});
|
||||||
}
|
};
|
||||||
|
|
||||||
$scope.saveNode = function () {
|
$scope.saveNode = function () {
|
||||||
|
var nodeCfg, done, i;
|
||||||
|
|
||||||
$('#editNode').modal('hide');
|
$('#editNode').modal('hide');
|
||||||
nodeCfg = $scope.currentNode;
|
nodeCfg = $scope.currentNode;
|
||||||
nodeCfg.Addresses = nodeCfg.AddressesStr.split(',').map(function (x) { return x.trim(); });
|
nodeCfg.Addresses = nodeCfg.AddressesStr.split(',').map(function (x) { return x.trim(); });
|
||||||
|
|
||||||
var done = false;
|
done = false;
|
||||||
for (var i = 0; i < $scope.nodes.length; i++) {
|
for (i = 0; i < $scope.nodes.length; i++) {
|
||||||
if ($scope.nodes[i].NodeID === nodeCfg.NodeID) {
|
if ($scope.nodes[i].NodeID === nodeCfg.NodeID) {
|
||||||
$scope.nodes[i] = nodeCfg;
|
$scope.nodes[i] = nodeCfg;
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!done) {
|
if (!done) {
|
||||||
$scope.nodes.push(nodeCfg);
|
$scope.nodes.push(nodeCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.nodes.sort(function (a, b) {
|
$scope.nodes.sort(nodeCompare);
|
||||||
if (a.NodeID < b.NodeID)
|
|
||||||
return -1;
|
|
||||||
return a.NodeID > b.NodeID;
|
|
||||||
})
|
|
||||||
|
|
||||||
$scope.config.Repositories[0].Nodes = $scope.nodes;
|
$scope.config.Repositories[0].Nodes = $scope.nodes;
|
||||||
|
|
||||||
$http.post('/rest/config', JSON.stringify($scope.config), {headers: {'Content-Type': 'application/json'}})
|
$http.post('/rest/config', JSON.stringify($scope.config), {headers: {'Content-Type': 'application/json'}});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.otherNodes = function () {
|
||||||
|
var nodes = [], i, n;
|
||||||
|
|
||||||
|
for (i = 0; i < $scope.nodes.length; i++) {
|
||||||
|
n = $scope.nodes[i];
|
||||||
|
if (n.NodeID !== $scope.myID) {
|
||||||
|
nodes.push(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.thisNode = function () {
|
||||||
|
var i, n;
|
||||||
|
|
||||||
|
for (i = 0; i < $scope.nodes.length; i++) {
|
||||||
|
n = $scope.nodes[i];
|
||||||
|
if (n.NodeID === $scope.myID) {
|
||||||
|
return [n];
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.refresh();
|
$scope.refresh();
|
||||||
@@ -241,22 +281,27 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function decimals(val, num) {
|
function decimals(val, num) {
|
||||||
if (val === 0) { return 0; }
|
var digits, decs;
|
||||||
var digits = Math.floor(Math.log(Math.abs(val))/Math.log(10));
|
|
||||||
var decimals = Math.max(0, num - digits);
|
if (val === 0) {
|
||||||
return decimals;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
digits = Math.floor(Math.log(Math.abs(val)) / Math.log(10));
|
||||||
|
decs = Math.max(0, num - digits);
|
||||||
|
return decs;
|
||||||
}
|
}
|
||||||
|
|
||||||
syncthing.filter('natural', function() {
|
syncthing.filter('natural', function () {
|
||||||
return function(input, valid) {
|
return function (input, valid) {
|
||||||
return input.toFixed(decimals(input, valid));
|
return input.toFixed(decimals(input, valid));
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
syncthing.filter('binary', function() {
|
syncthing.filter('binary', function () {
|
||||||
return function(input) {
|
return function (input) {
|
||||||
if (input === undefined) {
|
if (input === undefined) {
|
||||||
return '0 '
|
return '0 ';
|
||||||
}
|
}
|
||||||
if (input > 1024 * 1024 * 1024) {
|
if (input > 1024 * 1024 * 1024) {
|
||||||
input /= 1024 * 1024 * 1024;
|
input /= 1024 * 1024 * 1024;
|
||||||
@@ -271,13 +316,13 @@ syncthing.filter('binary', function() {
|
|||||||
return input.toFixed(decimals(input, 2)) + ' Ki';
|
return input.toFixed(decimals(input, 2)) + ' Ki';
|
||||||
}
|
}
|
||||||
return Math.round(input) + ' ';
|
return Math.round(input) + ' ';
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
syncthing.filter('metric', function() {
|
syncthing.filter('metric', function () {
|
||||||
return function(input) {
|
return function (input) {
|
||||||
if (input === undefined) {
|
if (input === undefined) {
|
||||||
return '0 '
|
return '0 ';
|
||||||
}
|
}
|
||||||
if (input > 1000 * 1000 * 1000) {
|
if (input > 1000 * 1000 * 1000) {
|
||||||
input /= 1000 * 1000 * 1000;
|
input /= 1000 * 1000 * 1000;
|
||||||
@@ -292,25 +337,25 @@ syncthing.filter('metric', function() {
|
|||||||
return input.toFixed(decimals(input, 2)) + ' k';
|
return input.toFixed(decimals(input, 2)) + ' k';
|
||||||
}
|
}
|
||||||
return Math.round(input) + ' ';
|
return Math.round(input) + ' ';
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
syncthing.filter('short', function() {
|
syncthing.filter('short', function () {
|
||||||
return function(input) {
|
return function (input) {
|
||||||
return input.substr(0, 6);
|
return input.substr(0, 6);
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
syncthing.filter('alwaysNumber', function() {
|
syncthing.filter('alwaysNumber', function () {
|
||||||
return function(input) {
|
return function (input) {
|
||||||
if (input === undefined) {
|
if (input === undefined) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return input;
|
return input;
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
syncthing.directive('optionEditor', function() {
|
syncthing.directive('optionEditor', function () {
|
||||||
return {
|
return {
|
||||||
restrict: 'C',
|
restrict: 'C',
|
||||||
replace: true,
|
replace: true,
|
||||||
@@ -320,4 +365,4 @@ syncthing.directive('optionEditor', function() {
|
|||||||
},
|
},
|
||||||
template: '<input type="text" ng-model="config.Options[setting.id]"></input>',
|
template: '<input type="text" ng-model="config.Options[setting.id]"></input>',
|
||||||
};
|
};
|
||||||
})
|
});
|
||||||
+7
-5
@@ -75,14 +75,14 @@ html, body {
|
|||||||
<table class="table table-condensed">
|
<table class="table table-condensed">
|
||||||
<tbody>
|
<tbody>
|
||||||
<!-- myself -->
|
<!-- myself -->
|
||||||
<tr class="text-muted">
|
<tr class="text-muted" ng-repeat="nodeCfg in thisNode()">
|
||||||
<td style="width:13%">
|
<td style="width:13%">
|
||||||
<span class="label label-default">
|
<span class="label label-default">
|
||||||
<span class="glyphicon glyphicon-ok"></span> This node
|
<span class="glyphicon glyphicon-ok"></span> This node
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:12%">
|
<td style="width:12%">
|
||||||
<span class="text-monospace">{{myID | short}}</span>
|
<span class="text-monospace">{{nodeName(nodeCfg)}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:20%">{{version}}</td>
|
<td style="width:20%">{{version}}</td>
|
||||||
<td style="width:25%"></td>
|
<td style="width:25%"></td>
|
||||||
@@ -98,10 +98,12 @@ html, body {
|
|||||||
<span class="text-muted glyphicon glyphicon-chevron-up"></span>
|
<span class="text-muted glyphicon glyphicon-chevron-up"></span>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:10%" class="text-right"></td>
|
<td class="text-right">
|
||||||
|
<button type="button" ng-click="editNode(nodeCfg)" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span> Edit</button>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- all other nodes -->
|
<!-- all other nodes -->
|
||||||
<tr ng-repeat="nodeCfg in nodes">
|
<tr ng-repeat="nodeCfg in otherNodes()">
|
||||||
<td>
|
<td>
|
||||||
<span class="label label-{{nodeClass(nodeCfg)}}">
|
<span class="label label-{{nodeClass(nodeCfg)}}">
|
||||||
<span class="glyphicon glyphicon-{{nodeIcon(nodeCfg)}}"></span> {{nodeStatus(nodeCfg)}}
|
<span class="glyphicon glyphicon-{{nodeIcon(nodeCfg)}}"></span> {{nodeStatus(nodeCfg)}}
|
||||||
@@ -248,7 +250,7 @@ html, body {
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="addresses">Addresses</label>
|
<label for="addresses">Addresses</label>
|
||||||
<input placeholder="dynamic" id="addresses" class="form-control" type="text" ng-model="currentNode.AddressesStr"></input>
|
<input placeholder="dynamic" ng-disabled="currentNode.NodeID == myID" id="addresses" class="form-control" type="text" ng-model="currentNode.AddressesStr"></input>
|
||||||
<p class="help-block">Enter comma separated <span class="text-monospace">ip:port</span> addresses or <span class="text-monospace">dynamic</span> to perform automatic discovery of the address.</p>
|
<p class="help-block">Enter comma separated <span class="text-monospace">ip:port</span> addresses or <span class="text-monospace">dynamic</span> to perform automatic discovery of the address.</p>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -147,6 +147,9 @@ func main() {
|
|||||||
infof("Edit %s to taste or use the GUI\n", cfgFile)
|
infof("Edit %s to taste or use the GUI\n", cfgFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure the local node is in the node list.
|
||||||
|
cfg.Repositories[0].Nodes = cleanNodeList(cfg.Repositories[0].Nodes, myID)
|
||||||
|
|
||||||
var dir = expandTilde(cfg.Repositories[0].Directory)
|
var dir = expandTilde(cfg.Repositories[0].Directory)
|
||||||
|
|
||||||
if len(profiler) > 0 {
|
if len(profiler) > 0 {
|
||||||
|
|||||||
Reference in new issue
Block a user