unclean SPARC
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<style>
|
||||
.config-snipet{
|
||||
background-color: #000;
|
||||
padding: 5px;
|
||||
width: 100vh;
|
||||
}
|
||||
</style>
|
||||
<div class="system-message-form">
|
||||
<pre class="config-snipet"><code class="view-config language-json"></code></pre>
|
||||
</div>
|
||||
@@ -0,0 +1,27 @@
|
||||
class PlatformConfigViewDialog extends EICDialogContent {
|
||||
|
||||
actions = [
|
||||
{
|
||||
label: 'ok',
|
||||
onclick: this.confirm.bind(this),
|
||||
severity: 'primary',
|
||||
role: 'confirm'
|
||||
}
|
||||
]
|
||||
|
||||
DOMContentLoaded(options) {
|
||||
ui.eicfy(this.el);
|
||||
this.codeBox = this.find('.view-config')
|
||||
let snipet = hljs.highlight(JSON.stringify(options.config, null, 4), { 'language':'json'} );
|
||||
this.codeBox.innerHTML = snipet.value
|
||||
}
|
||||
|
||||
confirm(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
this.commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
app.registerClass('PlatformConfigViewDialog', PlatformConfigViewDialog);
|
||||
@@ -0,0 +1,18 @@
|
||||
<style>
|
||||
.system-message-form .allowed-users{ /* room for the popup-input */
|
||||
min-height: calc(8*var(--base-font-size));
|
||||
}
|
||||
</style>
|
||||
<div class="system-message-form">
|
||||
<p danger>You are about to restrict the EIC platform access.</p>
|
||||
<p>All users will be disconnected and unable to login anymore.</p>
|
||||
<p>Only specific roles and users selected below will still have access.</p>
|
||||
<div>
|
||||
<label>Allowed roles:</label>
|
||||
<select eicselect name="allowedRoles" multiple></select>
|
||||
</div>
|
||||
<div class="allowed-users">
|
||||
<label>Allowed EU-logins:</label>
|
||||
<select eicselect name="allowedUUIDs" editable data-type="array" class="" placeholder="Type EUlogin-ID and press enter" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,72 @@
|
||||
class PlatformDownDialog extends EICDialogContent {
|
||||
|
||||
actions = [
|
||||
{
|
||||
label: 'cancel',
|
||||
onclick: this.cancel.bind(this),
|
||||
severity: 'secondary',
|
||||
role: 'cancel'
|
||||
},
|
||||
{
|
||||
label: 'Restrict access',
|
||||
onclick: this.confirm.bind(this),
|
||||
severity: 'danger',
|
||||
role: 'confirm'
|
||||
}
|
||||
]
|
||||
|
||||
DOMContentLoaded(options) {
|
||||
let components = ui.eicfy(this.el)
|
||||
|
||||
this.RolesSelect = components.find(component => component.el.name == 'allowedRoles')
|
||||
this.UUIDsSelect = components.find(component => component.el.name == 'allowedUUIDs')
|
||||
|
||||
options.platform.getPlatformStatus().then(this.fillSelects.bind(this))
|
||||
|
||||
this.form = new Form(this.el);
|
||||
}
|
||||
|
||||
fillSelects(data){
|
||||
let allowedRoles = []
|
||||
let allowedUUIDs = []
|
||||
if(data.platformRestrictions && Array.isArray(data.platformRestrictions.allowedRoles)) {
|
||||
allowedRoles = data.platformRestrictions.allowedRoles
|
||||
}
|
||||
if(data.platformRestrictions && Array.isArray(data.platformRestrictions.allowedUUIDs)) {
|
||||
allowedUUIDs = data.platformRestrictions.allowedUUIDs
|
||||
}
|
||||
|
||||
if(allowedRoles.indexOf('EIC_Dev')<0) allowedRoles.push('EIC_Dev') // Voluntarily hard-coded, other securities also BE-side
|
||||
|
||||
// Would be cool, but css issues & currently can't avoid getting the group item in the values.
|
||||
// let roleOptions = app.meta.toOptionsRecurse(app.meta.getCollection('user-roles'), allowedRoles, true)
|
||||
// this.RolesSelect.el.innerHTML = roleOptions ;
|
||||
|
||||
let RolesChildren = app.meta.getCollection('user-roles').reduce((acc, item)=>{ acc = [...acc, ...item.children]; return(acc)},[])
|
||||
let rolesOptions = app.meta.toOptions(RolesChildren, allowedRoles)
|
||||
rolesOptions.forEach(item => this.RolesSelect.el.append(item))
|
||||
//having several options selected (in a multiple) doesn't work when appending, but works on setting the value as an Array
|
||||
this.RolesSelect.value = allowedRoles
|
||||
this.UUIDsSelect.value = allowedUUIDs
|
||||
}
|
||||
|
||||
cancel(event){
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
this.RolesSelect.closeCatalog()
|
||||
super.cancel(event)
|
||||
}
|
||||
|
||||
confirm(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
this.RolesSelect.closeCatalog()
|
||||
this.actions.forEach(item=> {item.button.loading=true; item.button.disabled=true} )
|
||||
if(this.form.validate()) {
|
||||
this.commit(this.form.value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
app.registerClass('PlatformDownDialog', PlatformDownDialog);
|
||||
@@ -0,0 +1,32 @@
|
||||
<div class="system-message-form">
|
||||
<label>Please provide the message you want to send:</label>
|
||||
|
||||
<div>
|
||||
<label>Predefined messages:</label>
|
||||
<select eicselect name="predefined"></select>
|
||||
</div>
|
||||
|
||||
<div class="cols-2">
|
||||
<div>
|
||||
<label>severity:</label>
|
||||
<select eicselect name="growlSeverity">
|
||||
<option value="secondary">secondary</option>
|
||||
<option value="primary">primary</option>
|
||||
<option value="danger">danger</option>
|
||||
<option value="success">success</option>
|
||||
<option value="warning">warning</option>
|
||||
<option value="info">info</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label>duration:</label>
|
||||
<input eicinput type="number" name="growlTime" value="5" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>message:</label>
|
||||
<textarea eictextarea name="growlMessage" data-path="" class="required" rows="6"></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,58 @@
|
||||
class PlatformUserMessageDialog extends EICDialogContent {
|
||||
|
||||
actions = [
|
||||
{
|
||||
label: 'cancel',
|
||||
onclick: this.cancel.bind(this),
|
||||
severity: 'secondary',
|
||||
role: 'cancel'
|
||||
},
|
||||
{
|
||||
label: 'send',
|
||||
onclick: this.confirm.bind(this),
|
||||
severity: 'primary',
|
||||
role: 'confirm'
|
||||
}
|
||||
]
|
||||
|
||||
DOMContentLoaded(options) {
|
||||
let components = ui.eicfy(this.el);
|
||||
this.messagesSelect = components.find(component => component.el.name == 'predefined')
|
||||
this.growlSeverity = components.find(component => component.el.name == 'growlSeverity')
|
||||
this.growlTime = components.find(component => component.el.name == 'growlTime')
|
||||
this.growlMessage = components.find(component => component.el.name == 'growlMessage')
|
||||
|
||||
let messagesSelectOptions = app.meta.toOptions(app.meta.getCollection('user-messages'),[],true)
|
||||
messagesSelectOptions.forEach(item => this.messagesSelect.el.append(item))
|
||||
this.messagesSelect.change(this.onMessageChange.bind(this));
|
||||
this.form = new Form(this.el);
|
||||
}
|
||||
|
||||
confirm(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
this.actions.forEach(item=> {item.button.loading=true; item.button.disabled=true} )
|
||||
if(this.form.validate()) {
|
||||
this.commit(this.form.value);
|
||||
} else {
|
||||
this.actions.forEach(item=> {item.button.loading=false; item.button.disabled=false} )
|
||||
}
|
||||
}
|
||||
|
||||
onMessageChange(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if(this.messagesSelect.value) {
|
||||
let msgData = app.meta.getCollection('user-messages').find(item=>item.id==this.messagesSelect.value)
|
||||
this.growlSeverity.value = msgData.severity
|
||||
this.growlTime.value = msgData.duration
|
||||
this.growlMessage.value = msgData.message.join('\n')
|
||||
} else {
|
||||
this.growlSeverity.value = 'secondary'
|
||||
this.growlTime.value = 5
|
||||
this.growlMessage.value = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app.registerClass('PlatformUserMessageDialog', PlatformUserMessageDialog);
|
||||
Reference in New Issue
Block a user