{"action":"created","issue":{"url":"https://api.github.com/repos/billz/raspap-webgui/issues/156","repository_url":"https://api.github.com/repos/billz/raspap-webgui","labels_url":"https://api.github.com/repos/billz/raspap-webgui/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/billz/raspap-webgui/issues/156/comments","events_url":"https://api.github.com/repos/billz/raspap-webgui/issues/156/events","html_url":"https://github.com/billz/raspap-webgui/issues/156","id":296191886,"node_id":"MDU6SXNzdWUyOTYxOTE4ODY=","number":156,"title":"Proposed enhancement - customisable configuration","user":{"login":"njkeng","id":6022146,"node_id":"MDQ6VXNlcjYwMjIxNDY=","avatar_url":"https://avatars1.githubusercontent.com/u/6022146?v=4","gravatar_id":"","url":"https://api.github.com/users/njkeng","html_url":"https://github.com/njkeng","followers_url":"https://api.github.com/users/njkeng/followers","following_url":"https://api.github.com/users/njkeng/following{/other_user}","gists_url":"https://api.github.com/users/njkeng/gists{/gist_id}","starred_url":"https://api.github.com/users/njkeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njkeng/subscriptions","organizations_url":"https://api.github.com/users/njkeng/orgs","repos_url":"https://api.github.com/users/njkeng/repos","events_url":"https://api.github.com/users/njkeng/events{/privacy}","received_events_url":"https://api.github.com/users/njkeng/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-11T13:55:41Z","updated_at":"2018-11-11T18:06:42Z","closed_at":null,"author_association":"NONE","body":"### Subject of the issue\r\nCustomizable configuration of RaspAP\r\n\r\nHi Bill and Joseph and Lawrence\r\n\r\nI'm keen to add customisation / configuration options and a couple of customisable pages to RaspAP.  These can be used by developers when deploying RaspAP in custom applications and in devices other than pure access points. The enhancements I am proposing will also specifically address issues #91 and #149, but that's not exactly why I'm making the changes.\r\n\r\nFirst, some background:\r\n\r\nI am developing two personal projects at the moment.  The projects are quite different to each other, but I want the bulk of the configuration to use the same mechanism.  The projects I am building need to be configured:\r\n- By non-technical users\r\n- Using a nice-looking interface\r\n- Headless and wireless\r\n- Without a dedicated app, so web based\r\nAfter configuration, the device needs an internet connection, so must remain connected to a local wifi as a client.\r\n\r\nWhen the device is not yet configured by the user, it needs to operate as an access point.  The user can connect to the device's wifi access point and view the device's web pages.  The web pages allow re-configuration of the Pi as a client on a local wifi. After successful wifi connection, the access point is turned off and the device is visible as a web server on the local wifi. Additional configuration or re-configuration is done on the local wifi.  This is great for a non-technical user.  All configuration is done via a pretty interface and needs no special equipment.  Any wifi device that can display web pages will do.\r\n\r\nI didn't know of any such system for RaspberryPi and I assumed I had to develop such a system myself.  I stumbled across your useful project while I was searching for code snippets for configuration of wifi networks. Hey presto, all of the wifi part of the project is done! The web interface looks great on both desktop and mobile devices. \r\n\r\nNow to the mods I want to make to RaspAP.\r\nFor my projects I only need the wifi client functionality from the standard RaspAP.  I need to turn all the other RaspAP pages off, so I want to make all RaspAP pages \"optional\".  I also need to add new configuration pages for which I will develop my own /include/?.php scripts.\r\n\r\nI believe the changes I wish to make will have use for many projects and applications.  That is why I want to contribute my modifications to the RaspAP project.  I'm going to be making these modifications for my purposes anyway, so it's no problem for me to contribute them back to the project.  As examples of where these additional options are extremely useful, the following describes the two projects I am working on.\r\n\r\nTide clock.\r\nI am a keen kayak paddler and an occasional fisherman, so it's important to me to know what the tides are doing.  I am developing a tide \"clock\" that will use RGB LEDS to display the current tide level, whether it's rising or falling, the current temperature and the current wind speed.  I'm going to attempt to display all this on 30 RGB LEDs with some calming, unobtrusive animation, hopefully reminding the viewer of ocean waves. In order to get all of this data, the clock needs to read live values from a web page. The tide clock configuration interface will allow the user to select a web page with data for their location, anywhere on earth. The configuration will also let the user set max and min values for temperature and wind speed.  5degC may be a reasonable temperature for fishing for some people, but it's too cold for me!\r\n\r\nBike helmet camera.\r\nI do a lot of cycling and I'd like to carry a forward-facing camera on my bike.  None of the commercial products suit my needs, so I'm going to build my own using a Pi Zero W.  The configuration interface for this device will allow the user to adjust settings such as video quality, auto shutdown timers and the like.  I also want to implement auto uploading of video to services such as YouTube, Dropbox or in my case, my local NAS. The user will be able to set up these services and test the configuration directly from the configuration page. Whenever the device is within wifi range, all video data will be automatically uploaded to the preferred destination.\r\n\r\nSo as you can see, it would be great if I could hand non-technical people either of these devices in a default state that they could configure the device themselves using only a web browser.  \r\n\r\nOther notes:\r\nWith whatever changes I make, I will ensure that the RaspAP interface will act exactly as it does now unless it is specifically reconfigured by the developer. The interface appears to be mature and has all of the necessary features for a flexible AP. I won't change the functionality of the default interface.  I wish only to add options if a developer chooses to use them.\r\n\r\nOn to the specific changes to RaspAP.\r\n\r\nPart 1: Add RaspAP custom configuration options\r\n\r\nMods to index.php\r\nModify index.php to enable/disable ANY side menu items as per flags set in config.php.  This has already been implemented for TOR relay and OpenVPN, so I will copy this format to look for the new flags.\r\nAdd two new items to the side menu for custom configuration. For usability, add one near the top of the functions list and one near the bottom. Both the custom menu item names and icons will be defined in /includes/config.php\r\nOption to replace the RaspAP banner image with a developer-defined one.  If this option is used, RaspAP will display the user image PLUS the existing RaspAP image.  The text will be changed to \"Powered by RaspAP\" instead of \"RaspAP\".  I'll have to figure out a more suitable class for this text.  It's too big to mix with a second image.\r\n\r\nNew php scripts in the /includes directory\r\nAdd two demo/placeholder functions in the /includes directory, one for each new custom page.\r\nFor both of my own projects, I need to have quite a few configuration inputs.  So, since I need to figure this out anyway, so instead of having blank pages, I may as well do some well-commented general cases as examples. You know, here's how to add a button and a text input field.  Here's how to make tabbed sections.  Here's how to read options data in from a file and write updated data back out to a file.\r\n\r\nMods to /includes/config.php\r\nAdd boolean flags to enable / disable of ALL side menu items.  Ensure default flag values show the menu items as per current Raspap system.\r\nAdd two new placeholder menu items for custom configuration scripts. Add variables so that the developer can assign page names. Perhaps default these to \"Settings\" and \"Advanced\".\r\nAdd variables so that the developer can assign fa- icons from font-awesome.css.  Perhaps default these to \"fa-gear\" and \"fa-star\".\r\nEnable / disable physical reset button. (See issue 2 below)\r\nEnable / disable custom banner image or default RaspAP image.\r\nIMPORTANT: All values will default to the configuration as currently displayed in RaspAP. Anything else will be used only if explicitly enabled by the developer.\r\n\r\nMods to readme.md\r\nUpdate readme.md to indicate that lots of display and customization options are contained in the /includes/config.php file. Explain the new functionality of the flag options and the two custom configuration php menu items.\r\n\r\nOnce again, default values for all of this will make RaspAP look and behave exactly as it does now.\r\n\r\n\r\nPart 2: Physical reset button\r\n\r\nI think this is an extremely useful addition to the RaspAP system regardless of the application.  In the event that the configuration gets stuffed up or if (for example) the SSID of the local wifi changes, the physical reset button will restore all configuration back to default. There will be no need to resort to the terminal to sort things out. This will specifically address issue #149\r\n\r\nMods to common.sh\r\nCurrently, the default config files are MOVED from $webroot_dir/config to their destination folders.  I will change default_configuration() function to COPY these files instead.  Then, when a reset is performed, the original configuration files still reside in the  $webroot_dir/config directory.\r\nWhile I'm modifying common.sh I will correct a few typos where \"raspian\" is used instead of \"raspbian\"\r\n\r\nI want to use a PHP library called PiPHP/GPIO to establish an interrupt for a physical pushbutton installed on a GPIO pin.  The steps to get this going are:\r\nInstall a PHP dependancy manager called Composer. https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md\r\nUse Composer to install PiPHP/GPIO library https://github.com/PiPHP/GPIO\r\nUse a PHP script to monitor a GPIO pin for reset. The script will set up the button as an interrupt.\r\nThe reset input interrupt service routine will re-copy the default configuration files from the $webroot_dir/config directory. Implement this using a new script named /installers/reset.sh.  reset.sh will call default_configuration() from common.sh to copy the default config files back in.\r\n\r\nMods to common.sh\r\nAdd whatever is needed to get Composer and PiPHP/GPIO installed. Add some method of ensuring the reset monitor runs on startup of the pi.\r\n\r\nMods to /includes/system.php\r\nAdd a \"Reset to defaults\" button to compliment the Reboot and Shutdown functions. This will work fine so long as the config is not so stuffed up that you can't see the web pages!\r\n\r\nMods to readme.md\r\nUpdate readme.md.  Indicate that the customization options are contained in the /includes/config.php file. Explain the new functionality and detail the circuitry needed to make this happen.\r\n\r\nOther things to do:\r\n\r\nThe wi-fi client page \"Configure client\" goes way over to the right on mobile device displays, forcing the user to scroll a long way to see all of the fields. I will edit /includes/configure_client.php to reconfigure this page for a more mobile-friendly display. \r\n\r\nNow, because these changes are inter-linked I think it best if I create a single branch and perform all of these changes at once.  Please let me know if you think there's a better way to attack this.\r\n\r\nSo, what do you think?  This is what I need for my projects, but it's a significant change in philosophy to RaspAP as it stands.  I have no idea whether you'll think this change in philosophy is good or bad. Hopefully you can see I've put a fair bit of thought into this already, so I'm comfortable that all of this will work well. Are you interested in me contributing this to the RaspAP project?\r\n\r\nCheers,\r\n\r\nNathan.\r\n"},"comment":{"url":"https://api.github.com/repos/billz/raspap-webgui/issues/comments/437691324","html_url":"https://github.com/billz/raspap-webgui/issues/156#issuecomment-437691324","issue_url":"https://api.github.com/repos/billz/raspap-webgui/issues/156","id":437691324,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzY5MTMyNA==","user":{"login":"PRO2XY","id":4678368,"node_id":"MDQ6VXNlcjQ2NzgzNjg=","avatar_url":"https://avatars3.githubusercontent.com/u/4678368?v=4","gravatar_id":"","url":"https://api.github.com/users/PRO2XY","html_url":"https://github.com/PRO2XY","followers_url":"https://api.github.com/users/PRO2XY/followers","following_url":"https://api.github.com/users/PRO2XY/following{/other_user}","gists_url":"https://api.github.com/users/PRO2XY/gists{/gist_id}","starred_url":"https://api.github.com/users/PRO2XY/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PRO2XY/subscriptions","organizations_url":"https://api.github.com/users/PRO2XY/orgs","repos_url":"https://api.github.com/users/PRO2XY/repos","events_url":"https://api.github.com/users/PRO2XY/events{/privacy}","received_events_url":"https://api.github.com/users/PRO2XY/received_events","type":"User","site_admin":false},"created_at":"2018-11-11T18:06:42Z","updated_at":"2018-11-11T18:06:42Z","author_association":"NONE","body":"Have you since been able to make any of the mods? If so, you could share the code to be reviewed here. "}}
{"actor":{"display_login":"PRO2XY"}}