var UserProfilesPage = {
onPageShow: function () {
UserProfilesPage.loadPageData();
},
loadPageData: function () {
Dashboard.showLoadingMsg();
ApiClient.getAllUsers().done(UserProfilesPage.renderUsers);
},
renderUsers: function (users) {
var html = "";
html += '
Users
';
for (var i = 0, length = users.length; i < length; i++) {
var user = users[i];
html += "";
html += "";
if (user.PrimaryImageTag) {
var url = ApiClient.getUserImageUrl(user.Id, {
width: 225,
tag: user.PrimaryImageTag,
type: "Primary"
});
html += "";
} else {
html += "";
}
html += "" + user.Name + "
";
html += "";
html += "Delete";
html += "";
}
$('#ulUserProfiles', $('#userProfilesPage')).html(html).listview('refresh');
Dashboard.hideLoadingMsg();
},
deleteUser: function (link) {
var name = link.getAttribute('data-username');
var msg = "Are you sure you wish to delete " + name + "?";
Dashboard.confirm(msg, "Delete User", function (result) {
if (result) {
Dashboard.showLoadingMsg();
var id = link.getAttribute('data-userid');
ApiClient.deleteUser(id).done(function () {
Dashboard.validateCurrentUser();
UserProfilesPage.loadPageData();
});
}
});
}
};
$(document).on('pageshow', "#userProfilesPage", UserProfilesPage.onPageShow);