diff --git a/front/deviceDetails.php b/front/deviceDetails.php
index f090b4b1..1686ca42 100755
--- a/front/deviceDetails.php
+++ b/front/deviceDetails.php
@@ -347,6 +347,8 @@
+
+
@@ -463,11 +465,35 @@
-
-
+
+
+
@@ -949,6 +975,7 @@ function initializeCombos () {
initializeCombo ( '#dropdownNetworkNodeMac', 'getNetworkNodes', 'txtNetworkNodeMac', false);
initializeCombo ( '#dropdownIcon', 'getIcons', 'txtIcon', false);
initializeCombo ( '#dropdownAction', 'getActions', 'txtAction', false);
+ initializeCombo ( '#dropdownDevices', 'getDevices', 'txtFromDevice', false);
// Initialize static combos
initializeComboSkipRepeated ();
@@ -1623,6 +1650,29 @@ function deleteDeviceEvents () {
$('#panDetails :input').attr('disabled', true);
}
+// -----------------------------------------------------------------------------
+function askCopyFromDevice() {
+ // Ask
+ showModalWarning('= lang('BackDevDetail_Copy_Title');?>', '= lang('BackDevDetail_Copy_Ask');?>',
+ '= lang('Gen_Cancel');?>', '= lang('Gen_Run');?>', 'copyFromDevice');
+}
+
+function copyFromDevice() {
+
+ // Execute
+ $.get('php/server/devices.php?action=copyFromDevice&'
+ + '&macTo=' + $('#txtMAC').val()
+ + '&macFrom=' + $('#txtFromDevice').val()
+ , function(msg) {
+ showMessage (msg);
+
+ setTimeout(function() {
+ window.location.reload();
+ }, 2000);
+ });
+
+}
+
// -----------------------------------------------------------------------------
function askRunAction() {
// Ask
diff --git a/front/php/server/devices.php b/front/php/server/devices.php
index a557d885..39aaf5e2 100755
--- a/front/php/server/devices.php
+++ b/front/php/server/devices.php
@@ -58,6 +58,8 @@
case 'overwriteIconType': overwriteIconType(); break;
case 'getIcons': getIcons(); break;
case 'getActions': getActions(); break;
+ case 'getDevices': getDevices(); break;
+ case 'copyFromDevice': copyFromDevice(); break;
case 'wakeonlan': wakeonlan(); break;
default: logServerConsole ('Action: '. $action); break;
@@ -524,7 +526,7 @@ function ImportCSV() {
if($error == "")
{
// import succesful
- echo lang('BackDevices_DBTools_ImportCSV') . "(Skipped lines: " .$skipped .")";
+ echo lang('BackDevices_DBTools_ImportCSV') . " (Skipped lines: " .$skipped .") ";
}
else{
@@ -825,6 +827,36 @@ function getActions() {
echo (json_encode ($tableData));
}
+//------------------------------------------------------------------------------
+function getDevices() {
+
+ global $db;
+
+ // Device Data
+ $sql = 'select dev_MAC, dev_Name from Devices';
+
+ $result = $db->query($sql);
+
+ // arrays of rows
+ $tableData = array();
+
+ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
+ $name = handleNull($row['dev_Name'], "(unknown)");
+ $mac = handleNull($row['dev_MAC'], "(unknown)");
+ // Push row data
+ $tableData[] = array('id' => $mac,
+ 'name' => $name );
+ }
+
+ // Control no rows
+ if (empty($tableData)) {
+ $tableData = [];
+ }
+
+ // Return json
+ echo (json_encode ($tableData));
+}
+
//------------------------------------------------------------------------------
// Query the List of types
@@ -1176,6 +1208,56 @@ function wakeonlan() {
echo lang('BackDevDetail_Tools_WOL_okay');
}
+//------------------------------------------------------------------------------
+// Copy from device
+//------------------------------------------------------------------------------
+function copyFromDevice() {
+
+ $MAC_FROM = $_REQUEST['macFrom'];
+ $MAC_TO = $_REQUEST['macTo'];
+
+ if ((false === filter_var($MAC_FROM , FILTER_VALIDATE_MAC) && $MAC_FROM != "Internet" && $MAC_FROM != "") ) {
+ throw new Exception('Invalid mac address');
+ }
+ if ((false === filter_var($MAC_TO , FILTER_VALIDATE_MAC) && $MAC_TO != "Internet" && $MAC_TO != "") ) {
+ throw new Exception('Invalid mac address');
+ }
+
+ global $db;
+
+ // clean-up temporary table
+ $sql = "DROP TABLE temp_devices ";
+ $result = $db->query($sql);
+
+ // create temporary table with the source data
+ $sql = "CREATE TABLE temp_devices AS SELECT * FROM Devices WHERE dev_MAC = '". $MAC_FROM . "';";
+ $result = $db->query($sql);
+
+ // update temporary table with the correct target MAC
+ $sql = "UPDATE temp_devices SET dev_MAC = '". $MAC_TO . "';";
+ $result = $db->query($sql);
+
+ // delete previous entry
+ $sql = "DELETE FROM Devices WHERE dev_MAC = '". $MAC_TO . "';";
+ $result = $db->query($sql);
+
+ // insert new entry with the correct target MAC from the temporary table
+ $sql = "INSERT INTO Devices SELECT * FROM temp_devices WHERE dev_MAC = '".$MAC_TO."'";
+ $result = $db->query($sql);
+
+ // clean-up temporary table
+ $sql = "DROP TABLE temp_devices ";
+ $result = $db->query($sql);
+
+ // check result
+ if ($result == TRUE) {
+ echo 'OK';
+ } else {
+ echo lang('BackDevices_Device_UpdDevError');
+ }
+
+}
+
//------------------------------------------------------------------------------
// Status Where conditions
//------------------------------------------------------------------------------
diff --git a/front/php/templates/language/en_us.php b/front/php/templates/language/en_us.php
index c51d2d88..359b5154 100755
--- a/front/php/templates/language/en_us.php
+++ b/front/php/templates/language/en_us.php
@@ -19,6 +19,7 @@ $lang['en_us'] = array(
'Gen_Save' => 'Save',
'Gen_Saved' => 'Saved',
'Gen_Run' => 'Run',
+'Gen_Copy' => 'Run',
'Gen_Action' => 'Action',
'Gen_Purge' => 'Purge',
'Gen_Backup' => 'Run Backup',
@@ -245,6 +246,10 @@ $lang['en_us'] = array(
'DevDetail_WOL_Title' => ' Wake-on-LAN',
'DevDetail_Run_Actions_Title' => ' Run action on device',
'DevDetail_Run_Actions_Tooltip' => 'Run an action on the current device from the dropdown list.',
+'DevDetail_Copy_Device_Title' => ' Copy details from device',
+'DevDetail_Copy_Device_Tooltip' => 'Copy details from device from the dropdown list. Everything on this page will be overwritten',
+'BackDevDetail_Copy_Title' => 'Copy details',
+'BackDevDetail_Copy_Ask' => 'Copy details from device from the dropdown list (Everything on this page will be overwritten)?',
//////////////////////////////////////////////////////////////////
// Maintenance Page
@@ -368,7 +373,7 @@ $lang['en_us'] = array(
'BackDevices_DBTools_ImportCSV' => 'The devices from the CSV file were imported successfully.',
'BackDevices_DBTools_ImportCSVError' => 'The CSV file couldn\'t be imported. Make sure the format is correct.',
'BackDevices_DBTools_ImportCSVMissing' => 'The CSV file couldn\'t be found under /config/devices.csv.',
-'BackDevices_Device_UpdDevError' => 'Error updating devices, try later. The database is probable locked due to an ongoing task.',
+'BackDevices_Device_UpdDevError' => 'Error updating devices, try later. The database is probably locked due to an ongoing task.',
//////////////////////////////////////////////////////////////////