mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
Fixed internet pages
This commit is contained in:
parent
fc50bd3ed1
commit
456b5c03e4
5 changed files with 59 additions and 36 deletions
|
|
@ -175,7 +175,7 @@
|
|||
}
|
||||
},
|
||||
"network": {
|
||||
"ineterface": {
|
||||
"interface": {
|
||||
"is_lan": { dvalue: 1, type: Number },
|
||||
"ifname": { dvalue: "", type: String },
|
||||
"proto": { dvalue: "dhcp", type: String },
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<div class="form-group" class="col-md-6" ng-class="{ 'field-error': ngModel.error }" data-toggle="tooltip" data-placement="top" title="{{ngModel.error}}">
|
||||
<div class="form-group" class="col-md-6">
|
||||
<div class="col-md-5">
|
||||
<label class="{{labelClass}}">{{label|translate}}</label>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@
|
|||
<div ng-show="wan.peerdns.value == 1">
|
||||
<br/>
|
||||
<div class="col-md-12">
|
||||
<luci-input-ip-address id="firstDNSAddress" ng-model="wan.dns.value[0]" label="Domain Name Server (DNS) Address" label-class="detail-strong-input" />
|
||||
<luci-input-ip-address id="firstDNSAddress" ng-model="dns.primary" label="Domain Name Server (DNS) Address" label-class="detail-strong-input" />
|
||||
</div>
|
||||
<hr class="col-md-12"/>
|
||||
<div class="col-md-12">
|
||||
<luci-input-ip-address id="secondDNSAddress" ng-model="wan.dns.value[1]" label="Secondary DNS Address (optional)" label-class="detail-strong-input" />
|
||||
<luci-input-ip-address id="secondDNSAddress" ng-model="dns.secondary" label="Secondary DNS Address (optional)" label-class="detail-strong-input" />
|
||||
</div>
|
||||
</div>
|
||||
</luci-config-lines>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue