From eff2af2b109e3ce83351794c17c08775a1ef5651 Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Thu, 2 May 2024 11:29:56 +0200 Subject: [PATCH] Remove config-handler angularJS service (#6631) * Remove config-handler angularJS service * Add changelog --- CHANGELOG.md | 5 +- .../main/public/services/config-handler.js | 139 ------------------ plugins/main/public/services/index.js | 2 - 3 files changed, 3 insertions(+), 143 deletions(-) delete mode 100644 plugins/main/public/services/config-handler.js diff --git a/CHANGELOG.md b/CHANGELOG.md index e477f31c2b..d32cab6e8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,11 +41,12 @@ All notable changes to the Wazuh app project will be documented in this file. ### Removed -- Remove some branding references across the application. [#6155](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6155) +- Removed some branding references across the application. [#6155](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6155) - Removed API endpoint GET /api/timestamp [#6481](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6481) - Removed API endpoint PUT /api/update-hostname/{id} [#6481](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6481) - Removed API endpoint DELETE /hosts/remove-orphan-entries [#6481](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6481) -- Remove AngularJS component `click-action` [#6613](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6613) +- Removed AngularJS component `click-action` [#6613](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6613) +- Removed AngularJS service `config-handler` [#6631](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6631) ## Wazuh v4.8.0 - OpenSearch Dashboards 2.10.0 - Revision 08 diff --git a/plugins/main/public/services/config-handler.js b/plugins/main/public/services/config-handler.js deleted file mode 100644 index e87fde2436..0000000000 --- a/plugins/main/public/services/config-handler.js +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Wazuh app - Group handler service - * Copyright (C) 2015-2022 Wazuh, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Find more information about this on the LICENSE file. - */ -import { WzRequest } from '../react-services/wz-request'; -import { ErrorHandler } from '../react-services/error-handler'; - -export class ConfigHandler { - constructor($rootScope, errorHandler) { - this.$rootScope = $rootScope; - this.errorHandler = errorHandler; - } - - /** - * Send ossec.conf content for manager (single-node API call) - * @param {*} content XML raw content for ossec.conf file - */ - async saveManagerConfiguration(content) { - try { - const result = await WzRequest.apiReq('PUT', `/manager/configuration`, { - content, - origin: 'xmleditor', - }); - return result; - } catch (error) { - return Promise.reject(error); - } - } - - /** - * Send ossec.conf content for a cluster node - * @param {*} node Node name - * @param {*} content XML raw content for ossec.conf file - */ - async saveNodeConfiguration(node, content) { - try { - const result = await WzRequest.apiReq( - 'PUT', - `/cluster/${node}/configuration`, - { content, origin: 'xmleditor' }, - ); - return result; - } catch (error) { - return Promise.reject(error); - } - } - - async performClusterRestart() { - try { - await WzRequest.apiReq('PUT', `/cluster/restart`, { delay: 15000 }); - } catch (error) { - throw new Error('Error restarting cluster'); - } - } - - /** - * Restart manager (single-node API call) - */ - async restartManager() { - try { - const validationError = await WzRequest.apiReq( - 'GET', - `/manager/configuration/validation`, - {}, - ); - - const data = ((validationError || {}).data || {}).data || {}; - const isOk = data.status === 'OK'; - if (!isOk && Array.isArray(data.details)) { - const str = data.details.join(); - throw new Error(str); - } - - const result = await WzRequest.apiReq('PUT', `/manager/restart`, {}); - return result; - } catch (error) { - return Promise.reject(error); - } - } - - /** - * Restart cluster - */ - async restartCluster() { - try { - const validationError = await WzRequest.apiReq( - 'GET', - `/cluster/configuration/validation`, - {}, - ); - - const data = ((validationError || {}).data || {}).data || {}; - const isOk = data.status === 'OK'; - if (!isOk && Array.isArray(data.details)) { - const str = data.details.join(); - throw new Error(str); - } - this.performClusterRestart(); - return { data: { data: 'Restarting cluster' } }; - } catch (error) { - return Promise.reject(error); - } - } - - /** - * Restart a cluster node - */ - async restartNode(node) { - try { - const validationError = await WzRequest.apiReq( - 'GET', - `/cluster/${node}/configuration/validation`, - {}, - ); - - const data = ((validationError || {}).data || {}).data || {}; - const isOk = data.status === 'OK'; - if (!isOk && Array.isArray(data.details)) { - const str = data.details.join(); - throw new Error(str); - } - const result = await WzRequest.apiReq( - 'PUT', - `/cluster/${node}/restart`, - {}, - ); - return result; - } catch (error) { - return Promise.reject(error); - } - } -} diff --git a/plugins/main/public/services/index.js b/plugins/main/public/services/index.js index a82f4124c9..f74440a36d 100644 --- a/plugins/main/public/services/index.js +++ b/plugins/main/public/services/index.js @@ -18,7 +18,6 @@ import { ReportingService } from './reporting'; import { VisFactoryService } from './vis-factory-handler'; import './region-maps'; import './order-object-by'; -import { ConfigHandler } from './config-handler'; import { CheckDaemonsStatus } from './check-daemon-status'; import { getAngularModule } from '../kibana-services'; @@ -30,5 +29,4 @@ app .service('commonData', CommonData) .service('reportingService', ReportingService) .service('visFactoryService', VisFactoryService) - .service('configHandler', ConfigHandler) .service('checkDaemonsStatus', CheckDaemonsStatus);