diff --git a/Shared (Extension)/Resources/db.js b/Shared (Extension)/Resources/db.js index 65fbac9..e5f5278 100644 --- a/Shared (Extension)/Resources/db.js +++ b/Shared (Extension)/Resources/db.js @@ -35,3 +35,14 @@ export async function sortByIndex(index, query, asc, max) { } return events; } + +export async function getHosts() { + let db = await openEventsDb(); + let hosts = new Set(); + let cursor = await db.transaction('events').store.openCursor(); + while (cursor) { + hosts.add(cursor.value.metadata.host); + cursor = await cursor.continue(); + } + return [...hosts]; +} diff --git a/Shared (Extension)/Resources/event_log.html b/Shared (Extension)/Resources/event_log.html index 3e39cc5..1dad5b8 100644 --- a/Shared (Extension)/Resources/event_log.html +++ b/Shared (Extension)/Resources/event_log.html @@ -71,6 +71,16 @@ + +
+ + +
diff --git a/Shared (Extension)/Resources/event_log.js b/Shared (Extension)/Resources/event_log.js index 797757d..a67cffc 100644 --- a/Shared (Extension)/Resources/event_log.js +++ b/Shared (Extension)/Resources/event_log.js @@ -1,5 +1,5 @@ import Alpine from 'alpinejs'; -import { sortByIndex } from './db'; +import { getHosts, sortByIndex } from './db'; import { KINDS } from './utils'; Alpine.data('eventLog', () => ({ @@ -8,6 +8,8 @@ Alpine.data('eventLog', () => ({ view: 'created_at', max: 100, sort: 'asc', + allHosts: [], + host: '', // date view fromCreatedAt: '2008-10-31', @@ -30,6 +32,7 @@ Alpine.data('eventLog', () => ({ this.max ); this.events = events; + getHosts().then(hosts => (this.allHosts = hosts)); }, quickKindSelect() { @@ -60,6 +63,9 @@ Alpine.data('eventLog', () => ({ case 'kind': return IDBKeyRange.bound(this.fromKind, this.toKind); + case 'host': + if (this.host.length === 0) return null; + return IDBKeyRange.only(this.host); default: return null; }