Skip to content

Commit 0534059

Browse files
DovAmirManoMarks
authored andcommitted
add service colors
1 parent ef4604e commit 0534059

File tree

10 files changed

+167
-15
lines changed

10 files changed

+167
-15
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.git
2+
node_modules/caniuse-db/*
3+

.idea/uiDesigner.xml

+124
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
docker swarm init --advertise-addr 127.0.0.1:2377
3+
docker service create rabbitmq:3.6.5
4+
5+
npm run dist && npm start
6+
7+
8+
#docker swarm leave --force
9+

dist/app.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/app.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"keywords": ["Docker","Swarm","D3","Node Visualization"],
2121
"author": "Your name here",
2222
"devDependencies": {
23-
"babel-core": "^5.8.22",
24-
"babel-loader": "^5.3.2",
23+
"babel-core": "^5.8.38",
24+
"babel-loader": "^5.4.2",
2525
"chai": "^3.2.0",
2626
"copyfiles": "^0.2.1",
2727
"css-loader": "^0.16.0",

build_push.sh push.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
12
docker build -t=datarails/datarailsserver:visualizer .
23
docker push datarails/datarailsserver:visualizer
4+
docker swarm leave --force
35

4-
5-
# npm run dist && npm start

src/data-provider.js

+20-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ function nodeOrContainerExists(arr, value) {
3232
return false;
3333
}
3434

35+
var stringToColour = function(str) {
36+
37+
// str to hash
38+
for (var i = 0, hash = 0; i < str.length; hash = str.charCodeAt(i++) + ((hash << 5) - hash));
39+
40+
// int/hash to hex
41+
for (var i = 0, colour = "#"; i < 3; colour += ("00" + ((hash >> i++ * 8) & 0xFF).toString(16)).slice(-2));
42+
43+
return colour;
44+
}
3545

3646
function physicalStructProvider([initialNodes,initialContainers]){
3747
let containers = _.map(initialContainers, _.cloneDeep);
@@ -45,10 +55,14 @@ function physicalStructProvider([initialNodes,initialContainers]){
4555
_.find(root,(cluster) => {
4656
var node = _.find(cluster.children,{ ID:NodeID });
4757
if(!node) return;
48-
var dt=new Date(cloned.UpdatedAt)
49-
let imageTag = cloned.Spec.ContainerSpec.Image + " <br/> " + (cloned.Spec.ContainerSpec.Args?cloned.Spec.ContainerSpec.Args:"" ) +
50-
" <br/> updated : "+dt.getDate()+"/"+(dt.getMonth()+1)+" "+ dt.getHours()+":"+dt.getMinutes()+"<br/> ID : "+cloned.Status.ContainerStatus.ContainerID+
51-
"<br/> ip : ";
58+
var dt=new Date(cloned.UpdatedAt);
59+
var color= stringToColour(cloned.ServiceID);
60+
let imageTag ="<span style='color:" + color+"; font-weight: bold;font-size: 12px'>"+ cloned.Spec.ContainerSpec.Image.split(':')[0] +"</span>"+
61+
"<br/> tag : "+cloned.Spec.ContainerSpec.Image.split(':')[1]+
62+
"<br/>" + (cloned.Spec.ContainerSpec.Args?" cmd : "+cloned.Spec.ContainerSpec.Args:"" ) +
63+
"<br/> updated : "+dt.getDate()+"/"+(dt.getMonth()+1)+" "+ dt.getHours()+":"+dt.getMinutes()+
64+
"<br/> ID : "+cloned.Status.ContainerStatus.ContainerID+
65+
"<br/>";
5266
cloned.tag = imageTag;
5367
node.children.push(cloned);
5468
return true;
@@ -121,7 +135,8 @@ function physicalStructProvider([initialNodes,initialContainers]){
121135
name = node.Description.Hostname;
122136
if(name.length>0) {
123137
currentnode.Description.Hostname = name ;
124-
currentnode.name = name+" <br/> "+ object.Spec.Role+" <br/>mem : "+(object.Description.Resources.MemoryBytes/100000000).toFixed(0)+"G";
138+
currentnode.name = name+" <br/> "+ object.Spec.Role+
139+
" <br/>"+(object.Description.Resources.MemoryBytes/100000000).toFixed(0)+"G free";
125140
}
126141
updateNode(currentnode, node.state);
127142
}

src/utils/request.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ function filterStoppedNodes (objects) {
4444
object.state = "down"
4545
}
4646
object.name = object.Description.Hostname;
47-
object.name= object.name+" <br/>"+object.Spec.Role+" <br/>"+"mem : "+(object.Description.Resources.MemoryBytes/1000000000).toFixed(0)+"G";
47+
object.name= object.name+" <br/>"+object.Spec.Role+
48+
" <br/>"+(object.Description.Resources.MemoryBytes/1000000000).toFixed(0)+"G free";
4849
readyNodes.push(object);
4950
}
5051
readyNodes.sort(function (a, b) {

src/vis-physical/styles.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
}
7979

8080
.node-meta{
81-
line-height: 2;
81+
//line-height: 0;
8282
font-size: 20pt;
8383
text-align: center;
8484
text-indent: -3px;

0 commit comments

Comments
 (0)