path debug output #593, docs #598, Unassign network node #601

This commit is contained in:
Jokob-sk
2024-03-22 11:37:17 +11:00
parent 63fc716359
commit 8d4d985fba
8 changed files with 42 additions and 27 deletions

View File

@@ -49,7 +49,7 @@ docker run -d --rm --network=host \
| Required | Path | Description | | Required | Path | Description |
| :------------- | :------------- | :-------------| | :------------- | :------------- | :-------------|
| ✅ | `:/home/pi/pialert/config` | Folder which will contain the `pialert.conf` & `devices.csv` ([read about devices.csv](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEVICES_BULK_EDITING.md)) files (see below for details) | | ✅ | `:/home/pi/pialert/config` | Folder which will contain the `pialert.conf` & `devices.csv` ([read about devices.csv](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEVICES_BULK_EDITING.md)) files (see below for details). |
| ✅ | `:/home/pi/pialert/db` | Folder which will contain the `pialert.db` file | | ✅ | `:/home/pi/pialert/db` | Folder which will contain the `pialert.db` file |
| | `:/home/pi/pialert/front/log` | Logs folder useful for debugging if you have issues setting up the container | | | `:/home/pi/pialert/front/log` | Logs folder useful for debugging if you have issues setting up the container |
| | `:/etc/pihole/pihole-FTL.db` | PiHole's `pihole-FTL.db` database file. Required if you want to use PiHole DB mapping. | | | `:/etc/pihole/pihole-FTL.db` | PiHole's `pihole-FTL.db` database file. Required if you want to use PiHole DB mapping. |
@@ -58,6 +58,7 @@ docker run -d --rm --network=host \
| | `:/home/pi/pialert/front/plugins/<plugin>/ignore_plugin` | Map a file `ignore_plugin` to ignore a plugin. Plugins can be soft-disabled via settings. More in the [Plugin docs](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/README.md). | | | `:/home/pi/pialert/front/plugins/<plugin>/ignore_plugin` | Map a file `ignore_plugin` to ignore a plugin. Plugins can be soft-disabled via settings. More in the [Plugin docs](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/README.md). |
| | `:/etc/resolv.conf` | Use a custom `resolv.conf` file for [better name resolution](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/REVERSE_DNS.md). | | | `:/etc/resolv.conf` | Use a custom `resolv.conf` file for [better name resolution](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/REVERSE_DNS.md). |
> Use separate `db` and `config` directories, don't nest them.
### Modify the config (`pialert.conf`) only if UI is not available ### Modify the config (`pialert.conf`) only if UI is not available

View File

@@ -21,9 +21,17 @@ echo "longrun" > /etc/s6-overlay/s6-rc.d/pialert/type
echo -e "${INSTALL_DIR}/pialert/dockerfiles/setup.sh" > /etc/s6-overlay/s6-rc.d/SetupOneshot/up echo -e "${INSTALL_DIR}/pialert/dockerfiles/setup.sh" > /etc/s6-overlay/s6-rc.d/SetupOneshot/up
echo -e "#!/bin/execlineb -P\n/usr/sbin/php-fpm82 -F" > /etc/s6-overlay/s6-rc.d/php-fpm/run echo -e "#!/bin/execlineb -P\n/usr/sbin/php-fpm82 -F" > /etc/s6-overlay/s6-rc.d/php-fpm/run
echo -e '#!/bin/execlineb -P\nnginx -g "daemon off;"' > /etc/s6-overlay/s6-rc.d/nginx/run echo -e '#!/bin/execlineb -P\nnginx -g "daemon off;"' > /etc/s6-overlay/s6-rc.d/nginx/run
echo -e '#!/bin/execlineb -P\n\nwith-contenv\nimportas -i PORT PORT\nif { echo "[INSTALL] 🚀 Starting app - navigate to your <server IP>:${PORT}" }' > /etc/s6-overlay/s6-rc.d/pialert/run echo -e '#!/bin/execlineb -P
with-contenv
importas -u PORT PORT
if { echo
"
[INSTALL] 🚀 Starting app (:${PORT})
" }' > /etc/s6-overlay/s6-rc.d/pialert/run
echo -e "python ${INSTALL_DIR}/pialert/pialert" >> /etc/s6-overlay/s6-rc.d/pialert/run echo -e "python ${INSTALL_DIR}/pialert/pialert" >> /etc/s6-overlay/s6-rc.d/pialert/run
echo -e 'echo path is ${PATH}' >> /etc/s6-overlay/s6-rc.d/pialert/run
touch /etc/s6-overlay/s6-rc.d/user/contents.d/{SetupOneshot,php-fpm,nginx} /etc/s6-overlay/s6-rc.d/{php-fpm,nginx}/dependencies.d/SetupOneshot touch /etc/s6-overlay/s6-rc.d/user/contents.d/{SetupOneshot,php-fpm,nginx} /etc/s6-overlay/s6-rc.d/{php-fpm,nginx}/dependencies.d/SetupOneshot
touch /etc/s6-overlay/s6-rc.d/user/contents.d/{SetupOneshot,php-fpm,nginx,pialert} /etc/s6-overlay/s6-rc.d/{php-fpm,nginx,pialert}/dependencies.d/SetupOneshot touch /etc/s6-overlay/s6-rc.d/user/contents.d/{SetupOneshot,php-fpm,nginx,pialert} /etc/s6-overlay/s6-rc.d/{php-fpm,nginx,pialert}/dependencies.d/SetupOneshot
touch /etc/s6-overlay/s6-rc.d/nginx/dependencies.d/php-fpm touch /etc/s6-overlay/s6-rc.d/nginx/dependencies.d/php-fpm

View File

@@ -77,3 +77,11 @@ if [ ! -f "${INSTALL_DIR}/pialert/front/buildtimestamp.txt" ]; then
date +%s > "${INSTALL_DIR}/pialert/front/buildtimestamp.txt" date +%s > "${INSTALL_DIR}/pialert/front/buildtimestamp.txt"
chown nginx:www-data "${INSTALL_DIR}/pialert/front/buildtimestamp.txt" chown nginx:www-data "${INSTALL_DIR}/pialert/front/buildtimestamp.txt"
fi fi
echo -e "
[ENV] PATH is ${PATH}
[ENV] PORT is ${PORT}
[ENV] TZ is ${TZ}
[ENV] LISTEN_ADDR is ${LISTEN_ADDR}
[ENV] ALWAYS_FRESH_INSTALL is ${ALWAYS_FRESH_INSTALL}
"

View File

@@ -621,6 +621,10 @@
<script src="lib/AdminLTE/bower_components/moment/moment.js"></script> <script src="lib/AdminLTE/bower_components/moment/moment.js"></script>
<script src="lib/AdminLTE/bower_components/fullcalendar/dist/fullcalendar.min.js"></script> <script src="lib/AdminLTE/bower_components/fullcalendar/dist/fullcalendar.min.js"></script>
<script src="lib/AdminLTE/bower_components/fullcalendar/dist/locale-all.js"></script> <script src="lib/AdminLTE/bower_components/fullcalendar/dist/locale-all.js"></script>
<!-- ----------------------------------------------------------------------- -->
<script src="js/ui_components.js"></script>
<script src="js/db_methods.js"></script>
<!-- ----------------------------------------------------------------------- -->
<!-- Dark-Mode Patch --> <!-- Dark-Mode Patch -->
<?php <?php
@@ -825,6 +829,10 @@ function initializeCombos () {
initializeCombo ( '#dropdownGroup', 'getGroups', 'txtGroup', true); initializeCombo ( '#dropdownGroup', 'getGroups', 'txtGroup', true);
initializeCombo ( '#dropdownLocation', 'getLocations', 'txtLocation', true); initializeCombo ( '#dropdownLocation', 'getLocations', 'txtLocation', true);
initializeCombo ( '#dropdownNetworkNodeMac', 'getNetworkNodes', 'txtNetworkNodeMac', false); initializeCombo ( '#dropdownNetworkNodeMac', 'getNetworkNodes', 'txtNetworkNodeMac', false);
// initSettingDropdown("NEWDEV_dev_Network_Node_MAC_ADDR", [], "dropdownNetworkNodeMac", generateList)
initializeCombo ( '#dropdownIcon', 'getIcons', 'txtIcon', false); initializeCombo ( '#dropdownIcon', 'getIcons', 'txtIcon', false);
initializeCombo ( '#dropdownAction', 'getActions', 'txtAction', false); initializeCombo ( '#dropdownAction', 'getActions', 'txtAction', false);
initializeCombo ( '#dropdownDevices', 'getDevices', 'txtFromDevice', false); initializeCombo ( '#dropdownDevices', 'getDevices', 'txtFromDevice', false);

View File

@@ -113,7 +113,7 @@ $(function () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Initiate dropdown // Initiate dropdown
function initSettingDropdown(settingKey, valuesArray, targetLocation) function initSettingDropdown(settingKey, valuesArray, targetLocation, callbackToGenerateEntries)
{ {
var optionsHtml = "" var optionsHtml = ""
@@ -127,7 +127,7 @@ function initSettingDropdown(settingKey, valuesArray, targetLocation)
optionsHtml += `<option id="${targetLocation_options}"></option>`; optionsHtml += `<option id="${targetLocation_options}"></option>`;
readData(optionsArray[0], generateDropdownOptions, valuesArray, targetLocation_options); readData(optionsArray[0], callbackToGenerateEntries, valuesArray, targetLocation_options);
} else // this should be already an array, e.g. from a setting or pre-defined } else // this should be already an array, e.g. from a setting or pre-defined
{ {

View File

@@ -112,7 +112,7 @@
targetLocation = columns[j].Code_Name + "_initSettingDropdown" targetLocation = columns[j].Code_Name + "_initSettingDropdown"
initSettingDropdown(columns[j].Code_Name, [], targetLocation) initSettingDropdown(columns[j].Code_Name, [], targetLocation, generateDropdownOptions)
input = `<select class="form-control" input = `<select class="form-control"
id="${columns[j].Code_Name}" id="${columns[j].Code_Name}"

View File

@@ -800,6 +800,9 @@ function getNetworkNodes() {
'name' => $row['dev_Name'] ); 'name' => $row['dev_Name'] );
} }
// Add an empty option at the bottom
$tableData[] = array('id' => '', 'name' => '❌'.lang("Network_ManageUnassign")); // Add empty option
// Control no rows // Control no rows
if (empty($tableData)) { if (empty($tableData)) {
$tableData = []; $tableData = [];

View File

@@ -170,7 +170,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
pluginsData = res["data"]; pluginsData = res["data"];
initSettingsPage(settingsData, pluginsData); initSettingsPage(settingsData, pluginsData, generateDropdownOptions);
}) })
}) })
} }
@@ -536,28 +536,15 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
optionsArray = getSettingOptions(set['Code_Name'] ) optionsArray = getSettingOptions(set['Code_Name'] )
valuesArray = createArray(set['Value']); valuesArray = createArray(set['Value']);
// // check if the result is a SQL query - if so, dropdown will be populated async with AJAX
// if(isSQLQuery(optionsArray))
// {
var targetLocation = set['Code_Name'] + "_initSettingDropdown"; var targetLocation = set['Code_Name'] + "_initSettingDropdown";
// placeholder option which will be replaced on callback // placeholder option which will be replaced on callback
optionsHtml += `<option id="${targetLocation}" temporary="temporary"></option>`; optionsHtml += `<option id="${targetLocation}" temporary="temporary"></option>`;
// execute AJAX callabck + SQL query resolution // execute AJAX callabck + SQL query resolution
initSettingDropdown(set['Code_Name'] , valuesArray, targetLocation) initSettingDropdown(set['Code_Name'] , valuesArray, targetLocation, generateDropdownOptions)
// }
// else // it's a string without a SQL resolution requirements
// {
// options = createArray(optionsArray);
// options.forEach(option => {
// let selected = valuesArray.includes(option) ? 'selected' : '';
// optionsHtml += `<option value="${option}" ${selected}>${option}</option>`;
// });
// }
// main selection dropdown wrapper // main selection dropdown wrapper
input += ` input += `