Skip to content

Commit

Permalink
#431 fix issues in detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
WheelerXie committed Aug 17, 2017
1 parent 89eb674 commit 7f6bee5
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 142 deletions.
6 changes: 3 additions & 3 deletions public/main.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/js/controller/homeCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ module.exports = function ($scope, $rootScope, $window, $timeout, $http, $q, $sc
// },
onOpen: function () {
// debugger;
console.log($(this).find('.ui.segment.visible'))
$(this).find('.ui.segment').removeClass('visible');
$(this).find('div.echart').map(function (index, currentObj, array) {
echarts.getInstanceByDom(currentObj).resize();
Expand Down
67 changes: 21 additions & 46 deletions src/js/controller/socialCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ module.exports = function ($scope, $rootScope, $window, $timeout, $filter, $docu
$scope.order = $filter('orderBy');
$scope.query = {};
$scope.path = $location.path().split("/");
$scope.dateRange = '7';
$scope.isLargeDateRange = false;
$scope.commonTrendTitle = "Hourly Trend During a Week";
$scope.popInfoScope = "Hourly";
var totalrequests = 0;

Expand All @@ -20,6 +18,7 @@ module.exports = function ($scope, $rootScope, $window, $timeout, $filter, $docu
$scope.query.granularity = 3;
$scope.query.start = settings.start;
$scope.query.end = settings.end;
$scope.query.days = 7;

var dailyContainer = $($("#topic_select > div:nth-child(1) > div:nth-child(2) > span.daterange")[0]);
var hourlyContainer = $($("#topic_select > div:nth-child(1) > div:nth-child(2) > span.daterange")[1]);
Expand All @@ -38,7 +37,10 @@ module.exports = function ($scope, $rootScope, $window, $timeout, $filter, $docu
if (e.field === 'granularity') {
var granularity = this.get('granularity');
$scope.query.granularity = granularity;
if (granularity === 3) {
if (granularity === 2) {
$scope.popInfoScope = "Hourly";
} else {
$scope.popInfoScope = "Daily";
var start = this.get('start');
var end = this.get('end');
if (start > settings.end) {
Expand Down Expand Up @@ -104,28 +106,6 @@ module.exports = function ($scope, $rootScope, $window, $timeout, $filter, $docu
$scope.startGetData()
}
})
$scope.$watch('dateRange', function (newV, oldV) {
$scope.dateRange = newV;
if (newV !== '7') {
$scope.isLargeDateRange = true;
$scope.popInfoScope = "Daily";
} else {
$scope.isLargeDateRange = false;
$scope.popInfoScope = "Hourly";
}
$scope.commonTrendTitle = "Daily Trend In Last " + newV + " Days";
var timeRange = {
'start': moment.utc().startOf('day').subtract(newV, 'days').valueOf(),
'end': moment.utc().startOf('day').subtract(1, 'days').valueOf()
};
var timezoneOffset = (new Date()).getTimezoneOffset() * 60 * 1000;
$scope.dateList = utilitySrv.getTimeRange(timeRange.start, timeRange.end);
$scope.startUTCDateLocalsString = utilitySrv.getDateTimeLocaleStringInMinute(timeRange.start + timezoneOffset);
$scope.endUTCDateLocalsString = utilitySrv.getDateTimeLocaleStringInMinute(timeRange.end + timezoneOffset + 24 * 60 * 60 * 1000);
$scope.startDateLocalsString = utilitySrv.getDateTimeLocaleStringInMinute(timeRange.start);
$scope.endDateLocalsString = utilitySrv.getDateTimeLocaleStringInMinute(timeRange.end + 24 * 60 * 60 * 1000);
RefreshCharts();
})
$('#scrollspy .list .item .label').popup();
$('#topic_select').dimmer('show');
$scope.getTopics = function () {
Expand Down Expand Up @@ -200,6 +180,19 @@ module.exports = function ($scope, $rootScope, $window, $timeout, $filter, $docu
//getLanguageDistribution();
$scope.$broadcast('start-get-data', 'home');
}
$scope.getDownloadUrl = function () {
if (!$scope.$stateParams.platform) {
toastr.error('Platform Required');
return false;
}
if (!$scope.topic) {
toastr.error('Topic Select Required');
return false;
}
$scope.service.getDownloadUrl($scope.$stateParams.platform, $scope.topic, $scope.query.start, $scope.query.end).then(function (url) {
window.open(url);
})
}
// initLineCharts('.hourly-charts.home');
// echarts.connect('hourlyCharts');
function getStatistic() {
Expand All @@ -217,7 +210,7 @@ module.exports = function ($scope, $rootScope, $window, $timeout, $filter, $docu
$scope.languageDistribution = $filter('orderBy')(data, '-uniqueusers');
})
}
function getMentionedServiceTable () {
function getMentionedServiceTable() {
$scope.service.getMentionedMostServiceList($scope.$stateParams.platform, $scope.topic, 'all', $scope.query).then(function (data) {
$scope.mostMentionedService = data
$scope.$broadcast('data-got');
Expand All @@ -229,27 +222,9 @@ module.exports = function ($scope, $rootScope, $window, $timeout, $filter, $docu
})
}*/

$scope.getDownloadUrl = function () {
if (!$scope.$stateParams.platform) {
toastr.error('Platform Required');
return false;
}
if (!$scope.topic) {
toastr.error('Topic Select Required');
return false;
}
if (!$scope.dateRange) {
toastr.error('Date Range Required');
return false;
}
$scope.service.getDownloadUrl($scope.$stateParams.platform, $scope.topic, $scope.dateRange).then(function (url) {
window.open(url);
})
}

function CheckDateRangeSize() {
var diff = ($scope.query.end - $scope.query.start) / 1000 / 3600 / 24;
$scope.isLargeDateRange = (diff > 7);
$scope.query.days = ($scope.query.end - $scope.query.start) / 1000 / 3600 / 24;
$scope.isLargeDateRange = ($scope.query.days > 7);
$timeout(function () {
$scope.startGetData();
if ($scope.isLargeDateRange) {
Expand Down
1 change: 0 additions & 1 deletion src/js/directive/chartDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ module.exports = /*@ngInject*/ function ($rootScope, $filter, $q, $location, $co
})
break;
case 'getMessageVolSpikes':
console.log(_);
var fnPromise = apiFn(_.platform, _.query.topic, _.pnscope, _.query);
var fn = customHourlyData,
key = '';
Expand Down
56 changes: 23 additions & 33 deletions src/js/directive/statisticDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ var label_type = {
spike: 'Vol Spike Detected',
string: ''
};
var dateRangeAppend = function (dateRange) {
if (dateRange === '7') {
return ' Last Week'
} else {
return ' (Last ' + dateRange + ' days)';
}

}
module.exports = function ($parse, $filter, $timeout) {
var colors = ['red', 'orange', 'yellow', 'olive', 'green', 'teal', 'blue', 'violet', 'purple', 'pink', 'brown', 'grey', 'black'];
return {
Expand All @@ -45,10 +37,10 @@ module.exports = function ($parse, $filter, $timeout) {
replace: true,
scope: {
data: "=",
query: "=",
title: "@",
comment: "@",
color: "@",
dayrange: "="
color: "@"
},
link: function (scope, e, a) {
var numberFormat = $filter('thousandsuffix');
Expand All @@ -59,26 +51,24 @@ module.exports = function ($parse, $filter, $timeout) {
scope.comment = scope.data.comment;
$($(e).find('.popup').get(0)).popup();
}
// scope.data = $parse(scope.data);
// console.log(scope.data)
scope.randerUI = function () {
switch (a.type) {
case 'joinedusers':
scope.volume = numberFormat(scope.data.objectcountthistime)
if (scope.dayrange == '7') {
if (scope.query.days <= 7) {
scope.labels = [{
text: label_type.compared + dateRangeAppend(scope.dayrange),
text: label_type.compared + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.comparedratio,
type: 'ratio',
isCompared: true
}, {
text: label_type.spike + dateRangeAppend(scope.dayrange),
text: label_type.spike + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.detectedhourlyspikesvol,
color: 'red'
}]
} else {
scope.labels = [{
text: label_type.spike + dateRangeAppend(scope.dayrange),
text: label_type.spike + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.detectedhourlyspikesvol,
color: 'red'
}]
Expand All @@ -88,16 +78,16 @@ module.exports = function ($parse, $filter, $timeout) {
case 'regionofusers':
scope.volume = numberFormat(scope.data.objectcountthistime)
scope.volume = scope.volume === 0 ? "No Data Available" : scope.volume;
if ((scope.$parent.$parent.platform.toLowerCase() !== 'twitter') || scope.dayrange !== '7') {
if ((scope.$parent.$parent.platform.toLowerCase() !== 'twitter') || scope.query.days > 7) {
scope.labels = []
} else {
scope.labels = [{
text: label_type.compared + dateRangeAppend(scope.dayrange),
text: label_type.compared + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.comparedratio,
type: 'ratio',
isCompared: true
}, {
text: label_type.spike + dateRangeAppend(scope.dayrange),
text: label_type.spike + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.detectedhourlyspikesvol,
color: 'red'
}]
Expand All @@ -106,41 +96,41 @@ module.exports = function ($parse, $filter, $timeout) {
break;
case 'influenceofusers':
scope.volume = numberFormat(scope.data.objectcountthistime)
if (scope.dayrange == '7') {
if (scope.query.days <= 7) {
scope.labels = [{
text: label_type.compared + dateRangeAppend(scope.dayrange),
text: label_type.compared + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.comparedratio,
type: 'ratio',
isCompared: true
}, {
text: label_type.spike + dateRangeAppend(scope.dayrange),
text: label_type.spike + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.detectedhourlyspikesvol,
color: 'red'
}]
} else {
scope.labels = [{
text: "Spike Detected (Last " + scope.dayrange + " days)",
text: "Spike Detected (Last " + scope.query.days + " days)",
volume: scope.data.detectedhourlyspikesvol,
color: 'red'
}]
}
break;
case 'mentionedservicecount':
scope.volume = numberFormat(scope.data.objectcountthistime)
if (scope.dayrange == '7') {
if (scope.query.days <= 7) {
scope.labels = [{
text: label_type.compared + dateRangeAppend(scope.dayrange),
text: label_type.compared + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.comparedratio,
type: 'ratio',
isCompared: true
}, {
text: label_type.spike + dateRangeAppend(scope.dayrange),
text: label_type.spike + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.detectedhourlyspikesvol,
color: 'red'
}]
} else {
scope.labels = [{
text: label_type.spike + dateRangeAppend(scope.dayrange),
text: label_type.spike + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.detectedhourlyspikesvol,
color: 'red'
}]
Expand Down Expand Up @@ -179,20 +169,20 @@ module.exports = function ($parse, $filter, $timeout) {
break;
case 'vocinsightsVol':
scope.volume = numberFormat(scope.data.objectcountthistime.voctotalvol)
if (scope.dayrange == '7') {
if (scope.query.days <= 7) {
scope.labels = [{
text: label_type.compared + dateRangeAppend(scope.dayrange),
text: label_type.compared + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.comparedratio,
type: 'ratio',
isCompared: true
}, {
text: label_type.spike + dateRangeAppend(scope.dayrange),
text: label_type.spike + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.detectedhourlyspikesvol,
color: 'red'
}]
} else {
scope.labels = [{
text: label_type.spike + dateRangeAppend(scope.dayrange),
text: label_type.spike + ' (Last ' + scope.query.days + ' days)',
volume: scope.data.detectedhourlyspikesvol,
color: 'red'
}]
Expand Down Expand Up @@ -230,11 +220,11 @@ module.exports = function ($parse, $filter, $timeout) {
// + ":"
// + percentage(originBoj.neutraltotalvol/originBoj.voctotalvol,0)
scope.labels = [{
text: 'POS ' + label_type.spike + dateRangeAppend(scope.dayrange),
text: 'POS ' + label_type.spike + ' (Last ' + scope.query.days + ' days)',
volume: originBoj.detectedposispikesvol,
color: 'green'
}, {
text: 'NEG ' + label_type.spike + dateRangeAppend(scope.dayrange),
text: 'NEG ' + label_type.spike + ' (Last ' + scope.query.days + ' days)',
volume: originBoj.detectednegspikesvol,
color: 'red'
}]
Expand Down
4 changes: 2 additions & 2 deletions src/js/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,11 @@ app.factory('rawdataSrv', function (baseSrv) {
});

},
getDownloadUrl: function (platform, topic, days) {
getDownloadUrl: function (platform, topic, source) {
var params = params || {};
params.platform = platform || 'twitter';
params.topic = topic || 'azure';
params.days = days || 7;
setDateTimeRange(params, source);
return baseSrv.get('GetDownloadUrl', params);
},
getSubscribeSettings: function (platform, topic, msgtype, servicename) {
Expand Down
Loading

0 comments on commit 7f6bee5

Please sign in to comment.