Various bug fixes. (#314)
This commit is contained in:
@ -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
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user