mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Remove import statements from web worker file.
This commit is contained in:
parent
8bf9dd038e
commit
e4f0153a7d
34
awx/ui/src/util/simulationWorker.js
Normal file
34
awx/ui/src/util/simulationWorker.js
Normal file
@ -0,0 +1,34 @@
|
||||
/* eslint-disable no-undef */
|
||||
importScripts('https://d3js.org/d3-collection.v1.min.js');
|
||||
importScripts('https://d3js.org/d3-dispatch.v1.min.js');
|
||||
importScripts('https://d3js.org/d3-quadtree.v1.min.js');
|
||||
importScripts('https://d3js.org/d3-timer.v1.min.js');
|
||||
importScripts('https://d3js.org/d3-force.v1.min.js');
|
||||
|
||||
onmessage = function calculateLayout({ data: { nodes, links } }) {
|
||||
const simulation = d3
|
||||
.forceSimulation(nodes)
|
||||
.force('charge', d3.forceManyBody(15).strength(-50))
|
||||
.force(
|
||||
'link',
|
||||
d3.forceLink(links).id((d) => d.hostname)
|
||||
)
|
||||
.force('collide', d3.forceCollide(62))
|
||||
.force('forceX', d3.forceX(0))
|
||||
.force('forceY', d3.forceY(0))
|
||||
.stop();
|
||||
|
||||
for (
|
||||
let i = 0,
|
||||
n = Math.ceil(
|
||||
Math.log(simulation.alphaMin()) / Math.log(1 - simulation.alphaDecay())
|
||||
);
|
||||
i < n;
|
||||
++i
|
||||
) {
|
||||
postMessage({ type: 'tick', progress: i / n });
|
||||
simulation.tick();
|
||||
}
|
||||
|
||||
postMessage({ type: 'end', nodes, links });
|
||||
};
|
||||
@ -1,8 +1,3 @@
|
||||
export default function webWorker() {
|
||||
return new Worker(
|
||||
new URL(
|
||||
'screens/TopologyView/utils/workers/simulationWorker.js',
|
||||
import.meta.url
|
||||
)
|
||||
);
|
||||
return new Worker(new URL('./simulationWorker.js', import.meta.url));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user