Skip to content

Commit

Permalink
Merge branch 'release/0.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Valandur committed Oct 6, 2015
2 parents 6d7cc79 + a2f79b7 commit 6b806a4
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 73 deletions.
1 change: 1 addition & 0 deletions src/app/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"angular": "*",
"angular-material": "*",
"angular-route": "*",
"angular-sanitize": "*",
"material-design-icons-iconfont": "*"
}
}
64 changes: 47 additions & 17 deletions src/app/js/controllers.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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();
Expand All @@ -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() {
Expand All @@ -72,7 +103,6 @@ app.controller('MainController', ['$scope', '$rootScope', '$mdDialog',
};

$scope.playReplay = function() {
console.log("playing");
ipc.send("play");
};

Expand All @@ -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();
Expand Down
27 changes: 27 additions & 0 deletions src/app/tpl/dialog-alert.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<md-dialog aria-label="{{ title }}">
<form>
<md-toolbar>
<div class="md-toolbar-tools">
<h2>{{ title }}</h2>
<span flex></span>
<md-button class="md-icon-button" ng-click="cancel()">
<md-icon aria-label="Close dialog">close</md-icon>
</md-button>
</div>
</md-toolbar>
<md-dialog-content>
<div>
<p ng-bind-html="message"></p>
</div>
</md-dialog-content>
<div class="md-actions" layout="row">
<span flex></span>
<md-button ng-click="openLogs()">
Open send logs dialog
</md-button>
<md-button ng-click="cancel()" style="margin-right:20px;" >
Got it!
</md-button>
</div>
</form>
</md-dialog>
35 changes: 35 additions & 0 deletions src/app/tpl/dialog-sendlogs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<md-dialog aria-label="Send logs to aof.gg">
<form>
<md-toolbar>
<div class="md-toolbar-tools">
<h2>Send logs to aof.gg</h2>
<span flex></span>
<md-button class="md-icon-button" ng-click="cancel()">
<md-icon aria-label="Close dialog">close</md-icon>
</md-button>
</div>
</md-toolbar>
<md-dialog-content>
<div>
<p>
Sending us your logs will help to find out what went wrong.<br>
Please use this function immediately after an error occured since we only send the log file of the current session.
</p>
<label for="logEmail">Email</label><br />
<input type="text" id="logEmail" ng-model="logEmail" /><br />
<label for="logComment">Comment</label><br />
<textarea id="logComment" ng-model="logComment" style="width:100%; height: 100px;"></textarea>

</div>
</md-dialog-content>
<div class="md-actions" layout="row">
<span flex></span>
<md-button ng-click="cancel()" >
Cancel
</md-button>
<md-button ng-click="send(logEmail, logComment)" style="margin-right:20px;" >
Send logs
</md-button>
</div>
</form>
</md-dialog>
9 changes: 5 additions & 4 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
<link rel="stylesheet" type="text/css" href="app/lib/angular-material/angular-material.css">
<link rel="stylesheet" type="text/css" href="app/lib/material-design-icons-iconfont/dist/material-design-icons.css">
<link rel="stylesheet" type="text/css" href="app/css/style.css">

<script type="text/javascript" src="app/lib/angular/angular.js"></script>
<script type="text/javascript" src="app/lib/angular-animate/angular-animate.js"></script>
<script type="text/javascript" src="app/lib/angular-aria/angular-aria.js"></script>
<script type="text/javascript" src="app/lib/angular-material/angular-material.js"></script>
<script type="text/javascript" src="app/lib/angular-route/angular-route.js"></script>

<script type="text/javascript" src="app/lib/angular-route/angular-route.js"></script>
<script type="text/javascript" src="app/lib/angular-sanitize/angular-sanitize.js"></script>

<script type="text/javascript" src="app/js/app.js"></script>
<script type="text/javascript" src="app/js/routes.js"></script>
<script type="text/javascript" src="app/js/controllers.js"></script>
Expand All @@ -20,7 +21,7 @@
</head>
<body ng-cloak ng-controller="MainController">
<div ng-include="'app/tpl/header.html'"></div>

<div layout="column" id="content" flex>
<ng-view layout="column" class="md-paddding" flex></ng-view>
</div>
Expand Down
40 changes: 23 additions & 17 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -115,7 +115,7 @@ function checkForUpdates(callback) {
}

callback();
});
});
}


Expand All @@ -141,7 +141,7 @@ function getStaticData(callback) {

callback();
});
});
});
}


Expand Down Expand Up @@ -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" ]
Expand All @@ -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" ]
Expand All @@ -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<br>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<br />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,
Expand All @@ -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",
Expand All @@ -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.<br>Please report your issue to support@aof.gg and provide the following file: " + logFile });
} else {

}

});
});

Expand Down
Loading

0 comments on commit 6b806a4

Please sign in to comment.