unclean SPARC
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
class BypassAdminManagementContent extends BypassBaseManagementContent {
|
||||
|
||||
DOMContentLoaded(options) {
|
||||
|
||||
super.DOMContentLoaded(options);
|
||||
|
||||
let components = ui.eicfy(this.el);
|
||||
|
||||
this.gridKics = new DataGrid(this.find('.kic-domains-list'), {
|
||||
headers: [ { label: 'Thematic'}, { label: 'Tokens' }, { label: 'Remaining' } ],
|
||||
height: '320px'
|
||||
});
|
||||
|
||||
this.gridPlugins = new DataGrid(this.find('.plugin-domains-list'), {
|
||||
headers: [ { label: 'Country'}, { label: 'Tokens'}, { label: 'Remaining' } ],
|
||||
height: '320px'
|
||||
});
|
||||
|
||||
this.pluginEditButton = components.find(component => component.el.classList.contains('plugin-edit'));
|
||||
if(this.tokens.hasPrivilege('setSettings')) {
|
||||
this.pluginEditButton.addEventListener('click', this.onPluginEdit.bind(this));
|
||||
} else {
|
||||
ui.hide(this.pluginEditButton);
|
||||
}
|
||||
|
||||
this.kicEditButton = components.find(component => component.el.classList.contains('kic-edit'));
|
||||
if(this.tokens.hasPrivilege('setSettings')) {
|
||||
this.kicEditButton.addEventListener('click', this.onKicEdit.bind(this));
|
||||
} else {
|
||||
ui.hide(this.kicEditButton);
|
||||
}
|
||||
|
||||
this.gridKics.loading = true;
|
||||
this.tokens.getSettings('d7xAg5kIhQYeDMB1H6eXnBg')
|
||||
.then(this.fillKics.bind(this));
|
||||
|
||||
this.gridPlugins.loading = true;
|
||||
this.tokens.getSettings('daTai94ymStyRbQWybH3eDw')
|
||||
.then(this.fillPlugins.bind(this));
|
||||
}
|
||||
|
||||
fillKics(payload) {
|
||||
this.gridKics.clear();
|
||||
this.gridKics.loading = false;
|
||||
|
||||
for(let item of payload.domains) {
|
||||
this.gridKics.addRow(item.domain, [app.meta.toString('accelerator-tracks', item.domain), item.tokens, item.remaining])
|
||||
}
|
||||
this.gridKics.sort(1, 'asc');
|
||||
}
|
||||
|
||||
fillPlugins(payload) {
|
||||
this.gridPlugins.clear();
|
||||
this.gridPlugins.loading = false;
|
||||
for(let item of payload.domains) {
|
||||
this.gridPlugins.addRow(item.domain, [app.meta.toString('accelerator-tracks', item.domain), item.tokens, item.remaining])
|
||||
}
|
||||
this.gridPlugins.sort(1, 'asc');
|
||||
}
|
||||
|
||||
async onKicEdit(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
let result = await this.openDialog(
|
||||
await this.loadContent(
|
||||
'projects/bypass/dialogs/BypassTrackSetupDialog',
|
||||
{ title: 'Fast-Track Yearly token attribution', subtitle: 'Set up the yearly token attribution per domain' },
|
||||
{ model: this.tokens, track: 'd7xAg5kIhQYeDMB1H6eXnBg' }
|
||||
)
|
||||
);
|
||||
|
||||
if(result) {
|
||||
ui.growl.append('Settings updated', 'success');
|
||||
|
||||
this.gridKics.loading = true;
|
||||
this.tokens.getSettings('d7xAg5kIhQYeDMB1H6eXnBg')
|
||||
.then(this.fillKics.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
async onPluginEdit(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
let result = await this.openDialog(
|
||||
await this.loadContent(
|
||||
'projects/bypass/dialogs/BypassTrackSetupDialog',
|
||||
{ title: 'Plugins Yearly token attribution', subtitle: 'Set up the yearly token attribution per country' },
|
||||
{ model: this.tokens, track: 'daTai94ymStyRbQWybH3eDw' }
|
||||
)
|
||||
);
|
||||
|
||||
if(result) {
|
||||
ui.growl.append('Settings updated', 'success');
|
||||
|
||||
this.gridPlugins.loading = true;
|
||||
this.tokens.getSettings('daTai94ymStyRbQWybH3eDw')
|
||||
.then(this.fillPlugins.bind(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app.registerClass('BypassAdminManagementContent', BypassAdminManagementContent);
|
||||
Reference in New Issue
Block a user