mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-06 18:05:20 +00:00
Added event for refreshing xml content after it's loaded
This commit is contained in:
parent
4582ccd311
commit
1ca107e223
@ -257,7 +257,7 @@ export function GroupsController(
|
||||
$scope.editingFile = true;
|
||||
try {
|
||||
$scope.fetchedXML = await fetchFile();
|
||||
$scope.$broadcast('fetchedFile',{data:$scope.fetchedXML});
|
||||
$scope.$broadcast('fetchedFile', { data: $scope.fetchedXML });
|
||||
} catch (error) {
|
||||
$scope.fetchedXML = null;
|
||||
errorHandler.handle(error, 'Fetch file error');
|
||||
|
@ -16,7 +16,7 @@ import { uiModules } from 'ui/modules';
|
||||
|
||||
const app = uiModules.get('app/wazuh', []);
|
||||
|
||||
app.directive('wzXmlFileEditor', function () {
|
||||
app.directive('wzXmlFileEditor', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
@ -31,9 +31,15 @@ app.directive('wzXmlFileEditor', function () {
|
||||
try {
|
||||
const parser = new DOMParser(); // eslint-disable-line
|
||||
const xml = $scope.xmlCodeBox.getValue();
|
||||
const xmlDoc = parser.parseFromString('<file>' + xml + '</file>', 'text/xml');
|
||||
const xmlDoc = parser.parseFromString(
|
||||
'<file>' + xml + '</file>',
|
||||
'text/xml'
|
||||
);
|
||||
$scope.validFn({
|
||||
valid: !!xmlDoc.getElementsByTagName('parsererror').length || !xml || !xml.length
|
||||
valid:
|
||||
!!xmlDoc.getElementsByTagName('parsererror').length ||
|
||||
!xml ||
|
||||
!xml.length
|
||||
});
|
||||
} catch (error) {
|
||||
errorHandler.handle(error, 'Error validating XML');
|
||||
@ -84,16 +90,16 @@ app.directive('wzXmlFileEditor', function () {
|
||||
} catch (error) {
|
||||
errorHandler.handle(error, 'Fetching original file');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
// Refresh content if it's not the very first time we are loading data
|
||||
$scope.$on('fetchedFile',(ev,params) => {
|
||||
if(!firstTime) {
|
||||
$scope.$on('fetchedFile', (ev, params) => {
|
||||
if (!firstTime) {
|
||||
init(params.data);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$scope.xmlCodeBox.on('change', () => {
|
||||
checkXmlParseError();
|
||||
|
Loading…
Reference in New Issue
Block a user