Add API Key Manager for Super User
parent
428d17cf87
commit
6b3f2fc82e
|
|
@ -8460,32 +8460,62 @@ module.exports = function(s,config,lang){
|
|||
"Editor": {
|
||||
noHeader: true,
|
||||
"color": "grey",
|
||||
"noDefaultSectionClasses": true,
|
||||
"box-wrapper-class": "row",
|
||||
"info": [
|
||||
{
|
||||
"name": "mail",
|
||||
"field": lang.Email,
|
||||
isFormGroupGroup: true,
|
||||
"noHeader": true,
|
||||
"section-pre-class": "col-md-6",
|
||||
info: [
|
||||
{
|
||||
"name": "mail",
|
||||
"field": lang.Email,
|
||||
},
|
||||
{
|
||||
"name": "pass",
|
||||
"type": "password",
|
||||
"fieldType": "password",
|
||||
"field": lang['Password'],
|
||||
},
|
||||
{
|
||||
"name": "pass_again",
|
||||
"type": "password",
|
||||
"fieldType": "password",
|
||||
"field": lang['Password Again'],
|
||||
},
|
||||
{
|
||||
"fieldType": "btn-group",
|
||||
"btns": [
|
||||
{
|
||||
"fieldType": "btn",
|
||||
"class": `submit btn-success`,
|
||||
"btnContent": `${lang['Save']}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "pass",
|
||||
"type": "password",
|
||||
"fieldType": "password",
|
||||
"field": lang['Password'],
|
||||
},
|
||||
{
|
||||
"name": "pass_again",
|
||||
"type": "password",
|
||||
"fieldType": "password",
|
||||
"field": lang['Password Again'],
|
||||
},
|
||||
{
|
||||
"fieldType": "btn-group",
|
||||
"btns": [
|
||||
{
|
||||
"fieldType": "btn",
|
||||
"class": `submit btn-success`,
|
||||
"btnContent": `${lang['Save']}`,
|
||||
},
|
||||
],
|
||||
isFormGroupGroup: true,
|
||||
"name": lang["API Keys"],
|
||||
"section-pre-class": "col-md-6",
|
||||
info: [
|
||||
{
|
||||
"fieldType": "btn-group",
|
||||
"btns": [
|
||||
{
|
||||
"fieldType": "btn",
|
||||
"class": `new-token btn-success`,
|
||||
"btnContent": `${lang['Add']}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"id": "super-tokens",
|
||||
"fieldType": "div",
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -291,17 +291,17 @@ a {cursor:pointer}
|
|||
} */
|
||||
/* Slim Style */
|
||||
.form-control {
|
||||
background-color: transparent;
|
||||
/* background-color: transparent;
|
||||
border: 1px solid #E3E3E3;
|
||||
border-radius: 30px;
|
||||
color: #2c2c2c;
|
||||
line-height: normal;
|
||||
font-size: 0.8571em;
|
||||
box-shadow: none;
|
||||
box-shadow: none; */
|
||||
}
|
||||
.btn-round {
|
||||
border-width: 1px;
|
||||
border-radius: 30px !important;
|
||||
/* border-width: 1px; */
|
||||
/* border-radius: 30px !important; */
|
||||
}
|
||||
.btn, .navbar .navbar-nav>a.btn {
|
||||
font-weight: 400;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,49 @@
|
|||
$(document).ready(function(){
|
||||
var changeSuperPreferencesTab = $('#changeSuperPreferences')
|
||||
var tokenContainer = $('#super-tokens')
|
||||
var changeSuperPreferencesForm = changeSuperPreferencesTab.find('form')
|
||||
function drawTokenRow(tokenValue){
|
||||
var html = `<div class="d-flex flex-row token-row mt-3">
|
||||
<div class="flex-grow-1">
|
||||
<input class="form-control form-control-sm token-row-input" value="${tokenValue || ''}">
|
||||
</div>
|
||||
<div>
|
||||
<a class="delete-token btn btn-danger btn-sm my-0 ml-3"><i class="fa fa-trash"></i></a>
|
||||
</div>
|
||||
</div>`
|
||||
tokenContainer.append(html)
|
||||
}
|
||||
function getTokenRows(){
|
||||
var rowsFound = []
|
||||
changeSuperPreferencesTab.find('.token-row-input').each(function(n,v){
|
||||
var el = $(v)
|
||||
var tokenValue = el.val().trim()
|
||||
if(tokenValue)rowsFound.push(tokenValue);
|
||||
})
|
||||
return rowsFound
|
||||
}
|
||||
function loadPreferences(){
|
||||
var tokens = $user.tokens
|
||||
changeSuperPreferencesTab.find('[name=mail]').val($user.mail)
|
||||
if(tokens instanceof Array){
|
||||
tokens.forEach(function(token){
|
||||
drawTokenRow(token)
|
||||
})
|
||||
}
|
||||
}
|
||||
changeSuperPreferencesTab.find('.new-token').click(function(){
|
||||
drawTokenRow()
|
||||
})
|
||||
changeSuperPreferencesTab.on('click','.delete-token',function(){
|
||||
$(this).parents('.token-row').remove()
|
||||
})
|
||||
changeSuperPreferencesTab.find('.submit').click(function(){
|
||||
changeSuperPreferencesForm.submit()
|
||||
})
|
||||
changeSuperPreferencesForm.submit(function(e){
|
||||
e.preventDefault()
|
||||
var formValues = $(this).serializeObject()
|
||||
formValues.tokens = getTokenRows()
|
||||
// $.ccio.cx({f:'accounts',ff:'saveSuper',form:formValues})
|
||||
$.post(superApiPrefix + $user.sessionKey + '/accounts/saveSettings',{
|
||||
data: JSON.stringify(formValues)
|
||||
|
|
@ -15,8 +52,5 @@ $(document).ready(function(){
|
|||
})
|
||||
return false
|
||||
})
|
||||
function loadPreferences(){
|
||||
changeSuperPreferencesTab.find('[name=mail]').val($user.mail)
|
||||
}
|
||||
loadPreferences()
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue