Fixed invites

This commit is contained in:
samcm 2017-06-04 17:05:30 +10:00
parent 75fdc36e22
commit 41a9e40ea5
8 changed files with 150 additions and 140 deletions

4
.gitignore vendored
View File

@ -5,6 +5,4 @@ npm-debug.log
test/unit/coverage
test/e2e/reports
selenium-debug.log
npm-debug.log.3732580485
npm-debug.log.2139949888
.idea/

View File

@ -7,7 +7,7 @@
"scripts": {
"dev": "node build/dev-server.js",
"build": "node build/build.js",
"webapp": "node webapp.js",
"webapp": "node webapp.js -- ",
"server": "node server.js",
"unit": "karma start test/unit/karma.conf.js --single-run",
"e2e": "node test/e2e/runner.js",
@ -15,6 +15,7 @@
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
},
"dependencies": {
"args-parser": "^1.1.0",
"bootstrap-sass": "^3.3.7",
"connect-history-api-fallback": "^1.3.0",
"cors": "^2.8.3",

View File

@ -14,6 +14,7 @@ import 'assets/js/materialize.js';
export default {
mounted (){
console.log('route',this.$route)
if (this.$route.query.ptserver && this.$route.query.ptroom){
console.log('We should auto join')
// Looks like a valid request...

View File

@ -7,7 +7,7 @@
</div>
<h2> Libraries </h2>
<div v-if="libraries && !browsingLibrary" v-for="library in filteredLibraries">
<v-card v-on:click.native="setLibrary(library)" class="blue-grey darken-1 col l3 s12 hoverable" style="box-shadow:none">
<v-card v-on:click.native="setLibrary(library)" class="row blue-grey darken-1 col l3 s12 hoverable" style="box-shadow:none">
<div class="col s3 l3" style="height:100%">
<img :src="getThumb(library)" style="height:100%; width:100%" >
</div>

View File

@ -9,8 +9,14 @@
<h2 class="center"> Welcome to Plex Together!</h2>
<div class="row">
<div class="col l12 s12 center">
<div> <span style="font-weight:900">{{ owner }}</span> has invited to join the room <span style="font-weight:900">{{ room }}</span>.</div>
<small>Sit tight! You'll be in sync in no time.</small>
<div style="color:white">
<span style="font-weight:900">{{ owner }}</span> has invited you to join the room "<span style="font-weight:900">{{ room }}</span>"
</div>
<div class="row" style="margin:5%">
<div class="col l12 s12">
<v-btn class="center" style="background-color: #E5A00D" v-on:click.native="letsGo()">Accept Invite</v-btn>
</div>
</div>
</div>
</div>
</div>
@ -46,9 +52,6 @@ export default {
this.$store.commit('SET_AUTOJOINPASSWORD',this.password)
this.$store.commit('SET_AUTOJOINURL',this.server)
}
setTimeout(function(){
that.$router.push('/sync')
},2500)
},
created: function(){
},
@ -62,15 +65,14 @@ export default {
},
computed:{
logo: function(){
if (this.$store.getters.getSettingDARKMODE){
return 'static/logo-small-light.png'
}
return 'static/logo-small-dark.png'
},
}
},
methods: {
letsGo(){
this.$router.push('/sync')
}
}
}
</script>

View File

@ -7,8 +7,6 @@
<div>
<h1 class="center">Sign in to Plex.tv</h1>
</div>
<div v-if="!pin" class="center">
<v-progress-circular active large></v-progress-circular>
</div>
@ -16,7 +14,7 @@
<div class="col s12 l4 offset-l4">
<i style="font-size:150px; color:green" class="material-icons">done</i>
</div>
<div class="col s12 l4 offset-l4">
<div class="col s12 l4 offset-l4" style="color:white">
Signed in!
</div>
</div>

View File

@ -28,7 +28,7 @@ if(!getSetting('INIT')){
setSetting('CLIENTPOLLINTERVAL',1000)
setSetting('DARKMODE',false)
setSetting('SYNCMODE','cleanseek')
setSetting('SYNCFLEXABILITY',4000)
setSetting('SYNCFLEXABILITY',3000)
setSetting('CUSTOMSERVER','http://')
setSetting('INIT',true)
}
@ -36,16 +36,16 @@ if(!getSetting('INIT')){
let _webapp_socket = null
if (process.env.NODE_ENV == 'development'){
console.log('running in development')
/*
_webapp_socket = socketio.connect(''+window.location.hostname+':8088',{'forceNew':true,'connect timeout': 1000,path: '/ptweb/socket.io'})
_webapp_socket.on('connection',function(){
})
_webapp_socket.on('connect_error',function(){
})
*/
} else {
_webapp_socket = socketio.connect({'forceNew':true,
'connect timeout': 1000,path: '/ptweb/socket.io'})
'connect timeout': 1000, path: '/ptweb/socket.io'})
_webapp_socket.on('connection',function(){
})
_webapp_socket.on('connect_error',function(){
@ -98,7 +98,7 @@ const mutations = {
sendNotification('Now Playing: ' + metadata.title + ' from ' + state.plex.getServerById(metadata.machineIdentifier).name )
}
if (metadata.type == 'episode'){
sendNotification('Now Playing: ' + metadata.grandparentTitle + ' S' + metadata.parentIndex + 'E' + metadata.index + ' from ' + state.plex.getServerById(metadata.machineIdentifier).name )
sendNotification('Now Playing: ' + metadata.grandparentTitle + ' S' + metadata.parentIndex + 'E' + metadata.index + ' from ' + state.plex.getServerById(metadata.machineIdentifier).name)
}
state.chosenClient.clientPlayingMetadata = metadata
})
@ -591,7 +591,7 @@ const plexTogether = {
}
// Check if we need to autoplay
if ((ourTimeline.state == 'stopped' || !ourTimeline.state) && (hostTimeline.playerState != 'stopped')){
if (rootState.blockAutoPlay){
if (rootState.blockAutoPlay || !hostTimeline.rawTitle){
return
}
// We need to autoplay!

View File

@ -1,15 +1,24 @@
// ABOUT
// Runs the Plex Together Web App - handles serving the static web content and link shortening services
// Defaults to 8088
// Port defaults to 8088
// REQUIRED: --url argument
// USER CONFIG
const args = require("args-parser")(process.argv)
if (!args['url']){
console.log('Missing required argument -url. EG. "node webapp.js --url=http://example.com/ptweb". This URL is used for redirecting invite links.')
return
}
var accessIp = args['url'] // EG 'http://95.231.444.12:8088/ptweb' or 'http://example.com/ptweb'
if (accessIp.indexOf('/ptweb') == -1){
console.log('WARNING: /ptweb was not found in your url. Unless you have changed the URL Base make sure to include this.')
}
var PORT = 8088
var accessIp = 'http://ip:port/ptweb' // EG 'http://95.231.444.12:8088/ptweb' or 'http://example.com/ptweb'
if (args['port']){
PORT = parseInt(args['port'])
} else {
console.log('Defaulting to port 8088')
}
// USER CONFIG
// END USER CONFIG
var express = require('express');
@ -34,14 +43,15 @@ webapp.get('/invite/:id',function(req,res){
console.log('handling an invite')
let shortObj = shortenedLinks[req.params.id]
if (!shortObj){
return res.send('Whoops, looks like youve made a wrong turn..')
return res.send('Invite expired')
}
console.log('Redirecting an invite link')
console.log(JSON.stringify(shortObj,null,4))
return res.redirect(shortObj.fullUrl)
})
root.use('/ptweb',webapp)
root.get('*',function(req,res){
console.log('Catch all')
console.log('Catch all - have you run `npm run build`?')
return res.redirect('/ptweb')
})
@ -91,14 +101,14 @@ function shortenObj(data){
for (let key in params) {
query += encodeURIComponent(key)+'='+encodeURIComponent(params[key])+'&';
}
returnable.fullUrl = accessIp + '/#/?' + query
returnable.fullUrl = accessIp + '/#/join?' + query
shortenedLinks[returnable.id] = returnable
return returnable.shortUrl
}
webapp_io.on('connection', function(socket){
console.log('Someone connected to the webapp socket')
console.log('New connection to the webapp socket')
socket.on('shorten',function(data){
console.log('Creating a shortened link')
socket.emit('shorten-result',shortenObj(data))