Browse Source

UI-1071: Added fixed ranges to the SmartPBX Call Logs

4.3
Jean-Roch Maitre 11 years ago
parent
commit
cec81138c8
5 changed files with 152 additions and 42 deletions
  1. +9
    -1
      i18n/en-US.json
  2. +10
    -1
      i18n/fr-FR.json
  3. +41
    -17
      submodules/callLogs/callLogs.css
  4. +66
    -16
      submodules/callLogs/callLogs.js
  5. +26
    -7
      views/callLogs-layout.html

+ 9
- 1
i18n/en-US.json View File

@ -722,7 +722,15 @@
"getDetailsError": "An error occured while retrieving the call log's details."
},
"key": "Key",
"value": "Value"
"value": "Value",
"__comment": "UI-1071: Adding new Range buttons to Call Logs",
"__version": "3.20",
"thisMonth": "This Month",
"thisWeek": "This Week",
"thisDay": "Today",
"custom": "Custom",
"callsFrom": "Showing calls from",
"callsTo": "to"
},
"myOffice": {


+ 10
- 1
i18n/fr-FR.json View File

@ -692,7 +692,16 @@
"getDetailsError": "Une erreur est survenue en essayant de récuperer les détails de l'appel."
},
"key": "Clé",
"value": "Valeur"
"value": "Valeur",
"__comment": "UI-1071: Adding new Range buttons to Call Logs",
"__version": "3.20",
"thisMonth": "Ce mois",
"thisWeek": "Cette semaine",
"thisDay": "Aujourd'hui",
"custom": "Personnalisé",
"callsFrom": "Liste les appels depuis",
"callsTo": "jusqu'à"
},
"myOffice": {


+ 41
- 17
submodules/callLogs/callLogs.css View File

@ -11,30 +11,54 @@
#call_logs_container .call-logs-header .search-div input.search-query {
width: 140px;
}
#call_logs_container .call-logs-header .filter-div {
margin-right: 20px;
#call_logs_container .sub-ranges {
margin-top: 5px;
}
#call_logs_container .call-logs-header .filter-div > * {
margin: 0 10px 0 0;
vertical-align: middle;
#call_logs_container .sub-ranges > * {
display: inline-block;
}
#call_logs_container .call-logs-header .filter-div > span {
margin-right: 5px;
#call_logs_container .fixed-ranges {
width: 100%;
height: 35px;
margin-top: 20px;
}
#call_logs_container .call-logs-header .filter-div input.date-filter {
width: 80px;
#call_logs_container .fixed-ranges .btn-toolbar {
margin-top: 0;
}
#call_logs_container .call-logs-header .filter-div i.refresh-filter:hover {
text-shadow: 1px 1px 0px #999;
cursor: pointer;
#call_logs_container .fixed-ranges-date {
margin-top: 10px;
}
#call_logs_container .fixed-ranges-date .highlight-date {
color: #22CCFF;
font-weight: bold;
margin: 0 5px;
}
#call_logs_container .custom-range {
display: none;
}
#call_logs_container .custom-range.active {
display: inline-block;
}
#call_logs_container .call-logs-header .filter-div .download-csv i {
#call_logs_container .custom-range > * {
margin: 0 10px 0 0;
vertical-align: middle;
}
#call_logs_container .custom-range > span {
margin-right: 5px;
vertical-align: inherit;
}
#call_logs_container .call-logs-header .filter-div .download-csv:hover i {
text-shadow: 1px 1px 0px #999;
text-decoration: none;
#call_logs_container .custom-range input.date-filter {
width: 80px;
}
#call_logs_container .call-logs-content {


+ 66
- 16
submodules/callLogs/callLogs.js View File

@ -16,11 +16,8 @@ define(function(require){
self.callLogsRenderContent(args.parent);
},
callLogsRenderContent: function(parent, fromDate, toDate) {
callLogsRenderContent: function(parent, fromDate, toDate, type) {
var self = this,
dataTemplate = {
timezone: 'GMT' + jstz.determine_timezone().offset()
},
template,
defaultDateRange = 1,
maxDateRange = 31;
@ -31,6 +28,14 @@ define(function(require){
toDate = dates.to;
}
var dataTemplate = {
timezone: 'GMT' + jstz.determine_timezone().offset(),
type: type || 'today',
fromDate: fromDate,
toDate: toDate,
showFilteredDates: ['thisMonth', 'thisWeek'].indexOf(type) >= 0
};
// Reset variables used to link A-Legs & B-Legs sent by different pages in the API
delete self.lastALeg;
delete self.loneBLegs;
@ -83,26 +88,42 @@ define(function(require){
toDate = params.toDate,
startKey = params.nextStartKey;
template.find('.filter-div .apply-filter').on('click', function(e) {
var fromDate = template.find('.filter-div input.filter-from').datepicker("getDate"),
toDate = template.find('.filter-div input.filter-to').datepicker("getDate");
template.find('.apply-filter').on('click', function(e) {
var fromDate = template.find('input.filter-from').datepicker("getDate"),
toDate = template.find('input.filter-to').datepicker("getDate");
self.callLogsRenderContent(template.parents('.right-content'), fromDate, toDate);
self.callLogsRenderContent(template.parents('.right-content'), fromDate, toDate, 'custom');
});
template.find('.filter-div .refresh-filter').on('click', function(e) {
self.callLogsRenderContent(template.parents('.right-content'));
template.find('.fixed-ranges button').on('click', function(e) {
var $this = $(this),
type = $this.data('type');
// We don't really need to do that, but it looks better to the user if we still remove/add the classes instantly.
template.find('.fixed-ranges button').removeClass('active');
$this.addClass('active');
if(type !== 'custom') {
// Without this, it doesn't look like we're refreshing the data.
// GOod way to solve it would be to separate the filters from the call logs view, and only refresh the call logs.
template.find('.call-logs-content').empty();
var dates = self.callLogsGetFixedDatesFromType(type);
self.callLogsRenderContent(template.parents('.right-content'), dates.from, dates.to, type);
}
else {
template.find('.fixed-ranges-date').hide();
template.find('.custom-range').addClass('active');
}
});
template.find('.filter-div .download-csv').on('click', function(e) {
var fromDate = template.find('.filter-div input.filter-from').datepicker("getDate"),
toDate = template.find('.filter-div input.filter-to').datepicker("getDate"),
fromDateTimestamp = monster.util.dateToBeginningOfGregorianDay(fromDate),
template.find('.download-csv').on('click', function(e) {
var fromDateTimestamp = monster.util.dateToBeginningOfGregorianDay(fromDate),
toDateTimestamp = monster.util.dateToEndOfGregorianDay(toDate);
window.location.href = self.apiUrl + 'accounts/' + self.accountId
+ '/cdrs?created_from=' + fromDateTimestamp + '&created_to=' + toDateTimestamp
+ '&accept=text/csv&auth_token=' + self.authToken;
+ '/cdrs?created_from=' + fromDateTimestamp + '&created_to=' + toDateTimestamp
+ '&accept=text/csv&auth_token=' + self.authToken;
});
template.find('.search-div input.search-query').on('keyup', function(e) {
@ -214,6 +235,35 @@ define(function(require){
});
},
// Function built to return JS Dates for the fixed ranges.
callLogsGetFixedDatesFromType: function(type) {
var self = this,
from = new Date(),
to = new Date();
switch(type) {
case 'today':
break;
case 'thisWeek':
// First we need to know how many days separate today and monday.
// Since Sunday is 0 and Monday is 1, we do this little substraction to get the result.
var countDaysFromMonday = (from.getDay() - 1) % 7;
from.setDate(from.getDate() - countDaysFromMonday);
break;
case 'thisMonth':
from.setDate(1);
break;
default:
break;
}
return {
from: from,
to: to
};
},
callLogsGetCdrs: function(fromDate, toDate, callback, pageStartKey) {
var self = this,
fromDateTimestamp = monster.util.dateToBeginningOfGregorianDay(fromDate),


+ 26
- 7
views/callLogs-layout.html View File

@ -3,25 +3,44 @@
<div class="title-div">
{{i18n.callLogs.title}}
</div>
<div class="action-div">
<div class="fixed-ranges">
<div class="btn-toolbar pull-left">
<div class="btn-group">
<button data-type="today" class="btn{{#compare type "===" "today"}} active{{/compare}}" type="button">{{ i18n.callLogs.thisDay }}</button>
<button data-type="thisWeek" class="btn{{#compare type "===" "thisWeek"}} active{{/compare}}" type="button">{{ i18n.callLogs.thisWeek }}</button>
<button data-type="thisMonth" class="btn{{#compare type "===" "thisMonth"}} active{{/compare}}" type="button">{{ i18n.callLogs.thisMonth }}</button>
<button data-type="custom" class="btn{{#compare type "===" "custom"}} active{{/compare}}" type="button">{{ i18n.callLogs.custom }}</button>
</div>
</div>
<div class="search-div pull-right">
<span class="search-box">
<i class="icon-search"></i>
<input type="text" class="search-query" placeholder="{{i18n.table.search}}">
</span>
</div>
<div class="filter-div">
<i class="refresh-filter icon-refresh icon-blue" title="{{i18n.callLogs.resetFilter}}"></i>
<span>{{i18n.startDate}}:</span>
</div>
<div class="sub-ranges">
<div class="custom-range{{#compare type "===" "custom"}} active{{/compare}}">
<span>{{i18n.startDate}}</span>
<input id="startDate" type="text" class="date-filter filter-from">
<span>{{i18n.endDate}}:</span>
<span>{{i18n.endDate}}</span>
<input id="endDate" type="text" class="date-filter filter-to">
<button type="button" class="apply-filter btn btn-primary" title="{{i18n.callLogs.applyFilter}}">{{i18n.filter}}</button>
<a href="#" role="button" class="download-csv"><i class="icon-download-alt icon-green"></i>{{i18n.download}}</a>
<!-- <i class=" icon-download-alt icon-green" title="Download CSV File"></i> -->
</div>
{{#if showFilteredDates}}
<div class="fixed-ranges-date">
{{ i18n.callLogs.callsFrom }} <span class="highlight-date">{{ toFriendlyDate fromDate "short"}}</span> {{ i18n.callLogs.callsTo }} <span class="highlight-date">{{ toFriendlyDate toDate "short" }}</span>
</div>
{{/if}}
<a href="#" role="button" class="monster-link download-csv"><i class="icon-download-alt icon-green"></i>{{i18n.download}}</a>
</div>
</div>
<div class="call-logs-content">
<div class="call-logs-grid">
<div class="grid-row-group">


Loading…
Cancel
Save