diff --git a/CHANGELOG.md b/CHANGELOG.md index 8af13b6b71..4e427ef19c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Change the view of API is down and check connection to Server APIs application [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337) - Changed the usage of the endpoint GET /groups/{group_id}/files/{file_name} [#6385](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6385) - Refactoring and redesign endpoints summary visualizations [#6268](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6268) +- Move the AngularJS controller and template of blank screen to ReactJS component [#6538](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6538) - Moved the registry data to in-memory cache [#6481](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6481) - Remove AngularJS controller for manage groups [#6543](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6543) - Remove some branding references across the application. [#6155](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6155) diff --git a/plugins/main/public/components/wz-blank-screen/wz-blank-screen.js b/plugins/main/public/components/wz-blank-screen/wz-blank-screen.js index 8be0792463..1a3cd4ab3c 100644 --- a/plugins/main/public/components/wz-blank-screen/wz-blank-screen.js +++ b/plugins/main/public/components/wz-blank-screen/wz-blank-screen.js @@ -16,19 +16,71 @@ import { PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING, PLUGIN_PLATFORM_URL_GUIDE, PLUGIN_PLATFORM_URL_GUIDE_TITLE, + UI_LOGGER_LEVELS, } from '../../../common/constants'; import { webDocumentationLink } from '../../../common/services/web_documentation'; +import { AppState } from '../../react-services/app-state'; +import { WzMisc } from '../../factories/misc'; +import { getCore } from '../../kibana-services'; +import { ErrorHandler } from '../../react-services/error-handler'; +import { UI_ERROR_SEVERITIES } from '../../react-services/error-orchestrator/types'; +import { getErrorOrchestrator } from '../../react-services/common-services'; +import { overview } from '../../utils/applications'; +import { RedirectAppLinks } from '../../../../../src/plugins/opensearch_dashboards_react/public'; export class WzBlankScreen extends Component { constructor(props) { super(props); - this.state = {}; + this.state = { + errorToShow: null, + }; + + // Create instance of WzMisc that stores the error + this.wzMisc = new WzMisc(); + } + + componentDidMount() { + AppState.setWzMenu(); + const catchedError = this.wzMisc.getBlankScr(); + if (catchedError) { + let parsed = null; + try { + parsed = ErrorHandler.handle(catchedError, '', { silent: true }); + } catch (error) { + const options = { + context: `${WzBlankScreen.name}.componentDidMount`, + level: UI_LOGGER_LEVELS.ERROR, + severity: UI_ERROR_SEVERITIES.UI, + error: { + error: error, + message: error.message || error, + title: error.name, + }, + }; + getErrorOrchestrator().handleError(options); + } + + this.setState({ errorToShow: parsed || catchedError }); + this.wzMisc.setBlankScr(false); + } else { + this.goOverview(); + } + } + + /** + * This navigate to overview + */ + goOverview() { + getCore().application.navigateToApp(overview.id); } render() { + if (!this.state.errorToShow) { + return null; + } return ( @@ -56,9 +108,16 @@ export class WzBlankScreen extends Component {

- - Refresh - + + + Go to {overview.title} + + } /> diff --git a/plugins/main/public/controllers/index.ts b/plugins/main/public/controllers/index.ts index 7efae9fca6..d7c78c7e99 100644 --- a/plugins/main/public/controllers/index.ts +++ b/plugins/main/public/controllers/index.ts @@ -16,4 +16,3 @@ import './agent'; import './settings'; import './security'; import './tools'; -import './misc'; diff --git a/plugins/main/public/controllers/misc/blank-screen-controller.js b/plugins/main/public/controllers/misc/blank-screen-controller.js deleted file mode 100644 index 06496fd889..0000000000 --- a/plugins/main/public/controllers/misc/blank-screen-controller.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Wazuh app - Blank screen controller - * 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 { AppState } from '../../react-services/app-state'; -import { ErrorHandler } from '../../react-services/error-handler'; -import { WzMisc } from '../../factories/misc'; -import { UI_ERROR_SEVERITIES } from '../../react-services/error-orchestrator/types'; -import { UI_LOGGER_LEVELS } from '../../../common/constants'; -import { getErrorOrchestrator } from '../../react-services/common-services'; - -export class BlankScreenController { - /** - * Class constructor - * @param {*} $scope - * @param {*} $location - * @param {*} errorHandler - */ - constructor($scope, $location, errorHandler) { - this.$scope = $scope; - this.$location = $location; - this.errorHandler = errorHandler; - this.wzMisc = new WzMisc(); - this.showErrorPage = false; - } - - /** - * When controller loads - */ - $onInit() { - AppState.setWzMenu(); - const catchedError = this.wzMisc.getBlankScr(); - if (catchedError) { - let parsed = null; - try { - parsed = ErrorHandler.handle(catchedError, '', { silent: true }); - } catch (error) { - const options = { - context: `${BlankScreenController.name}.$onInit`, - level: UI_LOGGER_LEVELS.ERROR, - severity: UI_ERROR_SEVERITIES.UI, - error: { - error: error, - message: error.message || error, - title: error.name, - }, - }; - getErrorOrchestrator().handleError(options); - } - - this.errorToShow = parsed || catchedError; - this.$scope.$applyAsync(); - this.wzMisc.setBlankScr(false); - } else { - this.goOverview(); - return; - } - this.$scope.blankScreenProps = { - errorToShow: this.errorToShow, - goToOverview: () => this.goOverview() - }; - this.showErrorPage = true; - AppState.setWzMenu(false); - } - - /** - * This navigate to overview - */ - goOverview() { - this.$location.path('/overview'); - } -} diff --git a/plugins/main/public/controllers/misc/index.js b/plugins/main/public/controllers/misc/index.js deleted file mode 100644 index 1fe562e085..0000000000 --- a/plugins/main/public/controllers/misc/index.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Wazuh app - Load all the Misc controllers. - * 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 { BlankScreenController } from './blank-screen-controller'; -import { getAngularModule } from '../../kibana-services'; - -const app = getAngularModule(); - -app - .controller('blankScreenController', BlankScreenController); diff --git a/plugins/main/public/templates/error-handler/blank-screen.html b/plugins/main/public/templates/error-handler/blank-screen.html index f293ddd92f..d65b7c6466 100644 --- a/plugins/main/public/templates/error-handler/blank-screen.html +++ b/plugins/main/public/templates/error-handler/blank-screen.html @@ -1,5 +1 @@ -
-
- -
-
\ No newline at end of file +