-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
229 changed files
with
4,347 additions
and
3,386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
module.exports = ActivityController; | ||
|
||
ActivityController.$inject = ['$scope', '$translate', 'moment', 'ViewHelper']; | ||
|
||
function ActivityController($scope, $translate, moment, ViewHelper) { | ||
// Initial values | ||
$scope.isActivityAvailable = false; | ||
$scope.currentInterval = 'week'; | ||
$scope.editableInterval = 'week'; | ||
$scope.filters = { | ||
created_after: null, | ||
created_before: null | ||
}; | ||
$scope.filtersMenuOpen = false; | ||
$scope.dateOptions = { format : 'yyyy-mm-dd' }; | ||
|
||
$scope.saveFilters = saveFilters; | ||
$scope.cancelChangeFilters = cancelChangeFilters; | ||
|
||
activate(); | ||
|
||
function activate() { | ||
// Change mode | ||
$scope.$emit('event:mode:change', 'activity'); | ||
// Set the page title | ||
$translate('nav.activity').then(function (title) { | ||
$scope.$emit('setPageTitle', title); | ||
}); | ||
$scope.isActivityAvailable = ViewHelper.isViewAvailable('activity'); | ||
|
||
update(); | ||
} | ||
|
||
function saveFilters() { | ||
$scope.currentInterval = $scope.editableInterval; | ||
update(); | ||
$scope.filtersMenuOpen = false; | ||
} | ||
|
||
function cancelChangeFilters() { | ||
$scope.editableInterval = $scope.currentInterval; | ||
$scope.filtersMenuOpen = false; | ||
} | ||
|
||
function update() { | ||
//$scope.currentInterval = interval; | ||
setDateRange($scope.currentInterval); | ||
} | ||
|
||
/** | ||
* Util func to get date range when given an interval like | ||
* @param {String} interval month|week|all | ||
* @return {Object} | ||
*/ | ||
function setDateRange(interval) { | ||
switch (interval) { | ||
case 'month': | ||
$scope.filters.created_after = moment().startOf('month').toDate(); | ||
$scope.filters.created_before = null; | ||
break; | ||
case 'all': | ||
$scope.filters.created_after = null; | ||
$scope.filters.created_before = null; | ||
break; | ||
case 'custom': | ||
// Do nothing? | ||
$scope.filters.created_after = $scope.createdAfter; | ||
$scope.filters.created_before = $scope.createdBefore; | ||
break; | ||
// case 'week': | ||
default: | ||
// Default to this week | ||
$scope.filters.created_after = moment().startOf('week').toDate(); | ||
$scope.filters.created_before = null; | ||
} | ||
// Copy range to editable values | ||
$scope.createdAfter = $scope.filters.created_after; | ||
$scope.createdBefore = $scope.filters.created_before; | ||
return $scope.filters; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
module.exports = ActivityBarChart; | ||
|
||
function ActivityBarChart() { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
filters: '=' | ||
}, | ||
controller: ActivityBarChartController, | ||
templateUrl: 'templates/activity/bar-chart.html' | ||
}; | ||
} | ||
|
||
ActivityBarChartController.$inject = ['$scope', '$translate', 'PostEndpoint', 'd3', '_', 'PostFilters']; | ||
function ActivityBarChartController($scope, $translate, PostEndpoint, d3, _, PostFilters) { | ||
$scope.data = [{ | ||
values: [] | ||
}]; | ||
|
||
$scope.groupByOptions = { | ||
'tags' : 'nav.categories', | ||
'form' : 'app.surveys', | ||
'status' : 'post.status' | ||
}; | ||
|
||
$scope.groupBy = { | ||
value: 'tags' | ||
}; | ||
|
||
$scope.options = { | ||
chart: { | ||
type: 'multiBarHorizontalChart', | ||
height: 450, | ||
margin: { | ||
top: 0, | ||
right: 40, | ||
bottom: 40, | ||
left: 5 | ||
}, | ||
x: function (d) { | ||
return d.label; | ||
}, | ||
y: function (d) { | ||
return d.total; | ||
}, | ||
showValues: false, | ||
showControls: false, | ||
valueFormat: d3.format('d'), | ||
transitionDuration: 500, | ||
xAxis: { | ||
axisLabel: $translate.instant('post.categories'), | ||
tickPadding: -10, | ||
axisLabelDistance: 0 | ||
}, | ||
yAxis: { | ||
axisLabel: $translate.instant('graph.post_count'), | ||
tickFormat: d3.format('d') | ||
}, | ||
tooltip : { | ||
contentGenerator: function (data) { | ||
return '<h3>' + data.value + '</h3>' + | ||
'<p>' + data.data.total + '</p>'; | ||
} | ||
}, | ||
forceY: 0, | ||
barColor: d3.scale.category20().range(), | ||
noData: $translate.instant('graph.no_data') | ||
} | ||
}; | ||
|
||
$scope.reload = getPostStats; | ||
|
||
activate(); | ||
|
||
function activate() { | ||
// whenever the filters changes, update the current list of posts | ||
$scope.$watch('filters', function () { | ||
getPostStats(); | ||
}, true); | ||
} | ||
|
||
function getPostStats(query) { | ||
query = query || PostFilters.getQueryParams($scope.filters); | ||
var postQuery = _.extend({}, query, { | ||
'group_by' : $scope.groupBy.value | ||
}); | ||
|
||
$scope.isLoading = true; | ||
PostEndpoint.stats(postQuery).$promise.then(function (results) { | ||
$scope.options.chart.xAxis.axisLabel = $translate.instant($scope.groupByOptions[$scope.groupBy.value]); | ||
if (results.totals[0]) { | ||
results.totals[0].key = $scope.options.chart.yAxis.axisLabel; | ||
} | ||
$scope.data = results.totals; | ||
$scope.isLoading = false; | ||
}); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.