Milimetric has submitted this change and it was merged.
Change subject: added aggregation UI
......................................................................
added aggregation UI
Change-Id: Iccd2d4d3c1d36c8417c6ac16b0697cb9be5ca76a
---
M wikimetrics/static/css/site.css
M wikimetrics/static/js/reportCreate.js
M wikimetrics/static/js/site.js
D wikimetrics/templates/forms/output_configuration.html
M wikimetrics/templates/report.html
5 files changed, 138 insertions(+), 10 deletions(-)
Approvals:
Milimetric: Verified; Looks good to me, approved
diff --git a/wikimetrics/static/css/site.css b/wikimetrics/static/css/site.css
index bd510b2..9be2546 100644
--- a/wikimetrics/static/css/site.css
+++ b/wikimetrics/static/css/site.css
@@ -31,11 +31,17 @@
/* creating a new report */
+div.pick-cohorts .navbar-search { margin: 16px 0 0 0; }
+div.pick-cohorts .cohorts { margin: 14px 0 0 14px; max-height: 160px;
overflow-x: hide; overflow-y: auto; }
+div.pick-metrics, .sample-result { background-color: #fff; }
+div.pick-metrics .tabbable, .sample-result .tabbable { margin: 22px 0 0 0; }
td.blur-completely { text-shadow: 0 0 20px rgba(0,0,0,0.6); color:
transparent; }
-.pick-cohorts .navbar-search { margin: 16px 0 0 0; }
-.pick-cohorts .cohorts { margin: 14px 0 0 14px; max-height: 160px; overflow-x:
hide; overflow-y: auto; }
-.pick-metrics, .sample-result { background-color: #fff; }
-.pick-metrics .tabbable, .sample-result .tabbable { margin: 22px 0 0 0; }
+
+table.sample-results tbody.totals { border-top: 3px solid #000000; }
+table.sample-results tbody.totals td {
+ background-color: white !important;
+ font-weight: bold;
+}
/* uploading a cohort */
diff --git a/wikimetrics/static/js/reportCreate.js
b/wikimetrics/static/js/reportCreate.js
index 8c502eb..8b690ee 100644
--- a/wikimetrics/static/js/reportCreate.js
+++ b/wikimetrics/static/js/reportCreate.js
@@ -35,6 +35,7 @@
},
save: function(formElement){
+
if (site.hasValidationErrors()){
site.showWarning('Please configure and click Save
Configuration for each selected metric.');
return;
@@ -45,9 +46,24 @@
site.showWarning('Please select at least one cohort and one
metric.');
return;
}
+
+ var metricsWithoutOutput = {};
+ ko.utils.arrayForEach(vm.request().responses(), function(response){
+ if (!response.metric.outputConfigured()){
+ metricsWithoutOutput[response.metric.label] = true;
+ }
+ });
+ metricsWithoutOutput = site.keys(metricsWithoutOutput);
+
+ if (metricsWithoutOutput.length){
+ site.showWarning(metricsWithoutOutput.join(', ') + ' do not
have any output selected.');
+ return;
+ }
+
var form = $(formElement);
var data = ko.toJSON(vm.request().responses);
data = JSON.parse(data);
+
ko.utils.arrayForEach(data, function(response){
delete response.metric.configure;
delete response.cohort.wikiusers;
@@ -95,6 +111,7 @@
setTabIds(data.metrics, 'metric');
setSelected(data.metrics);
setConfigure(data.metrics);
+ setAggregationOptions(data.metrics);
viewModel.metrics(data.metrics);
}))
.fail(site.failure);
@@ -112,8 +129,6 @@
return metric.selected();
});
}, viewModel).extend({ throttle: 1 }),
-
- aggregators: ko.observable([]),
});
// second level computed pieces of the viewModel
@@ -162,6 +177,28 @@
});
};
+ function setAggregationOptions(list){
+ bareList = ko.utils.unwrapObservable(list);
+ ko.utils.arrayForEach(bareList, function(item){
+ item.individualResults = ko.observable(true);
+ item.aggregateResults = ko.observable(false);
+ item.aggregateSum = ko.observable(false);
+ item.aggregateAverage = ko.observable(false);
+ item.aggregateStandardDeviation = ko.observable(false);
+ item.outputConfigured = ko.computed(function(){
+ return this.individualResults()
+ || (
+ this.aggregateResults()
+ && (
+ this.aggregateSum()
+ || this.aggregateAverage()
+ || this.aggregateStandardDeviation()
+ )
+ );
+ }, item);
+ });
+ };
+
function setTabIds(list, prefix){
if (!prefix) {
prefix = 'should-be-unique';
diff --git a/wikimetrics/static/js/site.js b/wikimetrics/static/js/site.js
index 9923cb8..340e9fc 100644
--- a/wikimetrics/static/js/site.js
+++ b/wikimetrics/static/js/site.js
@@ -101,4 +101,20 @@
}))
.fail(site.failure);
},
+
+ // ***********************************************************
+ // Just some util functions so I don't have to
+ // import huge libraries like Underscore
+ // ***********************************************************
+ keys: function(obj){
+ var keys = [];
+
+ for(var key in obj){
+ if(obj.hasOwnProperty(key)){
+ keys.push(key);
+ }
+ }
+
+ return keys;
+ },
};
diff --git a/wikimetrics/templates/forms/output_configuration.html
b/wikimetrics/templates/forms/output_configuration.html
deleted file mode 100644
index e69de29..0000000
--- a/wikimetrics/templates/forms/output_configuration.html
+++ /dev/null
diff --git a/wikimetrics/templates/report.html
b/wikimetrics/templates/report.html
index e444c4a..107c1d1 100644
--- a/wikimetrics/templates/report.html
+++ b/wikimetrics/templates/report.html
@@ -45,6 +45,56 @@
</div>
</div>
</div>
+<div class="well pick-metrics">
+ <div class="navbar-inner">
+ <h3>Configure Output</h3>
+ </div>
+ <div class="tabbable tabs-left">
+ <ul class="nav nav-tabs" data-bind="foreach: request().metrics">
+ <li>
+ <a data-bind="attr: {href: tabIdSelector() + '-a'}, text:
label" data-toggle="tab">
+ </a>
+ </li>
+ </ul>
+ <div class="tab-content" data-bind="foreach: request().metrics">
+ <div class="tab-pane form-horizontal" data-bind="attr: {id:
tabId() + '-a'}">
+ <div class="control-group">
+ <label class="control-label" data-bind="attr: {for:
tabId() + '-a-ind'}">Individual Results</label>
+ <div class="controls">
+ <input type="checkbox" data-bind="checked:
individualResults, attr: {id: tabId() + '-a-ind'}"/>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" data-bind="attr: {for:
tabId() + '-a-agg'}">Aggregate Results</label>
+ <div class="controls">
+ <input type="checkbox" data-bind="checked:
aggregateResults, attr: {id: tabId() + '-a-agg'}"/>
+
+ <div data-bind="if: aggregateResults">
+ <div class="control-group">
+ <label class="control-label" data-bind="attr:
{for: tabId() + '-a-sum'}">Sum</label>
+ <div class="controls">
+ <input type="checkbox" data-bind="checked:
aggregateSum, attr: {id: tabId() + '-a-sum'}"/>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" data-bind="attr:
{for: tabId() + '-a-avg'}">Average</label>
+ <div class="controls">
+ <input type="checkbox" data-bind="checked:
aggregateAverage, attr: {id: tabId() + '-a-avg'}"/>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" data-bind="attr:
{for: tabId() + '-a-std'}">Standard Deviation</label>
+ <div class="controls">
+ <input type="checkbox" data-bind="checked:
aggregateStandardDeviation, attr: {id: tabId() + '-a-std'}"/>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
<div class="well sample-result">
<div class="navbar-inner">
<h3>Sample Result</h3>
@@ -57,22 +107,41 @@
</ul>
<div class="tab-content" data-bind="foreach: request().responses">
<div class="tab-pane" data-bind="attr: {id: tabId}">
- <table class="table table-striped">
+ <table class="table table-striped sample-results">
<thead>
<tr>
<th>Name</th>
- <th>Id</th>
<th>Project</th>
<th data-bind="text: metric.label"></th>
</tr>
</thead>
- <tbody data-bind="foreach: cohort.wikiusers">
+ <tbody data-bind="if: metric.individualResults">
+ <!-- ko foreach: cohort.wikiusers -->
<tr>
<td data-bind="text: mediawiki_username"></td>
- <td data-bind="text: mediawiki_userid"></td>
<td data-bind="text: project"></td>
<td class="blur-completely">123.45</td>
</tr>
+ <!-- /ko -->
+ </tbody>
+ <tbody class="totals" data-bind="if:
metric.aggregateResults">
+ <tr data-bind="if: metric.aggregateSum">
+ <td colspan="2">Sum</td>
+ <td class="blur-completely">123.45</td>
+ </tr>
+ <tr data-bind="if: metric.aggregateAverage">
+ <td colspan="2">Average</td>
+ <td class="blur-completely">123.45</td>
+ </tr>
+ <tr data-bind="if: metric.aggregateStandardDeviation">
+ <td colspan="2">Standard Deviation</td>
+ <td class="blur-completely">123.45</td>
+ </tr>
+ </tbody>
+ <tbody data-bind="if: !metric.outputConfigured()">
+ <tr>
+ <td colspan="3">You should select some type of
output for this metric. Check the section above</td>
+ </tr>
</tbody>
</table>
</div>
--
To view, visit https://gerrit.wikimedia.org/r/76742
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iccd2d4d3c1d36c8417c6ac16b0697cb9be5ca76a
Gerrit-PatchSet: 1
Gerrit-Project: analytics/wikimetrics
Gerrit-Branch: master
Gerrit-Owner: Milimetric <[email protected]>
Gerrit-Reviewer: Milimetric <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits