mirror of
https://github.com/getredash/redash.git
synced 2026-03-22 19:00:09 -04:00
#121 fixes:
* fork your own query * better redirect after saving new query * UI fixes
This commit is contained in:
@@ -8,8 +8,10 @@
|
||||
var route = $route.current;
|
||||
|
||||
$scope.dirty = undefined;
|
||||
$scope.isNewQuery = false;
|
||||
$scope.isOwner = false;
|
||||
$scope.canEdit = false;
|
||||
$scope.canFork = false;
|
||||
|
||||
$scope.isSourceVisible = route.locals.viewSource;
|
||||
|
||||
@@ -26,8 +28,14 @@
|
||||
}
|
||||
|
||||
function updateSourceHref() {
|
||||
$scope.sourceHref = $scope.isSourceVisible ?
|
||||
$location.url().replace('source', '') : $location.path() + '/source#' + $location.hash();
|
||||
if ($scope.query && $scope.query.id) {
|
||||
$scope.sourceHref = $scope.isSourceVisible ?
|
||||
$location.url().replace('source', '') : getQuerySourceUrl($scope.query.id);
|
||||
}
|
||||
};
|
||||
|
||||
function getQuerySourceUrl(queryId) {
|
||||
return '/queries/' + queryId + '/source#' + $location.hash();
|
||||
};
|
||||
|
||||
Mousetrap.bindGlobal("meta+s", function(e) {
|
||||
@@ -54,8 +62,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$parent.pageTitle = "Query Fiddle";
|
||||
|
||||
$scope.$watch(function() {
|
||||
return $location.hash()
|
||||
}, function(hash) {
|
||||
@@ -89,25 +95,13 @@
|
||||
$scope.dirty = false;
|
||||
|
||||
if (duplicate) {
|
||||
growl.addInfoMessage("Query duplicated.", {
|
||||
ttl: 2000
|
||||
});
|
||||
growl.addSuccessMessage("Query forked");
|
||||
} else {
|
||||
growl.addSuccessMessage("Query saved.", {
|
||||
ttl: 2000
|
||||
});
|
||||
growl.addSuccessMessage("Query saved");
|
||||
}
|
||||
|
||||
if (oldId != q.id) {
|
||||
if (oldId == undefined) {
|
||||
$location.path($location.path().replace('new', q.id)).replace();
|
||||
} else {
|
||||
// TODO: replace this with a safer method
|
||||
$location.path($location.path().replace(oldId, q.id)).replace();
|
||||
|
||||
// Reset visualizations tab to table after duplicating a query:
|
||||
$location.hash(DEFAULT_TAB);
|
||||
}
|
||||
$location.url(getQuerySourceUrl(q.id)).replace();
|
||||
}
|
||||
}, function(httpResponse) {
|
||||
growl.addErrorMessage("Query could not be saved");
|
||||
@@ -209,6 +203,7 @@
|
||||
|
||||
$scope.isOwner = currentUser.canEdit($scope.query);
|
||||
$scope.canEdit = $scope.isSourceVisible && $scope.isOwner;
|
||||
$scope.canFork = true;
|
||||
|
||||
} else {
|
||||
// new query
|
||||
@@ -220,6 +215,7 @@
|
||||
});
|
||||
$scope.lockButton(false);
|
||||
$scope.isOwner = $scope.canEdit = true;
|
||||
$scope.isNewQuery = true;
|
||||
}
|
||||
|
||||
$scope.$watch('query.name', function() {
|
||||
|
||||
@@ -233,7 +233,7 @@ to add those CSS styles here. */
|
||||
-webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
|
||||
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
|
||||
}
|
||||
textarea.rd-form-control {
|
||||
.rd-form-control {
|
||||
width: 100%;
|
||||
}
|
||||
visualization-renderer > div {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
</em>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-lg-2">
|
||||
<div class="col-lg-2" ng-hide="isNewQuery">
|
||||
<a ng-href="{{sourceHref}}" ng-click="toggleSource()" class="hidden-xs pull-right">
|
||||
<span ng-show="isSourceVisible">Hide Source</span>
|
||||
<span ng-show="!isSourceVisible">View Source</span>
|
||||
@@ -63,12 +63,13 @@
|
||||
<span class="glyphicon glyphicon-indent-left"></span> Format SQL
|
||||
</button>
|
||||
<span class="pull-right">
|
||||
<button class="btn btn-info btn-xs rd-hidden-xs" ng-show="canFork" ng-click="duplicateQuery()">
|
||||
<span class="glyphicon glyphicon-share-alt"></span> Fork
|
||||
</button>
|
||||
|
||||
<button class="btn btn-success btn-xs" ng-show="canEdit" ng-click="saveQuery()">
|
||||
<span class="glyphicon glyphicon-floppy-disk"> </span> Save<span ng-show="dirty">*</span>
|
||||
</button>
|
||||
<button class="btn btn-success btn-xs rd-hidden-xs" ng-show="!canEdit" ng-click="duplicateQuery()">
|
||||
<span class="glyphicon glyphicon-share-alt"></span> Fork
|
||||
</button>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user