Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wolass
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NOC
wolass
Commits
aeb74f89
Commit
aeb74f89
authored
2 years ago
by
Simon Ruderich
Browse files
Options
Downloads
Patches
Plain Diff
Add group to host to permit grouping hosts together
parent
f692867a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
data.go
+1
-0
1 addition, 0 deletions
data.go
static/wol.html
+7
-2
7 additions, 2 deletions
static/wol.html
static/wol.js
+25
-2
25 additions, 2 deletions
static/wol.js
with
33 additions
and
4 deletions
data.go
+
1
−
0
View file @
aeb74f89
...
...
@@ -35,6 +35,7 @@ type Host struct {
Network
string
`json:"network"`
// in CIDR notation
Name
string
`json:"name"`
MAC
string
`json:"mac"`
Group
string
`json:"group"`
}
func
LoadData
(
path
string
)
(
*
Data
,
error
)
{
...
...
This diff is collapsed.
Click to expand it.
static/wol.html
+
7
−
2
View file @
aeb74f89
...
...
@@ -17,9 +17,9 @@
<div
id=
"data"
hidden
>
<h2>
Hosts
<small>
(click to wake)
</small></h2>
<
ul
id=
"hosts"
>
<
div
id=
"hosts"
>
<!-- Filled via JavaScript -->
</
ul
>
</
div
>
<h2>
Add host
</h2>
...
...
@@ -37,6 +37,11 @@
<label
for=
"add-mac"
>
MAC:
</label>
<input
type=
"text"
id=
"add-mac"
>
</p>
<p>
<label
for=
"add-group"
>
Group:
</label>
<input
type=
"text"
id=
"add-group"
>
(optional, all hosts with the same group are grouped together)
</p>
<p>
<input
type=
"submit"
id=
"add-submit"
value=
"Add"
>
</p>
...
...
This diff is collapsed.
Click to expand it.
static/wol.js
+
25
−
2
View file @
aeb74f89
...
...
@@ -48,9 +48,28 @@ async function load() {
document
.
querySelector
(
'
#warning
'
).
hidden
=
!
noNetworks
;
document
.
querySelector
(
'
#data
'
).
hidden
=
noNetworks
;
// Group hosts with the same group together
const
groups
=
new
Map
();
for
(
const
x
of
json
.
hosts
)
{
if
(
!
groups
.
has
(
x
.
group
))
{
groups
.
set
(
x
.
group
,
[]);
}
groups
.
get
(
x
.
group
).
push
(
x
);
}
const
hosts
=
document
.
querySelector
(
'
#hosts
'
);
hosts
.
innerHTML
=
''
;
// delete all children
for
(
const
x
of
json
.
hosts
)
{
for
(
const
group
of
[...
groups
.
keys
()].
sort
())
{
// Group name
if
(
group
!==
''
)
{
const
h
=
document
.
createElement
(
'
h3
'
);
h
.
textContent
=
group
;
hosts
.
appendChild
(
h
);
}
const
ul
=
document
.
createElement
(
'
ul
'
);
hosts
.
appendChild
(
ul
);
for
(
const
x
of
groups
.
get
(
group
))
{
const
indicator
=
document
.
createElement
(
'
strong
'
);
const
wake
=
document
.
createElement
(
'
a
'
);
...
...
@@ -79,7 +98,8 @@ async function load() {
li
.
appendChild
(
document
.
createTextNode
(
'
)
'
));
li
.
appendChild
(
delSmall
);
hosts
.
appendChild
(
li
);
ul
.
appendChild
(
li
);
}
}
}
...
...
@@ -91,12 +111,14 @@ async function hostAdd(evt) {
const
network
=
document
.
querySelector
(
'
#add-network
'
).
value
;
const
name
=
document
.
querySelector
(
'
#add-name
'
).
value
;
const
mac
=
document
.
querySelector
(
'
#add-mac
'
).
value
.
trim
();
const
group
=
document
.
querySelector
(
'
#add-group
'
).
value
.
trim
();
const
data
=
{
host
:
{
network
:
network
,
name
:
name
,
mac
:
mac
,
group
:
group
,
},
};
const
resp
=
await
fetch
(
'
api/add
'
,
{
...
...
@@ -121,6 +143,7 @@ async function hostAdd(evt) {
// Don't reset "network" to not confuse the user
document
.
querySelector
(
'
#add-name
'
).
value
=
''
;
document
.
querySelector
(
'
#add-mac
'
).
value
=
''
;
document
.
querySelector
(
'
#add-group
'
).
value
=
''
;
// Simplest way to fetch latest version
load
();
...
...
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