Various bug fixes. (#314)
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
angular.module('lemur')
|
||||
|
||||
.controller('DestinationsCreateController', function ($scope, $modalInstance, PluginService, DestinationService, LemurRestangular){
|
||||
.controller('DestinationsCreateController', function ($scope, $uibModalInstance, PluginService, DestinationService, LemurRestangular, toaster){
|
||||
$scope.destination = LemurRestangular.restangularizeElement(null, {}, 'destinations');
|
||||
|
||||
PluginService.getByType('destination').then(function (plugins) {
|
||||
@ -10,24 +10,38 @@ angular.module('lemur')
|
||||
});
|
||||
|
||||
$scope.save = function (destination) {
|
||||
DestinationService.create(destination).then(function () {
|
||||
$modalInstance.close();
|
||||
DestinationService.create(destination).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: destination.label,
|
||||
body: 'Successfully Created!'
|
||||
});
|
||||
$uibModalInstance.close();
|
||||
}, function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: destination.label,
|
||||
body: 'lemur-bad-request',
|
||||
bodyOutputType: 'directive',
|
||||
directiveData: response.data,
|
||||
timeout: 100000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
};
|
||||
})
|
||||
|
||||
.controller('DestinationsEditController', function ($scope, $modalInstance, DestinationService, DestinationApi, PluginService, editId) {
|
||||
.controller('DestinationsEditController', function ($scope, $uibModalInstance, DestinationService, DestinationApi, PluginService, toaster, editId) {
|
||||
DestinationApi.get(editId).then(function (destination) {
|
||||
$scope.destination = destination;
|
||||
PluginService.getByType('destination').then(function (plugins) {
|
||||
$scope.plugins = plugins;
|
||||
_.each($scope.plugins, function (plugin) {
|
||||
if (plugin.slug === $scope.destination.pluginName) {
|
||||
plugin.pluginOptions = $scope.destination.destinationOptions;
|
||||
$scope.destination.plugin = plugin;
|
||||
}
|
||||
});
|
||||
@ -35,12 +49,27 @@ angular.module('lemur')
|
||||
});
|
||||
|
||||
$scope.save = function (destination) {
|
||||
DestinationService.update(destination).then(function () {
|
||||
$modalInstance.close();
|
||||
});
|
||||
DestinationService.update(destination).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: destination.label,
|
||||
body: 'Successfully Updated!'
|
||||
});
|
||||
$uibModalInstance.close();
|
||||
}, function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: destination.label,
|
||||
body: 'lemur-bad-request',
|
||||
bodyOutputType: 'directive',
|
||||
directiveData: response.data,
|
||||
timeout: 100000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
$modalInstance.dismiss('cancel');
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
};
|
||||
});
|
||||
|
@ -3,7 +3,7 @@ angular.module('lemur')
|
||||
.service('DestinationApi', function (LemurRestangular) {
|
||||
return LemurRestangular.all('destinations');
|
||||
})
|
||||
.service('DestinationService', function ($location, DestinationApi, PluginService, toaster) {
|
||||
.service('DestinationService', function ($location, DestinationApi, PluginService) {
|
||||
var DestinationService = this;
|
||||
DestinationService.findDestinationsByName = function (filterValue) {
|
||||
return DestinationApi.getList({'filter[label]': filterValue})
|
||||
@ -13,41 +13,11 @@ angular.module('lemur')
|
||||
};
|
||||
|
||||
DestinationService.create = function (destination) {
|
||||
return DestinationApi.post(destination).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: destination.label,
|
||||
body: 'Successfully created!'
|
||||
});
|
||||
$location.path('destinations');
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: destination.label,
|
||||
body: 'Was not created! ' + response.data.message
|
||||
});
|
||||
});
|
||||
return DestinationApi.post(destination);
|
||||
};
|
||||
|
||||
DestinationService.update = function (destination) {
|
||||
return destination.put().then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: destination.label,
|
||||
body: 'Successfully updated!'
|
||||
});
|
||||
$location.path('destinations');
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: destination.label,
|
||||
body: 'Was not updated! ' + response.data.message
|
||||
});
|
||||
});
|
||||
return destination.put();
|
||||
};
|
||||
|
||||
DestinationService.getPlugin = function (destination) {
|
||||
|
@ -10,7 +10,7 @@ angular.module('lemur')
|
||||
});
|
||||
})
|
||||
|
||||
.controller('DestinationsViewController', function ($scope, $modal, DestinationApi, DestinationService, ngTableParams, toaster) {
|
||||
.controller('DestinationsViewController', function ($scope, $uibModal, DestinationApi, DestinationService, ngTableParams, toaster) {
|
||||
$scope.filter = {};
|
||||
$scope.destinationsTable = new ngTableParams({
|
||||
page: 1, // show first page
|
||||
@ -24,9 +24,6 @@ angular.module('lemur')
|
||||
getData: function ($defer, params) {
|
||||
DestinationApi.getList(params.url()).then(
|
||||
function (data) {
|
||||
_.each(data, function (destination) {
|
||||
DestinationService.getPlugin(destination);
|
||||
});
|
||||
params.total(data.total);
|
||||
$defer.resolve(data);
|
||||
}
|
||||
@ -50,7 +47,7 @@ angular.module('lemur')
|
||||
};
|
||||
|
||||
$scope.edit = function (destinationId) {
|
||||
var modalInstance = $modal.open({
|
||||
var uibModalInstance = $uibModal.open({
|
||||
animation: true,
|
||||
templateUrl: '/angular/destinations/destination/destination.tpl.html',
|
||||
controller: 'DestinationsEditController',
|
||||
@ -63,14 +60,14 @@ angular.module('lemur')
|
||||
}
|
||||
});
|
||||
|
||||
modalInstance.result.then(function () {
|
||||
uibModalInstance.result.then(function () {
|
||||
$scope.destinationsTable.reload();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.create = function () {
|
||||
var modalInstance = $modal.open({
|
||||
var uibModalInstance = $uibModal.open({
|
||||
animation: true,
|
||||
controller: 'DestinationsCreateController',
|
||||
templateUrl: '/angular/destinations/destination/destination.tpl.html',
|
||||
@ -78,7 +75,7 @@ angular.module('lemur')
|
||||
backdrop: 'static'
|
||||
});
|
||||
|
||||
modalInstance.result.then(function () {
|
||||
uibModalInstance.result.then(function () {
|
||||
$scope.destinationsTable.reload();
|
||||
});
|
||||
|
||||
|
@ -2,13 +2,28 @@
|
||||
|
||||
angular.module('lemur')
|
||||
|
||||
.controller('DomainsCreateController', function ($scope, $uibModalInstance, PluginService, DomainService, LemurRestangular){
|
||||
.controller('DomainsCreateController', function ($scope, $uibModalInstance, PluginService, DomainService, LemurRestangular, toaster){
|
||||
$scope.domain = LemurRestangular.restangularizeElement(null, {}, 'domains');
|
||||
|
||||
$scope.save = function (domain) {
|
||||
DomainService.create(domain).then(function () {
|
||||
$uibModalInstance.close();
|
||||
});
|
||||
DomainService.create(domain).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: domain,
|
||||
body: 'Successfully Created!'
|
||||
});
|
||||
$uibModalInstance.close();
|
||||
}, function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: domain,
|
||||
body: 'lemur-bad-request',
|
||||
bodyOutputType: 'directive',
|
||||
directiveData: response.data,
|
||||
timeout: 100000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
@ -16,15 +31,30 @@ angular.module('lemur')
|
||||
};
|
||||
})
|
||||
|
||||
.controller('DomainsEditController', function ($scope, $uibModalInstance, DomainService, DomainApi, editId) {
|
||||
.controller('DomainsEditController', function ($scope, $uibModalInstance, DomainService, DomainApi, toaster, editId) {
|
||||
DomainApi.get(editId).then(function (domain) {
|
||||
$scope.domain = domain;
|
||||
});
|
||||
|
||||
$scope.save = function (domain) {
|
||||
DomainService.update(domain).then(function () {
|
||||
$uibModalInstance.close();
|
||||
});
|
||||
DomainService.update(domain).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: domain,
|
||||
body: 'Successfully Created!'
|
||||
});
|
||||
$uibModalInstance.close();
|
||||
}, function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: domain,
|
||||
body: 'lemur-bad-request',
|
||||
bodyOutputType: 'directive',
|
||||
directiveData: response.data,
|
||||
timeout: 100000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
angular.module('lemur')
|
||||
|
||||
.controller('NotificationsCreateController', function ($scope, $uibModalInstance, PluginService, NotificationService, CertificateService, LemurRestangular){
|
||||
.controller('NotificationsCreateController', function ($scope, $uibModalInstance, PluginService, NotificationService, CertificateService, LemurRestangular, toaster){
|
||||
$scope.notification = LemurRestangular.restangularizeElement(null, {}, 'notifications');
|
||||
|
||||
PluginService.getByType('notification').then(function (plugins) {
|
||||
@ -11,12 +11,22 @@ angular.module('lemur')
|
||||
$scope.save = function (notification) {
|
||||
NotificationService.create(notification).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: notification.label,
|
||||
body: 'Successfully Created!'
|
||||
});
|
||||
$uibModalInstance.close();
|
||||
},
|
||||
function () {
|
||||
|
||||
}
|
||||
);
|
||||
}, function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: notification.label,
|
||||
body: 'lemur-bad-request',
|
||||
bodyOutputType: 'directive',
|
||||
directiveData: response.data,
|
||||
timeout: 100000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
@ -26,7 +36,7 @@ angular.module('lemur')
|
||||
$scope.certificateService = CertificateService;
|
||||
})
|
||||
|
||||
.controller('NotificationsEditController', function ($scope, $uibModalInstance, NotificationService, NotificationApi, PluginService, CertificateService, editId) {
|
||||
.controller('NotificationsEditController', function ($scope, $uibModalInstance, NotificationService, NotificationApi, PluginService, CertificateService, toaster, editId) {
|
||||
NotificationApi.get(editId).then(function (notification) {
|
||||
$scope.notification = notification;
|
||||
PluginService.getByType('notification').then(function (plugins) {
|
||||
@ -52,9 +62,24 @@ angular.module('lemur')
|
||||
});
|
||||
|
||||
$scope.save = function (notification) {
|
||||
NotificationService.update(notification).then(function () {
|
||||
$uibModalInstance.close();
|
||||
});
|
||||
NotificationService.update(notification).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: notification.label,
|
||||
body: 'Successfully Created!'
|
||||
});
|
||||
$uibModalInstance.close();
|
||||
}, function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: notification.label,
|
||||
body: 'lemur-bad-request',
|
||||
bodyOutputType: 'directive',
|
||||
directiveData: response.data,
|
||||
timeout: 100000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
|
@ -17,7 +17,7 @@ angular.module('lemur')
|
||||
});
|
||||
return LemurRestangular.all('notifications');
|
||||
})
|
||||
.service('NotificationService', function ($location, NotificationApi, PluginService, toaster) {
|
||||
.service('NotificationService', function ($location, NotificationApi, PluginService) {
|
||||
var NotificationService = this;
|
||||
NotificationService.findNotificationsByName = function (filterValue) {
|
||||
return NotificationApi.getList({'filter[label]': filterValue})
|
||||
@ -48,59 +48,15 @@ angular.module('lemur')
|
||||
};
|
||||
|
||||
NotificationService.create = function (notification) {
|
||||
return NotificationApi.post(notification).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: notification.label,
|
||||
body: 'Successfully created!'
|
||||
});
|
||||
$location.path('notifications');
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: notification.label,
|
||||
body: 'Was not created! ' + response.data.message
|
||||
});
|
||||
});
|
||||
return NotificationApi.post(notification);
|
||||
};
|
||||
|
||||
NotificationService.update = function (notification) {
|
||||
return notification.put().then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: notification.label,
|
||||
body: 'Successfully updated!'
|
||||
});
|
||||
$location.path('notifications');
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: notification.label,
|
||||
body: 'Was not updated! ' + response.data.message
|
||||
});
|
||||
});
|
||||
return notification.put();
|
||||
};
|
||||
|
||||
NotificationService.updateActive = function (notification) {
|
||||
notification.put().then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: notification.name,
|
||||
body: 'Successfully updated!'
|
||||
});
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: notification.name,
|
||||
body: 'Was not updated! ' + response.data.message
|
||||
});
|
||||
});
|
||||
notification.put();
|
||||
};
|
||||
return NotificationService;
|
||||
});
|
||||
|
44
lemur/static/app/angular/roles/role/role.js
vendored
44
lemur/static/app/angular/roles/role/role.js
vendored
@ -2,15 +2,30 @@
|
||||
|
||||
angular.module('lemur')
|
||||
|
||||
.controller('RolesEditController', function ($scope, $uibModalInstance, RoleApi, RoleService, UserService, editId) {
|
||||
.controller('RolesEditController', function ($scope, $uibModalInstance, RoleApi, RoleService, UserService, toaster, editId) {
|
||||
RoleApi.get(editId).then(function (role) {
|
||||
$scope.role = role;
|
||||
RoleService.getUsers(role);
|
||||
});
|
||||
|
||||
$scope.save = function (role) {
|
||||
RoleService.update(role).then(function () {
|
||||
$uibModalInstance.close();
|
||||
RoleService.update(role).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: role.name,
|
||||
body: 'Successfully Created!'
|
||||
});
|
||||
$uibModalInstance.close();
|
||||
}, function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: role.name,
|
||||
body: 'lemur-bad-request',
|
||||
bodyOutputType: 'directive',
|
||||
directiveData: response.data,
|
||||
timeout: 100000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -28,14 +43,29 @@ angular.module('lemur')
|
||||
$scope.roleService = RoleService;
|
||||
})
|
||||
|
||||
.controller('RolesCreateController', function ($scope,$uibModalInstance, RoleApi, RoleService, UserService, LemurRestangular) {
|
||||
.controller('RolesCreateController', function ($scope,$uibModalInstance, RoleApi, RoleService, UserService, LemurRestangular, toaster) {
|
||||
$scope.role = LemurRestangular.restangularizeElement(null, {}, 'roles');
|
||||
$scope.userService = UserService;
|
||||
|
||||
$scope.save = function (role) {
|
||||
RoleService.create(role).then(function () {
|
||||
$uibModalInstance.close();
|
||||
});
|
||||
RoleService.create(role).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: role.name,
|
||||
body: 'Successfully Created!'
|
||||
});
|
||||
$uibModalInstance.close();
|
||||
}, function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: role.name,
|
||||
body: 'lemur-bad-request',
|
||||
bodyOutputType: 'directive',
|
||||
directiveData: response.data,
|
||||
timeout: 100000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
|
72
lemur/static/app/angular/roles/services.js
vendored
72
lemur/static/app/angular/roles/services.js
vendored
@ -18,7 +18,7 @@ angular.module('lemur')
|
||||
});
|
||||
return LemurRestangular.all('roles');
|
||||
})
|
||||
.service('RoleService', function ($location, RoleApi, toaster) {
|
||||
.service('RoleService', function ($location, RoleApi) {
|
||||
var RoleService = this;
|
||||
RoleService.findRoleByName = function (filterValue) {
|
||||
return RoleApi.getList({'filter[name]': filterValue})
|
||||
@ -48,80 +48,18 @@ angular.module('lemur')
|
||||
};
|
||||
|
||||
RoleService.create = function (role) {
|
||||
return RoleApi.post(role).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: role.name,
|
||||
body: 'Has been successfully created!'
|
||||
});
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: role.name,
|
||||
body: 'Has not been created! ' + response.data.message
|
||||
});
|
||||
});
|
||||
return RoleApi.post(role);
|
||||
};
|
||||
|
||||
RoleService.update = function (role) {
|
||||
return role.put().then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: role.name,
|
||||
body: 'Successfully updated!'
|
||||
});
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: role.name,
|
||||
body: 'Was not updated!' + response.data.message
|
||||
});
|
||||
});
|
||||
return role.put();
|
||||
};
|
||||
|
||||
RoleService.remove = function (role) {
|
||||
return role.remove().then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: role.name,
|
||||
body: 'Successfully deleted!'
|
||||
});
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: role.name,
|
||||
body: 'Was not deleted!' + response.data.message
|
||||
});
|
||||
}
|
||||
);
|
||||
return role.remove();
|
||||
};
|
||||
|
||||
RoleService.loadPassword = function (role) {
|
||||
return role.customGET('credentials').then(
|
||||
function (response) {
|
||||
if ( response.password === null) {
|
||||
toaster.pop({
|
||||
type: 'info',
|
||||
title: role.name,
|
||||
body: 'Has no password associated'
|
||||
});
|
||||
} else {
|
||||
role.password = response.password;
|
||||
role.username = response.username;
|
||||
}
|
||||
},
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: role.name,
|
||||
body: 'You do not have permission to view this password!'
|
||||
});
|
||||
});
|
||||
return role.customGET('credentials');
|
||||
};
|
||||
});
|
||||
|
36
lemur/static/app/angular/sources/services.js
vendored
36
lemur/static/app/angular/sources/services.js
vendored
@ -3,7 +3,7 @@ angular.module('lemur')
|
||||
.service('SourceApi', function (LemurRestangular) {
|
||||
return LemurRestangular.all('sources');
|
||||
})
|
||||
.service('SourceService', function ($location, SourceApi, PluginService, toaster) {
|
||||
.service('SourceService', function ($location, SourceApi, PluginService) {
|
||||
var SourceService = this;
|
||||
SourceService.findSourcesByName = function (filterValue) {
|
||||
return SourceApi.getList({'filter[label]': filterValue})
|
||||
@ -13,41 +13,11 @@ angular.module('lemur')
|
||||
};
|
||||
|
||||
SourceService.create = function (source) {
|
||||
return SourceApi.post(source).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: source.label,
|
||||
body: 'Successfully created!'
|
||||
});
|
||||
$location.path('sources');
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: source.label,
|
||||
body: 'Was not created! ' + response.data.message
|
||||
});
|
||||
});
|
||||
return SourceApi.post(source);
|
||||
};
|
||||
|
||||
SourceService.update = function (source) {
|
||||
return source.put().then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: source.label,
|
||||
body: 'Successfully updated!'
|
||||
});
|
||||
$location.path('sources');
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: source.label,
|
||||
body: 'Was not updated! ' + response.data.message
|
||||
});
|
||||
});
|
||||
return source.put();
|
||||
};
|
||||
|
||||
SourceService.getPlugin = function (source) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
angular.module('lemur')
|
||||
|
||||
.controller('SourcesCreateController', function ($scope, $uibModalInstance, PluginService, SourceService, LemurRestangular){
|
||||
.controller('SourcesCreateController', function ($scope, $uibModalInstance, PluginService, SourceService, LemurRestangular, toaster){
|
||||
$scope.source = LemurRestangular.restangularizeElement(null, {}, 'sources');
|
||||
|
||||
PluginService.getByType('source').then(function (plugins) {
|
||||
@ -10,9 +10,24 @@ angular.module('lemur')
|
||||
});
|
||||
|
||||
$scope.save = function (source) {
|
||||
SourceService.create(source).then(function () {
|
||||
$uibModalInstance.close();
|
||||
});
|
||||
SourceService.create(source).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: source.label,
|
||||
body: 'Successfully Created!'
|
||||
});
|
||||
$uibModalInstance.close();
|
||||
}, function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: source.label,
|
||||
body: 'lemur-bad-request',
|
||||
bodyOutputType: 'directive',
|
||||
directiveData: response.data,
|
||||
timeout: 100000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
@ -20,14 +35,13 @@ angular.module('lemur')
|
||||
};
|
||||
})
|
||||
|
||||
.controller('SourcesEditController', function ($scope, $uibModalInstance, SourceService, SourceApi, PluginService, editId) {
|
||||
.controller('SourcesEditController', function ($scope, $uibModalInstance, SourceService, SourceApi, PluginService, toaster, editId) {
|
||||
SourceApi.get(editId).then(function (source) {
|
||||
$scope.source = source;
|
||||
PluginService.getByType('source').then(function (plugins) {
|
||||
$scope.plugins = plugins;
|
||||
_.each($scope.plugins, function (plugin) {
|
||||
if (plugin.slug === $scope.source.pluginName) {
|
||||
plugin.pluginOptions = $scope.source.sourceOptions;
|
||||
$scope.source.plugin = plugin;
|
||||
}
|
||||
});
|
||||
@ -38,15 +52,29 @@ angular.module('lemur')
|
||||
$scope.plugins = plugins;
|
||||
_.each($scope.plugins, function (plugin) {
|
||||
if (plugin.slug === $scope.source.pluginName) {
|
||||
plugin.pluginOptions = $scope.source.sourceOptions;
|
||||
$scope.source.plugin = plugin;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$scope.save = function (source) {
|
||||
SourceService.update(source).then(function () {
|
||||
$uibModalInstance.close();
|
||||
SourceService.update(source).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: source.label,
|
||||
body: 'Successfully Updated!'
|
||||
});
|
||||
$uibModalInstance.close();
|
||||
}, function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: source.label,
|
||||
body: 'lemur-bad-request',
|
||||
bodyOutputType: 'directive',
|
||||
directiveData: response.data,
|
||||
timeout: 100000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -24,9 +24,6 @@ angular.module('lemur')
|
||||
getData: function ($defer, params) {
|
||||
SourceApi.getList(params.url()).then(
|
||||
function (data) {
|
||||
_.each(data, function (source) {
|
||||
SourceService.getPlugin(source);
|
||||
});
|
||||
params.total(data.total);
|
||||
$defer.resolve(data);
|
||||
}
|
||||
|
36
lemur/static/app/angular/users/services.js
vendored
36
lemur/static/app/angular/users/services.js
vendored
@ -20,7 +20,7 @@ angular.module('lemur')
|
||||
});
|
||||
return LemurRestangular.all('users');
|
||||
})
|
||||
.service('UserService', function ($location, UserApi, AuthenticationApi, toaster) {
|
||||
.service('UserService', function ($location, UserApi, AuthenticationApi) {
|
||||
var UserService = this;
|
||||
UserService.getCurrentUser = function () {
|
||||
return AuthenticationApi.customGET('me').then(function (user) {
|
||||
@ -50,40 +50,10 @@ angular.module('lemur')
|
||||
};
|
||||
|
||||
UserService.create = function (user) {
|
||||
return UserApi.post(user).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: user.username,
|
||||
body: 'Has been successfully created!'
|
||||
});
|
||||
$location.path('users');
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: user.username,
|
||||
body: 'Has not been created!' + response.data.message
|
||||
});
|
||||
});
|
||||
return UserApi.post(user);
|
||||
};
|
||||
|
||||
UserService.update = function (user) {
|
||||
return user.put().then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: user.username,
|
||||
body: 'Has been successfully updated!'
|
||||
});
|
||||
$location.path('users');
|
||||
},
|
||||
function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: user.username,
|
||||
body: 'Has not been updated!' + response.data.message
|
||||
});
|
||||
});
|
||||
return user.put();
|
||||
};
|
||||
});
|
||||
|
46
lemur/static/app/angular/users/user/user.js
vendored
46
lemur/static/app/angular/users/user/user.js
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
angular.module('lemur')
|
||||
|
||||
.controller('UsersEditController', function ($scope, $uibModalInstance, UserApi, UserService, RoleService, editId) {
|
||||
.controller('UsersEditController', function ($scope, $uibModalInstance, UserApi, UserService, RoleService, toaster, editId) {
|
||||
UserApi.get(editId).then(function (user) {
|
||||
UserService.getRoles(user);
|
||||
$scope.user = user;
|
||||
@ -15,9 +15,24 @@ angular.module('lemur')
|
||||
|
||||
|
||||
$scope.save = function (user) {
|
||||
UserService.update(user).then(function () {
|
||||
$uibModalInstance.close();
|
||||
});
|
||||
UserService.update(user).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: user.username,
|
||||
body: 'Successfully Updated!'
|
||||
});
|
||||
$uibModalInstance.close();
|
||||
}, function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: user.username,
|
||||
body: 'lemur-bad-request',
|
||||
bodyOutputType: 'directive',
|
||||
directiveData: response.data,
|
||||
timeout: 100000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
@ -30,15 +45,30 @@ angular.module('lemur')
|
||||
};
|
||||
})
|
||||
|
||||
.controller('UsersCreateController', function ($scope, $uibModalInstance, UserService, LemurRestangular, RoleService) {
|
||||
.controller('UsersCreateController', function ($scope, $uibModalInstance, UserService, LemurRestangular, RoleService, toaster) {
|
||||
$scope.user = LemurRestangular.restangularizeElement(null, {}, 'users');
|
||||
$scope.save = UserService.create;
|
||||
$scope.roleService = RoleService;
|
||||
|
||||
$scope.create = function (user) {
|
||||
UserService.create(user).then(function () {
|
||||
$uibModalInstance.close();
|
||||
});
|
||||
UserService.create(user).then(
|
||||
function () {
|
||||
toaster.pop({
|
||||
type: 'success',
|
||||
title: user.username,
|
||||
body: 'Successfully Created!'
|
||||
});
|
||||
$uibModalInstance.close();
|
||||
}, function (response) {
|
||||
toaster.pop({
|
||||
type: 'error',
|
||||
title: user.username,
|
||||
body: 'lemur-bad-request',
|
||||
bodyOutputType: 'directive',
|
||||
directiveData: response.data,
|
||||
timeout: 100000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
|
10
lemur/static/app/angular/users/view/view.js
vendored
10
lemur/static/app/angular/users/view/view.js
vendored
@ -10,7 +10,7 @@ angular.module('lemur')
|
||||
});
|
||||
})
|
||||
|
||||
.controller('UsersViewController', function ($scope, $modal, UserApi, UserService, ngTableParams) {
|
||||
.controller('UsersViewController', function ($scope, $uibModal, UserApi, UserService, ngTableParams) {
|
||||
$scope.filter = {};
|
||||
$scope.usersTable = new ngTableParams({
|
||||
page: 1, // show first page
|
||||
@ -38,7 +38,7 @@ angular.module('lemur')
|
||||
};
|
||||
|
||||
$scope.edit = function (userId) {
|
||||
var modalInstance = $modal.open({
|
||||
var uibModalInstance = $uibModal.open({
|
||||
animation: true,
|
||||
templateUrl: '/angular/users/user/user.tpl.html',
|
||||
controller: 'UsersEditController',
|
||||
@ -51,14 +51,14 @@ angular.module('lemur')
|
||||
}
|
||||
});
|
||||
|
||||
modalInstance.result.then(function () {
|
||||
uibModalInstance.result.then(function () {
|
||||
$scope.usersTable.reload();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.create = function () {
|
||||
var modalInstance = $modal.open({
|
||||
var uibModalInstance = $uibModal.open({
|
||||
animation: true,
|
||||
controller: 'UsersCreateController',
|
||||
templateUrl: '/angular/users/user/user.tpl.html',
|
||||
@ -66,7 +66,7 @@ angular.module('lemur')
|
||||
backdrop: 'static'
|
||||
});
|
||||
|
||||
modalInstance.result.then(function () {
|
||||
uibModalInstance.result.then(function () {
|
||||
$scope.usersTable.reload();
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user