Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csentry
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Harrisson
csentry
Commits
fd380108
Commit
fd380108
authored
6 years ago
by
Benjamin Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Set the IOC tag by default based on device type
JIRA INFRA-302
parent
f3dcad2b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/static/js/hosts.js
+13
-2
13 additions, 2 deletions
app/static/js/hosts.js
with
13 additions
and
2 deletions
app/static/js/hosts.js
+
13
−
2
View file @
fd380108
...
@@ -12,7 +12,17 @@ $(document).ready(function() {
...
@@ -12,7 +12,17 @@ $(document).ready(function() {
);
);
}
}
// Select the IOC tag by default depending on the device type
function
update_default_tags
(
device_type
)
{
var
ioc_device_types
=
[
"
PhysicalMachine
"
,
"
VirtualMachine
"
,
"
MicroTCA
"
,
"
VME
"
];
var
is_ioc_selected
=
$
.
inArray
(
device_type
,
ioc_device_types
)
>
-
1
;
$
(
"
#tags option
"
).
filter
(
function
()
{
return
this
.
text
==
"
IOC
"
;
}).
prop
(
"
selected
"
,
is_ioc_selected
).
change
();
}
// And check / uncheck random_mac checkbox
// And check / uncheck random_mac checkbox
// and update default tags
function
update_device_type_attributes
()
{
function
update_device_type_attributes
()
{
var
device_type
=
$
(
"
#device_type_id option:selected
"
).
text
();
var
device_type
=
$
(
"
#device_type_id option:selected
"
).
text
();
if
(
device_type
.
startsWith
(
"
Virtual
"
)
)
{
if
(
device_type
.
startsWith
(
"
Virtual
"
)
)
{
...
@@ -20,6 +30,7 @@ $(document).ready(function() {
...
@@ -20,6 +30,7 @@ $(document).ready(function() {
}
else
{
}
else
{
$
(
"
#random_mac
"
).
prop
(
"
checked
"
,
false
).
change
();
$
(
"
#random_mac
"
).
prop
(
"
checked
"
,
false
).
change
();
}
}
update_default_tags
(
device_type
);
}
}
// If random_mac is checked, generate a random address
// If random_mac is checked, generate a random address
...
@@ -55,8 +66,8 @@ $(document).ready(function() {
...
@@ -55,8 +66,8 @@ $(document).ready(function() {
set_default_ip
();
set_default_ip
();
});
});
// On register
and edit
host first page load
// On register host first page load
if
(
$
(
"
#hostForm
"
).
length
||
$
(
"
#editHostForm
"
).
length
)
{
if
(
$
(
"
#hostForm
"
).
length
)
{
update_device_type_attributes
();
update_device_type_attributes
();
}
}
...
...
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