Skip to content

Commit

Permalink
Merge pull request #318 from shankari/cleanup_data_models
Browse files Browse the repository at this point in the history
Minor UI improvements to bring them in line with the phone UI
  • Loading branch information
shankari authored Jul 17, 2016
2 parents 8a525c9 + d8cd339 commit 11d2250
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
5 changes: 5 additions & 0 deletions webapp/www/js/heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ angular.module('starter.heatmap', ['ui-leaflet'])
});

$scope.getPopRoute = function() {
$ionicLoading.show({
template: 'Loading...'
});
var data = {
modes: $scope.selectCtrl.modes,
from_local_date: $scope.selectCtrl.fromDate,
Expand All @@ -30,13 +33,15 @@ angular.module('starter.heatmap', ['ui-leaflet'])
console.log("Sending data "+JSON.stringify(data));
$http.post("/result/heatmap/pop.route", data)
.then(function(response) {
$ionicLoading.hide();
if (angular.isDefined(response.data.lnglat)) {
console.log("Got points in heatmap "+response.data.lnglat.length);
$scope.showHeatmap(response.data.lnglat);
} else {
console.log("did not find latlng in response data "+JSON.stringify(response.data));
}
}, function(error) {
$ionicLoading.hide();
console.log("Got error %s while trying to read heatmap data" +
JSON.stringify(error));
});
Expand Down
31 changes: 29 additions & 2 deletions webapp/www/js/metrics.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular.module('starter.metrics', ['nvd3'])

.controller('MetricsCtrl', function($scope, $ionicActionSheet, $http) {
.controller('MetricsCtrl', function($scope, $ionicActionSheet, $ionicLoading, $http) {
$scope.options = {
chart: {
type: 'multiBarChart',
Expand Down Expand Up @@ -48,14 +48,18 @@ angular.module('starter.metrics', ['nvd3'])

$scope.getMetrics = function() {
var data = {
freq: 'DAILY',
freq: $scope.selectCtrl.freq,
start_time: $scope.selectCtrl.fromDate,
end_time: $scope.selectCtrl.toDate,
metric: $scope.selectCtrl.metric
};
console.log("Sending data "+JSON.stringify(data));
$ionicLoading.show({
template: 'Loading...'
});
$http.post("/result/metrics/local_date", data)
.then(function(response) {
$ionicLoading.hide();
if (angular.isDefined(response.data.aggregate_metrics)) {
console.log("Got aggregate result "+response.data.aggregate_metrics.length);
$scope.showCharts(response.data.aggregate_metrics)
Expand All @@ -64,6 +68,7 @@ angular.module('starter.metrics', ['nvd3'])
console.log("did not find aggregate result in response data "+JSON.stringify(response.data));
}
}, function(error) {
$ionicLoading.hide();
console.log("Got error %s while trying to read metric data" +
JSON.stringify(error));
});
Expand Down Expand Up @@ -107,6 +112,12 @@ angular.module('starter.metrics', ['nvd3'])
{text: "MEDIAN_SPEED", value: 'median_speed'}
];

$scope.freqOptions = [
{text: "DAILY", value:'DAILY'},
{text: "MONTHLY", value: 'MONTHLY'},
{text: "YEARLY", value: 'YEARLY'}
];

$scope.changeFromWeekday = function() {
return $scope.changeWeekday(function(newVal) {
$scope.selectCtrl.fromDateWeekdayString = newVal;
Expand Down Expand Up @@ -157,11 +168,27 @@ angular.module('starter.metrics', ['nvd3'])
});
};

$scope.changeFreq = function() {
$ionicActionSheet.show({
buttons: $scope.freqOptions,
titleText: "Select summary freq",
cancelText: "Cancel",
buttonClicked: function(index, button) {
$scope.selectCtrl.freqString = button.text;
$scope.selectCtrl.freq = button.value;
return true;
}
});
};


var initSelect = function() {
var now = moment();
var monthago = moment().subtract(3, 'M');
$scope.selectCtrl.metric = 'count';
$scope.selectCtrl.metricString = "COUNT";
$scope.selectCtrl.freq = 'MONTHLY';
$scope.selectCtrl.freqString = "MONTHLY";
$scope.selectCtrl.fromDate = moment2Localdate(monthago)
$scope.selectCtrl.toDate = moment2Localdate(now);
$scope.selectCtrl.fromDateWeekdayString = "All"
Expand Down
8 changes: 6 additions & 2 deletions webapp/www/templates/metrics.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<ion-view view-title="Metrics">
<ion-content class="has-header padding">
<div class="row">
<div class="col col-25">
<div class="col col-20">
<button class="button button-stable button-block row"
ng-click="changeMetric()">{{selectCtrl.metricString}}</button>
</div>
<div class="col col-66">
<div class="col col-50">
<div class="row">
<div class="col">
<button class="button button-small" ng-disabled="true" style="text-align:right">From:</button>
Expand Down Expand Up @@ -47,6 +47,10 @@
</div> <!-- col-->
</div> <!-- row -->
</div> <!-- col -->
<div class="col col-20">
<button class="button button-stable button-block row"
ng-click="changeFreq()">{{selectCtrl.freqString}}</button>
</div>
<div class="col col-10">
<button class="button button-assertive"
ng-click="getMetrics()">Get!</button>
Expand Down

0 comments on commit 11d2250

Please sign in to comment.