mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-06 20:14:10 +08:00
🎈 Sync 2026-05-22 14:28:32
This commit is contained in:
1 parent
7f7b99cc2f
commit
5635d6c1ec
70 files changed
+7296
-4358
No files matched your search
@@ -32,13 +32,22 @@ application/json-seq: ␊ = \n | ^J | 0xa, ␞ = ␞ | ^^ | 0x1e
|
||||
|
||||
return dm2.dv.extend({
|
||||
load() {
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
this.js_api = false;
|
||||
return Promise.resolve([]);
|
||||
|
||||
return Promise.all([
|
||||
dm2.docker_events({ query: { since: `0`, until: `${now}` } }),
|
||||
dm2.js_api_ready.then(([ok, ]) => this.js_api = ok),
|
||||
]);
|
||||
},
|
||||
|
||||
render() {
|
||||
this.outputText = '';
|
||||
const event_list = [];
|
||||
render([events, js_api_available]) {
|
||||
if (events?.code !== 200) {
|
||||
return E('div', {}, [ events?.body?.message ]);
|
||||
}
|
||||
|
||||
this.outputText = events?.body ? JSON.stringify(events?.body, null, 2) + '\n' : '';
|
||||
const event_list = events?.body || [];
|
||||
const view = this;
|
||||
|
||||
const mainContainer = E('div', { 'class': 'cbi-map' }, [
|
||||
@@ -89,7 +98,7 @@ return dm2.dv.extend({
|
||||
E('input', {
|
||||
'id': 'event-from-date',
|
||||
'type': 'datetime-local',
|
||||
'value': new Date(Date.now() - (60 * 60 * 1000)).toISOString().slice(0, 16),
|
||||
'value': '1970-01-01T00:00',
|
||||
'step': 60,
|
||||
'style': 'width: 180px;',
|
||||
'change': () => { view.renderEventsTable(event_list); }
|
||||
@@ -141,16 +150,6 @@ return dm2.dv.extend({
|
||||
}
|
||||
}, _('Now'))
|
||||
])
|
||||
]),
|
||||
E('div', { 'class': 'cbi-value' }, [
|
||||
E('label', { 'class': 'cbi-value-title' }, '\u00a0'),
|
||||
E('div', { 'class': 'cbi-value-field' }, [
|
||||
E('button', {
|
||||
'type': 'button',
|
||||
'class': 'cbi-button cbi-button-action',
|
||||
'click': () => { view.renderEventsTable(event_list); }
|
||||
}, _('Load Events'))
|
||||
])
|
||||
])
|
||||
])
|
||||
]);
|
||||
@@ -159,18 +158,10 @@ return dm2.dv.extend({
|
||||
this.tableSection = E('div', { 'class': 'cbi-section', 'id': 'events-section' });
|
||||
mainContainer.appendChild(this.tableSection);
|
||||
|
||||
this.tableSection.appendChild(E('em', {}, _('Loading recent events…')));
|
||||
this.renderEventsTable(event_list);
|
||||
|
||||
mainContainer.appendChild(this.insertOutputFrame(E('div', {}), null));
|
||||
|
||||
dm2.js_api_ready.then(([ok, ]) => {
|
||||
view.js_api = ok;
|
||||
}).catch(() => {
|
||||
view.js_api = false;
|
||||
});
|
||||
|
||||
window.setTimeout(() => view.renderEventsTable(event_list), 0);
|
||||
|
||||
return mainContainer;
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user