Skip to content

Commit

Permalink
Added unique count to stacked grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
r0goyal committed Dec 2, 2016
1 parent 5667440 commit 1b168d1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
7 changes: 7 additions & 0 deletions foxtrot-server/src/main/resources/console/index.htm
Expand Up @@ -659,6 +659,13 @@ <h4 class="modal-title" id="setupStackedChartModalLabel">Setup Stacked Bar Chart
</div>
</div>

<div class="form-group">
<label class="col-sm-4 control-label"><strong>Generate Unique Of</strong></label>
<div class="col-sm-8">
<select class="selectpicker" data-live-search="true" id="stacked-unique-field" data-style="btn-warning" required></select>
</div>
</div>

<div class="form-group">
<label class="col-sm-4 control-label"
for="stacked_selected_filters"><strong>Filters</strong></label>
Expand Down
Expand Up @@ -25,6 +25,7 @@ function Stacked() {

this.stackingKey = null;
this.groupingKey = null;
this.uniqueCountOn = null;
}

Stacked.prototype = new Tile();
Expand Down Expand Up @@ -179,7 +180,8 @@ Stacked.prototype.getQuery = function () {
opcode: "group",
table: table,
filters: filters,
nesting: [this.groupingKey, this.stackingKey]
nesting: [this.groupingKey, this.stackingKey],
uniqueCountOn: this.uniqueCountOn && this.uniqueCountOn != "none" ? this.uniqueCountOn : null,
});
}
};
Expand All @@ -199,6 +201,7 @@ Stacked.prototype.configChanged = function () {
this.periodValue = parseInt(modal.find(".tile-time-value").first().val());
this.stackingKey = modal.find(".stacked-stacking-key").first().val();
this.groupingKey = modal.find(".stacked-grouping-key").first().val();
this.uniqueCountOn = modal.find("#stacked-unique-field").val();

var filters = modal.find(".selected-filters").val();
if (filters != undefined && filters != "") {
Expand Down Expand Up @@ -243,6 +246,24 @@ Stacked.prototype.loadFieldList = function () {
}
grouping_select.selectpicker('refresh');
}.bind(this));

var unique_field_select = modal.find("#stacked-unique-field");
unique_field_select.find('option').remove();
unique_field_select.append('<option value="none">None</option>');

this.tables.loadTableMeta(selected_table, function () {
console.log("callback function called");
for (var i = selected_table.mappings.length - 1; i >= 0; i--) {
unique_field_select.append('<option>' + selected_table.mappings[i].field + '</option>');
}

if (this.uniqueCountOn) {
unique_field_select.val(this.uniqueCountOn);
} else {
unique_field_select.val("none");
}
unique_field_select.selectpicker('refresh');
}.bind(this));
};

Stacked.prototype.populateSetupDialog = function () {
Expand Down Expand Up @@ -278,6 +299,7 @@ Stacked.prototype.registerSpecificData = function (representation) {
representation['periodValue'] = this.periodValue;
representation['stackingKey'] = this.stackingKey;
representation['groupingKey'] = this.groupingKey;
representation['uniqueCountOn'] = this.uniqueCountOn;
if (this.selectedFilters) {
representation['selectedFilters'] = btoa(JSON.stringify(this.selectedFilters));
}
Expand Down

0 comments on commit 1b168d1

Please sign in to comment.