2016-03-18 21:26:17 -07:00
|
|
|
|
define(['jQuery'], function ($) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-14 08:10:51 -07:00
|
|
|
|
function deleteUser(page, id) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2015-07-15 04:26:47 -07:00
|
|
|
|
var msg = Globalize.translate('DeleteUserConfirmation');
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2016-02-22 11:35:44 -07:00
|
|
|
|
require(['confirm'], function (confirm) {
|
|
|
|
|
|
|
|
|
|
confirm(msg, Globalize.translate('DeleteUser')).then(function () {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2015-07-15 04:26:47 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.deleteUser(id).then(function () {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2015-07-15 04:26:47 -07:00
|
|
|
|
loadData(page);
|
|
|
|
|
});
|
2016-02-22 11:35:44 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-07-15 04:26:47 -07:00
|
|
|
|
});
|
2014-09-14 08:10:51 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showUserMenu(elem) {
|
|
|
|
|
|
2015-07-15 04:26:47 -07:00
|
|
|
|
var card = $(elem).parents('.card')[0];
|
|
|
|
|
var page = $(card).parents('.page')[0];
|
|
|
|
|
var userId = card.getAttribute('data-userid');
|
2014-09-14 08:10:51 -07:00
|
|
|
|
|
2015-07-15 04:26:47 -07:00
|
|
|
|
var menuItems = [];
|
2014-10-14 17:05:09 -07:00
|
|
|
|
|
2015-07-15 04:26:47 -07:00
|
|
|
|
menuItems.push({
|
|
|
|
|
name: Globalize.translate('ButtonOpen'),
|
|
|
|
|
id: 'open',
|
|
|
|
|
ironIcon: 'mode-edit'
|
|
|
|
|
});
|
2014-09-14 08:10:51 -07:00
|
|
|
|
|
2015-07-15 04:26:47 -07:00
|
|
|
|
menuItems.push({
|
|
|
|
|
name: Globalize.translate('ButtonLibraryAccess'),
|
|
|
|
|
id: 'access',
|
|
|
|
|
ironIcon: 'lock'
|
|
|
|
|
});
|
2014-09-14 08:10:51 -07:00
|
|
|
|
|
2015-07-15 04:26:47 -07:00
|
|
|
|
menuItems.push({
|
|
|
|
|
name: Globalize.translate('ButtonParentalControl'),
|
|
|
|
|
id: 'parentalcontrol',
|
|
|
|
|
ironIcon: 'person'
|
|
|
|
|
});
|
2014-09-14 08:10:51 -07:00
|
|
|
|
|
2015-07-15 04:26:47 -07:00
|
|
|
|
menuItems.push({
|
|
|
|
|
name: Globalize.translate('ButtonDelete'),
|
|
|
|
|
id: 'delete',
|
|
|
|
|
ironIcon: 'delete'
|
2014-09-14 08:10:51 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-01-30 21:04:00 -07:00
|
|
|
|
require(['actionsheet'], function (actionsheet) {
|
2015-07-15 04:26:47 -07:00
|
|
|
|
|
2016-01-30 21:04:00 -07:00
|
|
|
|
actionsheet.show({
|
2015-07-15 04:26:47 -07:00
|
|
|
|
items: menuItems,
|
|
|
|
|
positionTo: card,
|
|
|
|
|
callback: function (id) {
|
|
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
|
|
|
|
|
|
case 'open':
|
|
|
|
|
Dashboard.navigate('useredit.html?userid=' + userId);
|
|
|
|
|
break;
|
|
|
|
|
case 'access':
|
|
|
|
|
Dashboard.navigate('userlibraryaccess.html?userid=' + userId);
|
|
|
|
|
break;
|
|
|
|
|
case 'parentalcontrol':
|
|
|
|
|
Dashboard.navigate('userparentalcontrol.html?userid=' + userId);
|
|
|
|
|
break;
|
|
|
|
|
case 'delete':
|
|
|
|
|
deleteUser(page, userId);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-10-13 21:59:34 -07:00
|
|
|
|
function getUserHtml(user, addConnectIndicator) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
var html = '';
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2015-10-15 10:21:18 -07:00
|
|
|
|
var cssClass = "card squareCard bottomPaddedCard";
|
2014-09-14 08:10:51 -07:00
|
|
|
|
|
2014-12-19 23:06:27 -07:00
|
|
|
|
if (user.Policy.IsDisabled) {
|
2014-09-14 08:10:51 -07:00
|
|
|
|
cssClass += ' grayscale';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += "<div data-userid='" + user.Id + "' class='" + cssClass + "'>";
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
html += '<div class="cardBox visualCardBox">';
|
|
|
|
|
html += '<div class="cardScalable">';
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
html += '<div class="cardPadder"></div>';
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
var href = "useredit.html?userId=" + user.Id + "";
|
|
|
|
|
html += '<a class="cardContent" href="' + href + '">';
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
var imgUrl;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
if (user.PrimaryImageTag) {
|
2013-03-30 08:04:59 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
imgUrl = ApiClient.getUserImageUrl(user.Id, {
|
2014-09-14 08:10:51 -07:00
|
|
|
|
width: 300,
|
2014-09-13 07:10:30 -07:00
|
|
|
|
tag: user.PrimaryImageTag,
|
|
|
|
|
type: "Primary"
|
|
|
|
|
});
|
2013-03-29 19:39:36 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
} else {
|
|
|
|
|
imgUrl = 'css/images/userflyoutdefault.png';
|
|
|
|
|
}
|
2013-03-30 08:04:59 -07:00
|
|
|
|
|
2015-02-28 06:43:06 -07:00
|
|
|
|
var imageClass = 'cardImage';
|
|
|
|
|
if (user.Policy.IsDisabled) {
|
|
|
|
|
imageClass += ' disabledUser';
|
|
|
|
|
}
|
|
|
|
|
html += '<div class="' + imageClass + '" style="background-image:url(\'' + imgUrl + '\');">';
|
2013-03-30 08:04:59 -07:00
|
|
|
|
|
2014-10-13 21:59:34 -07:00
|
|
|
|
if (user.ConnectUserId && addConnectIndicator) {
|
2015-06-29 21:33:53 -07:00
|
|
|
|
html += '<div class="playedIndicator" title="' + Globalize.translate('TooltipLinkedToEmbyConnect') + '"><iron-icon icon="cloud"></iron-icon></div>';
|
2014-09-14 11:47:48 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
html += "</div>";
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
// cardContent
|
|
|
|
|
html += "</a>";
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
// cardScalable
|
|
|
|
|
html += "</div>";
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
html += '<div class="cardFooter">';
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2015-06-23 21:38:46 -07:00
|
|
|
|
html += '<div class="cardText" style="text-align:right; float:right;padding:0;">';
|
2015-07-14 09:39:34 -07:00
|
|
|
|
html += '<paper-icon-button icon="' + AppInfo.moreIcon + '" class="btnUserMenu"></paper-icon-button>';
|
2014-09-13 07:10:30 -07:00
|
|
|
|
html += "</div>";
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2015-06-17 23:23:44 -07:00
|
|
|
|
html += '<div class="cardText" style="padding-top:10px;padding-bottom:10px;">';
|
2014-09-13 07:10:30 -07:00
|
|
|
|
html += user.Name;
|
|
|
|
|
html += "</div>";
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
// cardFooter
|
|
|
|
|
html += "</div>";
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
// cardBox
|
|
|
|
|
html += "</div>";
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-13 07:10:30 -07:00
|
|
|
|
// card
|
|
|
|
|
html += "</div>";
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-14 08:10:51 -07:00
|
|
|
|
return html;
|
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-10-13 21:59:34 -07:00
|
|
|
|
function getUserSectionHtml(users, addConnectIndicator) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-09-14 08:10:51 -07:00
|
|
|
|
var html = '';
|
2014-09-13 07:10:30 -07:00
|
|
|
|
|
2014-10-13 21:59:34 -07:00
|
|
|
|
html += users.map(function (u) {
|
|
|
|
|
|
|
|
|
|
return getUserHtml(u, addConnectIndicator);
|
|
|
|
|
|
|
|
|
|
}).join('');
|
2014-09-13 07:10:30 -07:00
|
|
|
|
|
2014-09-14 08:10:51 -07:00
|
|
|
|
return html;
|
|
|
|
|
}
|
2014-09-13 07:10:30 -07:00
|
|
|
|
|
2014-10-13 21:59:34 -07:00
|
|
|
|
function renderUsersIntoElement(elem, users, addConnectIndicator) {
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
2014-10-13 21:59:34 -07:00
|
|
|
|
var html = getUserSectionHtml(users, addConnectIndicator);
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
2016-03-06 11:09:20 -07:00
|
|
|
|
elem.html(html);
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
|
|
|
|
$('.btnUserMenu', elem).on('click', function () {
|
|
|
|
|
showUserMenu(this);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-14 08:10:51 -07:00
|
|
|
|
function renderUsers(page, users) {
|
2014-09-13 07:10:30 -07:00
|
|
|
|
|
2014-10-13 21:22:17 -07:00
|
|
|
|
renderUsersIntoElement($('.localUsers', page), users.filter(function (u) {
|
|
|
|
|
return u.ConnectLinkType != 'Guest';
|
2014-10-13 21:59:34 -07:00
|
|
|
|
}), true);
|
2014-10-13 21:22:17 -07:00
|
|
|
|
|
|
|
|
|
renderUsersIntoElement($('.connectUsers', page), users.filter(function (u) {
|
|
|
|
|
return u.ConnectLinkType == 'Guest';
|
|
|
|
|
}));
|
2014-10-13 13:14:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showPendingUserMenu(elem) {
|
|
|
|
|
|
2016-02-08 21:46:25 -07:00
|
|
|
|
var menuItems = [];
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
2016-02-08 21:46:25 -07:00
|
|
|
|
menuItems.push({
|
|
|
|
|
name: Globalize.translate('ButtonCancel'),
|
|
|
|
|
id: 'delete',
|
|
|
|
|
ironIcon: 'delete'
|
|
|
|
|
});
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
2016-02-08 21:46:25 -07:00
|
|
|
|
require(['actionsheet'], function (actionsheet) {
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
2016-02-08 21:46:25 -07:00
|
|
|
|
var card = $(elem).parents('.card');
|
|
|
|
|
var page = $(elem).parents('.page');
|
|
|
|
|
var id = card.attr('data-id');
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
2016-02-08 21:46:25 -07:00
|
|
|
|
actionsheet.show({
|
|
|
|
|
items: menuItems,
|
|
|
|
|
positionTo: card,
|
|
|
|
|
callback: function (menuItemId) {
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
2016-02-08 21:46:25 -07:00
|
|
|
|
switch (menuItemId) {
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
2016-02-08 21:46:25 -07:00
|
|
|
|
case 'delete':
|
|
|
|
|
cancelAuthorization(page, id);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-31 21:15:10 -07:00
|
|
|
|
});
|
2014-10-13 13:14:53 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getPendingUserHtml(user) {
|
|
|
|
|
|
2014-09-14 08:10:51 -07:00
|
|
|
|
var html = '';
|
2014-09-13 07:10:30 -07:00
|
|
|
|
|
2015-10-15 10:21:18 -07:00
|
|
|
|
var cssClass = "card squareCard bottomPaddedCard";
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
|
|
|
|
html += "<div data-id='" + user.Id + "' class='" + cssClass + "'>";
|
|
|
|
|
|
|
|
|
|
html += '<div class="cardBox visualCardBox">';
|
|
|
|
|
html += '<div class="cardScalable">';
|
|
|
|
|
|
|
|
|
|
html += '<div class="cardPadder"></div>';
|
|
|
|
|
|
|
|
|
|
var href = "#";
|
|
|
|
|
html += '<a class="cardContent" href="' + href + '">';
|
|
|
|
|
|
|
|
|
|
var imgUrl = user.ImageUrl || 'css/images/userflyoutdefault.png';
|
|
|
|
|
|
|
|
|
|
html += '<div class="cardImage" style="background-image:url(\'' + imgUrl + '\');">';
|
|
|
|
|
|
|
|
|
|
html += "</div>";
|
2014-09-13 07:10:30 -07:00
|
|
|
|
|
2014-10-13 13:14:53 -07:00
|
|
|
|
// cardContent
|
|
|
|
|
html += "</a>";
|
|
|
|
|
|
|
|
|
|
// cardScalable
|
|
|
|
|
html += "</div>";
|
|
|
|
|
|
|
|
|
|
html += '<div class="cardFooter">';
|
|
|
|
|
|
2015-09-06 12:09:36 -07:00
|
|
|
|
html += '<div class="cardText" style="text-align:right; float:right;padding:0;">';
|
|
|
|
|
html += '<paper-icon-button icon="' + AppInfo.moreIcon + '" class="btnUserMenu"></paper-icon-button>';
|
2014-10-13 13:14:53 -07:00
|
|
|
|
html += "</div>";
|
|
|
|
|
|
2015-10-22 08:03:08 -07:00
|
|
|
|
html += '<div class="cardText" style="padding-top:10px;padding-bottom:10px;">';
|
2014-10-13 13:14:53 -07:00
|
|
|
|
html += user.UserName;
|
|
|
|
|
html += "</div>";
|
|
|
|
|
|
|
|
|
|
// cardFooter
|
|
|
|
|
html += "</div>";
|
|
|
|
|
|
|
|
|
|
// cardBox
|
|
|
|
|
html += "</div>";
|
|
|
|
|
|
|
|
|
|
// card
|
|
|
|
|
html += "</div>";
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderPendingGuests(page, users) {
|
|
|
|
|
|
|
|
|
|
if (users.length) {
|
|
|
|
|
$('.sectionPendingGuests', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.sectionPendingGuests', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var html = users.map(getPendingUserHtml).join('');
|
|
|
|
|
|
2016-03-06 11:09:20 -07:00
|
|
|
|
var elem = $('.pending', page).html(html);
|
2014-09-13 07:10:30 -07:00
|
|
|
|
|
2014-09-14 08:10:51 -07:00
|
|
|
|
$('.btnUserMenu', elem).on('click', function () {
|
2014-10-13 13:14:53 -07:00
|
|
|
|
showPendingUserMenu(this);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function cancelAuthorization(page, id) {
|
2014-10-13 21:22:17 -07:00
|
|
|
|
|
2014-10-13 13:14:53 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
// Add/Update connect info
|
|
|
|
|
ApiClient.ajax({
|
|
|
|
|
|
|
|
|
|
type: "DELETE",
|
|
|
|
|
url: ApiClient.getUrl('Connect/Pending', {
|
|
|
|
|
|
|
|
|
|
Id: id
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}).then(function () {
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
|
|
|
|
loadData(page);
|
|
|
|
|
|
2014-09-14 08:10:51 -07:00
|
|
|
|
});
|
2014-09-13 07:10:30 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 13:14:53 -07:00
|
|
|
|
function loadData(page) {
|
2014-09-13 07:10:30 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getUsers().then(function (users) {
|
2014-09-14 08:10:51 -07:00
|
|
|
|
renderUsers(page, users);
|
2014-09-13 07:10:30 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
});
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl('Connect/Pending')).then(function (pending) {
|
2014-10-13 13:14:53 -07:00
|
|
|
|
|
|
|
|
|
renderPendingGuests(page, pending);
|
|
|
|
|
});
|
2014-10-22 21:26:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 21:22:17 -07:00
|
|
|
|
function showInvitePopup(page) {
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
Dashboard.getCurrentUser().then(function (user) {
|
2014-10-13 21:22:17 -07:00
|
|
|
|
|
2016-02-08 21:46:25 -07:00
|
|
|
|
if (!user.ConnectUserId) {
|
2014-11-18 19:45:12 -07:00
|
|
|
|
|
|
|
|
|
var msg = Globalize.translate('MessageConnectAccountRequiredToInviteGuest');
|
|
|
|
|
|
|
|
|
|
msg += '<br/>';
|
|
|
|
|
msg += '<br/>';
|
2015-03-21 11:12:12 -07:00
|
|
|
|
msg += '<a href="useredit.html?userId=' + user.Id + '">' + Globalize.translate('ButtonLinkMyEmbyAccount') + '</a>';
|
2014-11-18 19:45:12 -07:00
|
|
|
|
msg += '<br/>';
|
|
|
|
|
|
2016-02-26 13:29:27 -07:00
|
|
|
|
require(['alert'], function (alert) {
|
|
|
|
|
alert({
|
|
|
|
|
title: Globalize.translate('HeaderInviteGuest'),
|
|
|
|
|
text: msg
|
|
|
|
|
});
|
2014-11-18 19:45:12 -07:00
|
|
|
|
});
|
2016-02-08 21:46:25 -07:00
|
|
|
|
return;
|
2014-11-18 19:45:12 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-08 21:46:25 -07:00
|
|
|
|
require(['components/guestinviter/guestinviter'], function (guestinviter) {
|
2015-06-08 22:56:46 -07:00
|
|
|
|
|
2016-02-08 21:46:25 -07:00
|
|
|
|
guestinviter.show().then(function () {
|
|
|
|
|
loadData(page);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
2015-06-08 22:56:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 07:01:59 -07:00
|
|
|
|
$(document).on('pageinit', "#userProfilesPage", function () {
|
2014-10-13 21:22:17 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.btnInvite', page).on('click', function () {
|
|
|
|
|
|
|
|
|
|
showInvitePopup(page);
|
|
|
|
|
});
|
|
|
|
|
|
2015-09-06 12:09:36 -07:00
|
|
|
|
$('.btnAddUser', page).on('click', function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.navigate('usernew.html');
|
|
|
|
|
});
|
|
|
|
|
|
2015-08-31 23:22:46 -07:00
|
|
|
|
}).on('pagebeforeshow', "#userProfilesPage", function () {
|
2014-09-13 07:10:30 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2014-10-13 13:14:53 -07:00
|
|
|
|
loadData(page);
|
2014-09-13 07:10:30 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|