69 lines
2.4 KiB
JavaScript
69 lines
2.4 KiB
JavaScript
/**
|
|
* _ ___ Another
|
|
* / |/ (_)______ __ _____
|
|
* / / / __(_-</ // (_-<
|
|
* /_/|_/_/\__/___/\_, /___/
|
|
* /___/
|
|
* production !
|
|
*
|
|
* Licensed under the MIT License:
|
|
* This code is free to use and modify,
|
|
* as long as the copyright notice and license are kept.
|
|
*/
|
|
class myProfileView extends WindozDomContent {
|
|
|
|
DOMContentLoaded() {
|
|
ui.eicfy(this.el)
|
|
|
|
this.tabs = new Tab();
|
|
this.tabs.addTabs(this.findAll('menu li'), this.findAll('.tab-content'))
|
|
|
|
this.gridIdentity = new DataGrid(this.find('.identity [eicdatagrid]'), {
|
|
headers: [ { label: ''}, { label: ''} ]
|
|
});
|
|
this.gridIdentity.addRow('', [ 'First name',app.User.identity.firstname ]);
|
|
this.gridIdentity.addRow('', [ 'Last name',app.User.identity.lastname ]);
|
|
this.gridIdentity.addRow('', [ 'Email',app.User.identity.email ]);
|
|
this.gridIdentity.addRow('', [ 'EU Login',app.User.identity.uuid ]);
|
|
|
|
this.gridRoles = new DataGrid(this.find('.roles [eicdatagrid]'), {
|
|
headers: [ { label: 'Role name', filter: null, sortable: true} ]
|
|
});
|
|
for(let role of app.User.roles) { this.gridRoles.addRow(role, [ role ]); }
|
|
|
|
this.gridPreferences = new DataGrid(this.find('.preferences [eicdatagrid]'), {
|
|
headers: [
|
|
{ label: 'Key', filter: 'text', sortable: true},
|
|
{ label: 'Value', filter: 'text', sortable: false},
|
|
]
|
|
});
|
|
this.scanPreferences(app.User.preferences, '')
|
|
|
|
let resetButton = new Button(this.find('.preferences button.reset'));
|
|
resetButton.click = this.onPreferencesReset.bind(this);
|
|
}
|
|
|
|
scanPreferences(tree, path) {
|
|
for(const key in tree) {
|
|
let item = tree[key];
|
|
let newPath = `${path}${ path ? '.': ''}${key}`;
|
|
|
|
if(typeof item == 'object')
|
|
this.scanPreferences(item, newPath)
|
|
else
|
|
this.gridPreferences.addRow(key, [ newPath, item ] );
|
|
}
|
|
}
|
|
|
|
async onPreferencesReset() {
|
|
let resetted = await this.openDialog(
|
|
await this.loadContent(
|
|
'common/profile/dialogs/ProfilePreferencesResetDialog',
|
|
{ title: 'Reset your preferences' }, {}
|
|
)
|
|
);
|
|
|
|
if(resetted) { this.gridPreferences.clear(); }
|
|
}
|
|
}
|
|
app.registerClass('myProfileView',myProfileView); |