Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FED issue #1 [r=arikfr] #47

Merged
merged 3 commits into from
Dec 31, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 53 additions & 14 deletions rd_ui/app/scripts/app.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,58 @@
angular.module('redash', ['redash.directives', 'redash.admin_controllers', 'redash.controllers', 'redash.filters', 'redash.services',
'redash.renderers',
'ui.codemirror', 'highchart', 'angular-growl', 'angularMoment', 'ui.bootstrap', 'smartTable.table', 'ngResource']).
config(['$routeProvider', '$locationProvider', '$compileProvider', function ($routeProvider, $locationProvider, $compileProvider) {
angular.module('redash', [
'redash.directives',
'redash.admin_controllers',
'redash.controllers',
'redash.filters',
'redash.services',
'redash.renderers',
'ui.codemirror',
'highchart',
'angular-growl',
'angularMoment',
'ui.bootstrap',
'smartTable.table',
'ngResource'
]).config(['$routeProvider', '$locationProvider', '$compileProvider', 'growlProvider',
function($routeProvider, $locationProvider, $compileProvider, growlProvider) {

$compileProvider.urlSanitizationWhitelist(/^\s*(https?|http|data):/);

$locationProvider.html5Mode(true);
$routeProvider.when('/dashboard/:dashboardSlug', {templateUrl: '/views/dashboard.html', controller: 'DashboardCtrl'});
$routeProvider.when('/queries', {templateUrl: '/views/queries.html', controller: 'QueriesCtrl', reloadOnSearch: false});
$routeProvider.when('/queries/new', {templateUrl: '/views/queryfiddle.html', controller: 'QueryFiddleCtrl', reloadOnSearch: false});
$routeProvider.when('/queries/:queryId', {templateUrl: '/views/queryfiddle.html', controller: 'QueryFiddleCtrl', reloadOnSearch: false});
$routeProvider.when('/admin/status', {templateUrl: '/views/admin_status.html', controller: 'AdminStatusCtrl'});
$routeProvider.when('/', {templateUrl: '/views/index.html', controller: 'IndexCtrl'});
$routeProvider.otherwise({redirectTo: '/'});
growlProvider.globalTimeToLive(2000);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only real change in this file (everything else is whitespace)


Highcharts.setOptions({colors: ["#4572A7", "#AA4643", "#89A54E", "#80699B", "#3D96AE", "#DB843D", "#92A8CD", "#A47D7C", "#B5CA92"]});
}]);
$routeProvider.when('/dashboard/:dashboardSlug', {
templateUrl: '/views/dashboard.html',
controller: 'DashboardCtrl'
});
$routeProvider.when('/queries', {
templateUrl: '/views/queries.html',
controller: 'QueriesCtrl',
reloadOnSearch: false
});
$routeProvider.when('/queries/new', {
templateUrl: '/views/queryfiddle.html',
controller: 'QueryFiddleCtrl',
reloadOnSearch: false
});
$routeProvider.when('/queries/:queryId', {
templateUrl: '/views/queryfiddle.html',
controller: 'QueryFiddleCtrl',
reloadOnSearch: false
});
$routeProvider.when('/admin/status', {
templateUrl: '/views/admin_status.html',
controller: 'AdminStatusCtrl'
});
$routeProvider.when('/', {
templateUrl: '/views/index.html',
controller: 'IndexCtrl'
});
$routeProvider.otherwise({
redirectTo: '/'
});

Highcharts.setOptions({
colors: ["#4572A7", "#AA4643", "#89A54E", "#80699B", "#3D96AE",
"#DB843D", "#92A8CD", "#A47D7C", "#B5CA92"]
});
}
]);
33 changes: 30 additions & 3 deletions rd_ui/app/scripts/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,23 @@
$scope.updateTime = '';
}

var QueryFiddleCtrl = function ($scope, $routeParams, $http, $location, growl, notifications, Query) {
var QueryFiddleCtrl = function ($scope, $window, $routeParams, $http, $location, growl, notifications, Query) {
var leavingPageText = "You will lose your changes if you leave";
var pristineQuery = null;

$window.onbeforeunload = function(){
if ($scope.queryChanged) {
return leavingPageText;
}
}

$scope.$on('$locationChangeStart', function(event, next, current) {
if($scope.queryChanged &&
!confirm(leavingPageText + "\n\nAre you sure you want to leave this page?")) {
event.preventDefault();
}
});

$scope.$parent.pageTitle = "Query Fiddle";

$scope.tabs = [{'key': 'table', 'name': 'Table'}, {'key': 'chart', 'name': 'Chart'},
Expand All @@ -54,6 +70,9 @@
}
delete $scope.query.latest_query_data;
$scope.query.$save(function (q) {
pristineQuery = q.query;
$scope.queryChanged = false;

if (duplicate) {
growl.addInfoMessage("Query duplicated.", {ttl: 2000});
} else{
Expand All @@ -68,6 +87,8 @@
$location.path($location.path().replace(oldId, q.id)).replace();
}
}
}, function(httpResponse) {
growl.addErrorMessage("Query could not be saved");
});
};

Expand Down Expand Up @@ -142,7 +163,8 @@
});

if ($routeParams.queryId != undefined) {
$scope.query = Query.get({id: $routeParams.queryId}, function() {
$scope.query = Query.get({id: $routeParams.queryId}, function(q) {
pristineQuery = q.query;
$scope.queryResult = $scope.query.getQueryResult();
});
} else {
Expand All @@ -153,6 +175,11 @@
$scope.$watch('query.name', function() {
$scope.$parent.pageTitle = $scope.query.name;
});
$scope.$watch('query.query', function(q) {
if (q) {
$scope.queryChanged = (q != pristineQuery);
}
});

$scope.executeQuery = function() {
$scope.queryResult = $scope.query.getQueryResult(0);
Expand Down Expand Up @@ -320,7 +347,7 @@
.controller('DashboardCtrl', ['$scope', '$routeParams', '$http', 'Dashboard', DashboardCtrl])
.controller('WidgetCtrl', ['$scope', '$http', 'Query', WidgetCtrl])
.controller('QueriesCtrl', ['$scope', '$http', '$location', '$filter', 'Query', QueriesCtrl])
.controller('QueryFiddleCtrl', ['$scope', '$routeParams', '$http', '$location', 'growl', 'notifications', 'Query', QueryFiddleCtrl])
.controller('QueryFiddleCtrl', ['$scope', '$window', '$routeParams', '$http', '$location', 'growl', 'notifications', 'Query', QueryFiddleCtrl])
.controller('IndexCtrl', ['$scope', 'Dashboard', IndexCtrl])
.controller('MainCtrl', ['$scope', 'Dashboard', 'notifications', MainCtrl]);
})();
1 change: 1 addition & 0 deletions rd_ui/app/styles/redash.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ a.navbar-brand {
right: 10px;
float: right;
width: 250px;
z-index: 10000;
}

.growl-item.ng-enter,
Expand Down
4 changes: 3 additions & 1 deletion rd_ui/app/views/queryfiddle.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ <h3 class="panel-title">

<div class="btn-group pull-right">
<button type="button" class="btn btn-default" ng-click="duplicateQuery()">Duplicate</button>
<button type="button" class="btn btn-default" ng-disabled="currentUser.name != query.user" ng-click="saveQuery()">Save</button>
<button type="button" class="btn btn-default" ng-disabled="currentUser.name != query.user" ng-click="saveQuery()">Save
<span ng-show="queryChanged">&#42;</span>
</button>
<button type="button" class="btn btn-primary" ng-disabled="queryExecuting" ng-click="executeQuery()">Execute</button>
</div>
</div>
Expand Down