mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-07 02:15:24 +00:00
Merge pull request #1248 from wazuh/fixes-editconfig
Fix edit manager config
This commit is contained in:
commit
b16f24a76a
@ -94,7 +94,24 @@ export class AgentsController {
|
||||
|
||||
this.$scope.addingGroupToAgent = false;
|
||||
|
||||
this.$scope.expandArray = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false];
|
||||
this.$scope.expandArray = [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -501,7 +518,7 @@ export class AgentsController {
|
||||
(((agentInfo || {}).data || {}).data || {}).status ||
|
||||
this.$scope.agent.status;
|
||||
}
|
||||
} catch (error) { } // eslint-disable-line
|
||||
} catch (error) {} // eslint-disable-line
|
||||
|
||||
try {
|
||||
this.$scope.showSyscheckFiles = false;
|
||||
@ -518,7 +535,7 @@ export class AgentsController {
|
||||
if (tab === 'syscollector')
|
||||
try {
|
||||
await this.loadSyscollector(this.$scope.agent.id);
|
||||
} catch (error) { } // eslint-disable-line
|
||||
} catch (error) {} // eslint-disable-line
|
||||
if (tab === 'configuration') {
|
||||
const isSync = await this.apiReq.request(
|
||||
'GET',
|
||||
@ -636,7 +653,7 @@ export class AgentsController {
|
||||
{}
|
||||
);
|
||||
netifaceResponse = ((resultNetiface || {}).data || {}).data || false;
|
||||
} catch (error) { } // eslint-disable-line
|
||||
} catch (error) {} // eslint-disable-line
|
||||
|
||||
// This API call may fail so we put it out of Promise.all
|
||||
let netaddrResponse = false;
|
||||
@ -648,7 +665,7 @@ export class AgentsController {
|
||||
);
|
||||
netaddrResponse =
|
||||
((resultNetaddrResponse || {}).data || {}).data || false;
|
||||
} catch (error) { } // eslint-disable-line
|
||||
} catch (error) {} // eslint-disable-line
|
||||
|
||||
// Before proceeding, syscollector data is an empty object
|
||||
this.$scope.syscollector = {};
|
||||
@ -664,7 +681,7 @@ export class AgentsController {
|
||||
this.$scope.syscollector = {
|
||||
hardware:
|
||||
typeof hardwareResponse === 'object' &&
|
||||
Object.keys(hardwareResponse).length
|
||||
Object.keys(hardwareResponse).length
|
||||
? { ...hardwareResponse }
|
||||
: false,
|
||||
os:
|
||||
@ -885,7 +902,24 @@ export class AgentsController {
|
||||
}
|
||||
|
||||
falseAllExpand() {
|
||||
this.$scope.expandArray = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false];
|
||||
this.$scope.expandArray = [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
];
|
||||
}
|
||||
|
||||
expand(i) {
|
||||
|
@ -56,9 +56,11 @@ export class EditionController {
|
||||
try {
|
||||
let data = false;
|
||||
let xml = false;
|
||||
const clusterStatus =
|
||||
((this.$scope.clusterStatus || {}).data || {}).data || {};
|
||||
if (
|
||||
this.$scope.clusterStatus.data.data.enabled === 'yes' &&
|
||||
this.$scope.clusterStatus.data.data.running === 'yes'
|
||||
clusterStatus.enabled === 'yes' &&
|
||||
clusterStatus.running === 'yes'
|
||||
) {
|
||||
data = await this.apiReq.request(
|
||||
'GET',
|
||||
@ -105,9 +107,12 @@ export class EditionController {
|
||||
{}
|
||||
);
|
||||
let data;
|
||||
const clusterStatus =
|
||||
((this.$scope.clusterStatus || {}).data || {}).data || {};
|
||||
if (
|
||||
this.$scope.clusterStatus.data.data.enabled === 'yes' &&
|
||||
this.$scope.clusterStatus.data.data.running === 'yes'
|
||||
(clusterStatus.enabled === 'yes' &&
|
||||
clusterStatus.running === 'yes') ||
|
||||
(clusterStatus.enabled === 'no' && clusterStatus.running === 'yes')
|
||||
) {
|
||||
data = await this.configHandler.restartNode(selectedNode);
|
||||
} else {
|
||||
@ -128,20 +133,21 @@ export class EditionController {
|
||||
};
|
||||
this.$scope.saveConfiguration = async () => {
|
||||
try {
|
||||
if (
|
||||
this.$scope.clusterStatus.data.data.enabled === 'yes' &&
|
||||
this.$scope.clusterStatus.data.data.running === 'yes'
|
||||
) {
|
||||
this.$scope.$broadcast('saveXmlFile', {
|
||||
node: this.$scope.selectedNode,
|
||||
showRestartManager: 'cluster'
|
||||
});
|
||||
} else {
|
||||
this.$scope.$broadcast('saveXmlFile', {
|
||||
manager: this.$scope.selectedNode,
|
||||
showRestartManager: 'manager'
|
||||
});
|
||||
}
|
||||
const clusterStatus =
|
||||
((this.$scope.clusterStatus || {}).data || {}).data || {};
|
||||
const enabledAndRunning =
|
||||
clusterStatus.enabled === 'yes' && clusterStatus.running === 'yes';
|
||||
const parameters = enabledAndRunning
|
||||
? {
|
||||
node: this.$scope.selectedNode,
|
||||
showRestartManager: 'cluster'
|
||||
}
|
||||
: {
|
||||
manager: this.$scope.selectedNode,
|
||||
showRestartManager: 'manager'
|
||||
};
|
||||
|
||||
this.$scope.$broadcast('saveXmlFile', parameters);
|
||||
} catch (error) {
|
||||
this.$scope.fetchedXML = null;
|
||||
this.errorHandler.handle(error, 'Save file error');
|
||||
@ -175,16 +181,13 @@ export class EditionController {
|
||||
'/cluster/status',
|
||||
{}
|
||||
);
|
||||
if (
|
||||
this.$scope.clusterStatus &&
|
||||
this.$scope.clusterStatus.data.data.enabled === 'yes' &&
|
||||
this.$scope.clusterStatus.data.data.running === 'yes'
|
||||
) {
|
||||
const clusterStatus =
|
||||
((this.$scope.clusterStatus || {}).data || {}).data || {};
|
||||
if (clusterStatus.enabled === 'yes' && clusterStatus.running === 'yes') {
|
||||
const nodes = await this.apiReq.request('GET', '/cluster/nodes', {});
|
||||
this.$scope.nodes = nodes.data.data.items.reverse();
|
||||
const masterNode = nodes.data.data.items.filter(
|
||||
item => item.type === 'master'
|
||||
)[0];
|
||||
const items = nodes.data.data.items;
|
||||
this.$scope.nodes = items.reverse();
|
||||
const masterNode = items.filter(item => item.type === 'master')[0];
|
||||
this.$scope.selectedNode = masterNode.name;
|
||||
} else {
|
||||
this.$scope.selectedNode = 'manager';
|
||||
|
@ -301,18 +301,12 @@ export function GroupsController(
|
||||
};
|
||||
|
||||
$scope.doSaveGroupAgentConfig = () => {
|
||||
$scope.editingFile = false;
|
||||
$scope.$broadcast('saveXmlFile', {
|
||||
group: $scope.currentGroup.name,
|
||||
type: 'group'
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on('configurationSuccess', () => {
|
||||
$scope.editingFile = false;
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
});
|
||||
|
||||
$scope.reload = async (element, searchTerm, addOffset, start) => {
|
||||
if (element === 'left') {
|
||||
if (!$scope.availableAgents.loadedAll) {
|
||||
|
@ -289,13 +289,13 @@ export function ClusterController(
|
||||
|
||||
$scope.falseAllExpand = () => {
|
||||
$scope.expandArray = [false, false];
|
||||
}
|
||||
};
|
||||
|
||||
$scope.expand = i => {
|
||||
const oldValue = $scope.expandArray[i];
|
||||
$scope.falseAllExpand();
|
||||
$scope.expandArray[i] = !oldValue;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.expandArray = [false, false];
|
||||
|
||||
|
@ -65,7 +65,24 @@ export class OverviewController {
|
||||
this.reportingService = reportingService;
|
||||
this.visFactoryService = visFactoryService;
|
||||
this.wazuhConfig = wazuhConfig;
|
||||
this.expandArray = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false];
|
||||
this.expandArray = [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -333,7 +350,24 @@ export class OverviewController {
|
||||
}
|
||||
|
||||
falseAllExpand() {
|
||||
this.expandArray = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false];
|
||||
this.expandArray = [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
];
|
||||
}
|
||||
|
||||
expand(i) {
|
||||
|
@ -26,7 +26,7 @@ import { checkGap } from './lib/check-gap';
|
||||
|
||||
const app = uiModules.get('app/wazuh', []);
|
||||
|
||||
app.directive('wzTable', function () {
|
||||
app.directive('wzTable', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
@ -54,7 +54,7 @@ app.directive('wzTable', function () {
|
||||
) {
|
||||
$scope.showColumns = false;
|
||||
$scope.originalkeys = $scope.keys.map((key, idx) => ({ key, idx }));
|
||||
$scope.updateColumns = (key) => {
|
||||
$scope.updateColumns = key => {
|
||||
const str = key.key.value || key.key;
|
||||
const cleanArray = $scope.keys.map(item => item.value || item);
|
||||
if (cleanArray.includes(str)) {
|
||||
@ -63,19 +63,21 @@ app.directive('wzTable', function () {
|
||||
$scope.keys.splice(idx, 1);
|
||||
}
|
||||
} else {
|
||||
const originalIdx = $scope.originalkeys.findIndex(item => (item.key.value || item.key) === (key.key.value || key.key));
|
||||
const originalIdx = $scope.originalkeys.findIndex(
|
||||
item => (item.key.value || item.key) === (key.key.value || key.key)
|
||||
);
|
||||
if (originalIdx >= 0) {
|
||||
$scope.keys.splice(originalIdx, 0, key.key);
|
||||
} else {
|
||||
$scope.keys.push(key.key)
|
||||
$scope.keys.push(key.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
$scope.exists = (key) => {
|
||||
};
|
||||
$scope.exists = key => {
|
||||
const str = key.key.value || key.key;
|
||||
for (const k of $scope.keys) if ((k.value || k) === str) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Init variables
|
||||
@ -262,7 +264,7 @@ app.directive('wzTable', function () {
|
||||
$scope.prevPage = () => pagination.prevPage($scope);
|
||||
$scope.nextPage = async currentPage =>
|
||||
pagination.nextPage(currentPage, $scope, errorHandler, fetch);
|
||||
$scope.setPage = function () {
|
||||
$scope.setPage = function() {
|
||||
$scope.currentPage = this.n;
|
||||
$scope.nextPage(this.n);
|
||||
};
|
||||
|
@ -172,21 +172,38 @@ app.directive('wzXmlFileEditor', function() {
|
||||
return formatted.trim();
|
||||
};
|
||||
|
||||
const validateAfterSent = async () => {
|
||||
const validateAfterSent = async (node = false) => {
|
||||
try {
|
||||
const isCluster = appState.getClusterInfo().status === 'enabled';
|
||||
const clusterStatus = await apiReq.request(
|
||||
'GET',
|
||||
`/cluster/status`,
|
||||
{}
|
||||
);
|
||||
|
||||
const validation = isCluster
|
||||
? await apiReq.request(
|
||||
'GET',
|
||||
`/cluster/configuration/validation`,
|
||||
{}
|
||||
)
|
||||
: await apiReq.request(
|
||||
'GET',
|
||||
`/manager/configuration/validation`,
|
||||
{}
|
||||
);
|
||||
const clusterData = ((clusterStatus || {}).data || {}).data || {};
|
||||
const isCluster =
|
||||
clusterData.enabled === 'yes' && clusterData.running === 'yes';
|
||||
|
||||
let validation = false;
|
||||
if (node && isCluster) {
|
||||
validation = await apiReq.request(
|
||||
'GET',
|
||||
`/cluster/${node}/configuration/validation`,
|
||||
{}
|
||||
);
|
||||
} else {
|
||||
validation = isCluster
|
||||
? await apiReq.request(
|
||||
'GET',
|
||||
`/cluster/configuration/validation`,
|
||||
{}
|
||||
)
|
||||
: await apiReq.request(
|
||||
'GET',
|
||||
`/manager/configuration/validation`,
|
||||
{}
|
||||
);
|
||||
}
|
||||
const data = ((validation || {}).data || {}).data || {};
|
||||
const isOk = data.status === 'OK';
|
||||
if (!isOk && Array.isArray(data.details)) {
|
||||
@ -221,7 +238,6 @@ app.directive('wzXmlFileEditor', function() {
|
||||
? showRestartDialog(msg, params.showRestartManager)
|
||||
: errorHandler.handle(warnMsg, '', true)
|
||||
: errorHandler.info(msg, '');
|
||||
$scope.$emit('configurationSuccess');
|
||||
} else if (params.rule) {
|
||||
await rulesetHandler.sendRuleConfiguration(params.rule, xml);
|
||||
try {
|
||||
@ -253,7 +269,7 @@ app.directive('wzXmlFileEditor', function() {
|
||||
} else if (params.node) {
|
||||
await configHandler.saveNodeConfiguration(params.node, xml);
|
||||
try {
|
||||
await validateAfterSent();
|
||||
await validateAfterSent(params.node);
|
||||
} catch (err) {
|
||||
params.showRestartManager = 'warn';
|
||||
close = false;
|
||||
|
@ -16,7 +16,7 @@ import { timefilter } from 'ui/timefilter';
|
||||
|
||||
const app = uiModules.get('apps/webinar_app', []);
|
||||
let lockFields = false;
|
||||
app.directive('kbnVis', function () {
|
||||
app.directive('kbnVis', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
@ -131,13 +131,21 @@ app.directive('kbnVis', function () {
|
||||
}
|
||||
} catch (error) {
|
||||
if (
|
||||
((error || {}).message || '').includes('not locate that index-pattern-field')
|
||||
((error || {}).message || '').includes(
|
||||
'not locate that index-pattern-field'
|
||||
)
|
||||
) {
|
||||
if (!lockFields) {
|
||||
try {
|
||||
lockFields = true;
|
||||
errorHandler.info('Detected an incomplete index pattern, refreshing all its known fields...');
|
||||
await genericReq.request('GET', '/elastic/known-fields/all', {});
|
||||
errorHandler.info(
|
||||
'Detected an incomplete index pattern, refreshing all its known fields...'
|
||||
);
|
||||
await genericReq.request(
|
||||
'GET',
|
||||
'/elastic/known-fields/all',
|
||||
{}
|
||||
);
|
||||
lockFields = false;
|
||||
errorHandler.info('Success');
|
||||
return myRender(raw);
|
||||
@ -167,10 +175,10 @@ app.directive('kbnVis', function () {
|
||||
updateVisWatcher();
|
||||
try {
|
||||
visualization.destroy();
|
||||
} catch (error) { } // eslint-disable-line
|
||||
} catch (error) {} // eslint-disable-line
|
||||
try {
|
||||
visHandler.destroy();
|
||||
} catch (error) { } // eslint-disable-line
|
||||
} catch (error) {} // eslint-disable-line
|
||||
});
|
||||
|
||||
const renderComplete = () => {
|
||||
@ -179,11 +187,11 @@ app.directive('kbnVis', function () {
|
||||
const currentCompleted = Math.round(
|
||||
(loadedVisualizations.getList().length /
|
||||
tabVisualizations.getItem(tabVisualizations.getTab())) *
|
||||
100
|
||||
100
|
||||
);
|
||||
$rootScope.loadingStatus = `Rendering visualizations... ${
|
||||
currentCompleted > 100 ? 100 : currentCompleted
|
||||
} %`;
|
||||
} %`;
|
||||
|
||||
if (currentCompleted >= 100) {
|
||||
$rootScope.rendered = true;
|
||||
|
Loading…
Reference in New Issue
Block a user