feat: 🎸 Add sqlite handler and parser (#2933)

* feat: 🎸 Add sqlite handler and parser

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17410
This commit is contained in:
Zhihe Li committed 2025-09-03 11:41:41 -04:00
1 parent 8abed1a809
commit e0982da744
33 files changed
+1692 -111

No files matched your search

+14
View File
@@ -7,6 +7,7 @@ import Controller from '@ember/controller';
import { service } from '@ember/service';
import { getOwner } from '@ember/application';
import { action } from '@ember/object';
import { loading } from 'ember-loading';
import { defaultValidator } from 'ember-a11y-refocus';
import { paramValueFinder } from 'admin/utils/param-value-finder';
@@ -33,6 +34,7 @@ export default class ApplicationController extends Controller {
@service featureEdition;
@service flashMessages;
@service router;
@service sqlite;
/**
* Returns available themes.
@@ -113,6 +115,18 @@ export default class ApplicationController extends Controller {
}
}
@action
@loading
async downloadDatabase() {
await this.sqlite.downloadDatabase();
}
@action
async clearDatabase() {
await this.sqlite.clearDatabase();
this.router.refresh();
}
/**
* Add custom route change validation to prevent refocus when
* user is attempting to search, filter, or sort.
+2 -2
View File
@@ -22,7 +22,7 @@ export default class ApplicationRoute extends Route {
@service features;
@service featureEdition;
@service indexedDb;
@service sqliteDb;
@service sqlite;
@service('browser/window') window;
// =attributes
@@ -74,7 +74,7 @@ export default class ApplicationRoute extends Route {
const userId = this.session.data?.authenticated?.user_id;
const hostUrl = this.window.location.host;
if (userId && hostUrl) {
await this.sqliteDb.setup(formatDbName(userId, hostUrl));
await this.sqlite.setup(formatDbName(userId, hostUrl));
await this.indexedDb.setup(formatDbName(userId, hostUrl));
}
}
+2 -2
View File
@@ -9,7 +9,7 @@ import { formatDbName } from 'api/services/indexed-db';
export default class SessionService extends BaseSessionService {
@service indexedDb;
@service sqliteDb;
@service sqlite;
@service('browser/window') window;
/**
@@ -20,7 +20,7 @@ export default class SessionService extends BaseSessionService {
const userId = this.data?.authenticated?.user_id;
const hostUrl = this.window.location?.host;
if (userId && hostUrl) {
await this.sqliteDb.setup(formatDbName(userId, hostUrl));
await this.sqlite.setup(formatDbName(userId, hostUrl));
await this.indexedDb.setup(formatDbName(userId, hostUrl));
}
+13
View File
@@ -54,7 +54,20 @@
>
{{feature}}
</dd.Checkbox>
{{/each}}
<dd.Separator />
<dd.Title @text={{t 'actions.manage-db'}} />
<dd.Interactive
@icon='save'
@isLoading={{(is-loading)}}
{{on 'click' this.downloadDatabase}}
>
{{t 'actions.download-db'}}
</dd.Interactive>
<dd.Interactive @icon='trash' {{on 'click' this.clearDatabase}}>
{{t 'actions.clear-db'}}
</dd.Interactive>
</Hds::Dropdown>
{{/if}}