This commit is contained in:
Garrett 2021-08-01 20:57:23 +00:00
parent d68ffb3164
commit 9fb41a0a04
7 changed files with 100 additions and 30 deletions

View File

@ -39,6 +39,7 @@ Contents
**Changes introduced in 0.3.17
[Fix] Error when configuring managed cable connector type as ST
[Enhance] Added ability to delete managed cable from Cable Inventory
**Changes introduced in 0.3.17
[Fix] Backup export not converting HTML code to ASCII hyphen

View File

@ -32,10 +32,52 @@ $( document ).ready(function() {
var action = $(linkEditable).attr('data-action');
var cableID = $(linkEditable).attr('data-cableID');
var data = {
cableID: cableID,
action: action
if(action == 'delete') {
$(document).data('selectedCableID', cableID);
$('#modalConfirmTitle').html('Delete Cable');
$('#modalConfirmBody').html('Delete cable?');
} else {
var data = {
cableID: cableID,
action: action
}
data = JSON.stringify(data);
$.post("backend/process_cable-editable.php", {data:data}, function(response){
var responseJSON = JSON.parse(response);
if (responseJSON.active == 'inactive'){
window.location.replace("/");
} else if ($(responseJSON.error).size() > 0){
displayError(responseJSON.error);
} else {
if(action == 'lock') {
$(linkEditable).html('<i class="fa fa-lock"></i>');
$(linkEditable).attr('data-action', 'unlock');
$(linkEditable).attr('title', 'Unlock cable for editing');
} else if(action == 'unlock') {
$(linkEditable).html('<i class="fa fa-unlock"></i>');
$(linkEditable).attr('data-action', 'lock');
$(linkEditable).attr('title', 'Lock cable for editing');
}
}
});
}
});
// Delete a temlate
$('#modalConfirmBtn').click(function(){
var selectedCableID = $(document).data('selectedCableID');
var data = {
cableID: selectedCableID,
action: 'delete'
}
data = JSON.stringify(data);
$.post("backend/process_cable-editable.php", {data:data}, function(response){
@ -45,22 +87,8 @@ $( document ).ready(function() {
} else if ($(responseJSON.error).size() > 0){
displayError(responseJSON.error);
} else {
var pill = $(linkEditable).siblings('.label-pill');
if(action == 'finalize') {
$(pill).removeClass('label-danger').addClass('label-success');
$(pill).html('Yes');
$(linkEditable).html('unFinalize');
$(linkEditable).attr('data-action', 'unfinalize');
$(linkEditable).attr('title', 'Allow cable properties to be edited.');
} else if(action == 'unfinalize') {
$(pill).removeClass('label-success').addClass('label-danger');
$(pill).html('No');
$(linkEditable).html('Finalize');
$(linkEditable).attr('data-action', 'finalize');
$(linkEditable).attr('title', 'Remove the ability to edit cable properties.');
}
$('#'+selectedCableID).remove();
}
});
});

View File

@ -20,15 +20,37 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){
$cableID = $data['cableID'];
$action = $data['action'];
$editable = $action == 'finalize' ? 0 : 1;
if($action == 'lock' or $action == 'unlock') {
$qls->SQL->update('app_inventory', array('editable' => $editable), array('id' => array('=', $cableID)));
$editable = $action == 'lock' ? 0 : 1;
$qls->SQL->update('app_inventory', array('editable' => $editable), array('id' => array('=', $cableID)));
} else if($action == 'delete') {
if(isset($qls->App->inventoryAllArray[$cableID])) {
$cable = $qls->App->inventoryAllArray[$cableID];
if($cable['a_object_id'] != 0 and $cable['b_object_id'] != 0) {
$qls->SQL->delete('app_inventory', array('id' => array('=', $cableID)));
} else {
$errMsg = 'Unable to delete managed cables that are connected to ports. Clear cable connection(s) and try again.';
array_push($validate->returnData['error'], $errMsg);
}
}
}
}
echo json_encode($validate->returnData);
}
function validate($data, &$validate, &$qls){
$actionArray = array('finalize', 'unfinalize');
$actionArray = array('lock', 'unlock', 'delete');
$validate->validateID($data['cableID'], 'cable ID');

View File

@ -128,6 +128,14 @@ var $qls;
// Set app version to 0.3.18
$this->qls->SQL->update('app_organization_data', array('version' => $incrementalVersion), array('id' => array('=', 1)));
// Fix port description table
$query = $this->qls->SQL->query("SHOW COLUMNS FROM `{$this->qls->config['sql_prefix']}app_port_description` LIKE 'description'");
if(!$this->qls->SQL->num_rows($query)) {
// Add description column
$this->qls->SQL->alter('app_port_description', 'add', 'description', 'varchar(255)');
}
}
/**

View File

@ -18,9 +18,9 @@
echo '<th>ID</th>';
echo '<th>Connector</th>';
echo '<th>Connected</th>';
echo '<th>Finalized</th>';
echo '<th>Media</th>';
echo '<th>Length</th>';
echo '<th>Action</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
@ -30,7 +30,7 @@
$lengthValue = $row['length'];
$length = $qls->App->calculateCableLength($mediaTypeID, $lengthValue);
echo '<tr>';
echo '<tr id="'.$row['id'].'">';
echo '<td data-connectorID="'.$row['a_code39'].'"><a class="linkScan" href="#">'.$row['a_code39'].'</a><button class="displayBarcode pull-right btn btn-sm waves-effect waves-light btn-primary"><i class="fa fa-barcode"></i></button></td>';
echo '<td>'.$connectorTable[$row['a_connector']]['name'].'</td>';
if($row['a_object_id'] == 0) {
@ -45,13 +45,23 @@
} else {
echo '<td>'.$pillYes.'</td>';
}
if($row['editable'] == 0) {
echo '<td>'.$pillYes.'&nbsp&nbsp<a title="Allow cable properties to be edited." class="linkEditable" data-action="unfinalize" data-cableID="'.$row['id'].'" href="javascript:void(0);">unFinalize</a></td>';
} else {
echo '<td>'.$pillNo.'&nbsp&nbsp<a title="Remove the ability to edit cable properties." class="linkEditable" data-action="finalize" data-cableID="'.$row['id'].'" href="javascript:void(0);">Finalize</a></td>';
}
echo '<td>'.$mediaTypeTable[$row['mediaType']]['name'].'</td>';
echo '<td>'.$length.'</td>';
echo '<td>';
if($row['editable'] == 0) {
echo '<a title="Unlock cable for editing" class="linkEditable" data-action="unlock" data-cableID="'.$row['id'].'" href="javascript:void(0);">';
echo '<i class="fa fa-lock"></i>';
echo '</a>';
} else {
echo '<a title="Lock cable for editing" class="linkEditable" data-action="lock" data-cableID="'.$row['id'].'" href="javascript:void(0);">';
echo '<i class="fa fa-unlock"></i>';
echo '</a>';
}
echo '&nbsp&nbsp';
echo '<a title="Delete cable" class="linkEditable" data-action="delete" data-cableID="'.$row['id'].'" href="javascript:void(0);" data-toggle="modal" data-target="#modalConfirm">';
echo '<i class="fa fa-times"></i>';
echo '</a>';
echo '</td>';
echo '</tr>';
}
echo '</tbody>';

View File

@ -544,5 +544,6 @@ CREATE TABLE `{database_prefix}app_port_description` (
`object_face` int(11) NOT NULL,
`object_depth` int(11) NOT NULL,
`port_id` int(11) NOT NULL,
`description` varchar(255) NOT NULL,
PRIMARY KEY(`id`)
);

View File

@ -78,7 +78,7 @@ $qls->Security->check_auth_page('operator.php');
</table>
<button id="buttonFinalize" type="button" class="btn btn-success waves-effect waves-light m-t-10" style="display:none;" disabled>
<span class="btn-label"><i class="fa fa-check"></i></span>
Finalize*
Lock*
</button>
</blockquote>
</div>