diff --git a/luciexpress/htdocs/js/uci.js b/luciexpress/htdocs/js/uci.js index 1193d0b05..c7dbb4385 100644 --- a/luciexpress/htdocs/js/uci.js +++ b/luciexpress/htdocs/js/uci.js @@ -175,7 +175,7 @@ } }, "network": { - "ineterface": { + "interface": { "is_lan": { dvalue: 1, type: Number }, "ifname": { dvalue: "", type: String }, "proto": { dvalue: "dhcp", type: String }, diff --git a/luciexpress/htdocs/plugins/core/widgets/luci.input.ipaddress.html b/luciexpress/htdocs/plugins/core/widgets/luci.input.ipaddress.html index 69c6263f0..a1c51bc54 100644 --- a/luciexpress/htdocs/plugins/core/widgets/luci.input.ipaddress.html +++ b/luciexpress/htdocs/plugins/core/widgets/luci.input.ipaddress.html @@ -1,4 +1,4 @@ -
+
diff --git a/luciexpress/htdocs/plugins/core/widgets/luci.input.ipaddress.js b/luciexpress/htdocs/plugins/core/widgets/luci.input.ipaddress.js index 9381fe5a0..7fc726305 100644 --- a/luciexpress/htdocs/plugins/core/widgets/luci.input.ipaddress.js +++ b/luciexpress/htdocs/plugins/core/widgets/luci.input.ipaddress.js @@ -1,40 +1,39 @@ $juci.module("core") - .directive("luciInputIpAddress", function () { + .directive("luciInputIpAddress", function (gettext, $log) { var plugin_root = $juci.module("core").plugin_root; return { templateUrl: plugin_root + "/widgets/luci.input.ipaddress.html", restrict: 'E', - replace: true, scope: { id: "@", label: "@", ngModel: "=", labelClass: "@" }, - require: "ngModel", - controller: "luciInputIpAddressController" - }; - }) - .controller("luciInputIpAddressController", function($scope, $log) { - $scope.data = []; - $scope.ipAddress = ""; + require: "^ngModel", + link: function (scope, element, attrs, ctrl) { + $log.debug("scope", scope); + $log.debug("element", element); + $log.debug("attrs", attrs); + $log.debug("ctrl", ctrl); - $scope.$watch("ngModel", function(value){ - if(value && value.split){ - var parts = value.split("."); - $scope.data[0] = parts[0]||""; - $scope.data[1] = parts[1]||""; - $scope.data[2] = parts[2]||""; - $scope.data[3] = parts[3]||""; - } else { - $scope.ipAddress = value; + scope.data = []; + + console.log("MODEL VALUE: ", scope.ngModel); + if(ctrl.ngModel && ctrl.ngModel.split){ + var parts = value.split("."); + scope.data[0] = parts[0]||""; + scope.data[1] = parts[1]||""; + scope.data[2] = parts[2]||""; + scope.data[3] = parts[3]||""; + } + + scope.$watch("data", function() { + $log.debug("data", scope.data); + var ipAddress = scope.data.join('.'); + $log.debug('ip address', ipAddress); + scope.ngModel = ipAddress; + }, true); } - }); - - $scope.$watch("data", function(){ - $log.debug('data', $scope.data); - var ipAddress = $scope.data.join('.'); - $log.debug('ip address', ipAddress); - if ($scope.ngModel) $scope.ngModel = ipAddress; - }, true); + }; }); diff --git a/luciexpress/htdocs/plugins/internet/pages/internet.dns.html b/luciexpress/htdocs/plugins/internet/pages/internet.dns.html index 9ef805498..ff8c5180a 100644 --- a/luciexpress/htdocs/plugins/internet/pages/internet.dns.html +++ b/luciexpress/htdocs/plugins/internet/pages/internet.dns.html @@ -15,11 +15,11 @@

- +

- +
diff --git a/luciexpress/htdocs/plugins/internet/pages/internet.dns.js b/luciexpress/htdocs/plugins/internet/pages/internet.dns.js index 15603bef9..35290896b 100644 --- a/luciexpress/htdocs/plugins/internet/pages/internet.dns.js +++ b/luciexpress/htdocs/plugins/internet/pages/internet.dns.js @@ -1,19 +1,24 @@ $juci.module("internet") - .controller("InternetDNSPageCtrl", function ($scope, $uci) { + .controller("InternetDNSPageCtrl", function ($scope, $uci, $log) { $scope.providers = ["dyndns.org"]; + $scope.dns = { + primary: "", + secondary: "" + }; + $uci.sync("network") .done(function () { - console.log("network", $uci.network); if ($uci.network && $uci.network.wan) { + $log.info("wan", $uci.network.wan); $scope.wan = $uci.network.wan; } else { - console.error("wan network not available on box"); + $log.error("wan network not available on box"); // TODO show error message } }).fail(function () { - console.error("Could not sync network settings!"); + $log.error("Could not sync network settings!"); }) .always(function () { $scope.$apply(); @@ -27,13 +32,32 @@ $juci.module("internet") // $scope.$apply(); // }); + $scope.$watch("dns.primary", function(value){ + $log.debug("dns primary = " + value); + $log.debug("$uci.network.wan.dns.value", $uci.network.wan.dns.value); + if ($uci.network.wan.dns.value) { + $uci.network.wan.dns.value = [value]; + } else { + $uci.network.wan.dns.value = [value, ""]; + } + }); + + $scope.$watch("dns.secondary", function(value){ + $log.debug("dns secondary = " + value); + $log.debug("$uci.network.wan.dns.value", $uci.network.wan.dns.value); + if ($uci.network.wan.dns.value) { + $uci.network.wan.dns.value[1] = [value]; + } else { + $uci.network.wan.dns.value = ["", value]; + } + }); $scope.onApply = function () { $scope.busy = 1; $uci.save().done(function () { - console.log("Settings saved!"); + $log.info("Settings saved!"); }).fail(function () { - console.error("Could not save internet settings!"); + $log.error("Could not save internet settings!"); }).always(function () { $scope.$apply(); $scope.busy = 0;