From e0f47d31fb21aa76c42a6c02cbe97f8603b9f61c Mon Sep 17 00:00:00 2001 From: cv5ch <176032962+cv5ch@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:13:07 +0200 Subject: [PATCH] Changed agent binary type attribute to binaryType to conform to json:api standard and fix incompatibility with the serializer --- .../agent-binaries.component.ts | 9 ++--- .../agent-binaries-table.component.ts | 8 ++--- .../_datasources/agent-binaries.datasource.ts | 33 +++++-------------- src/app/core/_models/agent-binary.model.ts | 4 +-- src/app/core/_services/metadata.service.ts | 17 +++++----- 5 files changed, 29 insertions(+), 42 deletions(-) diff --git a/src/app/config/engine/agent-binaries/agent-binaries.component.ts b/src/app/config/engine/agent-binaries/agent-binaries.component.ts index 598015bb4..e26f700a9 100644 --- a/src/app/config/engine/agent-binaries/agent-binaries.component.ts +++ b/src/app/config/engine/agent-binaries/agent-binaries.component.ts @@ -1,10 +1,11 @@ -import { AutoTitleService } from 'src/app/core/_services/shared/autotitle.service'; import { Component } from '@angular/core'; +import { AutoTitleService } from '@services/shared/autotitle.service'; + @Component({ - selector: 'app-agent-binaries', - templateUrl: './agent-binaries.component.html', - standalone: false + selector: 'app-agent-binaries', + templateUrl: './agent-binaries.component.html', + standalone: false }) export class AgentBinariesComponent { constructor(private titleService: AutoTitleService) { diff --git a/src/app/core/_components/tables/agent-binaries-table/agent-binaries-table.component.ts b/src/app/core/_components/tables/agent-binaries-table/agent-binaries-table.component.ts index 0e9439654..c0573551b 100644 --- a/src/app/core/_components/tables/agent-binaries-table/agent-binaries-table.component.ts +++ b/src/app/core/_components/tables/agent-binaries-table/agent-binaries-table.component.ts @@ -63,7 +63,7 @@ export class AgentBinariesTableComponent extends BaseTableComponent implements O item.id.toString().includes(filterValue) || item.filename?.toLowerCase().includes(filterValue) || item.operatingSystems?.toLowerCase().includes(filterValue) || - item.agentbinaryType?.toLowerCase().includes(filterValue) || + item.binaryType?.toLowerCase().includes(filterValue) || item.updateTrack?.toLowerCase().includes(filterValue) || item.version?.toLowerCase().includes(filterValue) ); @@ -78,7 +78,7 @@ export class AgentBinariesTableComponent extends BaseTableComponent implements O return item.operatingSystems?.toLowerCase().includes(filterValue); } case 'type': { - return item.agentbinaryType?.toLowerCase().includes(filterValue); + return item.binaryType?.toLowerCase().includes(filterValue); } case 'updateTrack': { return item.updateTrack?.toLowerCase().includes(filterValue); @@ -105,8 +105,8 @@ export class AgentBinariesTableComponent extends BaseTableComponent implements O dataKey: 'type', isSortable: true, isSearchable: true, - render: (agentBinary: JAgentBinary) => agentBinary.agentbinaryType, - export: async (agentBinary: JAgentBinary) => agentBinary.agentbinaryType + render: (agentBinary: JAgentBinary) => agentBinary.binaryType, + export: async (agentBinary: JAgentBinary) => agentBinary.binaryType }, { id: AgentBinariesTableCol.OS, diff --git a/src/app/core/_datasources/agent-binaries.datasource.ts b/src/app/core/_datasources/agent-binaries.datasource.ts index 3920deefc..6c8af6934 100644 --- a/src/app/core/_datasources/agent-binaries.datasource.ts +++ b/src/app/core/_datasources/agent-binaries.datasource.ts @@ -1,16 +1,17 @@ -import { catchError, finalize, never, of } from 'rxjs'; +import { catchError, finalize, of } from 'rxjs'; -import { JAgentBinary } from '../_models/agent-binary.model'; -import { BaseDataSource } from './base.datasource'; -import { ResponseWrapper } from '../_models/response.model'; -import { SERV } from '../_services/main.config'; -import { RequestParamBuilder } from '@src/app/core/_services/params/builder-implementation.service'; +import { JAgentBinary } from '@models/agent-binary.model'; +import { ResponseWrapper } from '@models/response.model'; + +import { SERV } from '@services/main.config'; +import { RequestParamBuilder } from '@services/params/builder-implementation.service'; + +import { BaseDataSource } from '@datasources/base.datasource'; export class AgentBinariesDataSource extends BaseDataSource { loadAll(): void { this.loading = true; - //ToDo: Reactivate sorting this.sortingColumn.isSortable = false; @@ -23,26 +24,10 @@ export class AgentBinariesDataSource extends BaseDataSource { finalize(() => (this.loading = false)) ) .subscribe((response: ResponseWrapper) => { - - (response.data as []).forEach((agentBinary) => { - agentBinary['attributes']['agentbinaryType'] = agentBinary['attributes']['type']; - delete agentBinary['attributes']['type']; - }); - - - const responseData = { data: response.data, included: response.included }; const agentBinaries = this.serializer.deserialize(responseData); - const length = response.meta.page.total_elements; - - this.setPaginationConfig( - this.pageSize, - length, - this.pageAfter, - this.pageBefore, - this.index - ); + this.setPaginationConfig(this.pageSize, length, this.pageAfter, this.pageBefore, this.index); this.setData(agentBinaries); }) ); diff --git a/src/app/core/_models/agent-binary.model.ts b/src/app/core/_models/agent-binary.model.ts index d4b953ad1..22fe22354 100644 --- a/src/app/core/_models/agent-binary.model.ts +++ b/src/app/core/_models/agent-binary.model.ts @@ -4,7 +4,7 @@ import { BaseModel } from '@models/base.model'; * Interface for the agent binary running on the nodes * @prop filename Filename of agent binary * @prop operatingSystems Comma separated operating systems the binary runs - * @prop agent Type of agent (e.g. 'python') + * @prop binaryType Type of agent (e.g. 'python') * @prop updateAvailable Indicating if update is available * @prop updateTrack e.g 'stable' * @prop version Version of agent binary @@ -12,7 +12,7 @@ import { BaseModel } from '@models/base.model'; export interface JAgentBinary extends BaseModel { filename: string; operatingSystems: string; - agentbinaryType: string; + binaryType: string; updateAvailable: string; updateTrack: string; version: string; diff --git a/src/app/core/_services/metadata.service.ts b/src/app/core/_services/metadata.service.ts index 3fced8ba5..416b8b3d4 100644 --- a/src/app/core/_services/metadata.service.ts +++ b/src/app/core/_services/metadata.service.ts @@ -1,14 +1,15 @@ -import { ACTIONARRAY, NOTIFARRAY } from '@src/app/core/_constants/notifications.config'; +import { Injectable } from '@angular/core'; import { FormControl, Validators } from '@angular/forms'; -import { dateFormats, proxytype, serverlog } from '@src/app/core/_constants/settings.config'; -import { ACCESS_GROUP_FIELD_MAPPING } from '@src/app/core/_constants/select.config'; -import { GlobalService } from '@services/main.service'; -import { Injectable } from '@angular/core'; import { SERV } from '@services/main.config'; +import { GlobalService } from '@services/main.service'; import { TooltipService } from '@services/shared/tooltip.service'; -import { environment } from '@src/environments/environment'; + import { fileFormat } from '@src/app/core/_constants/files.config'; +import { ACTIONARRAY, NOTIFARRAY } from '@src/app/core/_constants/notifications.config'; +import { ACCESS_GROUP_FIELD_MAPPING } from '@src/app/core/_constants/select.config'; +import { dateFormats, proxytype, serverlog } from '@src/app/core/_constants/settings.config'; +import { environment } from '@src/environments/environment'; @Injectable({ providedIn: 'root' @@ -350,8 +351,8 @@ export class MetadataService { //This variable defines the fields and properties required when creating/editing an Agent Binary. agentbinary = [ { - name: 'type', - label: 'Type', + name: 'binaryType', + label: 'Binary Type', type: 'text', requiredasterisk: true, tooltip: false,