Skip to content

Commit

Permalink
Merge pull request #468 from EverythingMe/fix/visualization_api
Browse files Browse the repository at this point in the history
Fix: visualizations API fixes
  • Loading branch information
arikfr committed Jul 2, 2015
2 parents e6650e1 + 0b61b88 commit 2dab35b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
7 changes: 4 additions & 3 deletions rd_ui/app/scripts/visualizations/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
query: '=',
queryResult: '=',
visualization: '=?',
openEditor: '=?',
openEditor: '@',
onNewSuccess: '=?'
},
link: function (scope, element, attrs) {
Expand Down Expand Up @@ -150,9 +150,10 @@
scope.$watch('visualization.type', function (type, oldType) {
// if not edited by user, set name to match type
if (type && oldType != type && scope.visualization && !scope.visForm.name.$dirty) {
// poor man's titlecase
scope.visualization.name = scope.visualization.type[0] + scope.visualization.type.slice(1).toLowerCase();
scope.visualization.name = _.string.titleize(scope.visualization.type);
}

scope.visualization.options = Visualization.visualizations[scope.visualization.type].defaultOptions;
});

scope.submit = function () {
Expand Down
8 changes: 4 additions & 4 deletions rd_ui/app/scripts/visualizations/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
'</map-renderer>';

var editTemplate = '<map-editor></map-editor>';
var defaultOptions = { 'height': 500 };
var defaultOptions = {
'height': 500,
'draw': 'Marker'
};

VisualizationProvider.registerVisualization({
type: 'MAP',
Expand Down Expand Up @@ -227,9 +230,6 @@
link: function($scope, elm, attrs) {
$scope.visualization.options.draw_options = ['Marker','Color'];
$scope.visualization.options.classify_columns = $scope.queryResult.columnNames.concat('none');

//FIXME: The following line should be removed when defaultOptions work
$scope.visualization.options.height = $scope.visualization.options.height || 500;
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion rd_ui/app/views/visualizations/edit_visualization.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div>
<span ng-click="openEditor=!openEditor" class="details-toggle" ng-class="{open: openEditor}">Edit</span>

<form ng-if="openEditor" role="form" name="visForm" ng-submit="submit()">
<form ng-show="openEditor" role="form" name="visForm" ng-submit="submit()">
<div class="form-group">
<label class="control-label">Name</label>
<input name="name" type="text" class="form-control" ng-model="visualization.name" placeholder="{{visualization.type | capitalize}}">
Expand Down
9 changes: 7 additions & 2 deletions redash/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import logging

from flask import render_template, send_from_directory, make_response, request, jsonify, redirect, \
session, url_for
session, url_for, current_app
from flask.ext.restful import Resource, abort
from flask_login import current_user, login_user, logout_user
import sqlparse
Expand Down Expand Up @@ -547,7 +547,12 @@ def delete(self, job_id):

@app.route('/<path:filename>')
def send_static(filename):
return send_from_directory(settings.STATIC_ASSETS_PATH, filename)
if current_app.debug:
cache_timeout = 0
else:
cache_timeout = None

return send_from_directory(settings.STATIC_ASSETS_PATH, filename, cache_timeout=cache_timeout)


if __name__ == '__main__':
Expand Down

0 comments on commit 2dab35b

Please sign in to comment.