diff --git a/rd_ui/app/scripts/app.js b/rd_ui/app/scripts/app.js index f9031edcd29..f59c3528e87 100644 --- a/rd_ui/app/scripts/app.js +++ b/rd_ui/app/scripts/app.js @@ -43,9 +43,14 @@ angular.module('redash', [ reloadOnSearch: false }); $routeProvider.when('/queries/new', { - templateUrl: '/views/queryfiddle.html', - controller: 'QueryFiddleCtrl', - reloadOnSearch: false + templateUrl: '/views/queryview.html', + controller: 'QueryViewCtrl', + reloadOnSearch: false, + resolve: { + 'viewSource': function isViewSource() { + return true; + } + } }); // TODO // we should have 2 controllers: queryViewCtrl and queryEditCtrl @@ -62,7 +67,7 @@ angular.module('redash', [ controller: 'QueryFiddleCtrl', reloadOnSearch: false }); - $routeProvider.when('/queries/:queryId/src', { + $routeProvider.when('/queries/:queryId/source', { templateUrl: '/views/queryview.html', controller: 'QueryViewCtrl', reloadOnSearch: false, diff --git a/rd_ui/app/scripts/controllers/query_view.js b/rd_ui/app/scripts/controllers/query_view.js index bb6cf81ac39..85652679bdb 100644 --- a/rd_ui/app/scripts/controllers/query_view.js +++ b/rd_ui/app/scripts/controllers/query_view.js @@ -3,7 +3,7 @@ var QueryViewCtrl = function($scope, $window, $route, $http, $location, growl, notifications, Query, Visualization) { var DEFAULT_TAB = 'table'; - var pristineHash = null; + var pristineHash = ""; var leavingPageText = "You will lose your changes if you leave"; var route = $route.current; @@ -27,7 +27,7 @@ function updateSourceHref() { $scope.sourceHref = $scope.isSourceVisible ? - $location.url().replace('src', '') : $location.path() + '/src#' + $location.hash(); + $location.url().replace('source', '') : $location.path() + '/source#' + $location.hash(); }; Mousetrap.bindGlobal("meta+s", function(e) { @@ -219,6 +219,7 @@ user: currentUser }); $scope.lockButton(false); + $scope.isOwner = $scope.canEdit = true; } $scope.$watch('query.name', function() { @@ -248,6 +249,7 @@ Visualization.delete(vis); if ($scope.selectedTab == vis.id) { $scope.selectedTab = DEFAULT_TAB; + $location.hash($scope.selectedTab); } $scope.query.visualizations = $scope.query.visualizations.filter(function(v) { diff --git a/rd_ui/app/scripts/directives.js b/rd_ui/app/scripts/directives.js index 636856903c2..2fed6f5e7de 100644 --- a/rd_ui/app/scripts/directives.js +++ b/rd_ui/app/scripts/directives.js @@ -238,9 +238,7 @@ // ng-click handler to activate edit-in-place $scope.edit = function () { - if ($scope.ignoreBlanks) { - $scope.oldValue = $scope.value; - } + $scope.oldValue = $scope.value; $scope.editing = true; @@ -261,7 +259,9 @@ $scope.editing = false; element.removeClass('active'); - $scope.done && $scope.done(); + if ($scope.value !== $scope.oldValue) { + $scope.done && $scope.done(); + } } } diff --git a/rd_ui/app/styles/redash.css b/rd_ui/app/styles/redash.css index 1e4afd3e1ff..e022784fed0 100644 --- a/rd_ui/app/styles/redash.css +++ b/rd_ui/app/styles/redash.css @@ -27,7 +27,7 @@ a.navbar-brand { } .edit-in-place span { - white-space: pre; + white-space: pre-line; } .edit-in-place span.editable { cursor: pointer; diff --git a/rd_ui/app/views/queryview.html b/rd_ui/app/views/queryview.html index 0ec79117a67..c4a0d89a2d2 100644 --- a/rd_ui/app/views/queryview.html +++ b/rd_ui/app/views/queryview.html @@ -2,22 +2,28 @@
-

- +
+
+

+ +

+

+ + + +

+
+ +
- - Source - -

- - -
-

- {{ query.description }} -

Last update @@ -32,6 +38,12 @@

Rows {{queryResult.getData().length}}

+

+ + Hide Source + View Source + +