Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/package.json
This commit is contained in:
samcm 2016-12-08 00:29:39 +11:00
commit 1d591b4867
5 changed files with 49 additions and 18 deletions

View File

@ -132,7 +132,7 @@ Once the above is done you're all set! Depending on whether you're the host or a
----
## Issues
If you run in to any issues:
* Raise an Issue here on Github. Try to be as detailed as possible by including details such as
* Raise an Issue here on Github. Try to be as detailed as possible by including details such as:
* Node Version
* Operating System
* Plex Media Server details
@ -149,7 +149,7 @@ If you run in to any issues:
* Send the log file to anyone who is in the Discord group "Developer" with a link to the Github Issue. Although the log file does not contain any access tokens, it is still not recommended to post your log file publicly.
* Obtain your log file from here:
* on Linux: ~/.config/PlexTogether/log.log
* on OS X: ~/Library/Logs/PlexTogether/log.log
* on macOS: ~/Library/Logs/PlexTogether/log.log
* on Windows: %USERPROFILE%/AppData/Roaming/PlexTogether/log.log
----

View File

@ -8,7 +8,7 @@ const spawn = require('child_process').spawn;
global.log = require('electron-log');
global.log.transports.file.format = '[App] [{level}] {h}:{i}:{s}:{ms} {text}';
const storage = require('electron-json-storage');
global.storage = require('electron-json-storage');
global.io = require('socket.io-client');
global.socket = null;
@ -127,7 +127,7 @@ app.on('ready', function() {
--> If token is valid, send to Home
--> If token is not valid, send to Plex Login Screen
*/
storage.get('plex-together-settings', function(error, data) {
global.storage.get('plex-together-settings', function(error, data) {
if (error) throw error;
if (data.plextvtoken != null){
//We have a token
@ -273,7 +273,7 @@ ipcMain.on('plextv-signin', function(event,username,password){
//Sign in button pressed on Sign In page
plex.doStandardLogin(username,password,function(result){
if (result == 201){
storage.set('plex-together-settings',{'plextvtoken':plex.user.authToken}, function(error) {
global.storage.set('plex-together-settings',{'plextvtoken':plex.user.authToken}, function(error) {
if (error) throw error;
});
plex.getDevices(function(devicesResult){
@ -293,7 +293,7 @@ ipcMain.on('plextv-signin', function(event,username,password){
});
ipcMain.on('plextv-signout',function(event){
introWindow.loadURL('file://' + __dirname + '/signin.html')
storage.set('plex-together-settings',{'plextvtoken':""}, function(error) {
global.storage.set('plex-together-settings',{'plextvtoken':""}, function(error) {
if (error) throw error;
});
mainWindow.minimize();

View File

@ -77,15 +77,16 @@ function connectToPTServer(address){
document.getElementById('ptServerPreloader').style.opacity = 1
global.renderLog.info('connecting to ' + address)
ipcRenderer.send('connect-to-ptserver',address)
//global.socket = io.connect('au1.plextogether.com',{'sync disconnect on unload':true
//global.socket = io.connect('au1.plextogether.com',{'sync disconnect on unload':true
// global.socket = io.connect('localhost',{'sync disconnect on unload':true})
ipcRenderer.on('connect-ptserver-fail',function(event){
global.renderLog.info('FAILED TO CONNECT TO THE PTSERVER')
ipcRenderer.on('connect-ptserver-fail',function(event){
global.renderLog.info('FAILED TO CONNECT TO THE PTSERVER')
$('#serverSuccess').addClass('hide')
document.getElementById('ptServerPreloader').style.opacity = 0
})
})
ipcRenderer.on('connect-ptserver-success',function(event){
document.getElementById('ptServerPreloader').style.opacity = 0
saveCustomPTServer(address);
document.getElementById('ptServerPreloader').style.opacity = 0
$('#serverSuccess').removeClass('hide')
document.getElementById('ptRoom').focus()
ipcRenderer.send('pt-server-address-change',address)
@ -93,7 +94,7 @@ function connectToPTServer(address){
}
function joinPTRoom(){
global.renderLog.info('attempting to join room')
let wantedRoom = document.getElementById('ptRoom').value
let wantedRoom = document.getElementById('ptRoom').value
if (wantedRoom === '' || wantedRoom === null){
global.renderLog.info('Choose the room you\'d like to join first!')
return
@ -111,14 +112,14 @@ function joinPTRoom(){
function handleRoomJoinAttempt(result,data,details,currentUsers){
global.renderLog.info(currentUsers)
if (result){
//Join successful
//Join successful
//Now we'll pass over control to roomEvents in homejs to handle everything
ipcRenderer.send('pt-server-room-change',data.room,document.getElementById('ptRoomPassword').value)
setTimeout(function(){
ipcRenderer.send('join-room-ok',data,details,currentUsers,global.socket)
ipcRenderer.send('pt-server-showInfo')
},150)
} else {
} else {
//Join FAILED
if (details == 'wrong password'){
global.renderLog.info('wrong password')
@ -136,3 +137,30 @@ function getHandshakeUser(){
}
return tempUser
}
function getSavedCustomPTServer(input){
console.log("Loading custom server from storage");
var storage = remote.getGlobal('storage');
storage.get('plex-together-custom-settings', function(error, data) {
if (error) throw error;
if(data.customPTServer != null){
console.log("custom PT is defined " + data.customPTServer);
input.val(data.customPTServer);
}else{
//if key doesn't exists, create one with value "http://"
input.val("http://");
storage.set('plex-together-custom-settings',{'customPTServer':"http://"}, function(error) {
if (error) throw error;
});
}
});
}
function saveCustomPTServer(address){
console.log("Saving custom server " + address + " to storage");
var storage = remote.getGlobal('storage');
storage.set('plex-together-custom-settings',{'customPTServer':address}, function(error) {
if (error) throw error;
});
return address
}

View File

@ -20,6 +20,7 @@
"jquery": "2.1.1",
"mkdirp": "0.5.1",
"portfinder": "^1.0.10",
"remote": "^0.2.6",
"request": "2.74.0",
"safe-json-parse": "4.0.0",
"socket.io": "1.4.8",

View File

@ -34,7 +34,7 @@
</div>
</nav>
<div class="settingsTitle">
<div class="settingsTitle">
<div class="row" style="margin-bottom: 0;">
<div class="col s12">
<div>
@ -47,8 +47,8 @@
<div class="col s8">
<div class="input-field windowNoDrag">
<select id="PlexTogetherServers" class="browser-default" onchange="ServerSelectedChanged()">
<option value="" disabled selected>Select a PT Server</option>
<option value="custom">Custom</option>
<option value="" disabled>Select a PT Server</option>
<option value="custom" selected>Custom</option>
</select>
</div>
</div>
@ -71,7 +71,7 @@
<i class="material-icons close hide" id="serverSuccess" style="color: #1ECD97; margin-top: 24px; margin-left: -75px">check_circle</i>
</div>
</div>
<div class="row hide" id="customField">
<div class="row" id="customField">
<div class="col s8">
<div class="input-field col s12">
<input id="ptServerCustom" type="text" class="validate" value="http://" style="margin-bottom: 0px;">
@ -144,6 +144,8 @@
<script>
$(document).ready(function() {
$('select').material_select();
//set custom PTS to the custom server input
getSavedCustomPTServer($('#ptServerCustom'));
});
$(document).ready(function(){