Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web #88

Merged
merged 18 commits into from
Jun 18, 2020
Merged

Web #88

merged 18 commits into from
Jun 18, 2020

Conversation

JamesNewton
Copy link
Collaborator

@JamesNewton JamesNewton commented Jun 10, 2020

Adds the ability to edit files on the robot via web browser. Changes the web server to support serving all files under /srv/samba/share (vs just the files under /srv/samba/share/www previously) and adds functions for saving modified versions of those files back (while checking and retaining permissions) and for uploading or creating new files. The editor is based on
https://github.com/ajaxorg/ace-builds
and supports syntax highlighting for javascript (and it knows .dde is javascript), C / C++, bash (e.g. RunDexRun) and a few other files we might have on Dexter as well as standard text files. The idea is stolen from
https://github.com/me-no-dev/ESPAsyncWebServer/blob/master/src/edit.htm
and modified to better fit the Dexter environment. e.g. to support changing folders, longer lists of files, etc... than you might find on the ESP-8266 uC.

Nothing in this pull should cause /any/ problems with the robots essential functions.

Closes:
#85

- Checks for binary data in a file before serving it to the editor, and correctly sets the Content-type to application/octet-stream so the editor can warn the user
- Sends along size data for each file in the list of files so the editor can display it as a tool tip on the files on the left and also warn the user about loading very very large files. 
-
- Passes Content-type to callback when loading a file. 
- Adds file size in human readable form (1K, 3.53M, etc...) as a tool tip on each file in the list.
- Checks file size and warns if more than... really big. 
- Checks for binary files and warns user. 
- Allows editing all files, no matter the extension
- Checks for know image file extensions first and just displays them (preview images)
Changes required to support changing into new folders. 
- New logo, folder.png, is expected to be next the the existing page.png logo for folders to make it clear which is what, with sub class in css set by type as the list is built.
- "vars" is passed as a sort of global variable to track vars.dir.
- if the server provides '..' as a directory name, then it's expected that there are folders below the current one which we can move into. No checking is done of the path, but the method used to remove the last folder in the vars.dir string is surprisingly robust. 
- Right click context menu is removed for folders.

Also some changes made to improve language hinting to the ace.js editor.
Folder icon to help visually differentiate folders from files.
Add a "fake" folder called ".." if we are not already at root.
Track and correct permissions settings on replaced files.
- Make the directory list a bit wider. TODO: Make it user adjustable. 
- Prevent long directory lists form expanding the window vertically, scroll the list in place instead.
- Improved language detection... that part is a real mess and needs more work.
Making things happen in the current folder rather than the root folder.
- Create files works
- Upload files works 
- Saving files retains permissions of original file
- bug fix: don't return "ok" to the browser before you know it's ok. 
- Multiple small improvements related to debug messages, and formatting. 

TODO: The basic functions should be broken out. E.g. replaceFile(old, new), createFile(name), getDir(path), etc...
TODO: Delete file (actually copy to /tmp)
TODO: Chmod file? e.g. toggle executable.
Was loading the editor file, ace.js, from the internet instead of locally by default. Changed to try local first, then remote. 
Also added syntax highlighting for bash scripts detected by the start of the file having the `#!/bin/bash` tag
Allow local loading of the syntax highlighting definitions for the files we might encounter on Dexter.
Enable searching
Default to trying to open autoexec.jobs. If we eventually make the change to moving the jobs that run automatically out of RunDexRun then this will make it /super/ easy for users to edit that.
@JamesNewton JamesNewton linked an issue Jun 10, 2020 that may be closed by this pull request
@JamesNewton JamesNewton changed the base branch from Stable_2020_02_04_ConeDrive to Stable_Conedrive June 17, 2020 00:32
@JamesNewton JamesNewton merged commit e9e1615 into Stable_Conedrive Jun 18, 2020
@JamesNewton JamesNewton deleted the web branch June 18, 2020 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Browser based editing of files on Dexter via node web server
1 participant