diff --git a/src/js/client.js b/src/js/client.js index ea6c4d996..17fe1d915 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -962,7 +962,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.setIPv6Config = function (config, callback) { - post('/api/v1/settings/ipv6', config, null, function (error, data, status) { + post('/api/v1/settings/ipv6_config', config, null, function (error, data, status) { if (error) return callback(error); if (status !== 200) return callback(new ClientError(status, data)); callback(null); @@ -970,7 +970,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.getIPv6Config = function (callback) { - get('/api/v1/settings/ipv6', null, function (error, data, status) { + get('/api/v1/settings/ipv6_config', null, function (error, data, status) { if (error) return callback(error); if (status !== 200) return callback(new ClientError(status, data)); diff --git a/src/translation/en.json b/src/translation/en.json index 20a4afcce..01ba26473 100644 --- a/src/translation/en.json +++ b/src/translation/en.json @@ -741,7 +741,10 @@ "ipv6": { "address": "IPv6 Address", "title": "IPv6", - "description": "Enable this option to configure DNS AAAA records for the apps and the mail server." + "description": "Cloudron uses this IPv6 address to setup DNS AAAA records.\n" + }, + "configureIpv6": { + "title": "Configure IPv6 Provider" } }, "services": { diff --git a/src/views/network.html b/src/views/network.html index 8fbb3138d..ede1650d5 100644 --- a/src/views/network.html +++ b/src/views/network.html @@ -9,12 +9,12 @@
- +
- {{ 'network.configureIp.providerGenericDescription' | tr }} + {{ 'network.configureIp.providerGenericDescription' | tr }}
@@ -23,11 +23,6 @@

{{ sysinfo.error.ipv4 }}

-
- - -

{{ sysinfo.error.ipv6 }}

-
@@ -75,11 +70,58 @@
+ + +

{{ 'network.title' | tr }}

+

{{ 'network.ip.title' | tr }}

@@ -97,7 +139,7 @@ {{ 'network.ip.provider' | tr }}
- {{ prettySysinfoProviderName(sysinfo.provider) }} + {{ prettyIpProviderName(sysinfo.provider) }}
@@ -111,16 +153,6 @@ -
-
- {{ 'network.ipv6.address' | tr }} -
-
- {{ sysinfo.ipv6 }} - {{ sysinfo.serverIPv6 }} ({{ 'network.ip.detected' | tr }}) -
-
-
{{ 'network.ip.interface' | tr }} @@ -139,6 +171,7 @@
+

{{ 'network.firewall.title' | tr }}

@@ -154,22 +187,52 @@ +

{{ 'network.ipv6.title' | tr }}

-
-

{{ 'network.ipv6.description' | tr }}

-


{{ ipv6Configure.error }}

+
+ {{ 'network.ipv6.description' | tr }}
+
-
- - +
+ {{ 'network.ip.provider' | tr }} +
+
+ {{ prettyIpProviderName(ipv6Configure.provider) }} +
+
+ +
+
+ {{ 'network.ip.address' | tr }} +
+
+ {{ ipv6Configure.ipv6 }} + {{ ipv6Configure.serverIPv6 }} ({{ 'network.ip.detected' | tr }}) +
+
+ +
+
+ {{ 'network.ip.interface' | tr }} +
+
+ {{ ipv6Configure.ifname }} +
+
+ +
+ +
+
+
diff --git a/src/views/network.js b/src/views/network.js index 0c060e4ed..41b32d6f1 100644 --- a/src/views/network.js +++ b/src/views/network.js @@ -16,8 +16,16 @@ angular.module('Application').controller('NetworkController', ['$scope', '$locat { name: 'Network Interface', value: 'network-interface' } ]; - $scope.prettySysinfoProviderName = function (provider) { + $scope.ipv6ConfigureProvider = [ + { name: 'Disabled', value: 'noop' }, + { name: 'Public IP', value: 'generic' }, + { name: 'Static IP Address', value: 'fixed' }, + { name: 'Network Interface', value: 'network-interface' } + ]; + + $scope.prettyIpProviderName = function (provider) { switch (provider) { + case 'noop': return 'Disabled'; case 'generic': return 'Public IP'; case 'fixed': return 'Static IP Address'; case 'network-interface': return 'Network Interface'; @@ -53,26 +61,79 @@ angular.module('Application').controller('NetworkController', ['$scope', '$locat $scope.ipv6Configure = { busy: false, - error: '', - isEnabled: false, + error: {}, + + serverIPv6: '', + + provider: '', + ipv6: '', + ifname: '', + + // configure dialog + newProvider: '', + newIPv6: '', + newIfname: '', refresh: function () { - Client.getIPv6Config(function (error, enabled) { + Client.getIPv6Config(function (error, result) { if (error) return console.error(error); - $scope.ipv6Configure.isEnabled = enabled; + $scope.ipv6Configure.provider = result.provider; + $scope.ipv6Configure.ipv6 = result.ipv6 || ''; + $scope.ipv6Configure.ifname = result.ifname || ''; + if (result.provider === 'noop') return; + + Client.getServerIpv6(function (error, result) { + if (error) return console.error(error); + + $scope.ipv6Configure.serverIPv6 = result.ipv6; + }); }); }, - setEnabled: function (enabled) { + show: function () { + $scope.ipv6Configure.error = {}; + $scope.ipv6Configure.newProvider = $scope.ipv6Configure.provider; + $scope.ipv6Configure.newIPv6 = $scope.ipv6Configure.ipv6; + $scope.ipv6Configure.newIfname = $scope.ipv6Configure.ifname; + + $('#ipv6ConfigureModal').modal('show'); + }, + + submit: function () { + $scope.ipv6Configure.error = {}; $scope.ipv6Configure.busy = true; - $scope.ipv6Configure.error = ''; - Client.setIPv6Config(enabled, function (error) { + var config = { + provider: $scope.ipv6Configure.newProvider + }; + + if (config.provider === 'fixed') { + config.ipv4 = $scope.ipv6Configure.newIPv4; + } else if (config.provider === 'network-interface') { + config.ifname = $scope.ipv6Configure.newIfname; + } + + Client.setIPv6Config(config, function (error) { $scope.ipv6Configure.busy = false; + if (error && error.message.indexOf('ipv') !== -1) { + $scope.ipv6Configure.error.ipv6 = error.message; + $scope.ipv6ConfigureForm.$setPristine(); + $scope.ipv6ConfigureForm.$setUntouched(); + return; + } else if (error && (error.message.indexOf('interface') !== -1 || error.message.indexOf('IPv6') !== -1)) { + $scope.ipv6Configure.error.ifname = error.message; + $scope.ipv6ConfigureForm.$setPristine(); + $scope.ipv6ConfigureForm.$setUntouched(); + return; + } else if (error) { + console.error(error); + return; + } - if (error) $scope.ipv6Configure.error = error.message; - else $scope.ipv6Configure.isEnabled = enabled; + $scope.ipv6Configure.refresh(); + + $('#ipv6ConfigureModal').modal('hide'); }); } };