2013-02-20 18:33:05 -07:00
|
|
|
|
var UserProfilesPage = {
|
|
|
|
|
onPageShow: function () {
|
|
|
|
|
|
|
|
|
|
UserProfilesPage.loadPageData();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
loadPageData: function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
2013-03-21 13:43:42 -07:00
|
|
|
|
ApiClient.getUsers().done(UserProfilesPage.renderUsers);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
renderUsers: function (users) {
|
|
|
|
|
|
|
|
|
|
var html = "";
|
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
html += '<li data-role="list-divider"><h3>' + Globalize.translate('Users') + '</h3></li>';
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
for (var i = 0, length = users.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var user = users[i];
|
|
|
|
|
|
|
|
|
|
html += "<li>";
|
|
|
|
|
|
2013-12-26 08:40:38 -07:00
|
|
|
|
html += "<a href='useredit.html?userId=" + user.Id + "'>";
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
if (user.PrimaryImageTag) {
|
|
|
|
|
|
|
|
|
|
var url = ApiClient.getUserImageUrl(user.Id, {
|
2014-04-11 08:36:25 -07:00
|
|
|
|
width: 80,
|
2013-02-20 18:33:05 -07:00
|
|
|
|
tag: user.PrimaryImageTag,
|
|
|
|
|
type: "Primary"
|
|
|
|
|
});
|
|
|
|
|
html += "<img src='" + url + "' />";
|
|
|
|
|
} else {
|
2013-03-27 15:17:46 -07:00
|
|
|
|
html += "<img src='css/images/userflyoutdefault.png' />";
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-29 19:39:36 -07:00
|
|
|
|
html += "<h3>" + user.Name;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-03-30 08:04:59 -07:00
|
|
|
|
html += "</h3>";
|
|
|
|
|
|
|
|
|
|
html += "<p class='ui-li-aside'>";
|
2014-05-30 12:23:56 -07:00
|
|
|
|
if (user.Configuration.HasPassword) html += '<img src="css/images/userdata/password.png" alt="' + Globalize.translate('Password') + '" title="' + Globalize.translate('Password') + '" class="userProfileIcon" />';
|
|
|
|
|
if (user.Configuration.IsAdministrator) html += '<img src="css/images/userdata/administrator.png" alt="' + Globalize.translate('Administrator') + '" title="' + Globalize.translate('Administrator') + '" class="userProfileIcon" />';
|
2013-03-29 19:39:36 -07:00
|
|
|
|
|
2013-03-30 08:04:59 -07:00
|
|
|
|
html += "</p>";
|
|
|
|
|
|
|
|
|
|
html += "</a>";
|
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
html += "<a onclick='UserProfilesPage.deleteUser(this);' data-userid='" + user.Id + "' data-username='" + user.Name + "' href='#'>" + Globalize.translate('Delete') + "</a>";
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
html += "</li>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#ulUserProfiles', $('#userProfilesPage')).html(html).listview('refresh');
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
deleteUser: function (link) {
|
|
|
|
|
|
2013-12-27 09:18:42 -07:00
|
|
|
|
var page = $.mobile.activePage;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
var name = link.getAttribute('data-username');
|
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
var msg = Globalize.translate('DeleteUserConfirmation').replace('{0}', name);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
Dashboard.confirm(msg, Globalize.translate('DeleteUser'), function (result) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var id = link.getAttribute('data-userid');
|
|
|
|
|
|
|
|
|
|
ApiClient.deleteUser(id).done(function () {
|
|
|
|
|
|
|
|
|
|
UserProfilesPage.loadPageData();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$(document).on('pageshow', "#userProfilesPage", UserProfilesPage.onPageShow);
|