From a6f527bd51350775fe70d4ae1ef0e66154559149 Mon Sep 17 00:00:00 2001 From: Amir Nissim Date: Tue, 11 Mar 2014 12:28:00 +0200 Subject: [PATCH] #121 More UI issues: * source as link instead of button * fix source link when url has a hash * new query uses the new layout * rename url /src => /source... * when deleting a visualization update the hash * don't submit title/description if it hasn't changed * mobile: fix description field wrapping --- rd_ui/app/scripts/app.js | 13 +++++--- rd_ui/app/scripts/controllers/query_view.js | 6 ++-- rd_ui/app/scripts/directives.js | 8 ++--- rd_ui/app/styles/redash.css | 2 +- rd_ui/app/views/queryview.html | 36 ++++++++++++++------- 5 files changed, 42 insertions(+), 23 deletions(-) diff --git a/rd_ui/app/scripts/app.js b/rd_ui/app/scripts/app.js index f9031edc..f59c3528 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 bb6cf81a..85652679 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 63685690..2fed6f5e 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 1e4afd3e..e022784f 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 0ec79117..c4a0d89a 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 + +