This repository has been archived by the owner on Jan 19, 2019. It is now read-only.
forked from MediaBrowser/Emby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15c973d
commit 097d94e
Showing
12 changed files
with
238 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
MediaBrowser.WebDashboard/dashboard-ui/scripts/serversecurity.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 += '<tr>'; | ||
|
||
html += '<td>'; | ||
html += '<button data-token="' + item.AccessToken + '" class="btnRevoke" data-mini="true" title="' + Globalize.translate('ButtonRevoke') + '" style="margin:0;">' + Globalize.translate('ButtonRevoke') + '</button>'; | ||
html += '</td>'; | ||
|
||
html += '<td style="vertical-align:middle;">'; | ||
html += (item.AccessToken); | ||
html += '</td>'; | ||
|
||
html += '<td style="vertical-align:middle;">'; | ||
html += (item.AppName || ''); | ||
html += '</td>'; | ||
|
||
html += '<td style="vertical-align:middle;">'; | ||
html += (item.DeviceName || ''); | ||
html += '</td>'; | ||
|
||
html += '<td style="vertical-align:middle;">'; | ||
|
||
var user = users.filter(function (u) { | ||
|
||
return u.Id == item.UserId; | ||
})[0]; | ||
|
||
if (user) { | ||
html += user.Name; | ||
} | ||
|
||
html += '</td>'; | ||
|
||
html += '<td style="vertical-align:middle;">'; | ||
|
||
var date = parseISO8601Date(item.DateCreated, { toLocal: true }); | ||
|
||
html += date.toLocaleDateString() + ' ' + LibraryBrowser.getDisplayTime(date); | ||
|
||
html += '</td>'; | ||
|
||
html += '</tr>'; | ||
|
||
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
MediaBrowser.WebDashboard/dashboard-ui/serversecurity.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>${TitleAdvanced}</title> | ||
</head> | ||
<body> | ||
<div id="serverSecurityPage" data-role="page" class="page type-interior advancedConfigurationPage" data-require="jqmpanel,jqmtable,scripts/serversecurity,detailtablecss"> | ||
<div data-role="content"> | ||
<div class="content-primary"> | ||
<div data-role="controlgroup" data-type="horizontal" class="localnav" data-mini="true"> | ||
<a href="advanced.html" data-role="button">${TabGeneral}</a> | ||
<a href="dashboardhosting.html" data-role="button">${TabHosting}</a> | ||
<a href="#" data-role="button" class="ui-btn-active">${TabSecurity}</a> | ||
</div> | ||
<div class="detailSectionHeader" style="margin-top:2.5em;"> | ||
<h3 style="margin:.6em 0;vertical-align:middle;display:inline-block;"> | ||
${HeaderApiKeys} | ||
</h3> | ||
<paper-button raised class="btnNewKey submit mini" style="margin-left:1em;" title="${ButtonNew}"> | ||
<iron-icon icon="add"></iron-icon> | ||
<span>${ButtonAdd}</span> | ||
</paper-button> | ||
</div> | ||
<p>${HeaderApiKeysHelp}</p> | ||
<br /> | ||
<table data-role="table" data-mode="reflow" class="tblApiKeys stripedTable ui-responsive table-stroke" style="display: table;"> | ||
<thead> | ||
<tr> | ||
<th></th> | ||
<th>${HeaderApiKey}</th> | ||
<th>${HeaderApp}</th> | ||
<th>${HeaderDevice}</th> | ||
<th>${HeaderUser}</th> | ||
<th>${HeaderDateIssued}</th> | ||
</tr> | ||
</thead> | ||
<tbody class="resultBody"></tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<div data-role="panel" class="newKeyPanel" data-position="right" data-display="overlay" data-position-fixed="true"> | ||
<form class="newKeyForm"> | ||
<h3>${HeaderNewApiKey}</h3> | ||
<p>${HeaderNewApiKeyHelp}</p> | ||
<div> | ||
<label for="txtAppName">${LabelAppName}</label> | ||
<input type="text" id="txtAppName" required="required" /> | ||
<div class="fieldDescription">${LabelAppNameExample}</div> | ||
</div> | ||
<br /> | ||
<p> | ||
<button type="submit" data-icon="plus" data-mini="true" data-theme="b">${ButtonCreate}</button> | ||
</p> | ||
</form> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |