Commit Graph

71 Commits

Author SHA1 Message Date
Friedrich Weber
4fedb4e28d fix #4612: mobile: avoid crash due to missing getProxy method
A previous commit (51083ee) added an override of the internal ExtJS
method `Ext.data.Store.onProxyLoad` in order to fix a race condition.
This override calls `Operation.getProxy`. However, this method is not
available on Sencha Touch. As a consequence, the mobile UI was
broken.

This commit modifies the override such that it has no effect in the
mobile UI.

Fixes: 51083ee54a
Suggested-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
2023-03-26 17:36:55 +02:00
Thomas Lamprecht
c43929212d utils: use template strings for language map
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-03-24 12:24:09 +01:00
Noel Ullreich
58518b154e language selector: translate entries to both native and localized
Languages used to be hardcoded to English, change that to both the
native language plus writing system along with their translation in
the currently selected language.

Signed-off-by: Noel Ullreich <n.ullreich@proxmox.com>
 [ T: drop redundant info from subject and reword a bit ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-03-24 12:24:02 +01:00
Lukas Wagner
64f65c027d repo view: replace non-clickable checkbox with icons
From a usability view, having a checkbox that is not clickable is pretty
misleading, especially if the visual style is exactly the same as in
other places in the UI where the checkbox is functional.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-03-17 11:27:38 +01:00
Stefan Sterz
a017567bd8 utils: move to using the auto theme per default
make the new default theme the "auto" theme that uses media queries to
detect a users preferred theme.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-03-14 15:13:35 +01:00
Daniel Tschlatscher
15fddc20d1 util/window/form: add a theme selector
add a widget that implements a theme selector and sets a cookie to
load the appropriate theme.

Co-authored-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
Co-authored-by: Stefan Sterz <s.sterz@proxmox.com>
Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-03-08 17:49:20 +01:00
Friedrich Weber
51083ee54a fix #4421: ui: guard setProxy against races of slow vs fast requests
Some UI components use `Ext.data.Store.setProxy` to change their
associated API endpoint URL in reaction to user input. One example is
`BackupView`, which calls `setProxy` when the user switches from
listing backups on storage A to listing backups on storage B. However,
if A is slow, the UI may receive the response for A *after* the
response for B. It will then display the contents of A as if they were
the contents of B, resulting in a UI inconsistency.

The reason is that `Ext.data.Store` still processes the slow response
for A, even though it is obsolete. This patch overrides the
responsible callback of `Ext.data.Store` to only process responses
belonging to the currently active proxy object. This should rule out
similar race conditions in all components that use the `setProxy` API.
In the above example, the patch results in the response for A being
ignored.

Ignored responses are logged to the browser console.

Note that this patch only concerns components that use `setProxy` for
changing API endpoints. Other components (e.g. those using
`proxy.setURL` for the same purpose) may be open to similar race
conditions.

Link: https://lists.proxmox.com/pipermail/pve-devel/2023-March/056062.html
Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
2023-03-08 07:42:11 +01:00
Thomas Lamprecht
319d450bec api request: add wide spread alert-error logic as smart-on option
The "smartness" is mostly "enable it automatically if the caller did
not specify an explicit override and there's neither a failure nor
callback function define", but that should cover most cases.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-31 15:56:27 +01:00
Thomas Lamprecht
cf93d1da50 utils: always html-encode response message
while this is something that only the user that made the request will
see, and for most people the possibility of "hacking" themselves is
rather redundant, it is still not nice to have this possible in
general; as even if it's highly unlikely that there ever can be an
error triggered to another user via API2 request handling, hardening
against it is simply to cheap to not do it.

Reported-by: Marcel Fromkorth <marcel.fromkorth@8com.de>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-31 15:41:42 +01:00
Thomas Lamprecht
d53046d66b utils: code cleanup for extractRequestError
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-31 15:34:31 +01:00
Daniel Tschlatscher
8189ce639c Source file download in new Utils function
Adds a function for downloading a file from a remote URL in the Utils
class and uses it to revise one similar usage in FileBrowser.js

Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
Tested-by: Stefan Sterz <s.sterz@proxmox.com>
Reviewed-by: Stefan Sterz <s.sterz@proxmox.com>
2023-01-04 14:32:59 +01:00
Dominik Csapak
2396874180 add tag related helpers
helpers to
* generate a color from a string consistently
* generate a html tag for a tag
* related css classes

contrast is calculated according to SAPC draft:
https://github.com/Myndex/SAPC-APCA

which is likely to become a w3c guideline in the future and seems
to be a better algorithm for this

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-11-16 14:48:44 +01:00
Wolfgang Bumiller
54fc2533c8 simplify cpuset regex
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-10 10:56:03 +01:00
Daniel Bowder
9109c39202 fix #3593: add CpuSet type to js
Regex parses a cpuset via 2 matches. Find number(s) or range(s) folowed
by a comma, then, find a single number or a single range not followed
by a comma. E.g., 0-1,4-5,6,7,10,11,14-15
CpuSet function first checks regex, then ensures left num <= right num

Signed-off-by: Daniel Bowder <daniel@bowdernet.com>
2022-11-10 09:40:00 +01:00
Thomas Lamprecht
96fb7eaacd utils: add inline comment about cookie set-for-clear
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-03-18 15:58:53 +01:00
Dominik Csapak
c1a3584103 utils: clear cookies with secure flag set
otherwise firefox complains with a deprecation warning that the secure-flag
is not set but SameSite to 'None'. Since we cannot know how firefox will
behave once that behaviour is no longer supported, add the secure flag
now.

Note: ExtJS also clears by setting the cookie with an empty value,
there's no browser supported clear api.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-03-18 15:56:20 +01:00
Thomas Lamprecht
017a637682 tree-wide typo fixes
found with `codespell`, mostly comments but also a fn parameter and
an error in an exception message

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-14 11:28:29 +01:00
Matthias Heiserer
e06715d2e5 utils: render default value correctly 2022-02-10 13:08:11 +01:00
Thomas Lamprecht
3ccdce4055 utils: format_duration_human: calculate years too
Add years and skip showing minute scale once we got over a year,
that's just not relevant anymore at that scale..

Months are just not an ideal thing to show, as they have different
lengths too (leap years have similar issue, but they differ 0.27%
from a normal year, while shortest to longest month is 10.7%
difference!)

Weeks could be done though, they're fixed at 7 days, but for now I
want to avoid unwieldy day numbers like 2634 d as that's just hard to
frame correctly. Also adding years now does not makes adding weeks in
the future impossible anyway..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-23 09:39:50 +01:00
Thomas Lamprecht
851ebc36cd utils: add size unit related helpers to parse/auto-scale/format
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-20 21:36:01 +01:00
Thomas Lamprecht
1fad0e8822 bandwidth/utils: move out SizeUnits definition to more common module
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-20 21:35:26 +01:00
Wolfgang Bumiller
c7f2b15ac9 add Utils used for u2f and webauthn
base64url parts copied from pbs
render_u2f_error copied from pve

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-10 08:37:03 +01:00
Stoiko Ivanov
66c5ceb848 acme: allow wildcards as domain
allow wildcard dns-names as defined in [0,1] (only the prefix '*.' in
front of a valid dns-name) as domain.

[0] https://tools.ietf.org/html/rfc8555#section-7.1.3
[1] https://community.letsencrypt.org/t/acme-v2-production-environment-wildcards/55578

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2021-07-13 10:03:14 +02:00
Fabian Ebner
7c65b8bfe0 utils: add helper to format node's repository status
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-07-09 16:58:51 +02:00
Thomas Lamprecht
5c085daf0b add schema and move authDomains there
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-09 16:11:19 +02:00
Dominik Csapak
8f30708d44 add generic OpenIDInputPanel
mostly copied from pve, but includes a realm displayeditfield
as well as the comment field

in contrast to the inputpanel in PVE, this is not extended
from a base input panel (where in pve the comment/realm/default/etc.
fields come from)

we do this, since not all products can define a default or tfa

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-07-09 14:46:27 +02:00
Dominik Csapak
402964713a Utils: add authSchema from PVE and make it overrideable
like we do for the task_descriptions.
This way we can have a basic config that is true for all products
and override where necessary

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-07-09 14:46:27 +02:00
Thomas Lamprecht
fb4bb95e9d utils: fix typo in variable name
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-05 10:11:46 +02:00
Thomas Lamprecht
5b2485ace3 utils: updateColumnWidth: allow overriding tresholdWidth and make that more general
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-05 09:46:58 +02:00
Thomas Lamprecht
8b7e349a25 utils: column width handler: drop duplicate
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-05 09:34:32 +02:00
Dominik Csapak
fbbe68fd69 Utils: add get_health_icon from PVE
we'll need it here too

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-07-02 15:31:25 +02:00
Thomas Lamprecht
cd20320b7f utils: followup: fix base class
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-02 15:17:47 +02:00
Thomas Lamprecht
e722f108aa ui: Utils: refactor userid parsing to Utils
Originally-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-02 15:06:26 +02:00
Thomas Lamprecht
e8c60b3215 utils: add getOpenIDRedirectionAuthorization: to avoid code-duplication
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-02 13:53:11 +02:00
Thomas Lamprecht
b46ad78c2d format/render size: allow one to specifiy if base 2 or 10 is desired
Storage capacity and usage seems to prefer the base ten (SI unit) use
(makes the capacity a bigger number) while memory (RAM) is normally
preferred to use base 2.

So allow both, mostly to allow consistent displaying of metrics.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-07 17:56:04 +02:00
Thomas Lamprecht
ce8289fc58 utils: code cleanup/refactoring
no semantic change intended

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-04 10:27:19 +02:00
Thomas Lamprecht
fc0a18e6c2 utils: add comment note for task descriptions
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-04-30 14:10:55 +02:00
Fabian Ebner
9b4b243aa1 format task status: improve replace() usage
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-04-23 14:37:35 +02:00
Fabian Ebner
9865b73e56 format task status: rename variable
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-04-23 14:37:35 +02:00
Fabian Ebner
4294143f92 task status: create helper for formatting
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-04-23 14:37:35 +02:00
Stefan Reiter
661faeedf5 Utils: add errorCallback to monStoreErrors
Call a function to decide if we want to mask the component. If the
callback returns true, we assume it has already handled the error (i.e.
shown a messagebox or similar) and skip masking.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2021-04-22 17:52:52 +02:00
Thomas Lamprecht
1334cdcabc utils: render_cpu: fix theoretical bug
seems almost like this came from a failed application of the rules of
de-morgan...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-04-22 17:48:41 +02:00
Thomas Lamprecht
9e663a6a64 utils: code cleanup and refactoring
Looks like more change than it actually is, see
`--word-diff=color --word-diff-regex='\w+'`.

The single semantic change is the added space in the render_cpu,
between the maxcpu value and CPU/s text

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-04-22 17:47:41 +02:00
Dominik Csapak
d365540e14 Utils: refactor updateColumns from pve-manager
we want to reuse this in pbs

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-04-22 13:25:22 +02:00
Dominik Csapak
ef3f1cfcc4 Utils: add several render functions from PVE
we need the 'render_cpu_model' and '*_usage' methods in PBS,
the rest are the dependencies

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-04-22 13:25:22 +02:00
Fabian Ebner
64d85d96b3 tasks: add warningsText
to avoid having capitalized 'WARNINGS' (especially since 'Error' is not) and
support different languages.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-03-24 07:01:55 +01:00
Thomas Lamprecht
106fe29ef2 utils: async api: reject with whole failure response and add helper to alert it
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-03-23 11:26:17 +01:00
Thomas Lamprecht
c2c12542d7 utils: copy over async helpers
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-03-22 16:17:56 +01:00
Wolfgang Bumiller
25680ef503 Utils: add ACME related utilities
copied from PVE with linter fixups

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-03-16 12:25:58 +01:00
Dominic Jäger
7bff067a38 vlan edit: Fix automatic field disabling
The regex are are created as literals (with // and not new RegExp).
Therefore
 - The old Vlan_match value with double \\  has matched e.g. vlan\ddd instead
   of e.g. vlan123 and
 - the old VlanInterface_match value with double \\ has matched e.g.
   \www\X\dddd instead of e.g. vmbr0.1234

This fixes automatically disabling the fields vlan-raw-device and vlan-id (VLAN
tag) in the VLAN edit window.

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
2021-02-09 13:45:11 +01:00