Commit Graph

22 Commits

Author SHA1 Message Date
Daniel Markstedt ff017a9c1d
Web UI: Handling for non-existence of working dirs (#1130) 2023-03-23 20:07:19 -07:00
Daniel Markstedt 1082b6a7b4
Fix bugs in image subdir logic (#1108) 2023-02-26 14:15:13 -08:00
Daniel Markstedt dd00547f92
Formatted image file data structure that breaks down by subdir (#1102)
- New utility method for the web app, which sorts image files into dicts where the subdir is the key
- In the web ui, display each subdir in a table nested in a details tag.
- Allow for picking destination subdir when uploading files
- Style the expandable details blocks in the images table
- Add a check for ~ paths to the is_safe_path() utility method
2023-02-24 17:28:58 -08:00
Daniel Markstedt 52c2aa474f
Rebrand project to PiSCSI (#1016)
* Rebrand project to PiSCSI
- rascsi ->piscsi
- rasctl -> scsictl
- rasdump -> scsidump
- ras* -> piscsi* (rasutil -> piscsi_util, etc.)

* Refined the formatting and wording of the app startup banner
* Kept some references to rascsi and rasctl where backwards compatibility is concerned
* Point to the new github repo URL

Co-authored-by: nucleogenic <nr@nucleogenic.com>
Co-authored-by: Uwe Seimet <Uwe.Seimet@seimet.de>
2022-12-05 09:58:23 -08:00
nucleogenic 88ff542aeb
Run web API test suite in GitHub Actions (#1009)
- Fixed ignore patterns in .dockerignore
- Added healthchecks to backend and web containers
- Reduced Docker image sizes
- Removed RaSCSI references in various areas (e.g. rascsi -> backend)
- Added compilation-only step to easyinstall.sh
- Moved apt package lists to variables
- Revert to triggering GitHub Actions runs on push
- Updated web/frontend_checks workflow to run black and flake8 against all Python sources
- Capture log files from backend/web containers
- Fix None to float conversion bug when user agent is absent or unrecognised
2022-12-04 14:31:57 +00:00
nucleogenic 315ef9f248
Auto-format Python sources with black, fix all issues reported by flake8 (#1010)
* Update config for black and flake8
* Auto-format Python sources with black
* Fix issues reported by flake8
* Exclude protobuf files from black
* Address formatting feedback
2022-11-30 05:19:17 +00:00
Daniel Markstedt 4645e8c975
Display hardware info in footer; close open file handlers; better error handling (#989)
* Expose hardware info in env string

* Improve error handling for get_properties_by_drive_name

* Verbose uname parameters.

* Close open file in introspect method

* Add error handling for when no drive name was matched with props in the database
2022-11-15 22:28:27 -08:00
nucleogenic 3627b39af4
New theme for web UI (#957)
* Docker environment fixes

* New theme for web UI

* Apply breaking wrap to filenames only

* Reduce font sizes, whitespace and padding

* Right align action fields/buttons

* Improve mobile header, hide superfluous UI elements when logged out, drop placeholders from login labels, various other adjustments

* Force footer to bottom of screen

* Show manual link to logged out users

* Reduce header text size on desktop

* Fix incorrect selector ID

* Fix selector referencing old class name

* Fix right-aligned message when images table empty

* Add CSS linter/auto-formatter

* Run Stylelint + Prettier against modern theme CSS

* Select default theme based on browser’s user agent

* Style inputs on mobile/tablet devices

* Fixes for Safari 14 on iOS + iPad OS

* Explicitly define mobile browser support, switch to bare ua-parser without user-agent wrapper

* Add LICENSE file for modern theme icons

* Improve theme selection query string/field naming.

* Remove patch workaround from Docker build

* Update log level for UAs to info

* Move Bootstrap Reboot CSS to CDN

* Account for LUN column in attached devices table

* Prevent wrapping of config forms on small viewports

* Fix Stylelint issues

* Auto-format CSS with Prettier
2022-11-14 09:32:15 -08:00
Daniel Markstedt 4b109a70b0
Improve Web UI integration tests (#939)
* Remove deprecated critital log level from test

* Move drive_properties back into template data sets

* Move properties data integrity checks to test code

* Streamline the drive formatting logic
2022-10-25 08:51:04 -07:00
Daniel Markstedt 5172d167e7
Web UI: More file path sanitation, better network bridge warnings, each endpoint return one message (#932)
- Sanitize file paths with Path: for flat file structures, always extract Path().name, and for nested file structures either look for absolute paths, or someone trying to use ".." to traverse the dir strucutre.
- Reduce redundancy in network bridge detection method, and return somewhat more informative messages
- Make all endpoints return exactly one message
- Move some warning messages to logging
- Use tempfile for iso generation temp file handling
2022-10-23 19:05:29 -07:00
Daniel Markstedt 5a679509a1
More refactoring of Python code to address Sonar issues (#906)
- Use Path objects for file operations
- Use urllib to sanitize URLs
- Some explicit type conversions
- Consistent regex syntax
- Add rudimentary logging when archive extraction caching fails
- Fixed two cases of the property file creation not being notified in the Flash message
- added doctype and html lang attribute to the web server 502 page
2022-10-12 12:59:01 -07:00
Daniel Markstedt 1b10b123d2
Refactor python code to address Sonarcloud issues (#900)
- copy/move/delete file class methods now take Path objects as arguments
- The file download endpoint in the Web UI uses the safer download from dir method
- Simplified logging
- Merged nested if statements
- Removed naked handling of unknown error states
- Added fallback empty list for drive_properties, to avoid errors when json file is missing or broken
- Move drive_properties to env[]
- Constants for common error messages
- Dummy variable for list comprehension
2022-10-09 13:50:20 -07:00
Daniel Markstedt 62e287c96d
Remove redundant help text, table columns and parameters from the Web UI (#898)
- Remove the Size option from the Drives page, since we offer custom sizes with Drive profiles now in the Create Image form
- Fetch size from drive props data structure rather than the web form
- Remove a range of redundant / obvious help text to reduce UI clutter and emphasize the important help text
- Remove the Size column from the CD-ROM drives table since it's always N/A
- Merge the two Logging related sections, and the two Create Image related sections (semantically associated)
2022-10-07 19:55:53 -07:00
Daniel Markstedt 90ace5fd53
Introduce utility method to look up drive props by drive name. (#888)
* Introduce utility method to look up drive props by drive name.

* Make /drive/create endpoint fetch file ending from properties data structure; update tests
2022-10-06 14:04:41 -07:00
Daniel Markstedt 52ebb3a2ae
Improve the logic and data structure for SCSI ID management in Web UI (#893)
- Have the get_scsi_ids() utility method return a dict, while adding occupied_ids. Leverage this to improve the logic for detecting which IDs are available to be reserved in the Web UI. (Which fixes a recent regression bug that's causing no IDs to be detected as available to be reserved.)
- Improve /scsi/attach endpoint logic to capture dynamic parameter fields now prefixed with "param_" (previous it scanned for any arbitrary field, which wasn't very accurate or secure)
- Added Product string to the block_size:512 CD-ROM device, so that it's obvious when it's being used.
- Tweaked test data for attach_device tests
2022-10-06 10:00:57 -07:00
Daniel Markstedt 52259c374f
Improve the logic for checking the network bridge configuration (#894)
* Improve the logic for checking the network bridge configuration
2022-10-05 14:14:48 -07:00
Daniel Markstedt fd47411322
Device table refinement in Web UI (#884)
* Refine the attached device table to optimize information displayed

* Error handling when attempting to insert withough image file

* Format the parameters in the jinja template instead

* Call the DaynaPORT device Ethernet Adapter in the Web UI
2022-10-03 11:47:08 -07:00
Daniel Markstedt d969fbdcce
Attach empty removable drives in the Web UI (#877)
* Read the drive properties file once and store it in the Flask app config. Spin out the drive properties formatting to a helper method.

* Add empty removable disk drives to the attach peripherals UI

* Refinement of UI labels and help text, moving some context to the wiki
2022-10-01 16:51:30 -07:00
Daniel Markstedt e7775a72cc
Generate list of image types to create programmatically in the Web UI (#850)
* Generate list of image types to create programmatically based on rascsi capabilities, rather than a hard-coded list in the Web UI.

* Add explicit sorting of dicts for display in the Web UI, to avoid random order in certain environments.

* Remove redundant sorting line, and add code comments.

* Add helptext for the SCSI-1 image type
2022-09-21 17:14:53 -07:00
Uwe Seimet ddeede2beb
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:

- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 16:53:53 +02:00
Phil Eichinger a33a228b6b In case all IDs are reserved recommend 0
Otherwise the occupied list is empty and this exception brings down the
whole web interface.

This can be easily provoked by just reserving all IDs in the web interface.
2022-06-30 23:17:55 +02:00
Daniel Markstedt e8f392c3f1
Create SysCmds common class, and refactor Python codebase (#697)
* Move the oled script's PiCmds module to common, and rename it SysCmds.

* Use sys_cmds.get_ip_and_host() in web UI code.

* Move the auth_active() method to device_utils

* Rename device_utils to web_utils. Make auth_active() method take the group as argument.

* Migrate all pi_cmds methods to the SysCmds common class.

* Display hostname and ip in Web UI.

* Resolve or suppress pylint warnings.

* Resolve a pylint warning.

* Resolve or suppress pylint warnings.

* Import libraries at the top level for readability. In my testing on a Pi3B+, this leads to ~1.5k more memory being used by the python3 process.

* Change page title as requested by akuker.

* Reenable the import-outside-toplevel pylint rule.

* Resolve pylint warnings.

* Fix error following refactoring.

* Minor UI tweaks.

* Cleanup.

* Break out bridge config validation into a utility method.

* Move the dropzonejs method into the web_utils package

* Move get_logs method into SysCmds class.

* Improve get logs UI.

* Resolve pylint warning.

* Standardize class instance name.
2022-02-26 21:46:35 -08:00