added manual server form

This commit is contained in:
Luke Pulverenti 2015-05-05 11:24:47 -04:00
parent 5257e91628
commit c710303de9
9 changed files with 265 additions and 48 deletions

View File

@ -9,7 +9,7 @@
<div data-role="content"> <div data-role="content">
<form class="connectLoginForm" style="text-align: center; margin: 0 auto;"> <form class="connectLoginForm" style="text-align: center; margin: 0 auto;display:none;">
<h1 style="text-align: left;">${HeaderSignInWithConnect}</h1> <h1 style="text-align: left;">${HeaderSignInWithConnect}</h1>
<br /> <br />
@ -27,18 +27,64 @@
<button type="submit" data-icon="check"> <button type="submit" data-icon="check">
${ButtonSignIn} ${ButtonSignIn}
</button> </button>
<p> <p class="forgotPassword" style="display:none;">
<a href="http://emby.media/community/index.php?app=core&module=global&section=lostpass" target="_blank">${ButtonForgotPassword}</a> <a href="http://emby.media/community/index.php?app=core&module=global&section=lostpass" target="_blank">${ButtonForgotPassword}</a>
</p> </p>
<div class="skip">
<br />
<a data-role="button" data-icon="delete" href="connectlogin.html?mode=manualserver">${ButtonSkip}</a>
<div class="fieldDescription">${TextConnectToServerManually}</div>
</div>
<div class="newUsers" style="display:none;">
<br /> <br />
<h2 style="text-align: left;">${HeaderNewUsers}</h2> <h2 style="text-align: left;">${HeaderNewUsers}</h2>
<a data-role="button" data-icon="action" href="http://emby.media/community/index.php?app=core&module=global&section=register" target="_blank">${ButtonSignUp}</a> <a data-role="button" data-icon="action" href="http://emby.media/community/index.php?app=core&module=global&section=register" target="_blank">${ButtonSignUp}</a>
</div>
</form> </form>
<form class="manualServerForm" style="text-align: center; margin: 0 auto;display:none;">
<h1 style="text-align: left;">${HeaderNewServer}</h1>
<br />
<div>
<label for="txtServerHost" style="text-align: left;">${LabelServerHost}</label>
<input type="text" id="txtServerHost" required="required" />
<div class="fieldDescription" style="text-align:left;">${LabelServerHostHelp}</div>
</div>
<br />
<div>
<label for="txtServerPort" style="text-align: left;">${LabelServerPort}</label>
<input type="number" id="txtServerPort" step="1" min="0" />
</div>
<br /><br />
<button type="submit" data-icon="check">
${ButtonConnect}
</button>
</form>
<div class="welcomeContainer readOnlyContent" style="text-align: center; margin: 0 auto;display:none;">
<div style="text-align: left;">
<h1>${HeaderWelcomeToEmby}</h1>
<p style="margin:2em 0;">${EmbyIntroMessage}</p>
<p style="margin:2em 0;" class="embyIntroDownloadMessage"></p>
<a class="btn btnActionAccent btnIconRight" href="connectlogin.html">
<span>
${ButtonNext}
</span>
<i class="fa fa-arrow-right"></i>
</a>
</div>
</div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$('.connectLoginForm').off('submit', ConnectLoginPage.onSubmit).on('submit', ConnectLoginPage.onSubmit); $('.connectLoginForm').off('submit', ConnectLoginPage.onSubmit).on('submit', ConnectLoginPage.onSubmit);
$('.manualServerForm').off('submit', ConnectLoginPage.onManualServerSubmit).on('submit', ConnectLoginPage.onManualServerSubmit);
</script> </script>
</div> </div>
</body> </body>

View File

@ -202,11 +202,16 @@ button.btn:not(.btn-inline), button.btn-large:not(.btn-inline) {
vertical-align: middle; vertical-align: middle;
} }
.btn:not(.btn-inline):not(.btnNoText) i { .btn:not(.btn-inline):not(.btnNoText):not(.btnIconRight) i {
position: absolute; position: absolute;
left: 10px; left: 10px;
} }
.btnIconRight:not(.btn-inline):not(.btnNoText) i {
position: absolute;
right: 10px;
}
.btn-large i { .btn-large i {
position: absolute; position: absolute;
left: 24px; left: 24px;

View File

@ -36,7 +36,7 @@
} }
.videoControls { .videoControls {
padding: 0 .5em; padding: .5em .5em;
background-color: rgba(0, 0, 0, .8); background-color: rgba(0, 0, 0, .8);
position: fixed; position: fixed;
left: 0; left: 0;
@ -80,7 +80,7 @@
z-index: 99999; z-index: 99999;
} }
#videoPlayer .nowPlayingInfo img { #videoPlayer .nowPlayingImage img {
height: auto !important; height: auto !important;
max-width: 100px; max-width: 100px;
max-height: 200px; max-height: 200px;
@ -202,7 +202,7 @@
} }
@media all and (min-width: 1300px) { @media all and (min-width: 1300px) {
#videoPlayer .nowPlayingInfo img { #videoPlayer .nowPlayingImage img {
height: auto !important; height: auto !important;
max-width: 150px; max-width: 150px;
max-height: 300px; max-height: 300px;

View File

@ -28,6 +28,126 @@
} }
function handleConnectionResult(page, result) {
switch (result.State) {
case MediaBrowser.ConnectionState.SignedIn:
{
var apiClient = result.ApiClient;
Dashboard.serverAddress(apiClient.serverAddress());
Dashboard.setCurrentUser(apiClient.getCurrentUserId(), apiClient.accessToken());
window.location = 'index.html';
}
break;
case MediaBrowser.ConnectionState.ServerSignIn:
{
window.location = 'connectlogin.html?mode=serversignin&serverid=' + result.Servers[0].Id;
}
break;
case MediaBrowser.ConnectionState.ServerSelection:
{
onLoggedIn();
}
break;
case MediaBrowser.ConnectionState.ConnectSignIn:
{
loadMode(page, 'welcome');
}
break;
default:
break;
}
}
function loadAppConnection(page) {
Dashboard.showLoadingMsg();
ConnectionManager.connect().done(function (result) {
Dashboard.hideLoadingMsg();
handleConnectionResult(page, result);
});
}
function loadPage(page) {
var mode = getParameterByName('mode');
if (!mode) {
if (Dashboard.isRunningInCordova()) {
loadAppConnection(page);
return;
}
mode = 'connect';
}
loadMode(page, mode);
}
function loadMode(page, mode) {
if (mode == 'welcome') {
$('.connectLoginForm', page).hide();
$('.welcomeContainer', page).show();
$('.manualServerForm', page).hide();
}
else if (mode == 'connect') {
$('.connectLoginForm', page).show();
$('.welcomeContainer', page).hide();
$('.manualServerForm', page).hide();
}
else if (mode == 'manualserver') {
$('.manualServerForm', page).show();
$('.connectLoginForm', page).hide();
$('.welcomeContainer', page).hide();
}
}
$(document).on('pageshow', "#connectLoginPage", function () {
var page = this;
loadPage(page);
var link = '<a href="http://emby.media" target="_blank">http://emby.media</a>';
$('.embyIntroDownloadMessage', page).html(Globalize.translate('EmbyIntroDownloadMessage', link));
if (Dashboard.isRunningInCordova()) {
$('.newUsers', page).hide();
$('.forgotPassword', page).hide();
$('.skip', page).show();
} else {
$('.skip', page).hide();
$('.newUsers', page).show();
$('.forgotPassword', page).show();
}
});
function submitManualServer(page) {
var host = $('#txtServerHost', page).val();
var port = $('#txtServerPort', page).val();
if (port) {
host += ':' + port;
}
Dashboard.showLoadingMsg();
ConnectionManager.connectToAddress(host).done(function (result) {
Dashboard.hideLoadingMsg();
handleConnectionResult(page, result);
});
}
function submit(page) { function submit(page) {
var user = $('#txtManualName', page).val(); var user = $('#txtManualName', page).val();
@ -45,6 +165,15 @@
submit(page); submit(page);
return false; return false;
},
onManualServerSubmit: function () {
var page = $(this).parents('.page');
submitManualServer(page);
return false;
} }
}; };

View File

@ -41,6 +41,8 @@
} }
if (user.name) {
html += '<a class="headerButton headerButtonRight headerUserButton" href="#" onclick="Dashboard.showUserFlyout(this);">'; html += '<a class="headerButton headerButtonRight headerUserButton" href="#" onclick="Dashboard.showUserFlyout(this);">';
if (user.imageUrl) { if (user.imageUrl) {
@ -59,6 +61,7 @@
} }
html += '</a>'; html += '</a>';
}
if (user.canManageServer) { if (user.canManageServer) {
html += '<a href="dashboard.html" class="headerButton headerButtonRight dashboardEntryHeaderButton"><div class="fa fa-cog"></div></a>'; html += '<a href="dashboard.html" class="headerButton headerButtonRight dashboardEntryHeaderButton"><div class="fa fa-cog"></div></a>';

View File

@ -19,6 +19,15 @@
window.location = 'index.html'; window.location = 'index.html';
} }
break; break;
case MediaBrowser.ConnectionState.ServerSignIn:
{
if (Dashboard.isRunningInCordova()) {
window.location = 'connectlogin.html?mode=serversignin&serverid=' + result.Servers[0].Id;
} else {
showServerConnectionFailure();
}
}
break;
default: default:
showServerConnectionFailure(); showServerConnectionFailure();
break; break;
@ -326,11 +335,19 @@
function loadInvitations(page) { function loadInvitations(page) {
if (ConnectionManager.isLoggedIntoConnect()) {
ConnectionManager.getUserInvitations().done(function (list) { ConnectionManager.getUserInvitations().done(function (list) {
renderInvitations(page, list); renderInvitations(page, list);
}); });
} else {
renderInvitations(page, []);
}
} }
function loadPage(page) { function loadPage(page) {
@ -345,6 +362,14 @@
}); });
loadInvitations(page); loadInvitations(page);
if (Dashboard.isRunningInCordova()) {
$('.newServer', page).show();
$('.connectLogin', page).show();
} else {
$('.newServer', page).hide();
$('.connectLogin', page).hide();
}
} }
$(document).on('pageshow', "#selectServerPage", function () { $(document).on('pageshow', "#selectServerPage", function () {

View File

@ -42,8 +42,22 @@ var Dashboard = {
$.mobile.panel.prototype.options.classes.panel = "largePanel ui-panel"; $.mobile.panel.prototype.options.classes.panel = "largePanel ui-panel";
}, },
isConnectMode: function () {
return true;
if (Dashboard.isRunningInCordova()) {
return true;
}
var url = getWindowUrl().toLowerCase();
return url.indexOf('mediabrowser.tv') != -1 ||
url.indexOf('emby.media') != -1;
},
isRunningInCordova: function () { isRunningInCordova: function () {
return true;
return window.appMode == 'cordova'; return window.appMode == 'cordova';
}, },
@ -185,18 +199,6 @@ var Dashboard = {
Dashboard.getUserPromise = null; Dashboard.getUserPromise = null;
}, },
isConnectMode: function () {
if (Dashboard.isRunningInCordova()) {
return true;
}
var url = getWindowUrl().toLowerCase();
return url.indexOf('mediabrowser.tv') != -1 ||
url.indexOf('emby.media') != -1;
},
logout: function (logoutWithServer) { logout: function (logoutWithServer) {
store.removeItem("userId"); store.removeItem("userId");
@ -1648,18 +1650,6 @@ $(document).on('pagecreate', ".page", function () {
var page = $(this); var page = $(this);
var isConnectMode = Dashboard.isConnectMode();
if (isConnectMode && !page.hasClass('connectLoginPage')) {
if (!ConnectionManager.isLoggedIntoConnect()) {
console.log('Not logged into connect. Redirecting to login.');
Dashboard.logout();
return;
}
}
var apiClient = ConnectionManager.currentApiClient(); var apiClient = ConnectionManager.currentApiClient();
if (Dashboard.getAccessToken() && Dashboard.getCurrentUserId()) { if (Dashboard.getAccessToken() && Dashboard.getCurrentUserId()) {
@ -1686,6 +1676,16 @@ $(document).on('pagecreate', ".page", function () {
else { else {
var isConnectMode = Dashboard.isConnectMode();
if (isConnectMode) {
if (!Dashboard.isServerlessPage()) {
Dashboard.logout();
return;
}
}
if (this.id !== "loginPage" && !page.hasClass('forgotPasswordPage') && !page.hasClass('wizardPage') && !isConnectMode) { if (this.id !== "loginPage" && !page.hasClass('forgotPasswordPage') && !page.hasClass('wizardPage') && !isConnectMode) {
console.log('Not logged into server. Redirecting to login.'); console.log('Not logged into server. Redirecting to login.');

View File

@ -400,7 +400,9 @@
var page = this; var page = this;
if (!Dashboard.isServerlessPage()) {
showSyncButtonsPerUser(page); showSyncButtonsPerUser(page);
}
}); });

View File

@ -19,6 +19,13 @@
</div> </div>
<div class="serverList"></div> <div class="serverList"></div>
<div class="newServer">
<br />
<a data-role="button" href="connectlogin.html?mode=manualserver" data-icon="plus">${ButtonNewServer}</a>
</div>
<div class="connectLogin">
<a data-role="button" href="connectlogin.html?mode=connect" data-icon="action">${ButtonSignInWithConnect}</a>
</div>
<br /> <br />
<div class="noServersMessage" style="display:none;padding-left:5px;"> <div class="noServersMessage" style="display:none;padding-left:5px;">
${MessageNoServersAvailableToConnect} ${MessageNoServersAvailableToConnect}