Project

General

Profile

« Previous | Next » 

Revision 361f3d61

Added by Ondřej Ezr about 3 years ago

Refs #30288 - improves CPUs counter input

In 22fa163731b38f597e4f96e0c0b345518a360b37 we've introduced React
component to implement the counter funcionality.
This uses the old `counter_f` form helper to render the React component
and effectivelly remove our dependency on the ui.spinner library.

View differences:

webpack/assets/javascripts/compute_resource/ovirt.js
}
function setMemoryInputProps(props) {
const memoryInputElement = document
.getElementById('memory-input')
.getElementsByTagName('foreman-react-component')[0];
const memoryInputElement = getComponentByWrapperId('memory-input');
memoryInputElement.reactProps = {
...memoryInputElement.reactProps,
...props,
......
}
function updateCoresAndSockets(result) {
const coresInputElement = document
.getElementById('cores-input')
.getElementsByTagName('foreman-react-component')[0];
coresInputElement.setAttribute(
'data-props',
JSON.stringify({
...coresInputElement.reactProps,
defaultValue: result.cores,
})
);
const socketInputElement = document
.getElementById('sockets-input')
.getElementsByTagName('foreman-react-component')[0];
socketInputElement.setAttribute(
'data-props',
JSON.stringify({
...socketInputElement.reactProps,
defaultValue: result.sockets,
})
);
const coresInputElement = getComponentByWrapperId('cores-input');
coresInputElement.reactProps = {
...coresInputElement.reactProps,
value: result.cores,
};
const socketInputElement = getComponentByWrapperId('sockets-input');
socketInputElement.reactProps = {
...socketInputElement.reactProps,
value: result.sockets,
};
}
function disableCoresAndSockets(result) {
const coresInputElement = document
.getElementById('cores-input')
.getElementsByTagName('foreman-react-component')[0];
coresInputElement.setAttribute(
'data-props',
JSON.stringify({
...coresInputElement.reactProps,
disabled: result.name != null,
})
);
const socketInputElement = document
.getElementById('sockets-input')
const coresInputElement = getComponentByWrapperId('cores-input');
coresInputElement.reactProps = {
...coresInputElement.reactProps,
disabled: result.name != null,
};
const socketInputElement = getComponentByWrapperId('sockets-input');
socketInputElement.reactProps = {
...socketInputElement.reactProps,
disabled: result.name != null,
};
}
function getComponentByWrapperId(wrapperId) {
return document
.getElementById(wrapperId)
.getElementsByTagName('foreman-react-component')[0];
socketInputElement.setAttribute(
'data-props',
JSON.stringify({
...socketInputElement.reactProps,
disabled: result.name != null,
})
);
}
function disableElement(element) {

Also available in: Unified diff