update Settings Window Builder, cleanup LDAP presentation
parent
887586cf4e
commit
1d6ae4e5d9
|
|
@ -4224,6 +4224,11 @@ module.exports = function(s,config,lang){
|
|||
"fieldType": 'div',
|
||||
"id": "alternate-logins"
|
||||
},
|
||||
{
|
||||
"fieldType": "btn-group",
|
||||
"forForm": true,
|
||||
"btns": [],
|
||||
},
|
||||
]
|
||||
},
|
||||
"2-Factor Authentication": {
|
||||
|
|
@ -5394,29 +5399,11 @@ module.exports = function(s,config,lang){
|
|||
"name": lang["LDAP"],
|
||||
"color": "forestgreen",
|
||||
"info": [
|
||||
{
|
||||
"name": "ldap_enable",
|
||||
"field": lang.Enabled,
|
||||
"description": "Enable LDAP authentication for this Group.",
|
||||
"default": "0",
|
||||
"example": "",
|
||||
"fieldType": "select",
|
||||
"possible": [
|
||||
{
|
||||
"name": lang.No,
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"name": lang.Yes,
|
||||
"value": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ldap_url",
|
||||
"field": lang.URL,
|
||||
"description": "",
|
||||
"example": "",
|
||||
"example": "ldap://127.0.0.1:389",
|
||||
"possible": ""
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -95,9 +95,8 @@ module.exports = (s,config,lang,app) => {
|
|||
}
|
||||
return response
|
||||
}
|
||||
s.definitions["Account Settings"].blocks["AlternateLogins"].info.push({
|
||||
"form-group-class-pre-layer": "form-group",
|
||||
"fieldType": "btn",
|
||||
const alternateLoginsFieldList = s.definitions["Account Settings"].blocks["AlternateLogins"].info
|
||||
alternateLoginsFieldList[alternateLoginsFieldList.length - 1].btns.push({
|
||||
"class": `btn-info google-sign-in`,
|
||||
"btnContent": `<i class="fa fa-google"></i> ${lang['Link Google Account']}`,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -75,7 +75,6 @@ module.exports = (s,config,lang,app) => {
|
|||
return response
|
||||
}
|
||||
async function updateLdapBaseDetails(params,updateFields){
|
||||
const enabled = updateFields.ldap_enable
|
||||
const url = updateFields.ldap_url
|
||||
const bindDN = updateFields.ldap_bindDN
|
||||
const searchBase = updateFields.ldap_searchBase
|
||||
|
|
@ -90,7 +89,6 @@ module.exports = (s,config,lang,app) => {
|
|||
],
|
||||
})
|
||||
const userDetails = JSON.parse(userResponse.rows[0].details)
|
||||
userDetails.ldap_enable = enabled
|
||||
userDetails.ldap_url = url
|
||||
userDetails.ldap_bindDN = bindDN
|
||||
userDetails.ldap_searchBase = searchBase
|
||||
|
|
@ -148,9 +146,8 @@ module.exports = (s,config,lang,app) => {
|
|||
}
|
||||
return response
|
||||
}
|
||||
s.definitions["Account Settings"].blocks["AlternateLogins"].info.push({
|
||||
"form-group-class-pre-layer": "form-group",
|
||||
"fieldType": "btn",
|
||||
const alternateLoginsFieldList = s.definitions["Account Settings"].blocks["AlternateLogins"].info
|
||||
alternateLoginsFieldList[alternateLoginsFieldList.length - 1].btns.push({
|
||||
"class": `btn-info ldap-sign-in`,
|
||||
"btnContent": `<i class="fa fa-group"></i> ${lang['Link LDAP Account']}`,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -6,17 +6,19 @@ $(document).ready(function(){
|
|||
alternateLoginsBox.empty()
|
||||
if(rows.length > 0){
|
||||
$.each(rows,function(n,row){
|
||||
alternateLoginsBox.append(`<div class="row" login-id="${row.loginId}">
|
||||
<div class="col-md-4" style="text-transform:capitalize;font-size: 150%;">
|
||||
<i class="fa fa-${row.type}"></i>
|
||||
<span>${row.type}</span>
|
||||
alternateLoginsBox.append(`<div class="row" login-id="${row.loginId}" style="border-bottom: 1px solid #333;padding-top:1rem;padding-bottom:1rem;display:flex">
|
||||
<div class="col-md-3" style="flex: 3">
|
||||
<i class="fa fa-address-card"></i>
|
||||
<span class="epic-text text-white">${row.type}</span>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3" style="flex: 3">
|
||||
<div>${row.name}</div>
|
||||
</div>
|
||||
<div class="col-md-3" style="flex: 3">
|
||||
<div title="${lang.lastLogin}">${moment(row.lastLogin).format('YYYY-MM-DD hh:mm:ss A')}</div>
|
||||
</div>
|
||||
<div class="col-md-4 text-right">
|
||||
<a class="btn btn-sm btn-danger unlink-account"><i class="fa fa-unlink"></i> ${lang.Unlink}</a>
|
||||
<div class="col-md-3 text-right" style="flex: 3">
|
||||
<a class="btn badge-sm badge btn-danger unlink-account"><i class="fa fa-unlink"></i> ${lang.Unlink}</a>
|
||||
</div>
|
||||
</div>`)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
$(document).ready(function(){
|
||||
$('#settings').on('click','.ldap-sign-in',function(){
|
||||
var signInWindow = window.open(getApiPrefix('loginTokenAddLDAP'),'popup','width=300,height=300,scrollbars=no,resizable=no');
|
||||
var signInWindow = window.open(getApiPrefix('loginTokenAddLDAP'),'popup','width=500,height=700,scrollbars=no,resizable=no');
|
||||
if(!signInWindow || signInWindow.closed || typeof signInWindow.closed=='undefined'){
|
||||
alert(`Your Popup Blocker is disabling this feature.`)
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -144,6 +144,22 @@ drawBlock = function(monitorSettings){
|
|||
var fieldElement = ''
|
||||
var preFill = field.preFill || ''
|
||||
switch(fieldType){
|
||||
case'btn-group':
|
||||
let fieldBtnContent = ``
|
||||
field.btns.forEach((btn) => {
|
||||
let btnClass = []
|
||||
let btnAttributes = []
|
||||
const btnBaseElement = btn.forForm || field.forForm ? 'button' : 'a'
|
||||
if(btn.class){
|
||||
btnClass.push(`${btn.class}`)
|
||||
}
|
||||
if(btn.attribute){
|
||||
btnAttributes.push(btn.attribute)
|
||||
}
|
||||
fieldBtnContent += `<${btnBaseElement} class="btn ${btnClass.join(' ')}" ${btnAttributes.join(' ')}>${btn.btnContent}</${btnBaseElement}>`
|
||||
})
|
||||
fieldElement = `<div class="btn-group btn-group-justified ${fieldClass.join(' ')}" ${attributes.join(' ')}>${fieldBtnContent}</div>`
|
||||
break;
|
||||
case'btn':
|
||||
baseElement = field.forForm ? 'button' : 'a'
|
||||
fieldElement = `<${baseElement} class="btn btn-block ${fieldClass.join(' ')}" ${attributes.join(' ')}>${field.btnContent}</${baseElement}>`
|
||||
|
|
@ -190,7 +206,7 @@ drawBlock = function(monitorSettings){
|
|||
if(field['form-group-class-pre-layer']){ %>
|
||||
<div class="<%- field['form-group-class-pre-layer'] %>">
|
||||
<% }
|
||||
if(fieldType === 'ul' || fieldType === 'div' || fieldType === 'btn' || fieldType === 'table' || fieldType === 'form'){ %>
|
||||
if(fieldType === 'ul' || fieldType === 'div' || fieldType === 'btn' || fieldType === 'btn-group' || fieldType === 'table' || fieldType === 'form'){ %>
|
||||
<%- fieldElement %>
|
||||
<% }else{ %>
|
||||
<div <%- hidden %> class="form-group <%- field['form-group-class'] %>">
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
window.libURL = originalURL + global.s.checkCorrectPathEnding(config.webPaths.home)
|
||||
%>
|
||||
<link rel="stylesheet" href="<%-window.libURL%>libs/css/bootstrap4.min.css" />
|
||||
<link rel="stylesheet" href="<%-window.libURL%>libs/css/dash2.basic.css">
|
||||
<link rel="stylesheet" href="<%-window.libURL%>libs/css/dash2.forms.css">
|
||||
<script src="<%-window.libURL%>libs/js/jquery.min.js"></script>
|
||||
<script src="<%-window.libURL%>libs/js/jquery.serialize.js"></script>
|
||||
|
|
|
|||
|
|
@ -30,224 +30,11 @@
|
|||
</div>
|
||||
</div>
|
||||
<%
|
||||
var buildOptions = function(field,possiblities){
|
||||
if(!field)console.error('field',field)
|
||||
var fieldElement = ''
|
||||
possiblities.forEach(function(option){
|
||||
if(option.optgroup){
|
||||
fieldElement += '<optgroup label="' + option.name + '">'
|
||||
fieldElement += buildOptions(field,option.optgroup)
|
||||
fieldElement += '</optgroup>'
|
||||
}else{
|
||||
var selected = ''
|
||||
if(option.value === field.default){
|
||||
selected = 'selected'
|
||||
}
|
||||
fieldElement += '<option value="' + option.value + '" ' + selected + '>' + option.name + '</option>'
|
||||
}
|
||||
})
|
||||
return fieldElement
|
||||
}
|
||||
var drawBlock = function(monitorSettings){
|
||||
if(monitorSettings.evaluation && !eval(monitorSettings.evaluation)){
|
||||
return
|
||||
}
|
||||
var attributes = []
|
||||
var styles = []
|
||||
var sectionClass = []
|
||||
var headerTitle = monitorSettings.headerTitle || lang[monitorSettings.name] || monitorSettings.name
|
||||
if(monitorSettings.hidden === true){
|
||||
styles.push('display:none')
|
||||
}
|
||||
if(monitorSettings.style){
|
||||
styles.push(monitorSettings.style)
|
||||
}
|
||||
if(monitorSettings.isSection === true){
|
||||
attributes.push('section')
|
||||
}
|
||||
if(monitorSettings.attribute){
|
||||
attributes.push(monitorSettings.attribute)
|
||||
}
|
||||
if(!monitorSettings.id){
|
||||
var userSettingsId = monitorSettings.name.replace(/[^a-zA-Z ]/g, '').replace(/[^a-zA-Z ]/g, '').replace(/ /g, '')
|
||||
monitorSettings.id = userSettingsId
|
||||
}
|
||||
attributes.push(`id="${monitorSettings.id}"`)
|
||||
if(monitorSettings.color){
|
||||
sectionClass.push(monitorSettings.color)
|
||||
}
|
||||
if(monitorSettings['section-class']){
|
||||
sectionClass.push(monitorSettings['section-class'])
|
||||
}
|
||||
if(monitorSettings.isAdvanced){ %>
|
||||
<div class="h_us_input h_us_advanced" style="display:none">
|
||||
<% }
|
||||
if(monitorSettings['section-pre-pre-class']){ %>
|
||||
<div class="<%- monitorSettings['section-pre-pre-class'] %>">
|
||||
<% }
|
||||
if(monitorSettings['section-pre-class']){ %>
|
||||
<div class="<%- monitorSettings['section-pre-class'] %>">
|
||||
<% }
|
||||
%>
|
||||
<div <%- attributes.join(' ') %> style="<%- styles.join(';') %>" class="form-group-group <%- sectionClass.join(' ') %>">
|
||||
<h4 class="monitor-section-header <%- monitorSettings.headerClass %>"><%- headerTitle %>
|
||||
<% if(monitorSettings.headerButtons){ %>
|
||||
<div class="pull-right">
|
||||
<% monitorSettings.headerButtons.forEach(function(button){ %>
|
||||
<a class="btn btn-success btn-xs <%- button.class %>">
|
||||
<% if(button.icon){ %><i class="fa fa-<%- button.icon %>"></i><% } %>
|
||||
<% if(button.text){ %><%- button.text %><% } %>
|
||||
</a>
|
||||
<% }) %>
|
||||
</div>
|
||||
<% } %>
|
||||
</h4>
|
||||
<div class="box-wrapper">
|
||||
<% if(monitorSettings['input-mapping']){ %>
|
||||
<div class="form-group-group forestgreen" style="display:none" input-mapping="<%- monitorSettings['input-mapping'] %>">
|
||||
<h4><%-lang['Input Feed']%>
|
||||
<div class="pull-right">
|
||||
<a class="btn btn-success btn-xs add_map_row"><i class="fa fa-plus-square-o"></i></a>
|
||||
</div>
|
||||
</h4>
|
||||
<div class="choices"></div>
|
||||
</div>
|
||||
<% } %>
|
||||
<% if(monitorSettings.blockquote){ %>
|
||||
<blockquote class="<%- monitorSettings.blockquoteClass || '' %>">
|
||||
<%- monitorSettings.blockquote %>
|
||||
</blockquote>
|
||||
<% } %>
|
||||
<% if(monitorSettings.blocks){
|
||||
monitorSettings.blocks.forEach(function(settingsBlock){
|
||||
drawBlock(settingsBlock)
|
||||
})
|
||||
}
|
||||
if(monitorSettings.info){
|
||||
monitorSettings.info.forEach(function(field){
|
||||
if(field.isFormGroupGroup === true){
|
||||
drawBlock(field)
|
||||
}else{
|
||||
if(field.notForSubAccount === true){
|
||||
var notForSubAccount = '!details.sub'
|
||||
if(!field.evaluation){
|
||||
field.evaluation = notForSubAccount
|
||||
}else{
|
||||
field.evaluation += ' && ' + notForSubAccount
|
||||
}
|
||||
}
|
||||
if(field.evaluation && !eval(field.evaluation)){
|
||||
return
|
||||
}
|
||||
var hidden = ''
|
||||
if(field.hidden === true){
|
||||
hidden = 'style="display:none"'
|
||||
}
|
||||
var fieldClass = []
|
||||
var attributes = []
|
||||
if(field.name && field.name.indexOf('detail=') > -1){
|
||||
attributes.push(field.name)
|
||||
}else if(field.name){
|
||||
attributes.push("name=" + field.name)
|
||||
}
|
||||
if(field.placeholder || field.default){
|
||||
attributes.push(`placeholder="${field.placeholder || field.default}"`)
|
||||
}else if(field.example){
|
||||
attributes.push(`placeholder="Example : ${field.example}"`)
|
||||
}
|
||||
if(field.attribute){
|
||||
attributes.push(field.attribute)
|
||||
}
|
||||
if(field.selector){
|
||||
attributes.push(`selector="${field.selector}"`)
|
||||
}
|
||||
if(field.id){
|
||||
attributes.push(`id="${field.id}"`)
|
||||
}
|
||||
if(field.class){
|
||||
fieldClass.push(`${field.class}`)
|
||||
}
|
||||
var possiblities = field.possible || []
|
||||
var fieldType = field.fieldType || 'text'
|
||||
var fieldElement = ''
|
||||
var preFill = field.preFill || ''
|
||||
switch(fieldType){
|
||||
case'btn':
|
||||
|
||||
fieldElement = `<a class="btn btn-block ${fieldClass.join(' ')}" ${attributes.join(' ')}>${field.btnContent}</a>`
|
||||
break;
|
||||
case'ul':
|
||||
fieldElement = `<ul ${attributes.join(' ')} class="${fieldClass.join(' ')}" ></ul>`
|
||||
break;
|
||||
case'div':
|
||||
fieldElement = `<div ${attributes.join(' ')} class="${fieldClass.join(' ')}" ></div>`
|
||||
break;
|
||||
case'number':
|
||||
if(field.numberMin){
|
||||
attributes.push(`min="${field.numberMin}"`)
|
||||
}
|
||||
if(field.numberMax){
|
||||
attributes.push(`max="${field.numberMax}"`)
|
||||
}
|
||||
fieldElement = '<div><input type="number" class="form-control" ' + attributes.join(' ') + '></div>'
|
||||
break;
|
||||
case'password':
|
||||
fieldElement = '<div><input type="password" class="form-control" ' + attributes.join(' ') + '></div>'
|
||||
break;
|
||||
case'text':
|
||||
fieldElement = `<div><input class="form-control" ${attributes.join(' ')} value="${preFill}"></div>`
|
||||
break;
|
||||
case'textarea':
|
||||
fieldElement = '<div><textarea class="form-control" ' + attributes.join(' ') + '></textarea></div>'
|
||||
break;
|
||||
case'select':
|
||||
fieldElement = '<div><select class="form-control" ' + attributes.join(' ') + '>'
|
||||
fieldElement += buildOptions(field,possiblities)
|
||||
fieldElement += '</select></div>'
|
||||
break;
|
||||
}
|
||||
if(field['form-group-class-pre-pre-layer']){ %>
|
||||
<div class="<%- field['form-group-class-pre-pre-layer'] %>">
|
||||
<% }
|
||||
if(field['form-group-class-pre-layer']){ %>
|
||||
<div class="<%- field['form-group-class-pre-layer'] %>">
|
||||
<% }
|
||||
if(fieldType === 'ul' || fieldType === 'div' || fieldType === 'btn'){ %>
|
||||
<%- fieldElement %>
|
||||
<% }else{ %>
|
||||
<div <%- hidden %> class="form-group <%- field['form-group-class'] %>">
|
||||
<label><div><span><%- field.field %>
|
||||
<% if(field.description){ %>
|
||||
<small><%- field.description %></small>
|
||||
<% } %>
|
||||
</span></div>
|
||||
<%- fieldElement %>
|
||||
</label>
|
||||
</div>
|
||||
<% }
|
||||
}
|
||||
if(field['form-group-class-pre-layer']){ %>
|
||||
</div>
|
||||
<% }
|
||||
if(field['form-group-class-pre-pre-layer']){ %>
|
||||
</div>
|
||||
<% }
|
||||
})
|
||||
}
|
||||
var drawBlock
|
||||
var buildOptions
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
if(monitorSettings['section-pre-class']){ %>
|
||||
</div>
|
||||
<% }
|
||||
if(monitorSettings['section-pre-pre-class']){ %>
|
||||
</div>
|
||||
<% }
|
||||
if(monitorSettings.isAdvanced){ %>
|
||||
</div>
|
||||
<% }
|
||||
}
|
||||
include fieldBuilders.ejs
|
||||
%>
|
||||
<% Object.keys(define['Account Settings'].blocks).forEach(function(blockKey){
|
||||
var accountSettings = define['Account Settings'].blocks[blockKey]
|
||||
|
|
|
|||
Loading…
Reference in New Issue