0
0
mirror of https://github.com/dobin/lxd-webgui synced 2025-10-05 23:52:43 +02:00

Closes #5 Added checkbox in settings module to allow send XHRs with credentials. Also take a look at LXD updates.

This commit is contained in:
18augst
2016-07-31 02:52:39 +00:00
parent 1ed71f76ec
commit b8c5675697
5 changed files with 17 additions and 6 deletions

View File

@@ -114,6 +114,7 @@ $ sudo lxc config set core.https_address 127.0.0.1:9000
$ sudo lxc config set core.https_allowed_origin https://localhost:8000
$ sudo lxc config set core.https_allowed_methods "GET, POST, PUT, DELETE, OPTIONS"
$ sudo lxc config set core.https_allowed_headers "Origin, X-Requested-With, Content-Type, Accept"
$ sudo lxc config set core.https_allowed_credentials "true"
$ sudo lxd restart
```

3
app.js
View File

@@ -19,7 +19,8 @@ angular.module('myApp', [
'myApp.profile'
]).
config(['$routeProvider', function($routeProvider) {
config(['$routeProvider', '$httpProvider', 'SettingServicesProvider', function($routeProvider, $httpProvider, SettingServicesProvider) {
$httpProvider.defaults.withCredentials = SettingServicesProvider.$get().getMyCfg()["xhr_with_credentials"];
$routeProvider.otherwise({redirectTo: '/settings'});
}]);

View File

@@ -16,7 +16,9 @@ angular.module('myApp.setting', ['ngRoute'])
}])
.controller('settingListCtrl', function ($scope, $routeParams, $filter, $location, $uibModal, $window,
.controller('settingListCtrl', [
'$http', '$scope', '$routeParams', '$filter', '$location', '$uibModal', '$window', 'SettingServices', 'myconfig',
function ($httpProvider, $scope, $routeParams, $filter, $location, $uibModal, $window,
SettingServices, myconfig)
{
$scope.myconfig = myconfig;
@@ -30,6 +32,10 @@ angular.module('myApp.setting', ['ngRoute'])
$scope.errMsg = "Could not get config from server: " + SettingServices.getLxdUrl();
});
$scope.toggle_credentials = function() {
$httpProvider.defaults.withCredentials = $scope.myconfig.xhr_with_credentials;
$scope.save();
};
$scope.save = function() {
SettingServices.setMyCfg($scope.myconfig);
@@ -54,6 +60,4 @@ angular.module('myApp.setting', ['ngRoute'])
$scope.openTab = function() {
$window.open($scope.testUrl, '_blank');
}
})
;
}]);

View File

@@ -11,7 +11,8 @@ angular.module('myApp.setting')
if (cfg == null) {
cfg = {
lxdurl: 'localhost:9000'
lxdurl: 'localhost:9000',
xhr_with_credentials: false
}
obj.setMyCfg(cfg);

View File

@@ -13,6 +13,10 @@
<div class="col-md-5">
<input size="32" type="text" ng-model="myconfig.lxdurl">
<label for="xhr_with_credentials">
<input id="xhr_with_credentials" type="checkbox" ng-model="myconfig.xhr_with_credentials" ng-change="toggle_credentials()">
Send XHRs with credentials
</label>
</div>
<div class="col-md-2">