diff --git a/src/app/bower.json b/src/app/bower.json
index 396fb2b..68cf894 100644
--- a/src/app/bower.json
+++ b/src/app/bower.json
@@ -11,6 +11,7 @@
"angular": "*",
"angular-material": "*",
"angular-route": "*",
+ "angular-sanitize": "*",
"material-design-icons-iconfont": "*"
}
}
diff --git a/src/app/js/controllers.js b/src/app/js/controllers.js
index a650a4a..3db57ba 100644
--- a/src/app/js/controllers.js
+++ b/src/app/js/controllers.js
@@ -1,4 +1,4 @@
-var app = angular.module('app.controllers', []);
+var app = angular.module('app.controllers', ['ngSanitize']);
app.controller('MainController', ['$scope', '$rootScope', '$mdDialog',
function($scope, $rootScope, $mdDialog) {
@@ -35,18 +35,49 @@ app.controller('MainController', ['$scope', '$rootScope', '$mdDialog',
$scope.showDialog("Client info", 'v' + $scope.aofClientInfo.currVersion + updateText, event);
};
$scope.showDialog = function(title, content, event) {
- $mdDialog.show(
- $mdDialog.alert()
- .parent(angular.element(document.querySelector('#popupContainer')))
- .clickOutsideToClose(true)
- .title(title)
- .content(content)
- .ariaLabel(title)
- .ok('ok')
- .targetEvent(event)
- );
+ $mdDialog.show({
+ templateUrl: 'app/tpl/dialog-alert.html',
+ controller: AlertController
+ });
+
+ $myScope = $scope;
+ function AlertController($scope, $mdDialog) {
+ $scope.title = title;
+ $scope.message = content;
+ $scope.openLogs = function() {
+ $mdDialog.cancel();
+ $myScope.showSendLogs();
+ };
+ $scope.cancel = function() {
+ $mdDialog.cancel();
+ };
+ }
};
-
+
+ $scope.showSendLogs = function() {
+ $mdDialog.show({
+ templateUrl: 'app/tpl/dialog-sendlogs.html',
+ controller: DialogController
+ })
+ .then(function(data) {
+ if (data) {
+ $scope.sendLogs(data);
+ };
+ });
+
+ function DialogController($scope, $mdDialog) {
+ $scope.send = function(email, comment) {
+ $mdDialog.hide({email: email, comment: comment});
+ };
+ $scope.cancel = function() {
+ $mdDialog.cancel();
+ };
+ $scope.hide = function() {
+ $mdDialog.hide();
+ }
+ }
+ };
+
$scope.announceClick = function(index) {
if (index == 0) {
$scope.selectClient();
@@ -55,12 +86,12 @@ app.controller('MainController', ['$scope', '$rootScope', '$mdDialog',
$scope.showAofClientInfo();
}
if (index == 2) {
- $scope.sendLogs();
+ $scope.showSendLogs();
}
};
- $scope.sendLogs = function() {
- ipc.send("sendLogs");
+ $scope.sendLogs = function(data) {
+ ipc.send("sendLogs", data);
};
$scope.openFile = function() {
@@ -72,7 +103,6 @@ app.controller('MainController', ['$scope', '$rootScope', '$mdDialog',
};
$scope.playReplay = function() {
- console.log("playing");
ipc.send("play");
};
@@ -94,7 +124,7 @@ app.controller('MainController', ['$scope', '$rootScope', '$mdDialog',
$scope.lolClientFound = obj.found;
$scope.lolClientVersion = obj.version;
var regex = $scope.lolClientVersion.match(/(?:.*?\s)(\d+)\.(\d+)\./);
- if (regex.length == 3) {
+ if (regex && regex.length == 3) {
$scope.lolClientVersionShort = regex[1] + "." + regex[2];
}
matchClientVersionToReplayVersion();
diff --git a/src/app/tpl/dialog-alert.html b/src/app/tpl/dialog-alert.html
new file mode 100644
index 0000000..329ab47
--- /dev/null
+++ b/src/app/tpl/dialog-alert.html
@@ -0,0 +1,27 @@
+
+
+
diff --git a/src/app/tpl/dialog-sendlogs.html b/src/app/tpl/dialog-sendlogs.html
new file mode 100644
index 0000000..c95f57e
--- /dev/null
+++ b/src/app/tpl/dialog-sendlogs.html
@@ -0,0 +1,35 @@
+
+
+
\ No newline at end of file
diff --git a/src/index.html b/src/index.html
index 18f881b..5d348cb 100644
--- a/src/index.html
+++ b/src/index.html
@@ -5,13 +5,14 @@
-
+
-
-
+
+
+
@@ -20,7 +21,7 @@
-
+
diff --git a/src/index.js b/src/index.js
index 3f836c7..2c96143 100644
--- a/src/index.js
+++ b/src/index.js
@@ -38,7 +38,7 @@ if (!fs.existsSync(app.getPath("userCache") + "/logs/")){
let logFile = app.getPath("userCache") + "/logs/" + (new Date()).getTime() + ".log";
let logger = new winston.Logger({ transports: [] });
logger.add(winston.transports.Console, {
- "level": "info"
+ "level": "debug"
});
logger.add(winston.transports.File, {
"filename": logFile,
@@ -115,7 +115,7 @@ function checkForUpdates(callback) {
}
callback();
- });
+ });
}
@@ -141,7 +141,7 @@ function getStaticData(callback) {
callback();
});
- });
+ });
}
@@ -201,6 +201,8 @@ ipc.on("ready", function(event, args) {
// Called when the user wants to select the league client manually
ipc.on("selectClient", function(event, args) {
+ logger.info("ipc: Select client");
+
var files = dialog.showOpenDialog({
filters: [{ name: 'League of Legends Client', extensions: ['app', 'exe'] }],
properties: [ "openFile" ]
@@ -217,6 +219,8 @@ ipc.on("selectClient", function(event, args) {
// Called when the user wants to open a replay
ipc.on("openReplay", function(event, args) {
+ logger.info("ipc: Open replay");
+
let files = dialog.showOpenDialog({
filters: [{ name: 'Replay File', extensions: ['aof'] }],
properties: [ "openFile" ]
@@ -238,24 +242,28 @@ ipc.on("openReplay", function(event, args) {
// Called when the user wants to play a replay
ipc.on("play", function(event, args) {
+ logger.info("ipc: Play replay");
replayServer.resetReplay();
mainWindow.minimize();
- lolClient.launch(replayServer.host(), replayServer.port(), staticData.regions[replay.regionId].ShortName,
- replay.gameId, replay.key, function(success) {
+ lolClient.launch(replayServer.host(), replayServer.port(), replay.region, replay.gameId, replay.key, function(success) {
mainWindow.restore();
- if (!success)
- event.sender.send("error", {
+ if (!success) {
+ logger.error("Could not start league of legends client.");
+ event.sender.send("error", {
title: "LoL Client error",
- content: "Could not start the League of Legends client
Please send us your current log file so we can reproduce what happened. (You can send the report in the top right)."});
+ content: 'Could not start the League of Legends client
Please send us your current log file by clicking the button below and filling out the form.'
+ });
+ }
});
});
-ipc.on("sendLogs", function(event, args) {
- console.log("sending report");
+ipc.on("sendLogs", function(event, data) {
+ logger.info("ipc: Send logs");
+
let report = {
date: new Date(),
platform: process.platform,
@@ -265,11 +273,11 @@ ipc.on("sendLogs", function(event, args) {
path: lolClient.leaguePath(),
version: lolClient.version()
},
+ email: data.email,
+ comment: data.comment,
logs: fs.readFileSync(logFile, 'utf8')
};
-
- console.log(JSON.stringify(report));
-
+
request({
url: "http://api.aof.gg/client/reports",
method: "POST",
@@ -278,15 +286,13 @@ ipc.on("sendLogs", function(event, args) {
"content-type": "application/json"
},
body: report
- }, function(err,httpResponse,body){
+ }, function(err, httpResponse, body){
if (httpResponse.statusCode != 200) {
+ logger.error("Sending report failed.", {err: err, httpResponse: httpResponse, body: body});
event.sender.send("error", {
title: "Error sending report",
content: "Could not send error report.
Please report your issue to support@aof.gg and provide the following file: " + logFile });
- } else {
-
}
-
});
});
diff --git a/src/modules/lol-client.js b/src/modules/lol-client.js
index 9c8c956..834df1e 100644
--- a/src/modules/lol-client.js
+++ b/src/modules/lol-client.js
@@ -25,17 +25,16 @@ let regexLocations = [{
]
}];
-// Try and find the league of legends client
-function checkPath(callback) {
+// Try and extract the league of legends client version
+function checkVersion(callback) {
let logPath = leaguePath + "/../Logs/Game - R3d Logs/";
-
+
var errorCallback = function(err) {
- logger.warn("Error checking path " + logPath + ": " + err);
- leaguePath = false;
- leagueVersion = "";
+ logger.warn("Error checking version " + logPath + ": " + err);
+ leagueVersion = "unknown";
callback(false);
};
-
+
fs.readdir(logPath, function(err, files) {
if (err) {
errorCallback(err);
@@ -43,23 +42,46 @@ function checkPath(callback) {
files.sort(function(a, b) {
return fs.statSync(logPath + b).mtime.getTime() - fs.statSync(logPath + a).mtime.getTime();
});
-
+
fs.readFile(logPath + files[0], "utf8", function(err, content) {
if (err) {
errorCallback(err);
} else {
leagueVersion = content.substring(content.indexOf("Build Version:") + 15, content.indexOf("[PUBLIC]") - 1);
logger.info("LoL client version is: " + leagueVersion);
-
- fs.readdir(leaguePath + "/solutions/lol_game_client_sln/releases/", function(err, files) {
- if (err) {
- errorCallback(err);
- } else {
- fullPath = leaguePath + "/solutions/lol_game_client_sln/releases/" + files[0] + "/deploy/";
- logger.info("Complete league path is " + fullPath);
-
- callback(true);
- }
+ callback(true);
+ }
+ });
+ }
+ });
+};
+
+// Try and find the league of legends client
+function checkPath(callback) {
+
+ var errorCallback = function(err) {
+ logger.warn("Error checking path " + logPath + ": " + err);
+ leaguePath = false;
+ leagueVersion = "";
+ callback(false);
+ };
+
+ fs.readdir(leaguePath + "/solutions/lol_game_client_sln/releases/", function(err, files) {
+ if (err) {
+ errorCallback(err);
+ } else {
+ files.sort(function(a, b) {
+ return fs.statSync(logPath + b).mtime.getTime() - fs.statSync(logPath + a).mtime.getTime();
+ });
+ fullPath = leaguePath + "/solutions/lol_game_client_sln/releases/" + files[0] + "/deploy/";
+
+ fs.readdir(fullPath, function(err, files) {
+ if (err) {
+ errorCallback(err);
+ } else {
+ logger.info("Complete league path is " + fullPath);
+ checkVersion(function(){
+ callback(true);
});
}
});
@@ -87,9 +109,9 @@ function findRegKey(hive, key, callback) {
function find(hintPath, callback) {
leaguePath = false;
leagueVersion = "";
-
+
logger.info("Searching for the League of Legends client");
-
+
// Try the hint path if we have one
if (hintPath) {
leaguePath = hintPath;
@@ -112,7 +134,7 @@ function find(hintPath, callback) {
possiblePaths.push(path);
}
c++;
-
+
if (c == num) {
if (possiblePaths.length == 0) {
callback(false);
@@ -120,12 +142,12 @@ function find(hintPath, callback) {
for (let k = 0; k < possiblePaths.length; k++) {
if (leaguePath)
break;
-
+
logger.info("Checking possible LoL client @ " + possiblePaths[k]);
leaguePath = possiblePaths[k];
checkPath(callback);
}
- }
+ }
}
});
}
@@ -140,7 +162,7 @@ function find(hintPath, callback) {
checkPath(callback);
}
});
- }
+ }
}
}
@@ -160,6 +182,7 @@ module.exports = function(extLogger) {
launch: function(host, port, replayRegionName, replayGameId, replayKey, callback) {
// Ask for LoL client path if we didn't find it
if (!fullPath) {
+ logger.error("fullPath not set");
callback(false);
return;
}
@@ -192,15 +215,22 @@ module.exports = function(extLogger) {
cmd = opts.cwd + "/LeagueofLegends";
}
- // Run LoL client
- let client = spawn(cmd, args, opts);
- client.on("error", function (err) {
- logger.error("!!! ERROR WHILE RUNNING THE LEAGUE OF LEGENDS CLIENT !!!");
- logger.error(err);
- callback(false);
- });
- client.on("close", function (code) {
- callback(true);
+ // Check if client is executable
+ fs.access(cmd, fs.X_OK, function (err) {
+ if (err) {
+ logger.error("No permissions to execute the league of legends client.", {err: err});
+ callback(false);
+ } else {
+ // Run LoL client
+ let client = spawn(cmd, args, opts);
+ client.on("error", function (err) {
+ logger.error("!!! ERROR WHILE RUNNING THE LEAGUE OF LEGENDS CLIENT !!!", {err: err});
+ callback(false);
+ });
+ client.on("close", function (code) {
+ callback(true);
+ });
+ }
});
},
extractPath: function(file, callback) {
@@ -218,7 +248,7 @@ module.exports = function(extLogger) {
leaguePath = file + "/Contents/LoL/RADS";
}
logger.info("League path set to " + leaguePath);
-
+
if (leaguePath)
checkPath(callback);
else
diff --git a/src/package.json b/src/package.json
index 5ee633c..aa4ed5c 100644
--- a/src/package.json
+++ b/src/package.json
@@ -1,6 +1,6 @@
{
"name": "aof-replay-client",
- "version": "0.1.3",
+ "version": "0.1.4",
"main": "./index.js",
"scripts": {
"start": "./node_modules/.bin/electron ."