-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chores] Improve management ip field
- Loading branch information
Showing
9 changed files
with
85 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
openwisp_controller/config/migrations/0037_alter_management_ip_help_text.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 3.1.13 on 2021-08-11 16:12 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('config', '0036_device_group'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='device', | ||
name='management_ip', | ||
field=models.GenericIPAddressField( | ||
blank=True, | ||
db_index=True, | ||
help_text='IP address used by OpenWISP to reach the device when ' | ||
'performing any type of push operation or active check. The ' | ||
'value of this field is generally sent by the device and hence ' | ||
'does not need to be changed, but can be changed or cleared ' | ||
'manually if needed.', | ||
null=True, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
django.jQuery(function ($) { | ||
if ($(".add-form").length || !$("#device_form").length) { | ||
return; | ||
} | ||
|
||
// replaces the management ip field with text with the option to edit it | ||
var ip_input = $(".field-management_ip > div > input"); | ||
var initial_ip = ip_input.prop("value"); | ||
ip_input.after(function () { | ||
ip_input.hide(); | ||
return ( | ||
'<span class="readonly" id="management_ip_text">' + | ||
(initial_ip === "" ? "-n/a-" : initial_ip) + | ||
"</span>" | ||
); | ||
}); | ||
$("#management_ip_text").after( | ||
'<a id="edit_management_ip"> <img src="/static/admin/img/icon-changelink.svg" alt="Edit"></a>' | ||
); | ||
$("#edit_management_ip").click(function () { | ||
var ip_text = $("#management_ip_text"); | ||
var img_element = $("#edit_management_ip > img"); | ||
if (img_element.attr("alt") === "Edit") { | ||
ip_input.show(); | ||
ip_text.hide(); | ||
img_element.attr("src", "/static/admin/img/icon-deletelink.svg"); | ||
img_element.attr("alt", "Cancel"); | ||
} else { | ||
ip_text.show(); | ||
ip_input.hide(); | ||
ip_input.val(initial_ip); | ||
img_element.attr("src", "/static/admin/img/icon-changelink.svg"); | ||
img_element.attr("alt", "Edit"); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters