diff --git a/migrations/0023_add_notification_destination.py b/migrations/0023_add_notification_destination.py index 6bdf87c4f..68a44dfbf 100644 --- a/migrations/0023_add_notification_destination.py +++ b/migrations/0023_add_notification_destination.py @@ -52,7 +52,7 @@ if __name__ == '__main__': hipchat = NotificationDestination.create( org=1, user=1, - name="Hipchat", + name="HipChat", type="hipchat", options=options ) diff --git a/rd_ui/app/scripts/controllers/data_sources.js b/rd_ui/app/scripts/controllers/data_sources.js index 522ab360c..cec140be9 100644 --- a/rd_ui/app/scripts/controllers/data_sources.js +++ b/rd_ui/app/scripts/controllers/data_sources.js @@ -7,7 +7,7 @@ }; - var DataSourceCtrl = function ($scope, $routeParams, $http, $location, Events, DataSource) { + var DataSourceCtrl = function ($scope, $routeParams, $http, $location, growl, Events, DataSource) { Events.record(currentUser, "view", "page", "admin/data_source"); $scope.$parent.pageTitle = "Data Sources"; @@ -24,9 +24,21 @@ $location.path('/data_sources/' + id).replace(); } }); + + $scope.delete = function () { + Events.record(currentUser, "delete", "datasource", $scope.dataSource.id); + + $scope.dataSource.$delete(function (resource) { + growl.addSuccessMessage("Data source deleted successfully."); + $location.path('/data_sources/'); + }.bind(this), function (httpResponse) { + console.log("Failed to delete data source: ", httpResponse.status, httpResponse.statusText, httpResponse.data); + growl.addErrorMessage("Failed to delete data source."); + }); + } }; angular.module('redash.controllers') .controller('DataSourcesCtrl', ['$scope', '$location', 'growl', 'Events', 'DataSource', DataSourcesCtrl]) - .controller('DataSourceCtrl', ['$scope', '$routeParams', '$http', '$location', 'Events', 'DataSource', DataSourceCtrl]) + .controller('DataSourceCtrl', ['$scope', '$routeParams', '$http', '$location', 'growl', 'Events', 'DataSource', DataSourceCtrl]) })(); diff --git a/rd_ui/app/scripts/controllers/destinations.js b/rd_ui/app/scripts/controllers/destinations.js index 5a4f3122f..28474e6ac 100644 --- a/rd_ui/app/scripts/controllers/destinations.js +++ b/rd_ui/app/scripts/controllers/destinations.js @@ -5,24 +5,9 @@ $scope.destinations = Destination.query(); - $scope.openDestination = function(destination) { - $location.path('/destinations/' + destination.id); - }; - - $scope.deleteDestination = function(event, destination) { - event.stopPropagation(); - Events.record(currentUser, "delete", "destination", destination.id); - destination.$delete(function(resource) { - growl.addSuccessMessage("Destination deleted successfully."); - this.$parent.destinations = _.without(this.destinations, resource); - }.bind(this), function(httpResponse) { - console.log("Failed to delete destination: ", httpResponse.status, httpResponse.statusText, httpResponse.data); - growl.addErrorMessage("Failed to delete destination."); - }); - } }; - var DestinationCtrl = function ($scope, $routeParams, $http, $location, Events, Destination) { + var DestinationCtrl = function ($scope, $routeParams, $http, $location, growl, Events, Destination) { Events.record(currentUser, "view", "page", "admin/destination"); $scope.$parent.pageTitle = "Destinations"; @@ -39,9 +24,21 @@ $location.path('/destinations/' + id).replace(); } }); + + $scope.delete = function() { + Events.record(currentUser, "delete", "destination", $scope.destination.id); + + $scope.destination.$delete(function(resource) { + growl.addSuccessMessage("Destination deleted successfully."); + $location.path('/destinations/'); + }.bind(this), function(httpResponse) { + console.log("Failed to delete destination: ", httpResponse.status, httpResponse.statusText, httpResponse.data); + growl.addErrorMessage("Failed to delete destination."); + }); + } }; angular.module('redash.controllers') .controller('DestinationsCtrl', ['$scope', '$location', 'growl', 'Events', 'Destination', DestinationsCtrl]) - .controller('DestinationCtrl', ['$scope', '$routeParams', '$http', '$location', 'Events', 'Destination', DestinationCtrl]) + .controller('DestinationCtrl', ['$scope', '$routeParams', '$http', '$location', 'growl', 'Events', 'Destination', DestinationCtrl]) })(); diff --git a/rd_ui/app/scripts/directives/directives.js b/rd_ui/app/scripts/directives/directives.js index e7a4595c5..fef6a423f 100644 --- a/rd_ui/app/scripts/directives/directives.js +++ b/rd_ui/app/scripts/directives/directives.js @@ -389,9 +389,8 @@ return { restrict: 'E', replace: 'true', - templateUrl: function(elem, attr) { - return '/views/' + attr.type+ '/form.html'; - }, + transclude: true, + templateUrl: '/views/directives/dynamic_form.html', scope: { 'target': '=', 'type': '@type' @@ -487,10 +486,12 @@ scope.usersPage = _.string.startsWith($location.path(), '/users'); scope.groupsPage = _.string.startsWith($location.path(), '/groups'); scope.dsPage = _.string.startsWith($location.path(), '/data_sources'); + scope.destinationsPage = _.string.startsWith($location.path(), '/destinations'); scope.showGroupsLink = currentUser.hasPermission('list_users'); scope.showUsersLink = currentUser.hasPermission('list_users'); scope.showDsLink = currentUser.hasPermission('admin'); + scope.showDestinationsLink = currentUser.hasPermission('admin'); } } }]); diff --git a/rd_ui/app/styles/redash.css b/rd_ui/app/styles/redash.css index bb4cd99ef..c93fc193f 100644 --- a/rd_ui/app/styles/redash.css +++ b/rd_ui/app/styles/redash.css @@ -566,7 +566,6 @@ div.table-name:hover { padding-right: 5px; } -<<<<<<< HEAD .modal-xl { position: fixed; top: 0; diff --git a/rd_ui/app/views/alerts/edit.html b/rd_ui/app/views/alerts/edit.html index c8bb69e0f..6daf61e7a 100644 --- a/rd_ui/app/views/alerts/edit.html +++ b/rd_ui/app/views/alerts/edit.html @@ -20,7 +20,6 @@ -<<<<<<< HEAD