35 Commits

Author SHA1 Message Date
Joseph Nuthalapati
0f9fe4f111
notifications: Close dropdown when clicking outside
The notifications dropdown does not behave like the other 3 dropdowns in
the navigation bar, but a user would expect it to, since it is also
visually a dropdown like the others.

Added JavaScript for a click listener that would collapse the
notifications dropdown if the user clicks anywhere outside the dropdown
area.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2026-01-10 07:47:21 -05:00
Sunil Mohan Adapa
85f04dde1a
ui: Fix dark theme colors for running status indicator
Tests:

- Insert event.preventDefault() in form submission code for submission buttons.

- For various button styles, submit the form. Running status indicator appears
on the form button. The styles for the indicator is appropriate in dark and
light themes.

  - Calibre delete library confirmation page has btn-danger.

  - Software Update, configuration update button has btn-primary.

  - Software Update, 'update now' button has btn-default.

  - Change a button from btn-primary to btn-link. Running status is not shown
  for this type of button.

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-12-02 20:17:36 -05:00
Sunil Mohan Adapa
00a69108dd
ui: Implement a toggle menu for setting dark mode
- Add a toggle menu for selecting the color scheme. JS code largely taken from
Bootstrap documentation and slightly customized.

- Use local storage to store the setting for dark/light/auto. Default to auto
which means browser level preference is picked up (which could be system level
preference).

Tests:

- Appearance of the toggle menu is consistent. Check box is shown on the
currently selected value.

- Deleting the local storage value reverts the preference to browser set value.

- Menu is collapsed at smaller screen sizes. Appearance and functionality as
expected.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-12-02 20:17:06 -05:00
Sunil Mohan Adapa
e82d959c85
views: Add a menu entry and view for showing logs of an app
Tests:

- View logs menu entry is shown only for apps with daemons. It is now shown for
others such as Backups. It does not add menu for apps such as power.

- View logs entry for Date & Time shows show logs for multiple units. View logs
entry for Nextcloud shows many units.

- The textarea occupies full width. It is not editable. It is always scrolled to
the bottom. Control-A and Control-C selects all the text in it. It is re-sizable
vertically.

- The header shows unit name and unit description correctly.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-18 16:35:23 +03:00
Sunil Mohan Adapa
4e1ee2371f
ui: Fix missing semicolon in JS file
- Mostly for styling and just to fix the linter.

Tests:

- After package availability check in bepasty page, 'Install' button is enabled.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-08-21 10:58:35 +03:00
Joseph Nuthalapati
bdf24d93cd
apps: Fix regression in enabling install button
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-08-02 21:34:52 +05:30
Sunil Mohan Adapa
acd2f515d7
package: Refresh apt cache if old and some packages are not found
Fixes: #1358

- Refresh the apt cache if required packages for an app are not found and if the
cache is more than 1 hour old (or non-existent).

- If required packages are found, don't refresh the package cache even if the
cache is outdated. This is because the check operation could lead to many
minutes of waiting before app can be installed.

Tests:

- Remove /var/lib/apt/lists/* and /var/cache/apt/pkgcache.bin. Visit an app
setup page. apt cache is updated and it take a while to check that the app is
available. App is shown as available. If page is refreshed, this time, the cache
is not updated.

- Set the modification of /var/cache/apt/pkgcache.bin file to more than 2 hours
ago with 'touch -d "2 hours ago" /var/cache/apt/pkgcache.bin'. Then refreshing
the page will not refresh the cache.

- Repeat test with an app that is not available such as Janus. Again apt cache
is refreshed. App is shown as not available. On refresh, the cache is not
updated.

- Set the modification of /var/cache/apt/pkgcache.bin file to more than 2 hours
ago with 'touch -d "2 hours ago" /var/cache/apt/pkgcache.bin'. Then refreshing
the page will not refresh the cache.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>

- Remove redundant if condition in setup.html template
- Use JavaScript fetch() API instead of XMLHTTPRequest class
- Update a comment in test_package.py
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-08-02 21:06:33 +05:30
Sunil Mohan Adapa
1f98dfcad1
setup: Perform a check for app availability after the page loads
- Using AJAX request instead of loading the initial page slowly.

Tests:

- Unit tests passes.

- Deluge app is not available in bookworm and is available in Trixie.

- When app is available, no message is shown. Install button is enabled.

- When app is not available a proper warning alert message is shown. Install
button is disabled.

- During check for the availability, the progress message is shown. Install
button is disabled.

- When Javascript is disabled on the page, no availability check is performed.
Install button is enabled.

- When an exception is raised in the is-available view, error message is shown.
Install button is enabled.

- When is-available view return HTML response, error message is shown. Install
button is enabled.

- When is-available view invalid JSON response, error message is shown. Install
button is enabled.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-08-02 21:06:17 +05:30
Veiko Aasa
92aa66114c
users: Fix unable to delete user
Fixes an issue where confirming user deletion is not submitting the user
edit form.

Also fixes an issue where the user edit submit button is disabled after user
deletion confirmation is cancelled.

Fixes #2513.

Tests performed:
- Deleting a user works.
- All the users module tests pass.
- After cancelling the user deletion confirmation dialog, the user edit
  submit button is clickable.
- On the app pages, submit buttons are disabled when app enabling or disabling
is in progress.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2025-04-15 12:02:15 -07:00
Sunil Mohan Adapa
54b956c602
ui: Drop the temporary fix for missing popper.js 2.0
- Latest version of libjs-bootstrap5 depends on
node-popper2. However, version in Debian bookworm still continue to have
incorrect dependency. So, add explicit dependency on node-popper2 until we stop
supporting Bookworm.

Tests:

- In stable and testing VMs, install node-popper2 and notices that the following
work as expected:
  - User menu dropdown in desktop and mobile layouts.
  - Help menu dropdown in desktop and mobile layouts.
  - Notification dropdown.
  - App extra actions dropdown.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-01-24 11:20:16 +02:00
Sunil Mohan Adapa
9aa81e5c58
ui: Workaround dropdowns not working with Bootstrap 5
- Workaround Debian bug #1087969. popper.js 2.x is needed for Bootstrap 5,
however, the current version on in Debian is 1.x. Implement a Popper 2.x method
that Bootstrap 5 is expecting and translate the call into Popper 1.x.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-12 13:00:15 +02:00
Sunil Mohan Adapa
7ba559a8a9
base.html: Drop dependency on modernizr.js library
- The library performs a large number of tests to determine if various features
are available in the browser. In Debian most tests seem to be present unlike
other methods of distribution where users select which tests they want and build
a customized library for their app. This leads to increased page load time.

- The only functionality we use from Modernizr library are the .js and .no-js
classes we use in our CSS styling. Modernizr is not needed by Bootstrap library.
We don't use 'Modernizr.' properties in Javascript.

- A bug in the test to determine if an <input> element with type="number" allows
localization or not causes the page to scroll down to the end. This behavior
appeared in version 3.x of modernizr and despite the bug report and the fix, it
is not gone. Dropping modernizr fixes this issue.

Tests:

- The logout link in the header bar is visible only when Javascript is disabled.

- The dropdown icons next to header menus only appear when Javascript is
enabled.

- For each feature detection provided by Modernizr library, search if our
project is using that in CSS styling.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-08-07 23:26:32 +03:00
Sunil Mohan Adapa
a150cd15bd
static: js: css: Make multiple select fields work with Django 4.0
Closes: #2228.

- Django 4.0 changed to using <div> instead of using <ul> and <li> for multiple
choice select fields. Update code for the select-all button to work with the new
HTML structure.

- Add styling to ensure that multiple choice select field appears similar to
previous <ul> and <li> based style.

- This patch assumes that django-bootstrap-form has support for Django 4.0 as
seen in https://github.com/tzangms/django-bootstrap-form/pull/110 .

Tests:

- Radio select seem to have no issues. Checked in networks -> connection type
page.

- Open Backups -> Create backup page and ensure that select all button works
and appears same on testing (Django 3.2) and unstable (Django 4.0).

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-07-04 21:03:02 -04:00
Sunil Mohan Adapa
d79f97f752
ui: css: New style for select all checkbox
- Make the box look different from the rest of the options so that this it does
not look like an option without label.

- Give it the appearance of a button so that it is becomes an operation rather
than option.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-01-21 20:33:34 -05:00
Sunil Mohan Adapa
9b8388734d
ui: js: Make select all checkbox option available more broadly
- Make the code work outside backups module.

- Move code to main.js so that any app can use this functionality.

- Make the code work for multiple such form fields in the same page.

- Use only pure JS, don't use jQuery.

- Add event handlers only after DOM content is loaded to avoid race conditions.

Tests performed:

- Checking the select-all button checks all options.

- De-checking the select-all button de-checks all options.

- De-checking one option when everything is checked, de-checks the select-all
button.

- Checking the last option when everything else is checked, checks the
select-all button.

- When loading a schedule page with all options checked, select-all button is
checked.

- When loading a schedule page with some option unchecked, select-all button is
unchecked.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-01-21 20:33:28 -05:00
Veiko Aasa
472590f6fc
javascript: Fix disabled submit buttons when navigating back to a page
When navigating back to a page, enable buttons that were previously
**temporarily** disabled.

Closes #1996

Tested that on the manage snapshots page, when browsing to delete view
and then back, the "Create Snapshot" button is enabled.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-12-19 14:01:33 -08:00
Veiko Aasa
5829fde5f4
templates: Make toggle button responsive
- Immediately after submitting a form with a toggle button, toggle and disable
the button and show a spinner on the button.
- Disable all other form button elements on the page when a form is submitted
to allow only one form submission at a time.

Closes #1993

Tests performed:
- Check that when enabling and disabling an app, the toggle button is responsive
- On the Samba app page, check that when enabling a share, the toggle button is
responsive and all other toggle buttons on the page are disabled.
- On the Samba app page, check that clicking the diagnostics button still works
while a share is being enabled or disabled.
- On the SSH confugration app page, check that after clicking the Update setup button,
a spinner is shown and the app enable/disable toggle button is disabled.
- Test on Firefox and Chromium.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil: Narrow the scope to only toggle buttons excluding others cases]
[sunil: Minor cosmetic and styling changes]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-12-13 19:43:27 -08:00
Sunil Mohan Adapa
4a6a936de4
js: Don't show running status on buttons pulled to right
This prevents incorrect animation for running status on first wizard steps.

Tests:

- In the first boot wizard, network topology step, click next and notice that
the running status does not appear next to 'skip wizard' link.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2020-08-22 10:52:32 +05:30
Sunil Mohan Adapa
3efff2fa42
js: Simplify auto-refresh page logic
- Implement ability to refresh page at the framework level so that every page
does not need to handle it.

- Refresh after number of seconds specified in context of the view.

Tests performed:

- Trigger the following functions and ensure that page reload after 3 seconds
during the running operation while it does refresh before and after the
operation.
  - Diagnostics tests from the module.
  - Gitweb repository cloning.
  - Monkeysphere publish key to server.
  - OpenVPN setup.
  - Tor configuration update.
  - Manual software update.
  - App installation.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-06-29 10:09:04 +03:00
Sunil Mohan Adapa
ff84d3f97e
templates: Disable button and show spinner on submit for all forms
Tests performed:

- Submit a form and notice that button has a spinner soon after click.

- Select a from like Gitweb repository creation form and submit it. After submit
go back to previous form using back button. Notice that button has been restored
to proper state.

- Without filling valid information the form, press submit. Notice that the
button does not change to a spinner.

- Check installing an app, snapshots management, network forms, wireguard forms,
etc.

- Test on Firefox and Chromium.

- Test with LibreJS that the script is accepted as valid free software license.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-06-29 10:08:23 +03:00
Alice Kile
0b5b384651
app: Separate app enable/disable form from config form
- Introduce new API to mark an app that it can't be disabled.

- Mark jsxc, storage, config, upgrade and firewall apps as can't be disabled.

- Fixed functional tests

- Replaced AppForm with forms.Form in all modules' forms.py.

- Remove app.template.js.

- Remove unused styles.

- Remove app status checks in form_valid of Deluge, Diaspora, Matrix, Ejabberd,
MediaWiki, Storage, Transmission, Quassel

- Purge unused is_enabled context variables (Ikiwiki)

- ejabberd: Minor cleanup in template

- jsxc: Cleanup unneeded overrides

- tahoe: Cleanup unnecessary overrides

Tests performed:

- For all apps affected, test enable/disable button works and submitting
configuration form works: with changes updates message and without changes
'settings unchanged' message.
  - avahi
  - bind
  - cockpit
  - SKIP: coquelicot
  - datetime
  - deluge
  - SKIP: diaspora
  - ejabberd
  - gitweb
  - i2p
  - infinoted
  - ikiwiki
  - matrixsynapse
  - mediawiki
  - minetest
  - minidlna
  - mldonkey
  - mumble
  - pagekite
  - privoxy
  - quassel
  - radicale
  - roundcube
  - SKIP: samba
  - searx
  - SKIP: shaarli
  - shadowsocks
  - ssh
  - tahoe
  - transmission
  - FAIL: tt-rss (not installable)
  - wireguard
- Deluge test that configuration changes when app is disabled work
- Quassel test that setting the domain works when app is diabled
- Transmission test that setting the domain works when app is diabled
- Ikiwiki create form works properly
- Enable/disable button appears as expected when enabled and when disabled
- Enable/disable button works without Javascript
- Functional tests work for affected apps, Tor and OpenVPN
- AppForm is removed from developer documentation
  - Forms reference
  - Customizing tutorial
- Test all apps using directory select form
  - Transmission
  - Deluge
- Visit each template that overrides block configuration and ensure that it is
loaded properly and the display is as expected.
- All apps that use AppView that are not tested above should not have an
enable/disable button. That is JSXC, update, config, firewall, storage, users.

Signed-off-by: Alice Kile <buoyantair@protonmail.com>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-03-29 09:42:31 +03:00
Sunil Mohan Adapa
a2f897e33d
*.js: Use SPDX license identifier
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-02-19 14:40:43 +02:00
Veiko Aasa
851d1c7c28
app: Fix javascript doesn't run on first visit
Merge Request !1644 fixed the 'const redeclaration' error but introduced
another issue - javascript on the app configuration page doesn't run
on first visit.

Relates to #1715

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-20 16:38:31 -05:00
Veiko Aasa
06b4a447c6
app: fix javascript constant redeclaration error
Closes #1715

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2019-12-03 00:04:17 +05:30
Alice Kile
a8166bae7e
Fix error with app toggle input
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-01 07:36:41 -05:00
Joseph Nuthalapati
62bcae4975
app: Avoid showing empty configuration block
Several applications whose configuration form only includes an "Enable
application" checkbox look empty with an "Update setup" button when JavaScript
is enabled. Fixed this.

Added license header for LibreJS compliance.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
2019-11-19 00:02:16 +05:30
Alice Kile
1a65c88881
app: Use single form for app toggle and configuration
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2019-11-19 00:02:16 +05:30
Alice Kile
ec62f331b8
app: Implement toggle button in app page
- revamp the old form submission model to enable/disable apps into a
  simple toggle button
- provide backwards compatibility when javascript is disabled

Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2019-11-19 00:02:16 +05:30
Sunil Mohan Adapa
ea037aa944
javascript: Don't resubmit when refreshing the page
This was not caught earlier because the problem was masked by turbolinks usage.

Tests:

- Install an app and see the page refreshing.
- Run manual update and see the page refreshing.
- Update Tor configuration and see the page refreshing.
- Run diagnostics from the diagnostics module and see the page refreshing.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-08-26 17:56:18 -04:00
Prachi Srivastava
f43e185a8c
security: Moves inline javascript to files
Signed-off-by: Prachi Srivastava <prachi.chs.2009@gmail.com>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-01-28 17:39:12 -08:00
Sunil Mohan Adapa
915b8013d9
setup: Reduce refresh time when application is already installed
In the event setup page is being shown after the application installation is
already completed. Immediately reload instead of waiting for 3 seconds are
usual.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-01-14 17:40:26 -05:00
Joseph Nuthalapati
36774c9f41
turbolinks: Reload page using JavaScript
Using the existing meta tag for refresh as a noscript fallback.

Fixes #1350

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-08-12 08:43:11 -04:00
Sunil Mohan Adapa
b5bfb388e9 Remove symlinks to javascript libraries 2015-01-13 12:25:17 +05:30
fonfon
64c1682b2c removed bootstrap2 static files 2014-11-11 22:32:41 +01:00
Sunil Mohan Adapa
c95db2fe7e Move themes directory into static directory 2014-08-30 09:31:46 +05:30