update tabs

This commit is contained in:
Luke Pulverenti 2016-09-01 21:54:30 -04:00
parent 4e2c7058ca
commit 06b766604b
5 changed files with 75 additions and 104 deletions

View File

@ -9,7 +9,7 @@
align-items: center;
justify-content: center;
text-transform: none !important;
font-size: 12px !important;
font-size: 12.4px !important;
padding: 0 !important;
margin: 0 !important;
text-align: center;

View File

@ -170,6 +170,9 @@
e.preventDefault();
e.stopPropagation();
break;
case 6:
Dashboard.navigate('dashboard.html');
break;
default:
break;
}
@ -206,7 +209,7 @@
var html = '';
var liveTVButtonClass = appHost.supports('sync') ? ' dockedtab-midsize' : '';
html += ' <div is="emby-tabs" class="dockedtabs-tabs" data-selectionbar="false">\
<button is="emby-button" class="dockedtabs-tab-button emby-tab-button emby-tab-button-active" data-index="0">\
<div class="dockedtabs-tab-button-foreground emby-button-foreground"><i class="dockedtabs-tab-button-icon md-icon">home</i><div>' + globalize.translate('TabHome') + '</div></div>\
@ -214,7 +217,7 @@
<button is="emby-button" class="dockedtabs-tab-button emby-tab-button" data-index="1">\
<div class="dockedtabs-tab-button-foreground emby-button-foreground"><i class="dockedtabs-tab-button-icon md-icon">dvr</i><div>' + globalize.translate('HeaderLibraries') + '</div></div>\
</button>\
<button is="emby-button" class="dockedtabs-tab-button emby-tab-button docked-tab-livetv' + liveTVButtonClass + '" data-index="2">\
<button is="emby-button" class="dockedtabs-tab-button emby-tab-button docked-tab-livetv hide' + liveTVButtonClass + '" data-index="2">\
<div class="dockedtabs-tab-button-foreground emby-button-foreground"><i class="dockedtabs-tab-button-icon md-icon">live_tv</i><div>' + globalize.translate('HeaderLiveTV') + '</div></div>\
</button>\
<button is="emby-button" class="dockedtabs-tab-button emby-tab-button homeFavoritesTab" data-index="3">\
@ -229,6 +232,11 @@
';
}
html += '<button is="emby-button" class="dockedtabs-tab-button emby-tab-button docked-tab-manageserver hide dockedtab-midsize" data-index="6">\
<div class="dockedtabs-tab-button-foreground emby-button-foreground"><i class="dockedtabs-tab-button-icon md-icon">dashboard</i><div>' + globalize.translate('ButtonManageServer') + '</div></div>\
</button>\
';
html += '<button is="emby-button" class="dockedtabs-tab-button emby-tab-button" data-index="5">\
<div class="dockedtabs-tab-button-foreground emby-button-foreground"><i class="dockedtabs-tab-button-icon md-icon">menu</i><div>' + globalize.translate('ButtonMore') + '</div></div>\
</button>\
@ -261,6 +269,12 @@
} else {
element.querySelector('.docked-tab-livetv').classList.add('hide');
}
if (user.Policy.IsAdministrator) {
element.querySelector('.docked-tab-manageserver').classList.remove('hide');
} else {
element.querySelector('.docked-tab-manageserver').classList.add('hide');
}
}
function showUserTabs(user, element) {

View File

@ -91,7 +91,7 @@
.libraryMenuButtonText {
text-decoration: none;
font-weight: 400 !important;
font-weight: 500 !important;
display: inline-flex;
vertical-align: middle;
padding-left: 0 !important;
@ -102,7 +102,8 @@
overflow: hidden;
text-overflow: ellipsis;
align-items: center;
margin-left: 1em;
margin-left: .5em;
font-size: 108%;
}
.viewMenuBar {
@ -230,13 +231,6 @@
background-color: #1D1D20;
}
@media all and (max-width: 360px) {
.libraryMenuButtonText {
display: none;
}
}
@media all and (max-width: 800px) {
/* The sidebar isn't visible at this size, so there's no way to navigate within the editor */

View File

@ -76,19 +76,6 @@ h1, h1 a {
font-weight: 400;
}
.libraryMenuButtonText {
font-weight: 500 !important;
position: absolute;
left: 100px;
right: 100px;
top: 12px;
text-align: center;
font-size: 16px;
margin: 0 auto !important;
padding: 0 !important;
justify-content: center;
}
.noSecondaryNavPage .itemBackdrop {
margin-top: 0;
}
@ -121,10 +108,6 @@ h1, h1 a {
right: 5px !important;
}
.searchBackButton {
display: none !important;
}
.txtSearch {
padding-bottom: .5em !important;
text-indent: 0 !important;

View File

@ -1,76 +1,44 @@
define(['appSettings', 'cardStyle', 'emby-checkbox'], function (appSettings) {
define(['appSettings', 'dom', 'connectionManager', 'cardStyle', 'emby-checkbox'], function (appSettings, dom, connectionManager) {
function getApiClient() {
function authenticateUserByName(page, apiClient, username, password) {
var serverId = getParameterByName('serverid');
Dashboard.showLoadingMsg();
if (serverId) {
return ConnectionManager.getOrCreateApiClient(serverId);
apiClient.authenticateUserByName(username, password).then(function (result) {
} else {
return ApiClient;
}
}
var user = result.User;
var LoginPage = {
var serverId = getParameterByName('serverid');
showVisualForm: function (page) {
var newUrl;
page.querySelector('.visualLoginForm').classList.remove('hide');
page.querySelector('.manualLoginForm').classList.add('hide');
},
getLastSeenText: function (lastActivityDate) {
if (!lastActivityDate) {
return "";
if (user.Policy.IsAdministrator && !serverId) {
newUrl = "dashboard.html";
} else {
newUrl = "home.html";
}
return "Last seen " + humane_date(lastActivityDate);
},
Dashboard.hideLoadingMsg();
authenticateUserByName: function (page, apiClient, username, password) {
Dashboard.onServerChanged(user.Id, result.AccessToken, apiClient);
Dashboard.navigate(newUrl);
Dashboard.showLoadingMsg();
}, function (response) {
apiClient.authenticateUserByName(username, password).then(function (result) {
page.querySelector('#txtManualName').value = '';
page.querySelector('#txtManualPassword').value = '';
var user = result.User;
Dashboard.hideLoadingMsg();
var serverId = getParameterByName('serverid');
var newUrl;
if (user.Policy.IsAdministrator && !serverId) {
newUrl = "dashboard.html";
} else {
newUrl = "home.html";
}
Dashboard.hideLoadingMsg();
Dashboard.onServerChanged(user.Id, result.AccessToken, apiClient);
Dashboard.navigate(newUrl);
}, function (response) {
page.querySelector('#txtManualName').value = '';
page.querySelector('#txtManualPassword').value = '';
Dashboard.hideLoadingMsg();
if (response.status == 401) {
require(['toast'], function (toast) {
toast(Globalize.translate('MessageInvalidUser'));
});
} else {
showServerConnectionFailure();
}
});
}
};
if (response.status == 401) {
require(['toast'], function (toast) {
toast(Globalize.translate('MessageInvalidUser'));
});
} else {
showServerConnectionFailure();
}
});
}
function showServerConnectionFailure() {
@ -166,7 +134,7 @@
html += '<div class="cardText">' + user.Name + '</div>';
html += '<div class="cardText cardText-secondary">';
var lastSeen = LoginPage.getLastSeenText(user.LastActivityDate);
var lastSeen = getLastSeenText(user.LastActivityDate);
if (lastSeen != "") {
html += lastSeen;
}
@ -183,25 +151,39 @@
context.querySelector('#divUsers').innerHTML = html;
}
function parentWithClass(elem, className) {
function getLastSeenText(lastActivityDate) {
while (!elem.classList || !elem.classList.contains(className)) {
elem = elem.parentNode;
if (!elem) {
return null;
}
if (!lastActivityDate) {
return "";
}
return elem;
return "Last seen " + humane_date(lastActivityDate);
}
return function (view, params) {
var self = this;
function getApiClient() {
var serverId = params.serverid;
if (serverId) {
return connectionManager.getOrCreateApiClient(serverId);
} else {
return ApiClient;
}
}
function showVisualForm() {
view.querySelector('.visualLoginForm').classList.remove('hide');
view.querySelector('.manualLoginForm').classList.add('hide');
}
view.querySelector('#divUsers').addEventListener('click', function (e) {
var cardContent = parentWithClass(e.target, 'cardContent');
var cardContent = dom.parentWithClass(e.target, 'cardContent');
if (cardContent) {
@ -215,7 +197,7 @@
showManualForm(context, true);
}
else if (haspw == 'false') {
LoginPage.authenticateUserByName(context, getApiClient(), name, '');
authenticateUserByName(context, getApiClient(), name, '');
} else {
context.querySelector('#txtManualName').value = name;
@ -230,7 +212,7 @@
appSettings.enableAutoLogin(view.querySelector('.chkRememberLogin').checked);
var apiClient = getApiClient();
LoginPage.authenticateUserByName(view, apiClient, view.querySelector('#txtManualName').value, view.querySelector('#txtManualPassword').value);
authenticateUserByName(view, apiClient, view.querySelector('#txtManualName').value, view.querySelector('#txtManualPassword').value);
e.preventDefault();
// Disable default form submission
@ -241,9 +223,7 @@
Dashboard.navigate('forgotpassword.html');
});
view.querySelector('.btnCancel').addEventListener('click', function () {
LoginPage.showVisualForm(view);
});
view.querySelector('.btnCancel').addEventListener('click', showVisualForm);
view.querySelector('.btnManual').addEventListener('click', function () {
view.querySelector('#txtManualName').value = '';
@ -263,7 +243,7 @@
} else {
LoginPage.showVisualForm(view);
showVisualForm();
loadUserList(view, apiClient, users);
}