diff --git a/dashboard-ui/advanced.html b/dashboard-ui/advanced.html index 0079614c4c..74c690cffe 100644 --- a/dashboard-ui/advanced.html +++ b/dashboard-ui/advanced.html @@ -12,6 +12,7 @@
${TabGeneral} ${TabHosting} + ${TabSecurity}
diff --git a/dashboard-ui/dashboardhosting.html b/dashboard-ui/dashboardhosting.html index 1723848a98..d612632df3 100644 --- a/dashboard-ui/dashboardhosting.html +++ b/dashboard-ui/dashboardhosting.html @@ -12,6 +12,7 @@
${TabGeneral} ${TabHosting} + ${TabSecurity}
diff --git a/dashboard-ui/scripts/itembynamedetailpage.js b/dashboard-ui/scripts/itembynamedetailpage.js index 45ff455e47..0f1ec28439 100644 --- a/dashboard-ui/scripts/itembynamedetailpage.js +++ b/dashboard-ui/scripts/itembynamedetailpage.js @@ -1,4 +1,4 @@ -(function ($, document, LibraryBrowser) { +(function ($, document) { function renderItems(page, item) { @@ -337,4 +337,4 @@ renderItems: renderItems }; -})(jQuery, document, LibraryBrowser); \ No newline at end of file +})(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/itemdetailpage.js b/dashboard-ui/scripts/itemdetailpage.js index 56ea06aba8..d8f7448a70 100644 --- a/dashboard-ui/scripts/itemdetailpage.js +++ b/dashboard-ui/scripts/itemdetailpage.js @@ -1,4 +1,4 @@ -(function ($, document, LibraryBrowser, window) { +(function ($, document, window) { var currentItem; @@ -2092,4 +2092,4 @@ window.ItemDetailPage = new itemDetailPage(); -})(jQuery, document, LibraryBrowser, window); \ No newline at end of file +})(jQuery, document, window); \ No newline at end of file diff --git a/dashboard-ui/scripts/notifications.js b/dashboard-ui/scripts/notifications.js index 205d2a1234..e21512a9a9 100644 --- a/dashboard-ui/scripts/notifications.js +++ b/dashboard-ui/scripts/notifications.js @@ -1,4 +1,4 @@ -(function ($, document, Dashboard, LibraryBrowser) { +(function ($, document, Dashboard) { function notifications() { @@ -205,4 +205,4 @@ }); -})(jQuery, document, Dashboard, LibraryBrowser); \ No newline at end of file +})(jQuery, document, Dashboard); \ No newline at end of file diff --git a/dashboard-ui/scripts/serversecurity.js b/dashboard-ui/scripts/serversecurity.js new file mode 100644 index 0000000000..e675c548c6 --- /dev/null +++ b/dashboard-ui/scripts/serversecurity.js @@ -0,0 +1,144 @@ +(function ($, document) { + + function revoke(page, key) { + + Dashboard.confirm(Globalize.translate('MessageConfirmRevokeApiKey'), Globalize.translate('HeaderConfirmRevokeApiKey'), function (result) { + + if (result) { + + Dashboard.showLoadingMsg(); + + ApiClient.ajax({ + type: "DELETE", + url: ApiClient.getUrl('Auth/Keys/' + key) + + }).then(function () { + + loadData(page); + }); + } + + }); + } + + function renderKeys(page, keys, users) { + + var rows = keys.map(function (item) { + + var html = ''; + + html += ''; + + html += ''; + html += ''; + html += ''; + + html += ''; + html += (item.AccessToken); + html += ''; + + html += ''; + html += (item.AppName || ''); + html += ''; + + html += ''; + html += (item.DeviceName || ''); + html += ''; + + html += ''; + + var user = users.filter(function (u) { + + return u.Id == item.UserId; + })[0]; + + if (user) { + html += user.Name; + } + + html += ''; + + html += ''; + + var date = parseISO8601Date(item.DateCreated, { toLocal: true }); + + html += date.toLocaleDateString() + ' ' + LibraryBrowser.getDisplayTime(date); + + html += ''; + + html += ''; + + return html; + + }).join(''); + + var elem = $('.resultBody', page).html(rows).parents('.tblApiKeys').table("refresh").trigger('create'); + + $('.btnRevoke', elem).on('click', function () { + + revoke(page, this.getAttribute('data-token')); + }); + + Dashboard.hideLoadingMsg(); + } + + function loadData(page) { + + Dashboard.showLoadingMsg(); + + ApiClient.getUsers().then(function (users) { + + ApiClient.getJSON(ApiClient.getUrl('Auth/Keys')).then(function (result) { + + renderKeys(page, result.Items, users); + }); + }); + } + + function onSubmit() { + var form = this; + var page = $(form).parents('.page'); + + Dashboard.showLoadingMsg(); + + ApiClient.ajax({ + type: "POST", + url: ApiClient.getUrl('Auth/Keys', { + + App: $('#txtAppName', form).val() + + }) + + }).then(function () { + + $('.newKeyPanel', page).panel('close'); + + loadData(page); + }); + + return false; + } + + pageIdOn('pageinit', "serverSecurityPage", function () { + + var page = this; + + $('.btnNewKey', page).on('click', function () { + + $('.newKeyPanel', page).panel('toggle'); + + $('#txtAppName', page).val('').focus(); + + }); + + $('.newKeyForm').off('submit', onSubmit).on('submit', onSubmit); + + }); + pageIdOn('pagebeforeshow', "serverSecurityPage", function () { + + var page = this; + + loadData(page); + }); + +})(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/shared.js b/dashboard-ui/scripts/shared.js index c0aafb969a..41c3ef6fec 100644 --- a/dashboard-ui/scripts/shared.js +++ b/dashboard-ui/scripts/shared.js @@ -1,4 +1,4 @@ -(function ($, document, LibraryBrowser, window) { +(function ($, document, window) { var currentItem; @@ -87,4 +87,4 @@ }); -})(jQuery, document, LibraryBrowser, window); \ No newline at end of file +})(jQuery, document, window); \ No newline at end of file diff --git a/dashboard-ui/serversecurity.html b/dashboard-ui/serversecurity.html new file mode 100644 index 0000000000..9d301b38f6 --- /dev/null +++ b/dashboard-ui/serversecurity.html @@ -0,0 +1,58 @@ + + + + ${TitleAdvanced} + + +
+
+
+ +
+

+ ${HeaderApiKeys} +

+ + + ${ButtonAdd} + +
+

${HeaderApiKeysHelp}

+
+ + + + + + + + + + + + +
${HeaderApiKey}${HeaderApp}${HeaderDevice}${HeaderUser}${HeaderDateIssued}
+
+
+
+ +

${HeaderNewApiKey}

+

${HeaderNewApiKeyHelp}

+
+ + +
${LabelAppNameExample}
+
+
+

+ +

+ +
+
+ +