simple abm info
This commit is contained in:
parent
38f323fd2d
commit
0144f0afe4
@ -26,6 +26,7 @@
|
||||
<script src="js/components/node-preview-normal.js"></script>
|
||||
<script src="js/components/node-preview-inventoryimage.js"></script>
|
||||
<script src="js/components/node-info.js"></script>
|
||||
<script src="js/components/abm-info.js"></script>
|
||||
|
||||
<!-- Utilities -->
|
||||
<script src="js/util/imageresolver.js"></script>
|
||||
|
28
app/js/components/abm-info.js
Normal file
28
app/js/components/abm-info.js
Normal file
@ -0,0 +1,28 @@
|
||||
Vue.component("abm-info", {
|
||||
props: ["abm_key"],
|
||||
created: function(){
|
||||
this.abm = mtinfo.abm_labels[this.abm_key];
|
||||
|
||||
//TODO: debug
|
||||
console.log(this.abm, this.abm_key);
|
||||
},
|
||||
template: /*html*/`
|
||||
<div>
|
||||
<h4>{{ abm_key }}</h4>
|
||||
<p>Chance: {{ abm.chance }}</p>
|
||||
<p>Interval: {{ abm.interval }}</p>
|
||||
<p>Nodenames</p>
|
||||
<ul>
|
||||
<li v-for="nodename in abm.nodenames">
|
||||
{{ nodename }}
|
||||
</li>
|
||||
</ul>
|
||||
<p>Neighbors</p>
|
||||
<ul>
|
||||
<li v-for="neighbor in abm.neighbors">
|
||||
{{ neighbor }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
`
|
||||
});
|
@ -10,8 +10,8 @@ Vue.component("nav-bar", {
|
||||
</router-link>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<router-link to="/nodes/default:chest" class="nav-link">
|
||||
<i class="fa fa-question"></i> Test
|
||||
<router-link to="/nodes" class="nav-link">
|
||||
<i class="fa fa-question"></i> Nodes
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -1,6 +1,35 @@
|
||||
|
||||
Vue.component("node-detail", {
|
||||
props: ["node"],
|
||||
created: function(){
|
||||
let abms = [];
|
||||
let abm_neighbors = [];
|
||||
|
||||
if (mtinfo.abm_nodenames[this.name]){
|
||||
abms.push(mtinfo.abm_nodenames[this.name]);
|
||||
}
|
||||
if (mtinfo.abm_neighbors[this.name]){
|
||||
abm_neighbors.push(mtinfo.abm_neighbors[this.name]);
|
||||
}
|
||||
if (this.node.groups){
|
||||
Object.keys(this.node.groups).forEach(function(group){
|
||||
const name = "group:" + group;
|
||||
if (mtinfo.abm_nodenames[name]){
|
||||
abms.push(mtinfo.abm_nodenames[name]);
|
||||
}
|
||||
if (mtinfo.abm_neighbors[name]){
|
||||
abm_neighbors.push(mtinfo.abm_neighbors[name]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.abms = abms;
|
||||
this.abm_neighbors = abm_neighbors;
|
||||
|
||||
//TODO: debug
|
||||
console.log("abms", this.abms);
|
||||
console.log("abm_neighbors", this.abm_neighbors);
|
||||
},
|
||||
template: /*html*/`
|
||||
<div>
|
||||
<h3>{{ node.description }} <small class="text-muted">{{ node.name }}</small></h3>
|
||||
@ -18,6 +47,22 @@ Vue.component("node-detail", {
|
||||
{{ group }} {{ node.groups[group] }}
|
||||
</li>
|
||||
</ul>
|
||||
<p>ABMS</p>
|
||||
<ul>
|
||||
<li v-for="abm in abms">
|
||||
<router-link :to="'/abms/' + abm.key">
|
||||
{{ abm.key }}
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
<p>Neighbor ABMS</p>
|
||||
<ul>
|
||||
<li v-for="abm in abm_neighbors">
|
||||
<router-link :to="'/abms/' + abm.key">
|
||||
{{ abm.key }}
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
`
|
||||
});
|
||||
|
@ -2,28 +2,10 @@
|
||||
Vue.component("node-info", {
|
||||
props: ["name"],
|
||||
created: function(){
|
||||
//TODO: debug
|
||||
const nodename = this.name;
|
||||
const nodedef = mtinfo.nodes[this.name];
|
||||
console.log(nodedef);
|
||||
|
||||
if (mtinfo.abm_nodenames[this.name]){
|
||||
console.log("abm nodename", mtinfo.abm_nodenames[this.name]);
|
||||
}
|
||||
if (mtinfo.abm_neighbors[this.name]){
|
||||
console.log("abm neighbor", mtinfo.abm_neighbors[this.name]);
|
||||
}
|
||||
if (nodedef.groups){
|
||||
Object.keys(nodedef.groups).forEach(function(group){
|
||||
const name = "group:" + group;
|
||||
if (mtinfo.abm_nodenames[name]){
|
||||
console.log("abm group nodename", mtinfo.abm_nodenames[name]);
|
||||
}
|
||||
if (mtinfo.abm_neighbors[name]){
|
||||
console.log("abm group neighbor", mtinfo.abm_neighbors[name]);
|
||||
}
|
||||
});
|
||||
}
|
||||
//TODO: debug
|
||||
console.log(nodedef);
|
||||
},
|
||||
computed: {
|
||||
previewImage: function(){
|
||||
|
@ -9,6 +9,9 @@ const router = new VueRouter({
|
||||
},{
|
||||
path: "/nodes/:name",
|
||||
component: { template: `<node-info v-bind:name="$route.params.name"/>` }
|
||||
},{
|
||||
path: "/abms/:abm_key",
|
||||
component: { template: `<abm-info v-bind:abm_key="$route.params.abm_key"/>` }
|
||||
}]
|
||||
});
|
||||
|
||||
|
@ -8,6 +8,20 @@ mtinfo.abm_neighbors[nodename_or_group] = abm
|
||||
|
||||
mtinfo.abm_nodenames = {};
|
||||
mtinfo.abm_neighbors = {};
|
||||
mtinfo.abm_labels = {};
|
||||
|
||||
function register_abm_label(abm, index){
|
||||
const key = (abm.label || "abm") + (index ? ("_" + index) : "");
|
||||
if (!mtinfo.abm_labels[key]){
|
||||
// create
|
||||
mtinfo.abm_labels[key] = abm;
|
||||
abm.key = key;
|
||||
|
||||
} else {
|
||||
// try another index
|
||||
register_abm_label(abm, index || 1);
|
||||
}
|
||||
}
|
||||
|
||||
mtinfo.abm.forEach(function(abm){
|
||||
abm.nodenames.forEach(function(nodename){
|
||||
@ -22,4 +36,6 @@ mtinfo.abm.forEach(function(abm){
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
register_abm_label(abm);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user