Skip to content

Commit

Permalink
Merge pull request #421 from EverythingMe/fix/issue_417
Browse files Browse the repository at this point in the history
Feature: show visualization name next to query name (#418)
  • Loading branch information
arikfr committed May 8, 2015
2 parents e1c4093 + 0f022ab commit bf5fe7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 33 deletions.
50 changes: 17 additions & 33 deletions rd_ui/app/scripts/visualizations/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@
}];
};

var VisualizationName = function(Visualization) {
return {
restrict: 'E',
scope: {
visualization: '='
},
template: '<small>{{name}}</small>',
replace: false,
link: function (scope) {
if (Visualization.visualizations[scope.visualization.type].name != scope.visualization.name) {
scope.name = scope.visualization.name;
}
}
}
}

var VisualizationRenderer = function ($location, Visualization) {
return {
restrict: 'E',
Expand All @@ -72,42 +88,9 @@
width: '50%'
};

function readURL() {
var searchFilters = angular.fromJson($location.search().filters);
if (searchFilters) {
_.forEach(scope.filters, function(filter) {
var value = searchFilters[filter.friendlyName];
if (value) {
filter.current = value;
}
});
}
}

function updateURL(filters) {
var current = {};
_.each(filters, function(filter) {
if (filter.current) {
current[filter.friendlyName] = filter.current;
}
});

var newSearch = angular.extend($location.search(), {
filters: angular.toJson(current)
});
$location.search(newSearch);
}

scope.$watch('queryResult && queryResult.getFilters()', function (filters) {
if (filters) {
scope.filters = filters;

if (filters.length && false) {
readURL();

// start watching for changes and update URL
scope.$watch('filters', updateURL, true);
}
}
});
}
Expand Down Expand Up @@ -208,6 +191,7 @@
.provider('Visualization', VisualizationProvider)
.directive('visualizationRenderer', ['$location', 'Visualization', VisualizationRenderer])
.directive('visualizationOptionsEditor', ['Visualization', VisualizationOptionsEditor])
.directive('visualizationName', ['Visualization', VisualizationName])
.directive('filters', Filters)
.directive('editVisulatizationForm', ['Events', 'Visualization', 'growl', EditVisualizationForm])
})();
1 change: 1 addition & 0 deletions rd_ui/app/views/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ <h3 class="panel-title">
<p>
<span ng-hide="currentUser.hasPermission('view_query')">{{query.name}}</span>
<query-link query="query" visualization="widget.visualization" ng-show="currentUser.hasPermission('view_query')"></query-link>
<visualization-name visualization="widget.visualization"/>
</p>
<div class="text-muted" ng-bind-html="query.description | markdown"></div>
</h3>
Expand Down

0 comments on commit bf5fe7d

Please sign in to comment.