Showing the session log some love. Replaced slider with checkbox bar.
This commit is contained in:
parent
4f5d806ff7
commit
adc81ffa4c
16 changed files with 192 additions and 212 deletions
|
|
@ -11,7 +11,6 @@ var modules = [
|
|||
'ngLodash',
|
||||
'ngCsv',
|
||||
'angular-md5',
|
||||
'rzModule',
|
||||
'bwcModule',
|
||||
'bitauthModule',
|
||||
'copayApp.filters',
|
||||
|
|
|
|||
|
|
@ -1,91 +1,73 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesLogs',
|
||||
function($scope, historicLog, platformInfo, lodash, gettextCatalog) {
|
||||
function($scope, historicLog, lodash, configService, gettextCatalog) {
|
||||
|
||||
var config = configService.getSync();
|
||||
var logLevels = historicLog.getLevels();
|
||||
var defaultLevel = historicLog.getDefaultLevel();
|
||||
var selectedLevel;
|
||||
|
||||
// Log level slider setup.
|
||||
// var logLevelSliderInitialValue = logFilterWeight;
|
||||
// var logLevelSliderCeil = logFilterWeight;
|
||||
// var logLevelSliderStepsArray = [];
|
||||
$scope.logOptions = {};
|
||||
$scope.logOptions = lodash.indexBy(logLevels, 'level');
|
||||
|
||||
// for (var i = 0; i < logLevels.length; i++) {
|
||||
// logLevelSliderStepsArray.push({
|
||||
// value: logLevels[i].weight,
|
||||
// legend: logLevels[i].label
|
||||
// });
|
||||
// }
|
||||
var filterLogs = function(weight) {
|
||||
$scope.filteredLogs = historicLog.get(weight);
|
||||
};
|
||||
|
||||
$scope.setOptionSelected = function(level) {
|
||||
var weight = $scope.logOptions[level].weight;
|
||||
$scope.fillClass = 'fill-bar-' + level;
|
||||
$scope.filteredLogs = historicLog.get(weight);
|
||||
filterLogs(weight);
|
||||
lodash.each($scope.logOptions, function(opt) {
|
||||
opt.selected = opt.weight <= weight ? true : false;
|
||||
opt.head = opt.weight == weight;
|
||||
});
|
||||
|
||||
// Save the setting.
|
||||
var opts = {
|
||||
log: {
|
||||
filter: level
|
||||
}
|
||||
};
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
};
|
||||
|
||||
// $scope.logOptions = {
|
||||
// logLevelSlider: {
|
||||
// value: logLevelSliderInitialValue,
|
||||
// opts: {
|
||||
// floor: 0,
|
||||
// ceil: logLevelSliderCeil,
|
||||
// step: 1,
|
||||
// hideLimitLabels: true,
|
||||
// hidePointerLabels: true,
|
||||
// showTicks: true,
|
||||
// showTicksValues: false,
|
||||
// showSelectionBar: true,
|
||||
// stepsArray: logLevelSliderStepsArray,
|
||||
// onEnd: function(sliderId, modelValue, highValue, pointerType) {
|
||||
// $scope.filteredLogs = historicLog.get(modelValue);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
$scope.prepareLogs = function() {
|
||||
var log = 'Copay Session Logs\n Be careful, this could contain sensitive private data\n\n';
|
||||
log += '\n\n';
|
||||
log += historicLog.get().map(function(v) {
|
||||
return '[' + v.timestamp + '][' + v.level + ']' + v.msg;
|
||||
}).join('\n');
|
||||
|
||||
return log;
|
||||
};
|
||||
|
||||
$scope.sendLogs = function() {
|
||||
var body = $scope.prepareLogs();
|
||||
|
||||
window.plugins.socialsharing.shareViaEmail(
|
||||
body,
|
||||
'Copay Logs',
|
||||
null, // TO: must be null or an array
|
||||
null, // CC: must be null or an array
|
||||
null, // BCC: must be null or an array
|
||||
null, // FILES: can be null, a string, or an array
|
||||
function() {},
|
||||
function() {}
|
||||
);
|
||||
};
|
||||
|
||||
$scope.showOptionsMenu = function() {
|
||||
$scope.showOptions = true;
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.logOptionsTitle = gettextCatalog.getString('Filter log');
|
||||
$scope.logOptions = lodash.indexBy(logLevels, 'level');
|
||||
$scope.setOptionSelected(defaultLevel.level);
|
||||
selectedLevel = lodash.has(config, 'log.filter') ? historicLog.getLevel(config.log.filter) : historicLog.getDefaultLevel();
|
||||
$scope.setOptionSelected(selectedLevel.level);
|
||||
});
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
$scope.allLogs = historicLog.get();
|
||||
$scope.filteredLogs = historicLog.get(defaultLevel.weight);
|
||||
|
||||
$scope.prepare = function() {
|
||||
var log = 'Copay Session Logs\n Be careful, this could contain sensitive private data\n\n';
|
||||
log += '\n\n';
|
||||
log += $scope.allLogs.map(function(v) {
|
||||
return v.msg;
|
||||
}).join('\n');
|
||||
|
||||
return log;
|
||||
};
|
||||
|
||||
$scope.sendLogs = function() {
|
||||
var body = $scope.prepare();
|
||||
|
||||
window.plugins.socialsharing.shareViaEmail(
|
||||
body,
|
||||
'Copay Logs',
|
||||
null, // TO: must be null or an array
|
||||
null, // CC: must be null or an array
|
||||
null, // BCC: must be null or an array
|
||||
null, // FILES: can be null, a string, or an array
|
||||
function() {},
|
||||
function() {}
|
||||
);
|
||||
};
|
||||
|
||||
$scope.showOptionsMenu = function() {
|
||||
$scope.showOptions = true;
|
||||
};
|
||||
filterLogs(selectedLevel.weight);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.directives')
|
||||
.directive('logOptions', function($timeout) {
|
||||
.directive('logOptions', function($timeout, platformInfo) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'views/includes/logOptions.html',
|
||||
|
|
@ -10,13 +10,17 @@ angular.module('copayApp.directives')
|
|||
show: '=logOptionsShow',
|
||||
options: '=logOptions',
|
||||
fillClass: '=logOptionsFillClass',
|
||||
title: '=logOptionsTitle',
|
||||
onSelect: '=logOptionsOnSelect'
|
||||
onSelect: '=logOptionsOnSelect',
|
||||
onCopy: '=logOptionsOnCopy',
|
||||
onSend: '=logOptionsOnSend'
|
||||
},
|
||||
link: function(scope, element, attrs) {
|
||||
scope.isCordova = platformInfo.isCordova;
|
||||
|
||||
scope.hide = function() {
|
||||
scope.show = false;
|
||||
};
|
||||
|
||||
scope.getFillClass = function(index) {
|
||||
scope.onSelect(index);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -76,9 +76,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
console.log('Error at log decorator:', e);
|
||||
v = 'undefined';
|
||||
}
|
||||
var ts = '[' + new Date().toISOString() + ']';
|
||||
var lvl = '[' + level + '] ';
|
||||
return ts + lvl + v;
|
||||
return v;
|
||||
});
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -83,6 +83,10 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
|||
emailNotifications: {
|
||||
enabled: false,
|
||||
},
|
||||
|
||||
log: {
|
||||
filter: 'debug',
|
||||
},
|
||||
};
|
||||
|
||||
var configCache = null;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ angular.module('copayApp.services')
|
|||
var root = {};
|
||||
|
||||
var levels = [
|
||||
{ level: 'info', weight: 0, label: 'Info'},
|
||||
{ level: 'error', weight: 0, label: 'Error'},
|
||||
{ level: 'warn', weight: 1, label: 'Warning'},
|
||||
{ level: 'error', weight: 2, label: 'Error'},
|
||||
{ level: 'debug', weight: 3, label: 'Debug', default: true}
|
||||
{ level: 'info', weight: 2, label: 'Info', default: true},
|
||||
{ level: 'debug', weight: 3, label: 'Debug'}
|
||||
];
|
||||
|
||||
// Create an array of level weights for performant filtering.
|
||||
|
|
@ -21,6 +21,12 @@ angular.module('copayApp.services')
|
|||
return levels;
|
||||
};
|
||||
|
||||
root.getLevel = function(level) {
|
||||
return lodash.find(levels, function(l) {
|
||||
return l.level == level;
|
||||
});
|
||||
};
|
||||
|
||||
root.getDefaultLevel = function() {
|
||||
return lodash.find(levels, function(l) {
|
||||
return l.default;
|
||||
|
|
@ -29,6 +35,7 @@ angular.module('copayApp.services')
|
|||
|
||||
root.add = function(level, msg) {
|
||||
logs.push({
|
||||
timestamp: new Date().toISOString(),
|
||||
level: level,
|
||||
msg: msg,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue