wazuh-kibana-app/public/app.js

211 lines
6.2 KiB
JavaScript
Raw Normal View History

/*
* Wazuh app - File for app requirements and set up
2019-01-14 16:36:47 +00:00
* Copyright (C) 2015-2019 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.
*/
2018-11-12 09:33:53 +00:00
import 'ui/autoload/styles';
2018-09-10 08:32:49 +00:00
import 'uiExports/visTypes';
import 'uiExports/visResponseHandlers';
import 'uiExports/visRequestHandlers';
import 'uiExports/visEditorTypes';
import 'uiExports/savedObjectTypes';
import 'uiExports/spyModes';
import 'uiExports/fieldFormats';
import 'uiExports/fieldFormatEditors';
import 'uiExports/navbarExtensions';
import 'uiExports/managementSections';
import 'uiExports/devTools';
import 'uiExports/docViews';
import 'uiExports/embeddableFactories';
import 'uiExports/autocompleteProviders';
2016-06-29 01:43:18 +00:00
// Require CSS
2018-06-15 10:42:57 +00:00
import './less/loader';
2018-07-31 09:04:36 +00:00
import { uiModules } from 'ui/modules';
2016-06-29 01:43:18 +00:00
// Set up Wazuh app
2018-06-15 10:42:57 +00:00
const app = uiModules.get('app/wazuh', ['ngCookies', 'ngMaterial']);
2018-03-06 11:03:58 +00:00
2018-09-10 08:32:49 +00:00
app.config([
'$compileProvider',
2019-02-06 08:54:34 +00:00
function($compileProvider) {
2018-09-10 08:32:49 +00:00
$compileProvider.aHrefSanitizationWhitelist(
/^\s*(https?|ftp|mailto|data|blob):/
);
}
]);
2018-03-06 11:03:58 +00:00
2018-09-10 08:32:49 +00:00
app.config([
'$httpProvider',
2019-02-06 08:54:34 +00:00
function($httpProvider) {
$httpProvider.useApplyAsync(true);
2018-09-10 08:32:49 +00:00
}
]);
2016-06-29 01:43:18 +00:00
2019-02-06 08:54:34 +00:00
app.run(function($rootScope, $route, $location, appState, $window) {
2019-01-17 14:26:02 +00:00
appState.setNavigation({ status: false });
2019-02-04 09:40:19 +00:00
appState.setNavigation({
reloaded: false,
discoverPrevious: false,
2019-02-11 09:13:26 +00:00
discoverSections: [
'/wazuh-discover/',
'/overview/',
'/agents',
'/wazuh-dev'
]
2019-02-04 09:40:19 +00:00
});
2019-01-17 14:26:02 +00:00
2019-01-16 15:16:00 +00:00
$rootScope.$on('$routeChangeSuccess', () => {
2019-01-17 14:26:02 +00:00
appState.setNavigation({ prevLocation: $location.path() });
if (!appState.getNavigation().reloaded) {
appState.setNavigation({ status: true });
2019-01-16 15:16:00 +00:00
} else {
2019-01-17 14:26:02 +00:00
appState.setNavigation({ reloaded: false });
2019-01-16 15:16:00 +00:00
}
});
$rootScope.$on('$locationChangeSuccess', () => {
2019-01-17 14:26:02 +00:00
const navigation = appState.getNavigation();
appState.setNavigation({ currLocation: $location.path() });
2019-01-17 16:37:17 +00:00
if (navigation.currLocation !== navigation.prevLocation) {
if (navigation.discoverSections.includes(navigation.currLocation)) {
2019-02-04 09:40:19 +00:00
appState.setNavigation({ discoverPrevious: navigation.prevLocation });
2019-01-17 16:37:17 +00:00
}
} else {
if (!navigation.status && navigation.prevLocation) {
2019-02-06 08:54:34 +00:00
if (
!navigation.discoverSections.includes(navigation.currLocation) &&
$location.search().tabView !== 'cluster-monitoring'
) {
2019-01-17 14:26:02 +00:00
appState.setNavigation({ reloaded: true });
2019-01-31 11:03:44 +00:00
$location.search('configSubTab', null);
2019-02-04 10:53:00 +00:00
$location.search('editingFile', null);
2019-01-17 14:26:02 +00:00
$route.reload();
2019-01-17 16:37:17 +00:00
//discover sections
2019-02-04 09:40:19 +00:00
} else if (
navigation.discoverSections.includes(navigation.currLocation)
) {
2019-01-17 16:37:17 +00:00
if (navigation.currLocation === navigation.discoverSections[1]) {
2019-02-06 08:54:34 +00:00
$window.history.pushState(
{ page: 'wazuh#' + navigation.discoverPrevious + '/' },
'',
'wazuh#' + navigation.discoverPrevious + '/'
);
} else if (
navigation.currLocation === navigation.discoverSections[2]
) {
if (
$location.search().tab &&
$location.search().tab !== 'welcome'
) {
$window.history.pushState(
{ page: 'wazuh#' + navigation.discoverPrevious },
'',
'wazuh#' + navigation.discoverPrevious
);
$window.history.pushState(
{
page:
'wazuh#' +
navigation.discoverPrevious +
'?agent=' +
$location.search().agent
},
'',
'wazuh#' +
navigation.discoverPrevious +
'?agent=' +
$location.search().agent
);
2019-02-01 15:37:48 +00:00
} else {
2019-02-06 08:54:34 +00:00
$window.history.pushState(
{ page: 'wazuh#' + navigation.discoverPrevious },
'',
'wazuh#' + navigation.discoverPrevious
);
2019-02-01 15:37:48 +00:00
}
2019-02-06 08:54:34 +00:00
} else if (
navigation.currLocation === navigation.discoverSections[0] ||
navigation.currLocation === navigation.discoverSections[3]
) {
2019-02-04 09:40:19 +00:00
$window.history.pushState(
{ page: 'wazuh#' + navigation.discoverPrevious },
'',
'wazuh#' + navigation.discoverPrevious
);
2019-01-17 16:37:17 +00:00
}
2019-02-04 09:40:19 +00:00
$window.history.pushState(
{ page: '/app/wazuh#' + $location.$$url },
'',
'/app/wazuh#' + $location.$$url
);
2019-02-05 10:47:26 +00:00
} else if ($location.search().tabView === 'cluster-monitoring') {
$window.history.pushState(
{ page: '/app/wazuh#/manager//' },
'',
'/app/wazuh#/manager//'
);
$window.history.pushState(
{ page: '/app/wazuh#' + $location.$$url },
'',
'/app/wazuh#' + $location.$$url
);
2019-01-17 14:26:02 +00:00
}
}
}
appState.setNavigation({ status: false });
2019-01-16 15:16:00 +00:00
});
});
// Font Awesome, Kibana UI framework and others
2018-06-15 10:42:57 +00:00
import './utils/fontawesome/css/font-awesome.min.css';
2018-05-08 14:08:12 +00:00
// Dev tools
2018-09-10 08:32:49 +00:00
import './utils/codemirror';
2018-05-08 14:08:12 +00:00
// Material
2018-07-31 09:04:36 +00:00
import 'angular-material/angular-material.css';
import 'angular-aria/angular-aria';
import 'angular-animate/angular-animate';
import 'angular-material/angular-material';
// Cookies
2018-07-31 09:04:36 +00:00
import 'angular-cookies/angular-cookies';
import 'ui/autoload/all';
import 'ui/chrome';
2017-11-23 10:33:34 +00:00
2018-05-04 10:29:07 +00:00
// Wazuh
2018-09-10 08:32:49 +00:00
import './kibana-integrations';
import './services';
import './controllers';
import './factories';
import './directives';
2018-06-25 07:47:35 +00:00
// Added due to Kibana 6.3.0. Do not modify.
2018-09-10 08:32:49 +00:00
uiModules.get('kibana').provider('dashboardConfig', () => {
let hideWriteControls = false;
2018-06-25 07:47:35 +00:00
2018-09-10 08:32:49 +00:00
return {
/**
* Part of the exposed plugin API - do not remove without careful consideration.
* @type {boolean}
*/
turnHideWriteControlsOn() {
hideWriteControls = true;
},
$get() {
return {
getHideWriteControls() {
return hideWriteControls;
}
};
}
};
2018-07-02 07:28:08 +00:00
});