Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Power Distribution
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KSZK
Sysadmin
Power Distribution
Commits
176c00eb
Commit
176c00eb
authored
Sep 3, 2021
by
Tóth Miklós Tibor
Browse files
Options
Downloads
Patches
Plain Diff
color by location
parent
172d4096
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
web/locationToColor.go
+23
-0
23 additions, 0 deletions
web/locationToColor.go
web/visjs.go
+1
-1
1 addition, 1 deletion
web/visjs.go
with
24 additions
and
1 deletion
web/locationToColor.go
0 → 100644
+
23
−
0
View file @
176c00eb
package
web
import
(
"crypto/md5"
"fmt"
"git.sch.bme.hu/mikewashere/power-distribution/models"
)
func
hashStringToColor
(
s
string
)
string
{
data
:=
md5
.
Sum
([]
byte
(
s
))
col
:=
"#"
for
i
:=
0
;
i
<
3
;
i
++
{
col
+=
fmt
.
Sprintf
(
"%02X"
,
data
[
i
])
}
return
col
}
func
LocationColor
(
l
*
models
.
Location
)
string
{
return
hashStringToColor
(
l
.
String
())
}
This diff is collapsed.
Click to expand it.
web/visjs.go
+
1
−
1
View file @
176c00eb
...
@@ -43,7 +43,7 @@ func visJSFromGraph(roots []*models.GraphNode) *visJS {
...
@@ -43,7 +43,7 @@ func visJSFromGraph(roots []*models.GraphNode) *visJS {
i
:=
0
i
:=
0
for
d
:=
range
devicesMap
{
for
d
:=
range
devicesMap
{
shape
:=
"diamond"
shape
:=
"diamond"
color
:=
"#97C2FC"
color
:=
LocationColor
(
d
.
Location
)
fmt
.
Println
(
d
.
Type
)
fmt
.
Println
(
d
.
Type
)
switch
d
.
Type
.
Get
()
{
switch
d
.
Type
.
Get
()
{
case
d
.
Type
.
Ups
:
case
d
.
Type
.
Ups
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment