Skip to content

Commit

Permalink
Fix deprecated functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiarn committed Apr 29, 2023
1 parent 1233e89 commit e9eef4e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
20 changes: 10 additions & 10 deletions plugins/core/resources/js/core/services/identity.service.es
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ angular.module('core').service('identity', function($http, $location, $window, $
this.color = ajentiBootstrapColor;

this.init = () =>
$http.get('/api/core/identity').success(data => {
this.user = data.identity.user;
this.uid = data.identity.uid;
this.effective = data.identity.effective;
this.elevation_allowed = data.identity.elevation_allowed;
this.profile = data.identity.profile;
this.machine = data.machine;
this.color = data.color;
$http.get('/api/core/identity').then((resp) => {
identity = resp.data.identity;
this.user = identity.user;
this.uid = identity.uid;
this.effective = identity.effective;
this.elevation_allowed = identity.elevation_allowed;
this.profile = identity.profile;
this.machine = resp.data.machine;
this.color = resp.data.color;
this.isSuperuser = this.effective === 0;
q.resolve();
})
.error(() => q.reject());
}, () => q.reject());

this.auth = (username, password, mode) => {
let data = {
Expand Down
14 changes: 7 additions & 7 deletions plugins/plugins/resources/js/controllers/index.controller.es
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@ angular.module('ajenti.plugins').controller('PluginsIndexController', function($
}

$scope.refresh = () => {
$http.get('/api/plugins/installed').success((data) => {
$scope.installedPlugins = data;
$http.get('/api/plugins/installed').then((resp) => {
$scope.installedPlugins = resp.data;
$scope.repoList = null;
$scope.repoListOfficial = null;
$scope.repoListCommunity = null;
$http.get('/api/plugins/pypi/ajenti-plugins').success((data) => {
$scope.repoList = data;
$http.get('/api/plugins/pypi/ajenti-plugins').then((rsp) => {
$scope.repoList = rsp.data;
$scope.notInstalledRepoList = $scope.repoList.filter((x) => !$scope.isInstalled(x)).map((x) => x);
$scope.repoListOfficial = $scope.repoList.filter((x) => x.type === "official").map((x) => x);
$scope.repoListCommunity = $scope.repoList.filter((x) => x.type !== "official").map((x) => x);
}, err => {
}, (err) => {
notify.error(gettext('Could not load plugin repository'), err.message)
});
}, (err) => {
notify.error(gettext('Could not load the installed plugin list'), err.message)
});

$http.post('/api/plugins/core/check-upgrade').success(data => $scope.coreUpgradeAvailable = $scope.needUpgrade($rootScope.ajentiVersion,data));
$http.post('/api/plugins/core/check-upgrade').then((resp) => $scope.coreUpgradeAvailable = $scope.needUpgrade($rootScope.ajentiVersion, resp.data));

$scope.pypiList = null;
$http.get('/api/plugins/pypi/installed').success(data => $scope.pypiList = data);
$http.get('/api/plugins/pypi/installed').then((resp) => $scope.pypiList = resp.data);
};

$scope.refresh();
Expand Down
19 changes: 9 additions & 10 deletions plugins/settings/resources/js/controllers/index.controller.es
Original file line number Diff line number Diff line change
Expand Up @@ -151,30 +151,29 @@ angular.module('ajenti.settings').controller('SettingsIndexController', ($scope,
}).then(() => {
config.data.ssl.client_auth.force = false;
notify.info(gettext('Generating certificate'), gettext('Please wait'));
return $http.post('/api/settings/generate/server-certificate').success(function(data) {
return $http.post('/api/settings/generate/server-certificate').then(function(resp) {
notify.success(gettext('Certificate successfully generated'));
config.data.ssl.enable = true;
config.data.ssl.certificate = data.path;
config.data.ssl.certificate = resp.data.path;
config.data.ssl.client_auth.certificates = [];
$scope.save();
})
.error(err => notify.error(gettext('Certificate generation failed'), err.message));
}, (err) => notify.error(gettext('Certificate generation failed'), err.message));
})
;

$scope.generateClientCertificate = () => {
$scope.newClientCertificate.generating = true;
return $http.post('/api/settings/generate/client-certificate', $scope.newClientCertificate).success(function(data) {
return $http.post('/api/settings/generate/client-certificate', $scope.newClientCertificate).then(function(resp) {
$scope.newClientCertificate.generating = false;
$scope.newClientCertificate.generated = true;
$scope.newClientCertificate.url = $sce.trustAsUrl(`data:application/x-pkcs12;base64,${data.b64certificate}`);
$scope.newClientCertificate.url = $sce.trustAsUrl(`data:application/x-pkcs12;base64,${resp.data.b64certificate}`);
config.data.ssl.client_auth.certificates.push({
user: $scope.newClientCertificate.user,
digest: data.digest,
name: data.name,
serial: data.serial
digest: resp.data.digest,
name: resp.data.name,
serial: resp.data.serial
});
}).error((err) => {
}, (err) => {
$scope.newClientCertificate.generating = false;
$scope.newClientCertificateDialogVisible = false;
notify.error(gettext('Certificate generation failed'), err.message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ angular.module('ajenti.traffic').controller('TrafficWidgetController', ($scope,

angular.module('ajenti.traffic').controller('TrafficWidgetConfigController', ($scope, $http) => {
$scope.traffic = [];
$http.get('/api/traffic/interfaces').success(interfaces => $scope.interfaces = interfaces);
$http.get('/api/traffic/interfaces').then((resp) => $scope.interfaces = resp.data);
});

0 comments on commit e9eef4e

Please sign in to comment.