Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 0 additions & 97 deletions src/app/data/availableFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,103 +4,6 @@ export type Filter = {
}

const availableFilters: Filter[] = [
{
name: 'technical_approach',
children: [
{
name: 'Infrastructure as a Service (IaaS)',
children: [
{ name: 'Compute' },
{ name: 'Network' },
{ name: 'Storage' },
{ name: 'Security' },
],
},
{ name: 'Container as a Service (CaaS)' },
{
name: 'Platform as a Service (PaaS)',
children: [
{ name: 'Database' },
{ name: 'Development and Testing' },
{ name: 'Business Analytics' },
{ name: 'Process management' },
{ name: 'Knowledge management' },
{ name: 'Data management' },
],
},
{ name: 'Software as a Service (SaaS)' },
{ name: 'Artificial Intelligence and Machine Learning' },
{
name: 'Data as a Service (DaaS)',
children: [{ name: 'Data product distribution and exchange' }],
},
{ name: 'Cybersecurity and Data Privacy' },
{ name: 'Internet of Things (IoT)' },
],
},
{
name: 'business_domain',
children: [
{ name: 'Automotive' },
{ name: 'Agriculture, Forestry, Fishing' },
{ name: 'Blockchain (DLT)' },
{ name: 'Beauty and Perfume' },
{ name: 'Cleaning and Facility Management Services' },
{
name: 'Community Groups, Social, Political and Religious',
children: [{ name: 'Governmental Administration and Regulation' }],
},
{ name: 'Education' },
{ name: 'Construction' },
{ name: 'Employment, Recruitment, HR' },
{
name: 'Energy and Utility Suppliers',
children: [
{ name: 'Electricity' },
{ name: 'Gas' },
{ name: 'Waste Collection, Treatment and Disposal Activities' },
{ name: 'Water Supply' },
],
},
{ name: 'Financial Services and Insurance' },
{ name: 'Healthcare' },
{ name: 'IT' },
{ name: 'Leisure and Entertainment' },
{ name: 'Legal, Public Order, Security' },
{
name: 'Manufacturing',
children: [{ name: 'Manufacturing of Metal Products' }, { name: 'Other (manufacturing)' }],
},
{ name: 'Mining and Drilling' },
{ name: 'Project Management, Marketing and Admin' },
{ name: 'Personal Services' },
{ name: 'Restaurants, Bars, Cafes, Catering' },
{ name: 'Real Estate' },
{ name: 'Publishing, Printing and Photography' },
{ name: 'Tourism and Accommodation' },
{ name: 'Science and Engineering' },
{ name: 'Trade' },
{
name: 'Transportation and Transportation infrastructure',
children: [
{ name: 'Transport of Freight' },
{ name: 'Transport of Persons' },
{ name: 'Other' },
],
},
],
},
{
name: 'professional_services',
children: [
{ name: 'Implementation Services' },
{ name: 'Consulting' },
{
name: 'Service Management',
children: [{ name: 'Operations' }, { name: 'Maintenance' }, { name: 'Governance' }],
},
],
},
{
name: 'compliance_profile',
children: [
Expand Down
84 changes: 26 additions & 58 deletions src/app/pages/admin/categories/categories.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class CategoriesComponent implements OnDestroy {
initCatalogs(){
this.loading=true;
this.categories=[];
this.unformattedCategories=[];
let aux = this.localStorage.getObject('login_items') as LoginInfo;
if(aux.logged_as==aux.id){
this.partyId = aux.partyId;
Expand All @@ -69,7 +70,7 @@ export class CategoriesComponent implements OnDestroy {
this.partyId = loggedOrg.partyId
}

this.getCategories();
void this.getCategories();
initFlowbite();
}

Expand All @@ -81,7 +82,7 @@ export class CategoriesComponent implements OnDestroy {
this.eventMessage.emitUpdateCategory(cat);
}

getCategories(){
async getCategories(){
/*this.api.getCatalog(this.selectedCatalog.id).then(data => {
if(data.category){
for (let i=0; i<data.category.length; i++){
Expand All @@ -101,65 +102,31 @@ export class CategoriesComponent implements OnDestroy {
}
})*/
console.log('Getting categories...')
this.api.getDefaultCategories().then(data => {
for(let i=0; i < data.length; i++){
this.findChildren(data[i],data);
this.unformattedCategories.push(data[i]);
}
this.loading=false;
this.cdr.detectChanges();
initFlowbite();
})
}

findChildren(parent:any,data:any[]){
let childs = data.filter((p => p.parentId === parent.id));
parent["children"] = childs;
if(parent.isRoot == true){
this.categories.push(parent)
} else {
this.saveChildren(this.categories,parent)
}
if(childs.length != 0){
for(let i=0; i < childs.length; i++){
this.findChildren(childs[i],data)
}
}
}
const rootCategories = await this.api.getDefaultCategories().catch(() => []);
const roots = Array.isArray(rootCategories) ? rootCategories : [];

findChildrenByParent(parent:any){
let childs: any[] = []
this.api.getCategoriesByParentId(parent.id).then(c => {
childs=c;
parent["children"] = childs;
if(parent.isRoot == true){
this.categories.push(parent)
} else {
this.saveChildren(this.categories,parent)
}
if(childs.length != 0){
for(let i=0; i < childs.length; i++){
this.findChildrenByParent(childs[i])
}
}
initFlowbite();
})
this.unformattedCategories = [...roots];
const categoryTrees = await Promise.all(
roots.map((root: any) => this.loadCategorySubtree(root))
);

this.categories = categoryTrees.filter((cat): cat is Category => !!cat);
this.loading=false;
this.cdr.detectChanges();
initFlowbite();
}

saveChildren(superCategories:any[],parent:any){
for(let i=0; i < superCategories.length; i++){
let children = superCategories[i].children;
if (children != undefined){
let check = children.find((element: { id: any; }) => element.id == parent.id)
if (check != undefined) {
let idx = children.findIndex((element: { id: any; }) => element.id == parent.id)
children[idx] = parent
superCategories[i].children = children
}
this.saveChildren(children,parent)
}
}
private async loadCategorySubtree(parent:any): Promise<Category> {
const children = await this.api.getCategoriesByParentId(parent.id).catch(() => []);
const childList = Array.isArray(children) ? children : [];
const resolvedChildren = await Promise.all(
childList.map((child: any) => this.loadCategorySubtree(child))
);

return {
...parent,
children: resolvedChildren
};
}

/*addParent(parentId:any){
Expand Down Expand Up @@ -187,7 +154,8 @@ export class CategoriesComponent implements OnDestroy {
}
this.loading=true;
this.categories=[];
this.getCategories();
this.unformattedCategories=[];
void this.getCategories();
console.log('filter')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,74 +101,44 @@ export class CreateCategoryComponent implements OnInit, OnDestroy {
this.partyId = loggedOrg.partyId
}
}
this.getCategories();
void this.getCategories();
}

goBack() {
this.eventMessage.emitAdminCategories(true);
}

getCategories(){
async getCategories(){
console.log('Getting categories...')
this.api.getLaunchedCategories().then(data => {
for(let i=0; i < data.length; i++){
this.findChildren(data[i],data);
this.unformattedCategories.push(data[i]);
}
this.loading=false;
this.cdr.detectChanges();
initFlowbite();
})
}
this.loading = true;
this.categories = [];
this.unformattedCategories = [];

findChildren(parent:any,data:any[]){
let childs = data.filter((p => p.parentId === parent.id));
parent["children"] = childs;
if(parent.isRoot == true){
this.categories.push(parent)
} else {
this.saveChildren(this.categories,parent)
}
if(childs.length != 0){
for(let i=0; i < childs.length; i++){
this.findChildren(childs[i],data)
}
}
}
const rootCategories = await this.api.getDefaultCategories().catch(() => []);
const roots = Array.isArray(rootCategories) ? rootCategories : [];

findChildrenByParent(parent:any){
let childs: any[] = []
this.api.getCategoriesByParentId(parent.id).then(c => {
childs=c;
parent["children"] = childs;
if(parent.isRoot == true){
this.categories.push(parent)
} else {
this.saveChildren(this.categories,parent)
}
if(childs.length != 0){
for(let i=0; i < childs.length; i++){
this.findChildrenByParent(childs[i])
}
}
initFlowbite();
})
this.unformattedCategories = [...roots];
const categoryTrees = await Promise.all(
roots.map((root: any) => this.loadCategorySubtree(root))
);

this.categories = categoryTrees.filter(Boolean);
this.loading=false;
this.cdr.detectChanges();
initFlowbite();
}

saveChildren(superCategories:any[],parent:any){
for(let i=0; i < superCategories.length; i++){
let children = superCategories[i].children;
if (children != undefined){
let check = children.find((element: { id: any; }) => element.id == parent.id)
if (check != undefined) {
let idx = children.findIndex((element: { id: any; }) => element.id == parent.id)
children[idx] = parent
superCategories[i].children = children
}
this.saveChildren(children,parent)
}
}
private async loadCategorySubtree(parent:any): Promise<any> {
const children = await this.api.getCategoriesByParentId(parent.id).catch(() => []);
const childList = Array.isArray(children) ? children : [];
const resolvedChildren = await Promise.all(
childList.map((child: any) => this.loadCategorySubtree(child))
);

return {
...parent,
children: resolvedChildren
};
}

toggleGeneral(){
Expand Down
Loading
Loading