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