web app, get emane models for sessions joined and default emane nodes to the first model
This commit is contained in:
parent
8889d121c0
commit
ddfa0ddfa4
2 changed files with 20 additions and 17 deletions
|
@ -177,6 +177,7 @@ class CoreNetwork {
|
||||||
this.nodes = new vis.DataSet();
|
this.nodes = new vis.DataSet();
|
||||||
this.edges = new vis.DataSet();
|
this.edges = new vis.DataSet();
|
||||||
this.links = {};
|
this.links = {};
|
||||||
|
this.emaneModels = [];
|
||||||
this.networkData = {
|
this.networkData = {
|
||||||
nodes: this.nodes,
|
nodes: this.nodes,
|
||||||
edges: this.edges
|
edges: this.edges
|
||||||
|
@ -216,6 +217,7 @@ class CoreNetwork {
|
||||||
const session = await this.coreRest.createSession();
|
const session = await this.coreRest.createSession();
|
||||||
this.coreRest.currentSession = session.id;
|
this.coreRest.currentSession = session.id;
|
||||||
this.reset();
|
this.reset();
|
||||||
|
this.setEmaneModels();
|
||||||
toastr.success(`Created ${session.id}`, 'Session');
|
toastr.success(`Created ${session.id}`, 'Session');
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
@ -299,16 +301,21 @@ class CoreNetwork {
|
||||||
return this.nodeId;
|
return this.nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setEmaneModels() {
|
||||||
|
const response = await this.coreRest.getEmaneModels();
|
||||||
|
console.log('emane models: ', response);
|
||||||
|
this.emaneModels = response.models;
|
||||||
|
}
|
||||||
|
|
||||||
async joinSession(sessionId) {
|
async joinSession(sessionId) {
|
||||||
this.reset();
|
this.reset();
|
||||||
this.coreRest.currentSession = sessionId;
|
this.coreRest.currentSession = sessionId;
|
||||||
const session = await coreRest.getSession();
|
const session = await this.coreRest.getSession();
|
||||||
console.log('session info: ', session);
|
console.log('session info: ', session);
|
||||||
|
await this.setEmaneModels();
|
||||||
|
|
||||||
const nodes = session.nodes;
|
const nodes = session.nodes;
|
||||||
|
|
||||||
const self = this;
|
|
||||||
const nodeIds = [0];
|
const nodeIds = [0];
|
||||||
|
|
||||||
for (let node of nodes) {
|
for (let node of nodes) {
|
||||||
if (CoreNodeHelper.isSkipNode(node)) {
|
if (CoreNodeHelper.isSkipNode(node)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -323,16 +330,11 @@ class CoreNetwork {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.coreRest.getLinks(node.id)
|
const response = await this.coreRest.getLinks(node.id);
|
||||||
.then(function (response) {
|
console.log('link response: ', response);
|
||||||
console.log('link response: ', response);
|
for (let linkData of response.links) {
|
||||||
for (let linkData of response.links) {
|
this.createEdgeFromLink(linkData);
|
||||||
self.createEdgeFromLink(linkData);
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(function (err) {
|
|
||||||
console.log('get link error: ', err);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodes.length) {
|
if (nodes.length) {
|
||||||
|
@ -441,6 +443,9 @@ class CoreNetwork {
|
||||||
const name = `${nodeDisplay.name}${nodeId}`;
|
const name = `${nodeDisplay.name}${nodeId}`;
|
||||||
const coreNode = new CoreNode(nodeId, this.nodeType, name, x, y);
|
const coreNode = new CoreNode(nodeId, this.nodeType, name, x, y);
|
||||||
coreNode.model = this.nodeModel;
|
coreNode.model = this.nodeModel;
|
||||||
|
if (coreNode.type === CoreNodeHelper.emaneNode && this.emaneModels.length) {
|
||||||
|
coreNode.emane = this.emaneModels[0];
|
||||||
|
}
|
||||||
this.nodes.add(coreNode.getNetworkNode());
|
this.nodes.add(coreNode.getNetworkNode());
|
||||||
console.log('added node: ', coreNode.getNetworkNode());
|
console.log('added node: ', coreNode.getNetworkNode());
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,10 +273,8 @@ class NodeEditModal {
|
||||||
|
|
||||||
this.$formCustom.html('');
|
this.$formCustom.html('');
|
||||||
if (node.type === CoreNodeHelper.emaneNode) {
|
if (node.type === CoreNodeHelper.emaneNode) {
|
||||||
const response = await this.coreRest.getEmaneModels();
|
|
||||||
this.$formCustom.append($('<label>', {class: 'form-label', text: 'EMANE Model'}));
|
this.$formCustom.append($('<label>', {class: 'form-label', text: 'EMANE Model'}));
|
||||||
console.log('emane models: ', response);
|
for (let model of this.coreNetwork.emaneModels) {
|
||||||
for (let model of response.models) {
|
|
||||||
const checked = node.emane === model;
|
const checked = node.emane === model;
|
||||||
const label = model.split('_')[1];
|
const label = model.split('_')[1];
|
||||||
const $radio = createRadio('emane', model, label, checked);
|
const $radio = createRadio('emane', model, label, checked);
|
||||||
|
|
Loading…
Reference in a new issue