1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/* jshint -W041 */
/* jslint browser: true*/
/* global cordova,StatusBar,angular,console */
angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$rootScope', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$fileLogger', '$cordovaEmailComposer', function ($scope, $rootScope, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $fileLogger, $cordovaEmailComposer) {
$scope.openMenu = function () {
$ionicSideMenuDelegate.toggleLeft();
};
//--------------------------------------------------------------------------
// Convenience function to send logs via email
//--------------------------------------------------------------------------
$scope.sendEmail = function (logstring) {
if (window.cordova) {
// pass= password= should be replaced
//logstring = logstring.replace(/password=*?/g, 'password=xxxx'
$cordovaEmailComposer.isAvailable().then(function () {
var email = {
to: '',
subject: 'zmNinja Logs',
body: logstring,
isHtml: false
};
$cordovaEmailComposer.open(email);
}, function () {
ZMDataModel.zmLog("Email plugin not found", "error");
});
} else {
console.log("Skipping email module as cordova does not exist");
}
};
//-------------------------------------------------------------------------
// Lets make sure we set screen dim properly as we enter
// The problem is we enter other states before we leave previous states
// from a callback perspective in ionic, so we really can't predictably
// reset power state on exit as if it is called after we enter another
// state, that effectively overwrites current view power management needs
//------------------------------------------------------------------------
$scope.$on('$ionicView.enter', function () {
console.log("**VIEW ** Log Ctrl Entered");
ZMDataModel.setAwake(false);
$scope.zmLog = {
logString: ""
};
$fileLogger.getLogfile().then(function (l) {
$scope.zmLog.logString = l;
//console.log ("LOGS" + logstring);
},
function (error) {
$scope.zmLog.logString = "Error getting log: " + JSON.stringify(error);
});
});
}]);
|