mirror of
https://github.com/itflow-org/itflow
synced 2026-03-01 03:14:52 +00:00
Cleaned up the new JS edit Modal sperating Javascript vars with camelCase and php var with seperate_words
This commit is contained in:
@@ -2,13 +2,13 @@
|
|||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content bg-dark">
|
<div class="modal-content bg-dark">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title"><i class="fa fa-fw fa-network-wired"></i><span id="edit_network_name_header"></span></h5>
|
<h5 class="modal-title"><i class="fa fa-fw fa-network-wired"></i><span id="editNetworkHeader"></span></h5>
|
||||||
<button type="button" class="close text-white" data-dismiss="modal">
|
<button type="button" class="close text-white" data-dismiss="modal">
|
||||||
<span>×</span>
|
<span>×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<form action="post.php" method="post" autocomplete="off">
|
<form action="post.php" method="post" autocomplete="off">
|
||||||
<input type="hidden" name="network_id" id="edit_network_id" value="">
|
<input type="hidden" name="network_id" id="editNetworkId" value="">
|
||||||
<div class="modal-body bg-white">
|
<div class="modal-body bg-white">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-ethernet"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-ethernet"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-control" id="edit_network_name" name="name" placeholder="Network name (VLAN, WAN, LAN2 etc)" required>
|
<input type="text" class="form-control" id="editNetworkName" name="name" placeholder="Network name (VLAN, WAN, LAN2 etc)" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<input type="number" class="form-control" id="edit_network_vlan" name="vlan" placeholder="ex. 20" data-inputmask="'mask': '9999'">
|
<input type="number" class="form-control" id="editNetworkVlan" name="vlan" placeholder="ex. 20" data-inputmask="'mask': '9999'">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-network-wired"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-network-wired"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-control" id="edit_network_cidr" name="network" placeholder="Network ex 192.168.1.0/24" required>
|
<input type="text" class="form-control" id="editNetworkCidr" name="network" placeholder="Network ex 192.168.1.0/24" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-route"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-route"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-control" id="edit_network_gw" name="gateway" placeholder="ex 192.168.1.1" data-inputmask="'alias': 'ip'" data-mask required>
|
<input type="text" class="form-control" id="editNetworkGw" name="gateway" placeholder="ex 192.168.1.1" data-inputmask="'alias': 'ip'" data-mask required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-server"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-server"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-control" id="edit_network_dhcp" name="dhcp_range" placeholder="ex 192.168.1.11-199">
|
<input type="text" class="form-control" id="editNetworkDhcp" name="dhcp_range" placeholder="ex 192.168.1.11-199">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-map-marker-alt"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-map-marker-alt"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<select class="form-control select2" id="edit_network_location" name="location">
|
<select class="form-control select2" id="editNetworkLocation" name="location">
|
||||||
<option value="">- Location -</option>
|
<option value="">- Location -</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
//Paging
|
//Paging
|
||||||
@@ -172,51 +166,50 @@ include("client_network_add_modal.php");
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function populateNetworkEditModal(client_id, network_id) {
|
function populateNetworkEditModal(client_id, network_id) {
|
||||||
//alert (network_id)
|
|
||||||
|
// Send a GET request to post.php as post.php?network_get_json_details=true&client_id=NUM&network_id=NUM
|
||||||
|
jQuery.get(
|
||||||
|
"post.php",
|
||||||
|
{network_get_json_details: 'true', client_id: client_id, network_id: network_id},
|
||||||
|
function(data){
|
||||||
|
|
||||||
// Send a GET request to post.php as post.php?network_get_json_details=true&client_id=NUM&network_id=NUM
|
// If we get a response from post.php, parse it as JSON
|
||||||
jQuery.get(
|
const response = JSON.parse(data);
|
||||||
"post.php",
|
|
||||||
{network_get_json_details: 'true', client_id: client_id, network_id: network_id},
|
|
||||||
function(data){
|
|
||||||
|
|
||||||
// If we get a response from post.php, parse it as JSON
|
// Access the network (only one!) and locations (possibly multiple)
|
||||||
const response = JSON.parse(data);
|
const network = response.network[0];
|
||||||
|
const locations = response.locations;
|
||||||
|
|
||||||
// Access the network (only one!) and locations (possibly multiple)
|
// Populate the network modal fields
|
||||||
const network = response.network[0];
|
document.getElementById("editNetworkHeader").innerText = " " + network.network_name;
|
||||||
const locations = response.locations;
|
document.getElementById("editNetworkId").value = network_id;
|
||||||
|
document.getElementById("editNetworkName").value = network.network_name;
|
||||||
|
document.getElementById("editNetworkVlan").value = network.network_vlan;
|
||||||
|
document.getElementById("editNetworkCidr").value = network.network;
|
||||||
|
document.getElementById("editNetworkGw").value = network.network_gateway;
|
||||||
|
document.getElementById("editNetworkDhcp").value = network.network_dhcp_range;
|
||||||
|
|
||||||
// Populate the network modal fields
|
// Select the location dropdown
|
||||||
document.getElementById("edit_network_name_header").innerText = " " + network.network_name;
|
var locationDropdown = document.getElementById("editNetworkLocation");
|
||||||
document.getElementById("edit_network_id").value = network_id;
|
|
||||||
document.getElementById("edit_network_name").value = network.network_name;
|
|
||||||
document.getElementById("edit_network_vlan").value = network.network_vlan;
|
|
||||||
document.getElementById("edit_network_cidr").value = network.network;
|
|
||||||
document.getElementById("edit_network_gw").value = network.network_gateway;
|
|
||||||
document.getElementById("edit_network_dhcp").value = network.network_dhcp_range;
|
|
||||||
|
|
||||||
// Select the location dropdown
|
// Clear location dropdown
|
||||||
var location_dropdown = document.getElementById("edit_network_location");
|
var i, L = locationDropdown.options.length -1;
|
||||||
|
for(i = L; i >= 0; i--) {
|
||||||
|
locationDropdown.remove(i);
|
||||||
|
}
|
||||||
|
locationDropdown[locationDropdown.length] = new Option('- Location -', '0');
|
||||||
|
|
||||||
// Clear location dropdown
|
// Populate location dropdown
|
||||||
var i, L = location_dropdown.options.length -1;
|
locations.forEach(location => {
|
||||||
for(i = L; i >= 0; i--) {
|
if(parseInt(location.location_id) == parseInt(network.network_location_id)){
|
||||||
location_dropdown.remove(i);
|
locationDropdown[locationDropdown.length] = new Option(location.location_name, location.location_id, true, true);
|
||||||
}
|
}
|
||||||
location_dropdown[location_dropdown.length] = new Option('- Location -', '0');
|
else{
|
||||||
|
locationDropdown[locationDropdown.length] = new Option(location.location_name, location.location_id);
|
||||||
// Populate location dropdown
|
}
|
||||||
locations.forEach(location => {
|
});
|
||||||
if(parseInt(location.location_id) == parseInt(network.network_location_id)){
|
|
||||||
location_dropdown[location_dropdown.length] = new Option(location.location_name, location.location_id, true, true);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
location_dropdown[location_dropdown.length] = new Option(location.location_name, location.location_id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
10
post.php
10
post.php
@@ -4968,16 +4968,14 @@ if(isset($_GET['network_get_json_details'])){
|
|||||||
$network_id = intval($_GET['network_id']);
|
$network_id = intval($_GET['network_id']);
|
||||||
$client_id = intval($_GET['client_id']);
|
$client_id = intval($_GET['client_id']);
|
||||||
|
|
||||||
$network_sql = mysqli_query($mysqli,"SELECT * FROM networks
|
$network_sql = mysqli_query($mysqli,"SELECT * FROM networks WHERE network_id = $network_id AND network_client_id = $client_id");
|
||||||
WHERE network_id = $network_id
|
|
||||||
AND network_client_id = $client_id");
|
|
||||||
while($row = mysqli_fetch_array($network_sql)){
|
while($row = mysqli_fetch_array($network_sql)){
|
||||||
$response['network'][] = $row;
|
$response['network'][] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
$locations_sql = mysqli_query($mysqli, "SELECT location_id, location_name FROM locations
|
$locations_sql = mysqli_query($mysqli, "SELECT location_id, location_name FROM locations
|
||||||
WHERE location_client_id = '$client_id'
|
WHERE location_client_id = '$client_id' AND company_id = '$session_company_id'"
|
||||||
AND company_id = '$session_company_id'");
|
);
|
||||||
while($row = mysqli_fetch_array($locations_sql)){
|
while($row = mysqli_fetch_array($locations_sql)){
|
||||||
$response['locations'][] = $row;
|
$response['locations'][] = $row;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user