(function ($, document, window) { function loadProfiles(page) { Dashboard.showLoadingMsg(); ApiClient.getJSON(ApiClient.getUrl("Dlna/ProfileInfos")).then(function (result) { renderUserProfiles(page, result); renderSystemProfiles(page, result); Dashboard.hideLoadingMsg(); }); } function renderUserProfiles(page, profiles) { renderProfiles(page, page.querySelector('.customProfiles'), profiles.filter(function (p) { return p.Type == 'User'; })); } function renderSystemProfiles(page, profiles) { renderProfiles(page, page.querySelector('.systemProfiles'), profiles.filter(function (p) { return p.Type == 'System'; })); } function renderProfiles(page, element, profiles) { require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () { var html = ''; if (profiles.length) { html += '
'; } for (var i = 0, length = profiles.length; i < length; i++) { var profile = profiles[i]; html += ''; html += ""; html += ''; html += ""; html += ''; html += ""; html += "
" + profile.Name + "
"; //html += "
" + task.Description + "
"; html += "
"; html += '
'; if (profile.Type == 'User') { html += ''; } html += '
'; } if (profiles.length) { html += '
'; } element.innerHTML = html; $('.btnDeleteProfile', element).on('click', function () { var id = this.getAttribute('data-profileid'); deleteProfile(page, id); }); }); } function deleteProfile(page, id) { Dashboard.confirm(Globalize.translate('MessageConfirmProfileDeletion'), Globalize.translate('HeaderConfirmProfileDeletion'), function (result) { if (result) { Dashboard.showLoadingMsg(); ApiClient.ajax({ type: "DELETE", url: ApiClient.getUrl("Dlna/Profiles/" + id) }).then(function () { Dashboard.hideLoadingMsg(); loadProfiles(page); }); } }); } $(document).on('pageshow', "#dlnaProfilesPage", function () { var page = this; loadProfiles(page); }); })(jQuery, document, window);