Get processes from Service
This commit is contained in:
parent
1a6e6d595e
commit
7403fb7a5e
@ -5,8 +5,9 @@ import { Process } from 'pkg/sdk_client';
|
||||
import chatStyle from '../../../public/style/chat.css?inline';
|
||||
import { Database } from '../../services/database.service';
|
||||
|
||||
let myProcesses = new Set();
|
||||
let allProcesses = new Set();
|
||||
const service = await Service.getInstance();
|
||||
let myProcesses = service.getMyProcesses();
|
||||
let allProcesses = service.getProcesses();
|
||||
|
||||
// Initialize function, create initial tokens with itens that are already selected by the user
|
||||
export async function init() {
|
||||
@ -50,7 +51,7 @@ export async function init() {
|
||||
|
||||
addPlaceholder(wrapper);
|
||||
|
||||
await loadAllProcesses();
|
||||
// await loadAllProcesses();
|
||||
|
||||
const database = await Database.getInstance();
|
||||
|
||||
@ -385,19 +386,19 @@ addSubscription(document, 'click', () => {
|
||||
}
|
||||
});
|
||||
|
||||
async function loadAllProcesses() {
|
||||
try {
|
||||
const [allProcessesNew, myProcessesNew] = await Promise.all([
|
||||
getProcesses(),
|
||||
getMyProcesses()
|
||||
]);
|
||||
// async function loadAllProcesses() {
|
||||
// try {
|
||||
// const [allProcessesNew, myProcessesNew] = await Promise.all([
|
||||
// getProcesses(),
|
||||
// getMyProcesses()
|
||||
// ]);
|
||||
|
||||
myProcesses = myProcesses.union(myProcessesNew);
|
||||
allProcesses = allProcesses.union(allProcessesNew);
|
||||
} catch (error) {
|
||||
console.error("Error loading processes:", error);
|
||||
}
|
||||
}
|
||||
// myProcesses = myProcesses.union(myProcessesNew);
|
||||
// allProcesses = allProcesses.union(allProcessesNew);
|
||||
// } catch (error) {
|
||||
// console.error("Error loading processes:", error);
|
||||
// }
|
||||
// }
|
||||
|
||||
async function showSelectedProcess(elem: MouseEvent) {
|
||||
const container = getCorrectDOM('process-list-4nk-component') as HTMLElement;
|
||||
@ -546,39 +547,39 @@ async function getDescription(processId: string, process: Process): Promise<stri
|
||||
return null;
|
||||
}
|
||||
|
||||
async function getProcesses(): Promise<Set<string>> {
|
||||
const service = await Services.getInstance();
|
||||
const processes = await service.getProcesses();
|
||||
const processIds = new Set<string>(Object.keys(processes));
|
||||
// async function getProcesses(): Promise<Set<string>> {
|
||||
// const service = await Services.getInstance();
|
||||
// const processes = await service.getProcesses();
|
||||
// const processIds = new Set<string>(Object.keys(processes));
|
||||
|
||||
return processIds;
|
||||
}
|
||||
// return processIds;
|
||||
// }
|
||||
|
||||
async function getMyProcesses(): Promise<Set<string>> {
|
||||
const service = await Services.getInstance();
|
||||
try {
|
||||
const processes = await service.getProcesses();
|
||||
const userProcessSet = new Set<string>();
|
||||
// async function getMyProcesses(): Promise<Set<string>> {
|
||||
// const service = await Services.getInstance();
|
||||
// try {
|
||||
// const processes = await service.getProcesses();
|
||||
// const userProcessSet = new Set<string>();
|
||||
|
||||
for (const [processId, process] of Object.entries(processes)) {
|
||||
let roles;
|
||||
try {
|
||||
roles = await service.getRoles(process);
|
||||
// console.log("ROLES: ", roles);
|
||||
// for (const [processId, process] of Object.entries(processes)) {
|
||||
// let roles;
|
||||
// try {
|
||||
// roles = await service.getRoles(process);
|
||||
// // console.log("ROLES: ", roles);
|
||||
|
||||
const hasCurrentUser = service.rolesContainsUs(roles);
|
||||
// const hasCurrentUser = service.rolesContainsUs(roles);
|
||||
|
||||
if (hasCurrentUser) {
|
||||
userProcessSet.add(processId);
|
||||
}
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// if (hasCurrentUser) {
|
||||
// userProcessSet.add(processId);
|
||||
// }
|
||||
// } catch (e) {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
|
||||
return userProcessSet;
|
||||
// return userProcessSet;
|
||||
|
||||
} catch (e) {
|
||||
console.error("Failed to get processes:", e);
|
||||
}
|
||||
}
|
||||
// } catch (e) {
|
||||
// console.error("Failed to get processes:", e);
|
||||
// }
|
||||
// }
|
||||
|
Loading…
x
Reference in New Issue
Block a user