-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathScene.vue
134 lines (128 loc) · 2.8 KB
/
Scene.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<template lang='pug'>
a-scene
a-sky(
color='midnightblue'
)
a-plane(
position='0 0 -4'
rotation='-90 0 0'
color='grey'
width=10
height=10
)
a-entity(
v-for='(node, index) in nodes'
:position='(index+0.5-nodes.length/2)*2 + " .1 -4"'
rotation='0 -33 0'
)
a-plane(
rotation='-90 0 0'
)
a-text(
:value='node.Description.Hostname'
position='-0.5 0 0'
rotation='-90 0 0'
color='black'
side='double'
)
a-entity(
v-for='(task, index) in tasks.filter(t => t.DesiredState !== "shutdown" && t.NodeID === node.ID)'
:position='"0 " + (index*1.5 + 1) + " 0"'
)
a-box(
color='indigo'
)
a-text(
:value='services.find( s => s.ID === task.ServiceID ).Spec.Name'
position='-.7 0 .5'
color='yellow'
side='double'
)
</template>
<script>
import aframe from 'aframe'
export default {
data: () => ({
nodes: [],
services: [],
tasks: [],
nodeFetcher: null,
serviceFetcher: null,
taskFetcher: null,
}),
computed: {
vrNodes () {
return nodes.map( node => ({}))
}
},
methods: {
getNodes() {
return fetch( 'docker/nodes' )
.then( response => response.json() )
.then( nodes =>
this.nodes = nodes.sort(
(a,b) => a.Description.Hostname < b.Description.Hostname
)
)
},
getServices() {
return fetch( 'docker/services' )
.then( response => response.json() )
.then( services =>
this.services = services.sort(
(a,b) => a.Spec.Name < b.Spec.Name
)
)
},
getTasks() {
return fetch( 'docker/tasks' )
.then( response => response.json() )
.then( tasks =>
this.tasks = tasks.sort(
(a,b) => a.ServiceID < b.ServiceID
)
)
},
},
created () {
this.getNodes()
this.getServices()
this.getTasks()
this.nodeFetcher = setInterval(
this.getNodes, 1000
)
this.serviceFetcher = setInterval(
this.getServices, 1000
)
this.taskFetcher = setInterval(
this.getTasks, 1000
)
},
destroy () {
clearInterval( this.nodeFetcher )
clearInterval( this.serviceFetcher )
clearInterval( this.taskFetcher )
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
a-scene {
height: 56px;
width: 80px;
}
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>