2022-11-27 20:20:18 +00:00
|
|
|
<div class="hmax">
|
|
|
|
<div id="tabs"></div>
|
|
|
|
<div id="tabs-item">
|
|
|
|
<a href="javascript:{action}">
|
|
|
|
<div class="tab-content">
|
|
|
|
<span>{title}</span>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div id="content">
|
|
|
|
<div id="container"></div>
|
|
|
|
</div>
|
2022-11-24 01:35:00 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
2022-11-24 23:21:52 +00:00
|
|
|
function title__instance() {}
|
2022-11-24 01:35:00 +00:00
|
|
|
function load__instance(args) {
|
|
|
|
const hargs = parse_hash_arguments(args[1]);
|
|
|
|
|
|
|
|
const _error400 = function(msg) {
|
|
|
|
msg = msg || 'Parameters are not correct';
|
|
|
|
console.log('TODO: handle error correctly');
|
|
|
|
};
|
|
|
|
|
|
|
|
const _paint = function() {
|
2022-11-27 20:20:18 +00:00
|
|
|
const menu = [
|
|
|
|
{
|
|
|
|
title: 'Filter users',
|
|
|
|
action: 'alert("hello")',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Filter posts',
|
|
|
|
action: 'alert("hello")',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'New accounts',
|
|
|
|
action: 'alert("hello")',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
E.template('tabs', function(TPL) {
|
|
|
|
var html = '';
|
|
|
|
for (var i = 0; i < menu.length; i++) {
|
|
|
|
var tpl = TPL;
|
|
|
|
tpl = tpl.replaceAll('{title}', menu[i]['title']);
|
|
|
|
tpl = tpl.replaceAll('{action}', menu[i]['action']);
|
|
|
|
html += tpl;
|
|
|
|
}
|
|
|
|
return html;
|
|
|
|
});
|
2022-11-24 01:35:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const _main = function() {
|
|
|
|
if (hargs['software'] === undefined ||
|
|
|
|
!window.vars['instance_config']['supported_ap_software']
|
|
|
|
.includes(hargs['software']))
|
|
|
|
return _error400();
|
|
|
|
if (hargs['instance'] === undefined)
|
|
|
|
return _error400();
|
|
|
|
var found = false;
|
|
|
|
for (var i = 0; i < window.vars['instance_config']['hosts'][hargs['software']].length; i++)
|
|
|
|
{
|
|
|
|
const item = window.vars['instance_config']['hosts'][hargs['software']][i];
|
|
|
|
if (item['instance'] === hargs['instance']) {
|
|
|
|
window.vars['current_instance'] = item;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
return _error400();
|
2022-11-24 23:21:52 +00:00
|
|
|
|
|
|
|
apcontrol_title(`Instance (${hargs['instance']})`);
|
|
|
|
const config = parse_ini_config(window.vars['current_instance']['config']);
|
2022-11-27 20:20:18 +00:00
|
|
|
const musthave = window.consts['instance_config'][hargs['software']]['musthave'];
|
|
|
|
for (var i = 0; i < musthave.length; i++) {
|
|
|
|
if (config[musthave[i]] === undefined) {
|
|
|
|
window.location.hash = window.location.hash.replace('#instance/','#instance_config/');
|
|
|
|
return false;
|
2022-11-24 23:21:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return _paint();
|
2022-11-24 01:35:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (window.vars['instance_config'] === undefined) {
|
|
|
|
http.get('api/v1/config/get',{},function(data) {
|
|
|
|
window.vars['instance_config'] = JSON.parse(data);
|
|
|
|
_main();
|
|
|
|
});
|
|
|
|
} else { _main() }
|
|
|
|
}
|
|
|
|
</script>
|