ENTAXY-480 release version 1.8.3
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -0,0 +1,48 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* entaxy-management-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
var Entaxy;
|
||||
(function (Entaxy) {
|
||||
Entaxy._module
|
||||
.directive('modalDialog', function(){
|
||||
return {
|
||||
restrict: 'AC',
|
||||
link: function($scope, element) {
|
||||
var draggableStr = "draggableModal";
|
||||
var header = $(".modal-header", element);
|
||||
|
||||
header.on('mousedown', (mouseDownEvent) => {
|
||||
var modalDialog = element;
|
||||
var offset = header.offset();
|
||||
|
||||
modalDialog.addClass(draggableStr).parents().on('mousemove', (mouseMoveEvent) => {
|
||||
$("." + draggableStr, modalDialog.parents()).offset({
|
||||
top: mouseMoveEvent.pageY - (mouseDownEvent.pageY - offset.top),
|
||||
left: mouseMoveEvent.pageX - (mouseDownEvent.pageX - offset.left)
|
||||
});
|
||||
}).on('mouseup', () => {
|
||||
modalDialog.removeClass(draggableStr);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.name;
|
||||
|
||||
})(Entaxy || (Entaxy = {}));
|
@ -0,0 +1,77 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* entaxy-management-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
var Entaxy;
|
||||
(function (Entaxy) {
|
||||
Entaxy._module
|
||||
.component('entaxyModalListWithDescription', {
|
||||
bindings: {
|
||||
items: '<',
|
||||
selectedItem: '<',
|
||||
changeSelection: '<'
|
||||
},
|
||||
template:
|
||||
`
|
||||
<div class="modal-list-with-description-container">
|
||||
<div class="modal-list-with-description-list-container">
|
||||
<entaxy-modal-list items="$ctrl.items" selected="$ctrl.selectedItem" change-selection="$ctrl.changeSelection"
|
||||
enable-dbl-click="true" filter="$ctrl.matchesFilter"></entaxy-modal-list>
|
||||
</div>
|
||||
<div class="modal-description-container">
|
||||
<div class="modal-description-title">
|
||||
{{$ctrl.title}}
|
||||
</div>
|
||||
<div class="modal-description-body">
|
||||
<div ng-if="$ctrl.selectedItem.description">
|
||||
{{$ctrl.selectedItem.description}}
|
||||
</div>
|
||||
<div ng-if="!$ctrl.selectedItem.description">
|
||||
There is no selected factory.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
controller: entaxyModalListWithDescriptionController
|
||||
})
|
||||
.name;
|
||||
|
||||
function entaxyModalListWithDescriptionController() {
|
||||
|
||||
var ctrl = this;
|
||||
|
||||
ctrl.$onInit = function() {
|
||||
ctrl.title = 'Factory Description:';
|
||||
}
|
||||
|
||||
ctrl.matchesFilter = function(factory, filter) {
|
||||
var match = false;
|
||||
|
||||
if (factory.displayName.toLowerCase().match(filter.value.toLowerCase()) !== null ||
|
||||
factory.name.toLowerCase().match(filter.value.toLowerCase()) !== null ||
|
||||
(factory.label && factory.label.toLowerCase().match(filter.value.toLowerCase()) !== null)) {
|
||||
match = true;
|
||||
return match;
|
||||
}
|
||||
|
||||
return match;
|
||||
};
|
||||
}
|
||||
|
||||
})(Entaxy || (Entaxy = {}));
|
@ -0,0 +1,148 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* entaxy-management-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
var Entaxy;
|
||||
(function (Entaxy) {
|
||||
Entaxy._module
|
||||
.component('entaxyProperties', {
|
||||
template:
|
||||
`
|
||||
<h2>
|
||||
{{$ctrl.title}}
|
||||
</h2>
|
||||
<div class="properties-container">
|
||||
<entaxy-modal-group-fields groups="$ctrl.groups" fields="$ctrl.formFields"
|
||||
errors="$ctrl.errors" mode="$ctrl.mode" ng-if="$ctrl.groups && $ctrl.formFields"></entaxy-modal-group-fields>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary" ng-click="$ctrl.save($ctrl.formFields)">{{$ctrl.submitBtnTitle}}</button>
|
||||
`,
|
||||
controller: entaxyPropertiesController
|
||||
})
|
||||
.name;
|
||||
|
||||
function entaxyPropertiesController(workspace, operationsService, entaxyService) {
|
||||
'ngInject';
|
||||
|
||||
var ctrl = this;
|
||||
|
||||
ctrl.$onInit = function() {
|
||||
|
||||
ctrl.itemName = 'Profile';
|
||||
ctrl.mode = Entaxy.MODAL_MODES.EDIT;
|
||||
|
||||
let selectedMbean = workspace.getSelectedMBean();
|
||||
ctrl.title = 'Properties of ' + selectedMbean.title;
|
||||
ctrl.submitBtnTitle = Entaxy.getButtonTitleByMode(ctrl.mode);
|
||||
|
||||
let profilesMbean = workspace.tree.findDescendant(child => child.objectName ? child.objectName.endsWith('category=profiles') : false);
|
||||
let mbeanName = profilesMbean.objectName;
|
||||
|
||||
operationsService
|
||||
.executeOperation(mbeanName, { name: 'get' + ctrl.itemName + 'Config' }, [ selectedMbean.title ])
|
||||
.then(result => {
|
||||
ctrl.itemInfo = JSON.parse(result);
|
||||
let properties = Object.entries(ctrl.itemInfo.properties);
|
||||
ctrl.properties = properties.map(property => { return { name: property[0], value: property[1] }; });
|
||||
|
||||
let factory = workspace.tree.findDescendant(child => child.title === ctrl.itemInfo.factoryId);
|
||||
ctrl.factories = [{ name: factory.title, mbeanName: factory.objectName }];
|
||||
|
||||
makeFormFieldsAndGroups();
|
||||
}).catch(error => {
|
||||
Core.notification('danger', error, 5000);
|
||||
Entaxy.log.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
function makeFormFieldsAndGroups() {
|
||||
|
||||
ctrl.formFields = [];
|
||||
|
||||
ctrl.formFields.push({
|
||||
label: 'Factory Id',
|
||||
name: 'factoryId',
|
||||
type: 'java.lang.String',
|
||||
helpText: null,
|
||||
value: ctrl.factories[0].name,
|
||||
readOnly: true,
|
||||
required: true,
|
||||
group: 'general'
|
||||
});
|
||||
|
||||
let mbeanName = ctrl.factories[0].mbeanName;
|
||||
|
||||
operationsService.executeOperation(mbeanName, { name: 'getFields' }, [ 'init' ])
|
||||
.then((response) => {
|
||||
|
||||
let groups = new Set();
|
||||
groups.add('general');
|
||||
|
||||
_.forEach(JSON.parse(response), (field) => {
|
||||
|
||||
let formField = entaxyService.makeFormField(field, ctrl.itemInfo['objectId'], ctrl.properties, ctrl.mode);
|
||||
|
||||
ctrl.formFields.push(formField);
|
||||
groups.add(formField.group);
|
||||
});
|
||||
|
||||
ctrl.formFields.forEach(formField => formField.type = Entaxy.convertToHtmlInputType(formField.type));
|
||||
|
||||
ctrl.groups = Array.from(groups).map((group) => { return { name: group, displayName: group }; });
|
||||
});
|
||||
}
|
||||
|
||||
ctrl.save = function(fieldsOrigin) {
|
||||
|
||||
let fields = JSON.parse(JSON.stringify(fieldsOrigin));
|
||||
|
||||
entaxyService.validateFields(fields, ctrl.factories[0], ctrl.itemName)
|
||||
.then(errors => {
|
||||
ctrl.errors = errors;
|
||||
|
||||
if (Object.keys(ctrl.errors).length === 0) {
|
||||
let args = entaxyService.getArguments(fields, ctrl.factories);
|
||||
update(args);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function update(args) {
|
||||
|
||||
let objectId = args.fields.find((field) => field.name === 'objectId').value;
|
||||
|
||||
let fields = objectId ? args.fields.filter((field) => field.name !== 'objectId') : args.fields;
|
||||
|
||||
let mbeanName = args.factoryId.mbeanName;
|
||||
let properties = fields.reduce((obj, cur) => ({ ...obj, [cur.name] : cur.value }), {});
|
||||
let instructions = {"@LIFECYCLE":["general"]};
|
||||
|
||||
operationsService.executeOperation(mbeanName, { name: 'createObjectByInstructions' }, [ objectId, 'public', instructions, properties ] )
|
||||
.then(result => {
|
||||
let tableHtml = Entaxy.createTableFromResponse(result);
|
||||
Entaxy.notification('success', tableHtml, 10000);
|
||||
}).catch(error => {
|
||||
Core.notification('danger', error, 5000);
|
||||
Entaxy.log.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
entaxyPropertiesController.$inject = ['workspace', 'operationsService', 'entaxyService'];
|
||||
|
||||
})(Entaxy || (Entaxy = {}));
|
@ -0,0 +1,193 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* entaxy-management-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
var Entaxy;
|
||||
(function (Entaxy) {
|
||||
// fixme this component works only for connections now
|
||||
Entaxy._module
|
||||
.component('entaxySelect', {
|
||||
bindings: {
|
||||
type: '<',
|
||||
filter: '<',
|
||||
model: '=',
|
||||
updateParentFn: '<',
|
||||
options: '='
|
||||
},
|
||||
template:
|
||||
`
|
||||
<div class="custom-select">
|
||||
<button type="button" class="btn-select form-control dropdown-toggle" id="filter" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{$ctrl.selectedOption.name}}
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li ng-repeat="option in $ctrl.options" id="option.name" ng-click="$ctrl.changeSelection(option)">{{ option.name }}</li>
|
||||
<li id="addItem" class="dropdown-option-new" ng-click="$ctrl.addConnection()"><span class="pficon pficon-add-circle-o"></span>New private connection...</li>
|
||||
</ul>
|
||||
</div>
|
||||
`,
|
||||
controller: entaxySelectController
|
||||
})
|
||||
.name;
|
||||
|
||||
function entaxySelectController(workspace, jolokiaService, $q, $uibModal) {
|
||||
'ngInject';
|
||||
|
||||
var ctrl = this;
|
||||
|
||||
ctrl.$onInit = function() {
|
||||
|
||||
if (ctrl.type === 'entaxy.runtime.connection') {
|
||||
|
||||
if (!ctrl.options) {
|
||||
|
||||
let promises = [];
|
||||
let filteredConnections = [];
|
||||
|
||||
let connectionsFolder = workspace.tree.findDescendant(child => (child.objectName && child.objectName.endsWith('category=connections')));
|
||||
|
||||
if (connectionsFolder) {
|
||||
if (ctrl.filter) {
|
||||
connectionsFolder.children.forEach((child) => {
|
||||
promises.push(
|
||||
jolokiaService.getAttribute(child.objectName, 'Label')
|
||||
.then((label) => {
|
||||
if (label.indexOf(ctrl.filter) > -1) {
|
||||
filteredConnections.push({ name: child.title, mbeanName: connectionsFolder.objectName });
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
} else {
|
||||
filteredConnections = connectionsFolder.children ? connectionsFolder.children.map(child => { name: child.title }) : [];
|
||||
}
|
||||
}
|
||||
|
||||
$q.all(promises).then(() => {
|
||||
if (filteredConnections && filteredConnections.length > 0) {
|
||||
ctrl.options = filteredConnections.sort(Entaxy.compareBy('name'));
|
||||
ctrl.changeSelection(filteredConnections[0]);
|
||||
} else {
|
||||
Core.notification('danger', 'There are no suitable connections', 5000);
|
||||
// todo close the modal
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ctrl.selectedOption = ctrl.options.find((option) => option.name === ctrl.model || option.value === ctrl.model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctrl.changeSelection = function (option) {
|
||||
let previousOption = ctrl.selectedOption;
|
||||
ctrl.selectedOption = option;
|
||||
ctrl.model = option.value ? option.value : option.name;
|
||||
|
||||
if (ctrl.type === 'entaxy.runtime.connection') {
|
||||
if (previousOption) {
|
||||
Core.notification('warning', 'Changing connection field value may lead to changes in other fields of the current connector. ' +
|
||||
'Please, make sure to revise all fields before accepting.', 10000);
|
||||
}
|
||||
ctrl.updateParentFn(previousOption, option, 'Connection');
|
||||
}
|
||||
}
|
||||
|
||||
ctrl.addConnection = function () {
|
||||
ctrl.showModal();
|
||||
}
|
||||
|
||||
ctrl.showModal = function() {
|
||||
|
||||
let factories = [];
|
||||
let promises = [];
|
||||
|
||||
let factoryFolder = workspace.tree.findDescendant(child => child.title === ctrl.type);
|
||||
|
||||
if (factoryFolder && factoryFolder.children) {
|
||||
factoryFolder.children.forEach((child) => {
|
||||
promises.push(jolokiaService.getAttributes(child.objectName, ['Abstract', 'DisplayName', 'Label', 'Description', 'Deprecated'])
|
||||
.then((result) => {
|
||||
let label = result['Label'];
|
||||
|
||||
if (!result['Abstract']) {
|
||||
if (!ctrl.filter || (ctrl.filter && label && label.indexOf(ctrl.filter) > -1)) {
|
||||
factories.push({
|
||||
name: child.title,
|
||||
displayName: result['DisplayName'] ? result['DisplayName'] : child.title,
|
||||
label: result['Label'],
|
||||
mbeanName: child.objectName,
|
||||
description: result['Description'] ? result['Description'] : 'There is no description for this factory.',
|
||||
additionalInfo: result['Deprecated'] ? ['[DEPRECATED]'] : undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
$uibModal.open({
|
||||
component: 'entaxyModal',
|
||||
resolve: {
|
||||
mode: () => Entaxy.MODAL_MODES.ADD,
|
||||
itemType: () => 'Connection',
|
||||
factories: $q.all(promises).then(() => factories)
|
||||
},
|
||||
size: 'xl',
|
||||
backdrop: 'static',
|
||||
windowTopClass: 'modal-top-margin-override'
|
||||
})
|
||||
.result.then(args => {
|
||||
addItem(args);
|
||||
},
|
||||
reason => {
|
||||
if (reason) {
|
||||
Core.notification('danger', reason, 5000);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function addItem(args) {
|
||||
|
||||
let factoryId = args.factoryId.name;
|
||||
|
||||
let objectId = args.fields.find((field) => field.name === 'objectId').value;
|
||||
|
||||
let fields = objectId ? args.fields.filter((field) => field.name !== 'objectId') : args.fields;
|
||||
|
||||
let properties = fields.reduce((obj, cur) => ({ ...obj, [cur.name] : cur.value }), {});
|
||||
|
||||
let newObjectProperties = {
|
||||
factoryId: factoryId,
|
||||
objectId: objectId,
|
||||
scope: 'private',
|
||||
properties: properties
|
||||
};
|
||||
|
||||
let newObjectOption = {
|
||||
name: objectId ? objectId : 'private-connection',
|
||||
value: newObjectProperties
|
||||
};
|
||||
|
||||
ctrl.options.push(newObjectOption);
|
||||
ctrl.changeSelection(newObjectOption);
|
||||
}
|
||||
}
|
||||
entaxySelectController.$inject = ['workspace', 'jolokiaService', '$q', '$uibModal'];
|
||||
|
||||
})(Entaxy || (Entaxy = {}));
|
@ -0,0 +1,58 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* entaxy-management-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
var Entaxy;
|
||||
(function (Entaxy) {
|
||||
Entaxy._module
|
||||
.component('entaxySelectFromEnum', {
|
||||
bindings: {
|
||||
values: '<',
|
||||
isEmptyIncluded: '<',
|
||||
model: '='
|
||||
},
|
||||
template:
|
||||
`
|
||||
<select class="form-control" ng-options="option.name for option in $ctrl.options" ng-model="$ctrl.selectedOption"
|
||||
ng-change="$ctrl.changeSelection()">
|
||||
`,
|
||||
controller: entaxySelectFromEnumController
|
||||
})
|
||||
.name;
|
||||
|
||||
function entaxySelectFromEnumController() {
|
||||
|
||||
let ctrl = this;
|
||||
let emptyValue = { name: '--Empty value--' };
|
||||
|
||||
ctrl.$onInit = function() {
|
||||
ctrl.options = ctrl.values.map(value => { return { name: value } });
|
||||
|
||||
ctrl.options.unshift(emptyValue);
|
||||
|
||||
ctrl.selectedOption = ctrl.model ? ctrl.options.find((option) => option.name === ctrl.model) : ctrl.options[0];
|
||||
|
||||
ctrl.changeSelection();
|
||||
}
|
||||
|
||||
ctrl.changeSelection = function () {
|
||||
ctrl.model = (ctrl.selectedOption === emptyValue) ? undefined : ctrl.selectedOption.name;
|
||||
}
|
||||
}
|
||||
|
||||
})(Entaxy || (Entaxy = {}));
|
@ -0,0 +1,107 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* entaxy-management-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
var Entaxy;
|
||||
(function (Entaxy) {
|
||||
Entaxy._module
|
||||
.component('entaxySource', {
|
||||
template:
|
||||
`
|
||||
<div class="route-source-header-container">
|
||||
<h2>
|
||||
Source
|
||||
</h2>
|
||||
<span class="route-source-error-message" ng-if="$ctrl.errorMessage">*{{$ctrl.errorMessage}}</span>
|
||||
</div>
|
||||
<div ng-if="$ctrl.isContentPresent">
|
||||
<div class="xml-route-source-container">
|
||||
<div hawtio-editor="xml" mode="'xml'" output-editor="xmlEditor"></div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary" ng-click="$ctrl.save()">Save changes</button>
|
||||
</div>
|
||||
<div ng-if="$ctrl.isContentPresent === false">There is no viewable content.</div>
|
||||
`,
|
||||
controller: entaxySourceController
|
||||
})
|
||||
.name;
|
||||
|
||||
function entaxySourceController(workspace, operationsService, $scope) {
|
||||
'ngInject';
|
||||
|
||||
let ctrl = this;
|
||||
|
||||
ctrl.$onInit = function() {
|
||||
|
||||
let mbeanName = workspace.getSelectedMBeanName();
|
||||
|
||||
operationsService
|
||||
.executeOperation(mbeanName, { name: 'doGetRouteConfig' }, [])
|
||||
.then(result => {
|
||||
let info = JSON.parse(result);
|
||||
|
||||
let xml = info.properties.routeContent;
|
||||
if (xml) {
|
||||
ctrl.isContentPresent = true;
|
||||
|
||||
ctrl.objectId = info.objectId;
|
||||
ctrl.factoryId = info.factoryId;
|
||||
ctrl.scope = info.scope;
|
||||
ctrl.systemName = info.properties.systemName;
|
||||
|
||||
$scope.xml = atob(xml);
|
||||
} else {
|
||||
ctrl.isContentPresent = false;
|
||||
}
|
||||
|
||||
}).catch(error => {
|
||||
Core.notification('danger', error, 5000);
|
||||
Entaxy.log.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
ctrl.save = function() {
|
||||
if ($scope.xml.trim().length !== 0) {
|
||||
ctrl.errorMessage = '';
|
||||
|
||||
let factoryFolder = workspace.tree.findDescendant(child => child.title === ctrl.factoryId);
|
||||
let mbeanName = factoryFolder.objectName
|
||||
let properties = { systemName: ctrl.systemName, routeContent: btoa($scope.xml) };
|
||||
let instructions = {"@LIFECYCLE":["general"]};
|
||||
|
||||
operationsService.executeOperation(mbeanName, { name: 'createObjectByInstructions' }, [ ctrl.objectId, ctrl.scope, instructions, properties ] )
|
||||
.then(result => {
|
||||
let tableHtml = Entaxy.createTableFromResponse(result);
|
||||
Entaxy.notification('success', tableHtml, 10000);
|
||||
}).catch(error => {
|
||||
Core.notification('danger', error, 5000);
|
||||
Entaxy.log.error(error);
|
||||
});
|
||||
} else {
|
||||
ctrl.errorMessage = 'Value cannot be empty';
|
||||
}
|
||||
};
|
||||
|
||||
setTimeout(function() {
|
||||
$scope.xmlEditor.options.extraKeys = Entaxy.getExtraKeys();
|
||||
$scope.xmlEditor.options.hintOptions = Entaxy.getHintOptionsForRouteXml();
|
||||
}, 100);
|
||||
}
|
||||
entaxySourceController.$inject = ['workspace', 'operationsService', '$scope'];
|
||||
|
||||
})(Entaxy || (Entaxy = {}));
|
@ -0,0 +1,60 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* entaxy-management-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
var Entaxy;
|
||||
(function (Entaxy) {
|
||||
Entaxy._module
|
||||
.component('entaxyXml', {
|
||||
bindings: {
|
||||
ngModel: '=',
|
||||
mode: '<'
|
||||
},
|
||||
template:
|
||||
`
|
||||
<button class="entaxy-xml-form" ng-click="$ctrl.openEditor()">{{$ctrl.mode}}</button>
|
||||
`,
|
||||
controller: entaxyXmlController
|
||||
})
|
||||
.name;
|
||||
|
||||
function entaxyXmlController(workspace, $uibModal) {
|
||||
'ngInject';
|
||||
|
||||
var ctrl = this;
|
||||
|
||||
ctrl.openEditor = function() {
|
||||
|
||||
$uibModal.open({
|
||||
component: 'xmlModal',
|
||||
resolve: {
|
||||
xml: () => ctrl.ngModel,
|
||||
mode: () => ctrl.mode
|
||||
},
|
||||
size: 'xl',
|
||||
backdrop: 'static',
|
||||
windowTopClass: 'modal-top-margin-override'
|
||||
})
|
||||
.result.then(xml => {
|
||||
ctrl.ngModel = xml;
|
||||
});
|
||||
}
|
||||
}
|
||||
entaxyXmlController.$inject = ['workspace', '$uibModal'];
|
||||
|
||||
})(Entaxy || (Entaxy = {}));
|
@ -0,0 +1,82 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* entaxy-management-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
var Entaxy;
|
||||
(function (Entaxy) {
|
||||
Entaxy._module.component('xmlModal', {
|
||||
bindings: {
|
||||
modalInstance: '<',
|
||||
resolve: '<'
|
||||
},
|
||||
template:
|
||||
`
|
||||
<div class="entaxy-modal-container">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" aria-label="Close" ng-click="$ctrl.cancel()">
|
||||
<span class="pficon pficon-close" aria-hidden="true"></span>
|
||||
</button>
|
||||
<h4 class="modal-title">{{$ctrl.modalTitle}}</h4>
|
||||
</div>
|
||||
<div class="modal-body-without-header">
|
||||
<div class="xml-editor-container">
|
||||
<div hawtio-editor="xml" mode="'xml'" output-editor="xmlEditor"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary" ng-click="$ctrl.save($ctrl.formFields)">{{$ctrl.btnTitle}}</button>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
controller: xmlModalController
|
||||
})
|
||||
.name;
|
||||
|
||||
function xmlModalController(workspace, $uibModal, $scope) {
|
||||
'ngInject';
|
||||
|
||||
let ctrl = this;
|
||||
|
||||
ctrl.$onInit = function() {
|
||||
ctrl.mode = ctrl.resolve.mode;
|
||||
ctrl.modalTitle = ctrl.mode + ' XML';
|
||||
ctrl.btnTitle = Entaxy.getButtonTitleByMode(ctrl.mode);
|
||||
|
||||
$scope.xml = ctrl.resolve.xml;
|
||||
}
|
||||
|
||||
ctrl.cancel = function(reason) {
|
||||
ctrl.modalInstance.dismiss(reason);
|
||||
}
|
||||
|
||||
ctrl.save = function() {
|
||||
ctrl.modalInstance.close($scope.xml);
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
if (ctrl.mode === Entaxy.MODAL_MODES.VIEW) {
|
||||
$scope.xmlEditor.options.readOnly = true;
|
||||
} else {
|
||||
$scope.xmlEditor.options.extraKeys = Entaxy.getExtraKeys();
|
||||
$scope.xmlEditor.options.hintOptions = Entaxy.getHintOptionsForRouteXml();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
xmlModalController.$inject = ['workspace', '$uibModal', '$scope'];
|
||||
|
||||
})(Entaxy || (Entaxy = {}));
|
@ -0,0 +1,301 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* entaxy-management-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
|
||||
var Entaxy;
|
||||
(function (Entaxy) {
|
||||
Entaxy._module.factory('entaxyService', ['$q', 'workspace', 'jolokia', 'jolokiaService', 'operationsService',
|
||||
function($q, workspace, jolokia, jolokiaService, operationsService) {
|
||||
return {
|
||||
makeFormField: function (field, objectId, properties, mode) {
|
||||
return makeFormField(field, objectId, properties, mode);
|
||||
},
|
||||
getArguments: function (fields, factories) {
|
||||
return getArguments(fields, factories);
|
||||
},
|
||||
validateFields: function (fields, selectedFactory, itemType) {
|
||||
return validateFields(fields, selectedFactory, itemType);
|
||||
}
|
||||
};
|
||||
|
||||
function makeFormField(field, objectId, properties, mode) {
|
||||
|
||||
let formField;
|
||||
|
||||
if (mode !== Entaxy.MODAL_MODES.ADD) {
|
||||
|
||||
if (field.name === 'objectId') {
|
||||
field.value = objectId;
|
||||
}
|
||||
|
||||
let suitableProperty = properties.find(property => property.name === field.name);
|
||||
|
||||
if (suitableProperty) {
|
||||
if (field.type.startsWith('entaxy.runtime.')) {
|
||||
field.type = 'string';
|
||||
}
|
||||
|
||||
if (field.defaultValue && field.defaultValue['@RESOURCE'] && field.defaultValue['@RESOURCE'].format === 'base64') {
|
||||
suitableProperty.value = atob(suitableProperty.value);
|
||||
}
|
||||
|
||||
field.value = suitableProperty.value;
|
||||
}
|
||||
|
||||
if (!field.isHidden && field.defaultValue !== undefined && field.value === undefined) {
|
||||
field.displayName = field.displayName ? ('* ' + field.displayName) : ('* ' + field.name);
|
||||
}
|
||||
|
||||
if (field['@FACADE'] && field['@FACADE'].useFacade) {
|
||||
field.type = field['@FACADE'].type;
|
||||
field.value = field['@FACADE'].value;
|
||||
field.defaultValue = undefined;
|
||||
field.immutable = true;
|
||||
}
|
||||
|
||||
formField = {
|
||||
label: field.displayName ? field.displayName : field.name,
|
||||
name: field.name,
|
||||
type: field.type,
|
||||
description: field.description,
|
||||
value: field.value ? field.value : field.defaultValue,
|
||||
isRef: field.isRef,
|
||||
isBackRef: field.isBackRef,
|
||||
isHidden: field.isHidden,
|
||||
group: field.group ? field.group : 'general',
|
||||
tag: field.label,
|
||||
readOnly: mode === Entaxy.MODAL_MODES.VIEW ? true : field.immutable,
|
||||
required: mode === Entaxy.MODAL_MODES.EDIT ? field.required : undefined,
|
||||
typeInfo: mode === Entaxy.MODAL_MODES.EDIT ? field['@TYPEINFO'] : undefined,
|
||||
isFromResource: field.defaultValue && field.defaultValue['@RESOURCE'],
|
||||
defaultValue: field.defaultValue,
|
||||
isInternal: field['@INTERNAL']
|
||||
};
|
||||
} else {
|
||||
|
||||
if (field.defaultValue) {
|
||||
if (JSON.stringify(field.defaultValue).indexOf('@CALCULATED') > -1) {
|
||||
field.isCalculated = true;
|
||||
field.placeholder = 'has calculated default value';
|
||||
} else if (field.defaultValue['@RESOURCE']) {
|
||||
field.isFromResource = true;
|
||||
}
|
||||
}
|
||||
|
||||
formField = {
|
||||
label: field.displayName ? field.displayName : field.name,
|
||||
name: field.name,
|
||||
type: field.type,
|
||||
typeInfo: field['@TYPEINFO'],
|
||||
description: field.description,
|
||||
required: field.required,
|
||||
value: (field.isCalculated || field.isFromResource) ? undefined : field.defaultValue,
|
||||
defaultValue: field.defaultValue,
|
||||
conditional: field.conditional,
|
||||
isRef: field.isRef,
|
||||
isBackRef: field.isBackRef,
|
||||
group: field.group ? field.group : 'general',
|
||||
isHidden: field.isHidden,
|
||||
filter: field.filter ? field.filter.label : undefined,
|
||||
placeholder: field.placeholder,
|
||||
isCalculated: field.isCalculated,
|
||||
isFromResource: field.isFromResource,
|
||||
tag: field.label,
|
||||
uniquenessCheckedProperties: field['@UNIQUE'] ? field['@UNIQUE'].filterProperties : undefined
|
||||
};
|
||||
|
||||
if (formField.isFromResource) {
|
||||
let resourcePromise = getResource(formField.defaultValue['@RESOURCE']);
|
||||
|
||||
if (resourcePromise) {
|
||||
resourcePromise
|
||||
.then((response) => { formField.value = response; })
|
||||
.catch((error) => Entaxy.log.error(error));
|
||||
} else {
|
||||
Core.notification('danger', 'Resource service is not found', 5000);
|
||||
}
|
||||
}
|
||||
|
||||
if (formField.name === '__entaxyContainerId') {
|
||||
let selectedMbean = workspace.getSelectedMBean();
|
||||
|
||||
jolokiaService.getAttribute(selectedMbean.objectName, 'RuntimeType')
|
||||
.then((runtimeType) => {
|
||||
if (runtimeType && runtimeType.startsWith('entaxy.runtime.')) {
|
||||
formField.value = selectedMbean.title;
|
||||
}
|
||||
})
|
||||
.catch((error) => Entaxy.log.error('There is no runtime type'));
|
||||
}
|
||||
}
|
||||
|
||||
return formField;
|
||||
}
|
||||
|
||||
function getResource(resourceInfo) {
|
||||
let resource = workspace.tree.findDescendant(child => {
|
||||
let childObjectName = child.objectName;
|
||||
|
||||
if (childObjectName && childObjectName.endsWith('category=resource')) {
|
||||
return child;
|
||||
}
|
||||
});
|
||||
|
||||
if (resource) {
|
||||
return operationsService.executeOperation(
|
||||
resource.objectName,
|
||||
{ name: 'getResource' },
|
||||
[ resourceInfo.provider + ':' + resourceInfo.location ]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function getArguments(fields, factories) {
|
||||
|
||||
let factoryIdName = fields.shift().value;
|
||||
|
||||
return args = {
|
||||
factoryId: factories.find((factory) => factory.name === factoryIdName),
|
||||
fields: fields.map(field => {
|
||||
if (field.isFromResource && field.defaultValue['@RESOURCE'].format === 'base64') {
|
||||
field.value = btoa(field.value);
|
||||
}
|
||||
|
||||
if (field.isInternal) {
|
||||
field.defaultValue = undefined;
|
||||
field.value = undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
name: field.name,
|
||||
value: (field.defaultValue !== undefined && field.defaultValue === field.value) ? undefined : field.value
|
||||
};
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
function validateFields(fields, selectedFactory, itemType) {
|
||||
let errors = {};
|
||||
|
||||
_.forEach(fields, (field) => {
|
||||
if (field.required && !field.isBackRef && !field.isHidden && !field.isCalculated) {
|
||||
if (field.value === undefined || (typeof field.value === 'string' ? field.value.trim().length === 0 : false)) {
|
||||
errors[field.name] = 'Please fill out this field';
|
||||
}
|
||||
|
||||
if ((field.name === 'objectId' || field.name === 'systemName') && !errors[field.name]) {
|
||||
if (field.value.trim().length < 3) {
|
||||
errors[field.name] = 'Value must contain at least 3 characters';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (field.uniquenessCheckedProperties && !errors[field.name]) {
|
||||
errors[field.name] = checkUniqueness(field.name, field.value, field.uniquenessCheckedProperties, fields, selectedFactory, itemType);
|
||||
}
|
||||
});
|
||||
|
||||
let deferred = $q.defer();
|
||||
|
||||
if (Object.keys(errors).length !== 0) {
|
||||
let errorArrayWithPromises = [];
|
||||
|
||||
Object.keys(errors).forEach(key => {
|
||||
if (typeof errors[key] !== 'string') {
|
||||
errorArrayWithPromises.push({ name: key, promise: errors[key] });
|
||||
}
|
||||
});
|
||||
|
||||
if (errorArrayWithPromises.length !== 0) {
|
||||
|
||||
$q.all(errorArrayWithPromises.map(obj => { return obj.promise; }))
|
||||
.then(result => {
|
||||
for (let i = 0; i < errorArrayWithPromises.length; i++) {
|
||||
if (result[i]) {
|
||||
errors[errorArrayWithPromises[i].name] = result[i];
|
||||
} else {
|
||||
delete errors[errorArrayWithPromises[i].name];
|
||||
}
|
||||
}
|
||||
|
||||
deferred.resolve(errors);
|
||||
});
|
||||
} else {
|
||||
deferred.resolve(errors);
|
||||
}
|
||||
} else {
|
||||
deferred.resolve(errors);
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function checkUniqueness(fieldName, fieldValue, properties, fields, selectedFactory, itemType) {
|
||||
let message = 'Value must be unique';
|
||||
let isInvalid = false;
|
||||
let promises = [];
|
||||
|
||||
properties.unshift(fieldName);
|
||||
properties = properties.map(property => {
|
||||
return Entaxy.capitalize(property);
|
||||
});
|
||||
properties.unshift('RuntimeType');
|
||||
|
||||
let selectedMbean = workspace.getSelectedMBean();
|
||||
|
||||
if (selectedMbean && selectedMbean.isFolder) {
|
||||
let children = Entaxy.getChildrenRecursive(selectedMbean);
|
||||
|
||||
let childrenMbeanNames = children
|
||||
.map(child => { return child.objectName; })
|
||||
.filter(child => child !== null);
|
||||
|
||||
childrenMbeanNames.forEach(mbeanName => {
|
||||
promises.push(jolokiaService.getAttributes(mbeanName, properties)
|
||||
.then((response) => {
|
||||
if (response[properties[0]] === 'entaxy.runtime.' + itemType.toLowerCase()
|
||||
&& fieldValue === response[properties[1]]) {
|
||||
for (let i = 2; i < properties.length; i++) {
|
||||
let checkedField = fields.find(field => field.name === Entaxy.uncapitalize(properties[i]));
|
||||
|
||||
if (checkedField) {
|
||||
if (checkedField.value === response[properties[i]]) {
|
||||
isInvalid = true;
|
||||
}
|
||||
} else {
|
||||
return jolokiaService.getAttribute(selectedFactory.mbeanName, 'TypeInfo')
|
||||
.then((typeInfo) => {
|
||||
let typeInfoDesiredValue = typeInfo[Entaxy.uncapitalize(properties[i])];
|
||||
|
||||
if (typeInfoDesiredValue === response[properties[i]]) {
|
||||
isInvalid = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
return $q.all(promises).then(() => isInvalid ? message : '');
|
||||
}
|
||||
}
|
||||
])
|
||||
})(Entaxy || (Entaxy = {}));
|
@ -0,0 +1,102 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* entaxy-management-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
var Entaxy;
|
||||
(function (Entaxy) {
|
||||
Entaxy._module
|
||||
.run(AddHeaderTools);
|
||||
|
||||
function AddHeaderTools(HawtioExtension, $location, $http, $interval) {
|
||||
'ngInject';
|
||||
|
||||
let baseLocation = getBaseLocation();
|
||||
let path = '/system/health';
|
||||
let format = '?format=json';
|
||||
|
||||
HawtioExtension.add('context-selector', $scope => {
|
||||
let div = document.createElement('div');
|
||||
div.className = 'health-checks-status';
|
||||
div.appendChild(document.createTextNode('Health checks status:'));
|
||||
|
||||
return div;
|
||||
});
|
||||
|
||||
HawtioExtension.add('context-selector', $scope => {
|
||||
|
||||
let ref = document.createElement('a');
|
||||
ref.setAttribute('href', baseLocation + path);
|
||||
ref.setAttribute('target', '_blank');
|
||||
|
||||
let span = document.createElement('span');
|
||||
|
||||
changeSpanClassname();
|
||||
|
||||
ref.appendChild(span);
|
||||
|
||||
let updateStatus;
|
||||
|
||||
$scope.startUpdate = function() {
|
||||
if (angular.isDefined(updateStatus)) return;
|
||||
|
||||
updateStatus = $interval(changeSpanClassname, 15000);
|
||||
}
|
||||
|
||||
$scope.startUpdate();
|
||||
|
||||
$scope.stopUpdate = function() {
|
||||
if (angular.isDefined(updateStatus)) {
|
||||
$interval.cancel(updateStatus);
|
||||
updateStatus = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
$scope.stopUpdate();
|
||||
});
|
||||
|
||||
function changeSpanClassname() {
|
||||
$http.get(baseLocation + path + format).then(
|
||||
(response) => {
|
||||
let status = response.data.overallResult;
|
||||
|
||||
if (status === 'OK') {
|
||||
span.className = 'health-checks pficon pficon-ok';
|
||||
} else if (status === 'WARN') {
|
||||
span.className = 'health-checks pficon pficon-warning-triangle-o';
|
||||
} else {
|
||||
span.className = 'health-checks pficon pficon-error-circle-o';
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
Entaxy.log.error('Unable to get health checks status');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return ref;
|
||||
});
|
||||
|
||||
function getBaseLocation() {
|
||||
let port = $location.port();
|
||||
return $location.protocol() + '://' + $location.host() + (port ? (':' + port) : '');
|
||||
}
|
||||
}
|
||||
AddHeaderTools.$inject = ['HawtioExtension', '$location', '$http', '$interval'];
|
||||
|
||||
})(Entaxy || (Entaxy = {}));
|
@ -0,0 +1,74 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* entaxy-management-plugin
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
var Entaxy;
|
||||
(function (Entaxy) {
|
||||
|
||||
let CodeMirror = window.CodeMirror;
|
||||
|
||||
function completeAfter(cm, pred) {
|
||||
var cur = cm.getCursor();
|
||||
if (!pred || pred()) setTimeout(function() {
|
||||
if (!cm.state.completionActive) {
|
||||
cm.showHint({completeSingle: false});
|
||||
}
|
||||
}, 100);
|
||||
return CodeMirror.Pass;
|
||||
}
|
||||
|
||||
function completeIfAfterLt(cm) {
|
||||
return completeAfter(cm, function() {
|
||||
var cur = cm.getCursor();
|
||||
return cm.getRange(CodeMirror.Pos(cur.line, cur.ch - 1), cur) == "<";
|
||||
});
|
||||
}
|
||||
|
||||
function completeIfInTag(cm) {
|
||||
return completeAfter(cm, function() {
|
||||
var tok = cm.getTokenAt(cm.getCursor());
|
||||
if (tok.type == "string" && (!/['"]/.test(tok.string.charAt(tok.string.length - 1)) || tok.string.length == 1)) {
|
||||
return false;
|
||||
}
|
||||
var inner = CodeMirror.innerMode(cm.getMode(), tok.state).state;
|
||||
return inner.tagName;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
let extraKeys = {
|
||||
"'<'": completeAfter,
|
||||
"' '": completeIfInTag,
|
||||
"'='": completeIfInTag,
|
||||
"':'": completeIfInTag,
|
||||
"Ctrl-Space": "autocomplete"
|
||||
};
|
||||
|
||||
function getHintOptionsForRouteXml() {
|
||||
let tags = Entaxy.getCamelBlueprintTags();
|
||||
let hintOptions = { schemaInfo: tags };
|
||||
return hintOptions;
|
||||
}
|
||||
Entaxy.getHintOptionsForRouteXml = getHintOptionsForRouteXml;
|
||||
|
||||
function getExtraKeys() {
|
||||
return extraKeys;
|
||||
}
|
||||
Entaxy.getExtraKeys = getExtraKeys;
|
||||
|
||||
})(Entaxy || (Entaxy = {}));
|
Reference in New Issue
Block a user