Modify to add process in indexedDB.
This commit is contained in:
parent
c209bee651
commit
e5f7339ff8
@ -180,7 +180,7 @@ class Services {
|
||||
let style = "";
|
||||
let script = "";
|
||||
try {
|
||||
const processObject = await this.getProcessByName(Services.instance.current_process!);
|
||||
const processObject = await Services.instance.getProcessByName(Services.instance.current_process!);
|
||||
if (processObject) {
|
||||
body = processObject.html;
|
||||
style = processObject.style;
|
||||
@ -237,7 +237,7 @@ class Services {
|
||||
const selectProcess = document.getElementById("selectProcess");
|
||||
if (selectProcess) {
|
||||
processList.forEach((process) => {
|
||||
let child = new Option(process.name, process.name);
|
||||
let child = new Option(process.id.toString(), process.id.toString());
|
||||
if (!selectProcess.contains(child)) {
|
||||
selectProcess.appendChild(child);
|
||||
}
|
||||
@ -285,9 +285,11 @@ class Services {
|
||||
}
|
||||
|
||||
public async getProcessByName(name: string): Promise<Process | null> {
|
||||
console.error('getProcessByName name: '+name);
|
||||
const indexedDB = await IndexedDB.getInstance();
|
||||
const db = indexedDB.getDb();
|
||||
const process = await indexedDB.getFirstMatchWithIndex<Process>(db, indexedDB.getStoreList().AnkProcess, 'by_name', name);
|
||||
console.error('getProcessByName process: '+process);
|
||||
|
||||
return process;
|
||||
}
|
||||
@ -295,11 +297,15 @@ class Services {
|
||||
public async loadProcesses(): Promise<void> {
|
||||
const services = await Services.getInstance();
|
||||
const processList: Process[] = services.sdkClient.get_processes();
|
||||
console.error('processList size: '+processList.length);
|
||||
|
||||
processList.forEach(async (process: Process) => {
|
||||
const indexedDB = await IndexedDB.getInstance();
|
||||
const db = indexedDB.getDb();
|
||||
try {
|
||||
if (await indexedDB.getObject<Process>(db, indexedDB.getStoreList().AnkProcess, process.id) === null) {
|
||||
const processStore = await indexedDB.getObject<Process>(db, indexedDB.getStoreList().AnkProcess, process.id);
|
||||
if (!processStore) {
|
||||
console.error('Add process.id : '+process.id);
|
||||
await indexedDB.writeObject(db, indexedDB.getStoreList().AnkProcess, process, null);
|
||||
}
|
||||
} catch (error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user