Compare commits

..

188 Commits

Author SHA1 Message Date
b-Nollet
aa57fbf15b removing unecessary line 2024-02-14 09:57:56 +01:00
b-Nollet
f89ef1db40 suggested changes 2024-02-12 11:21:32 +01:00
b-Nollet
fe4568bfe4 feat(xo-server): testing https to accept specific certificate 2024-02-08 09:46:20 +01:00
Julien Fontanet
287378f9c6 fix(xo-web): changing items per page should select page 1
Fixes #7350
2024-02-07 16:03:53 +01:00
b-Nollet
83a94eefd6 fix(xo-server-load-balancer): error during optimize (#7362)
Introduced by d949112

Fixes #7359
2024-02-07 15:48:10 +01:00
Julien Fontanet
92fc19e2e3 fix(xo-server/api): never log proxy.getApplianceUpdaterState
Due to xo-web's subscription, there can be a lot of errors in case of XO Proxy failures.
2024-02-07 11:42:21 +01:00
Julien Fontanet
521d31ac84 feat(xo-server/logs-cli): display number of deleted entries 2024-02-07 11:42:21 +01:00
Florent BEAUCHAMP
2b3ccb4b0e fix(xo-server/vm.importFromEsxi): userdevice is a string (#7361)
Introduced by 59cc418973

From zammad#82017 and other tickets
2024-02-07 10:24:50 +01:00
Julien Fontanet
2498a4f47c feat: release 5.91.1 2024-02-06 17:18:47 +01:00
Julien Fontanet
dd61feeaf3 feat(xo-server): 5.135.1 2024-02-06 16:41:06 +01:00
Julien Fontanet
7851f8c196 feat(@xen-orchestra/xva): 1.0.2 2024-02-06 16:41:05 +01:00
Julien Fontanet
404a764821 feat(@xen-orchestra/immutable-backups): 1.0.1 2024-02-06 16:40:52 +01:00
Florent Beauchamp
59cc418973 fix(xva): disk order import 2024-02-06 15:00:08 +01:00
Florent Beauchamp
bc00551cb3 fix(xva): off by one
if last block is not already written we must write it, not the next bloxk
2024-02-06 15:00:08 +01:00
Florent Beauchamp
4d24248ea2 fix(xva): missing await 2024-02-06 15:00:08 +01:00
Florent BEAUCHAMP
5c731fd56e fix(xva): align block size 2024-02-06 15:00:08 +01:00
Florent BEAUCHAMP
79abb97b1f fix(xva): last block path
the last block may be added by a different code path where the block counter wasn't padded, leading to trying to allocate a few Ettabytes
2024-02-06 15:00:08 +01:00
Florent BEAUCHAMP
3314ba6e08 fix(xva): write block from time to time to handle timeout
when the source VM is very sparse, a long time can pass between write to xapi, triggering a timeout
2024-02-06 15:00:08 +01:00
Florent Beauchamp
0fe8f8cac3 fix(xo-server/migrate-vms): use thin mode for vhdraw
when importing a snapshot, the parent (raw) does not need to go through a full read
to generate a thin BAT
2024-02-06 15:00:08 +01:00
Julien Fontanet
aaffe8c872 fix(xo-server/rest-api): fix incorrect object's tasks href
Introduced by f3c5e817a

`req.baseUrl` is already handled by `sendObjects`.
2024-02-05 13:38:14 +01:00
Julien Fontanet
cf0e820632 fix(xo-server/rest-api): fix empty object's tasks list
Introduced by 1da05e239

Since task data were moved into properties, the relation between an object and
its tasks was incorrectly checked which led to an abnormal empty tasks list.
2024-02-05 13:38:14 +01:00
Julien Fontanet
82fdfbd18b fix(xo-server/_createProxyVm): {,_}getOrWaitObject
Introduced by 48c3a65cc
2024-02-05 13:38:14 +01:00
OlivierFL
116f2ec47a fix(ISSUE_TEMPLATE/bug_report): verbatim error field (#7357) 2024-02-05 12:42:16 +01:00
Julien Fontanet
5d4723ec06 fix(xo-server/vm.import): fix fetching UUID from ref
Introduced by 70b09839c
Reported by @ydirson

This led to `UUID_INVALID(VM, OpaqueRef:...)` when importing from URL.
2024-02-02 16:47:55 +01:00
Julien Fontanet
092475d57f chore: update to tap@18 2024-02-02 12:52:11 +01:00
Julien Fontanet
e7a97fd175 test(audit-core,predicates,otp,xo-server): move from tap to test
Support of Mocha syntax is much easier than in latest versions of tap
2024-02-02 12:52:11 +01:00
Julien Fontanet
2262ce8814 chore(async-each): remove unused dev dep tap 2024-02-02 12:52:11 +01:00
Julien Fontanet
7ec64476a4 chore: remove unused script ci 2024-02-02 12:52:02 +01:00
Julien Fontanet
bbb43808dd fix(ci): run unit tests 2024-02-02 12:52:02 +01:00
Florent Beauchamp
02d7f0f20b fix(immutable-backups): handle index files too big 2024-02-02 11:28:28 +01:00
Florent Beauchamp
e226db708a fix(immutable-backups): since index is not immutable anymore we should consider an EPERM Error as relevantt 2024-02-02 11:28:28 +01:00
Florent Beauchamp
b7af74e27e fix(immutable-backups): fix variable name errors 2024-02-02 11:28:28 +01:00
Florent Beauchamp
70f2e50274 fix(immutable-backups): index files aren't immutable anymore 2024-02-02 11:28:28 +01:00
Florent Beauchamp
619b3f3c78 test(immutable-backups): add missing tests 2024-02-02 11:28:28 +01:00
Florent Beauchamp
ac182374d6 fix(immutable-backups): tests
introduced by ed7046c1ab
these tests need to be run by root in a linux system => move them to integ.mjs
2024-02-02 11:28:28 +01:00
Florent BEAUCHAMP
8461d68d40 fix(xva): use a buildless dependency for hashes (#7348)
Native dependencies can have some problems on closed systems

Introduced by 2d047c4fef
2024-02-01 16:30:57 +01:00
Julien Fontanet
838f9a42d1 feat: release 5.91.0 2024-01-31 17:59:34 +01:00
Julien Fontanet
a9dbc01b84 feat(xo-web): 5.136.0 2024-01-31 17:34:53 +01:00
Julien Fontanet
5daf269ab3 feat(xo-server): 5.135.0 2024-01-31 17:34:41 +01:00
Julien Fontanet
383677f4dd feat(xo-cli): 0.26.0 2024-01-31 17:33:13 +01:00
Julien Fontanet
28ad2af9b0 feat(@xen-orchestra/proxy): 0.26.45 2024-01-31 17:25:02 +01:00
Julien Fontanet
53b25508af feat(@xen-orchestra/immutable-backups): 1.0.0 2024-01-31 17:22:51 +01:00
Julien Fontanet
54836ec576 fix(immutable-backups): package should be public
Introduced by ed7046c1a
2024-01-31 17:22:04 +01:00
Julien Fontanet
c9897166e0 feat(@xen-orchestra/backups): 0.44.6 2024-01-31 17:18:52 +01:00
Julien Fontanet
1b35fddf3d feat(@xen-orchestra/fs): 4.1.4 2024-01-31 17:16:15 +01:00
MlssFrncJrg
fc2ca1f4d4 fix(xo-web/pool/advanced): added delete button in backup/migration network (#7349)
Introduced by 0f1f459
2024-01-31 17:00:45 +01:00
Florent BEAUCHAMP
ed7046c1ab feat: immutable backups (#6928) 2024-01-31 16:57:28 +01:00
Julien Fontanet
215579ff4d fix(fs/Local#readFile): fix flags handling 2024-01-31 16:50:29 +01:00
Julien Fontanet
4c79a78a05 fix(fs): remove unnecessary/incorrect readFile param 2024-01-31 16:47:33 +01:00
Julien Fontanet
7864c05ee1 fix: race condition between normalize-packages and usage-to-readme
The first was writting `package.json` at the same time the second one was reading it.

The file is now read only once by `normalize-packages`.
2024-01-31 16:22:07 +01:00
Julien Fontanet
1026d18e4b fix(usage-to-readme): remove another debug log
Introduced by a62433081
2024-01-31 16:10:42 +01:00
Julien Fontanet
d62acd3fe7 fix: format with Prettier 2024-01-31 15:54:43 +01:00
Julien Fontanet
cc1b4bc06c feat(xo-server/rest-api): add pool action create_vm
Fixes #6749
2024-01-31 15:07:01 +01:00
Julien Fontanet
d45f843308 feat(xo-cli/rest): dot syntax for deep properties
`foo.bar=baz` can be used instead of `foo=json:'{ "bar": "baz" }'`.
2024-01-31 15:04:34 +01:00
b-Nollet
3c7fa05c43 feat: technical release (#7347) 2024-01-31 13:56:02 +01:00
MlssFrncJrg
05df055552 feat(xo-web/xostor): expose ignoreFileSystems at creation (#7338) 2024-01-31 13:07:24 +01:00
Pierre Donias
755b206901 chore(web): use relative asset URLs (#7337) 2024-01-31 11:51:40 +01:00
Julien Fontanet
3360399b2a fix(usage-to-readme): remove debug logs
Introduced by a62433081
2024-01-31 10:15:37 +01:00
Florent BEAUCHAMP
091bc04ace fix(xo-server): import of @xen-orchestra/xva package (#7346)
Fix https://github.com/vatesfr/xen-orchestra/issues/7344
Introduced by 2d047c4fef

Cause: we did not run the normalize-package command after renaming
2024-01-31 09:58:34 +01:00
Florent Beauchamp
3ab2a8354b feat(xo-web/import): all the import are thin, remove toggle 2024-01-30 18:54:46 +01:00
Florent Beauchamp
2d047c4fef feat(vmware/import): use xva to load base disk 2024-01-30 18:54:46 +01:00
Florent Beauchamp
0f1dcda7db feat(vmware-explorer): don't read from parent when delta block is already complete 2024-01-30 18:54:46 +01:00
Florent Beauchamp
44760668a3 feat(vmware-explorer): batch reading for sesparse delta 2024-01-30 18:54:46 +01:00
Julien Fontanet
a4023dbc54 feat(ci): ensure yarn.lock is up-to-date 2024-01-30 18:33:25 +01:00
Julien Fontanet
3cad7e2467 fix(yarn.lock): refresh
Introduced by 2e6f7d35e
2024-01-30 17:49:46 +01:00
Julien Fontanet
ad5f37436a fix(CHANGELOG.unreleased): add xo-server@minor
Introduced by 06d411543
2024-01-30 17:35:46 +01:00
MlssFrncJrg
8c05eab720 feat(xo-web/pool/patches): disable rolling pool update button (#7294)
Fixes https://github.com/vatesfr/xen-orchestra/issues/6415
2024-01-30 17:30:36 +01:00
Florent BEAUCHAMP
4db605f14a fix(backups/formatVmBackup): handle snapshotless backups (#7342)
Introduced by b48d955c44
2024-01-30 17:25:59 +01:00
MlssFrncJrg
06d411543a feat(xo-web/SR): add possibility to create SMB shared SR (#7330)
Fixes #991
2024-01-30 17:24:31 +01:00
MlssFrncJrg
6084db22a9 fix(xo-web/import/disk): can't change file name when importing from URL (#7332)
Fixes [#7326](https://github.com/vatesfr/xen-orchestra/issues/7326)
2024-01-30 15:04:27 +01:00
Thierry Goettelmann
2e6f7d35ef feat(xo6): setup file based router (#7318) 2024-01-30 11:31:58 +01:00
MlssFrncJrg
0f1f45953c fix(xo-web/pool/advanced): show backup/migration network even when deleted (#7303) 2024-01-30 11:28:43 +01:00
b-Nollet
89a4de5b21 feat: technical release (#7341) 2024-01-30 09:51:24 +01:00
Julien Fontanet
32dd16114e fix(xo-web/backup): smart mode preview should ignore xo:no-bak tags (#7331)
Introduced by 87a9fbe23

Fixes https://xcp-ng.org/forum/post/69797
2024-01-29 15:56:43 +01:00
Julien Fontanet
f5a3cc0cdb fix(xo-server/rest-api): handle empty fields param
Introduced by c18373bb0
2024-01-29 11:57:47 +01:00
Julien Fontanet
5cabf9916a feat(xo-server/rest-api): expose actions' params schema 2024-01-29 11:08:38 +01:00
OlivierFL
8e65ef7dbc feat(xo-web/logs): transform objects UUIDs into clickable links (#7300)
In Settings/Logs modals : transform objects UUIDs into clickable links, leading
to the corresponding object page.
For objects that are not found, UUID can be copied to clipboard.
2024-01-26 17:28:30 +01:00
Mathieu
0c0251082d feat(xo-web/pool): ability to do a rolling pool reboot (#7243)
Fixes #6885
See #7242
2024-01-26 17:08:52 +01:00
Pierre Donias
c250cd9b89 feat(xo-web/VM): ability to add custom notes (#7322)
Fixes #5792
2024-01-26 14:59:32 +01:00
Florent BEAUCHAMP
d6abdb246b feat(xo-server): implement rolling pool reboot (#7242) 2024-01-25 17:50:34 +01:00
Pierre Donias
5769da3ebc feat(xo-web/tags): add tooltips on xo:no-bak and xo:notify-on-snapshot tags (#7335) 2024-01-25 10:27:42 +01:00
Julien Fontanet
4f383635ef feat(xo-server/rest-api): validate params 2024-01-24 11:41:22 +01:00
Julien Fontanet
8a7abc2e54 feat(xo-cli/rest): display error response body 2024-01-24 11:23:43 +01:00
Julien Fontanet
af1650bd14 chore: update dev deps 2024-01-24 10:54:02 +01:00
Julien Fontanet
c6fdef33c4 feat(xo-server): web signin with auth token in query string (#7314)
Potential issue: the token stays in the browser history.
2024-01-24 10:02:38 +01:00
Florent BEAUCHAMP
5f73f09f59 feat(fuse-vhd): implement cli (#7310) 2024-01-23 17:14:18 +01:00
Thierry Goettelmann
1b0fc62e2e feat(xo6): introducing @xen-orchestra/web (#7309)
Introduces `@xen-orchestra/web`, which will be the home for the new incoming
Xen Orchestra v6.

It uses `@xen-orchestra/web-core` as a foundation.

Upgraded common dependencies of Lite/Web/Core.
2024-01-23 11:25:18 +01:00
Julien Fontanet
aa2dc9206d chore: format with Prettier
Introduced by 85ec26194
2024-01-23 11:02:28 +01:00
Mathieu
2b1562da81 fix(xo-server/PIF): IPv4 reconfiguration only worked when mode was updated (#7324) 2024-01-23 10:55:37 +01:00
Mathieu
25e270edb4 feat(xo-web,xo-server/tag): add colored tag (#7262) 2024-01-23 09:46:06 +01:00
MlssFrncJrg
51c11c15a8 feat(xo-web/pool): disable Rolling Pool Update if pool has 1 host (#7286)
See #6415
2024-01-22 11:04:38 +01:00
Julien Fontanet
47922dee56 fix(xo-server/patching): fix typo
Introduced by 901f7b3fe

Fixes #7325
2024-01-20 09:35:48 +01:00
Julien Fontanet
3dda4dbaad chore: format with Prettier 2024-01-19 16:42:10 +01:00
Julien Fontanet
901f7b3fe2 chore(xo-server): remove object properties decorator syntax
This syntax is not supported by Prettier.
2024-01-19 16:42:10 +01:00
Julien Fontanet
774d66512e feat(decorate-with): decorateObject() 2024-01-19 16:42:10 +01:00
b-Nollet
ec1669a32e feat(xo-server-load-balancer): limit concurrent migrations (#7297)
Fixes #7084
2024-01-19 16:37:55 +01:00
Florent BEAUCHAMP
bbcd4184b0 feat(xo-web,backups): fix dynamic disks count with suspend_VDI (#7315)
`suspend_VDI` was counted as a dynamic VHD.

This commit ignores it in the computation, but add a tag if the backup is with memory.
2024-01-19 16:34:06 +01:00
Mathieu
85ec26194b feat(xo-web/host): ask for confirmation to reboot the updated slave host if the master is not (#7293)
Fixes #7059

In case a slave host requires a reboot to apply updates and the master is using
the same version as the slave host, a confirmation modal is triggered.
2024-01-19 11:18:40 +01:00
MlssFrncJrg
f0242380ca feat(xo-web/tab-advanced): allow to update VM creator (#7276)
Related to [forum#7313](https://xcp-ng.org/forum/topic/7313/change-created-by-and-date-information)
2024-01-19 10:40:08 +01:00
Julien Fontanet
a624330818 fix(usage-to-readme): fix multiple .USAGE.md changes 2024-01-19 10:23:52 +01:00
Julien Fontanet
3892efcca2 feat(xo-web/plugins): auto-load follow load/unload (#7317)
Loading, or unloading, will respectively enable, or disable, _Auto-load at server start_,
this should lead to least surprising behaviors.
2024-01-19 09:55:36 +01:00
Mathieu
c1c122d92c feat(xo-web/pool/host): add warning if hosts don't have the same version (#7280)
Fixes #7059
2024-01-18 17:13:57 +01:00
Julien Fontanet
b7a66e9f73 chore(web-core): add missing npmignore
Follow-up of d92d2efc7
2024-01-18 13:29:30 +01:00
Julien Fontanet
d92d2efc78 chore(web-core): normalize package.json 2024-01-18 12:39:39 +01:00
Julien Fontanet
c2cb51a470 feat(lint-staged): add .USAGE.md → README.md
So that it's not needed to manually runs from `normalize-packages.js`.
2024-01-18 12:34:23 +01:00
Thierry Goettelmann
5242affdc1 feat(lite): introducing @xen-orchestra/web-core (#7302)
This PR introduces `@xen-orchestra/web-core`, which will be the common base for
XO Lite and XO 6.

This package is not meant to be distributed and will be used as-is in other
packages thanks to Yarn Workspace. This mean that the files of XO Web Core will
not be built by themselves but by either the package which use it.

Styles have been moved from XO Lite to XO Web Core.

Colors variable have been renamed and updated according to the new Design
System. XO Lite has been updated accordingly.
- `extra-blue` → `purple`
- `green-infra` → `green`
- `orange-world` → `orange`
- `red-vates` → `red`
- `blue-scale` → `grey`

⚠️ A new intermediate shade has been introduced (`--color-grey-400`). So
`--color-blue-scale-400` is now `--color-grey-500` and `--color-blue-scale-500`
is now `--color-grey-600`.

PostCSS color function plugin is used to generate the shades of color like it is
done on the Figma mockup (with blending the base color with black or white at
different degrees).

PostCSS custom media are now loaded globally thanks to a plugin and no longer
require to import `_responsive.pcss` file manually in each file where a custom
media was needed.
2024-01-18 10:04:25 +01:00
Dom Del Nano
71f3be288b feat(xo-server): add xenStoreData to XO VM objects (#7316)
The initial support added in #7055 to support terraform resource support doesn't provide read access to a VM's state.

Since Tterraform's model requires read and write access to the resource it's managing, this PR implements the missing piece for terra-farm/terraform-provider-xenorchestra#261.
2024-01-17 10:24:08 +01:00
OlivierFL
58769815b0 fix(xo-web/modal): close modal when navigating to another url (#7301) 2024-01-16 20:47:21 +01:00
Florent BEAUCHAMP
c81c23c0d0 fix(fuse-vhd): potential race condition in mount/unmount (#7312)
The code was not properly waiting mount/unmount to be done.
2024-01-16 18:27:30 +01:00
Julien Fontanet
f06f89b5b4 feat(self-signed): readCert utility (#7282)
Expired certificates are not automatically detected, which is not a big deal for user certificates because they can still be used and it's their responsibility to update them.

But automatic certificates must be regenerated in that case which was not the case until now.

This commit unifies certificate/key reading, checking and generation for both xo-server and xo-proxy.
2024-01-16 16:58:15 +01:00
Julien Fontanet
fa748ed9de feat(xo-server): load plugins from mono-repo
Contrary to 3e3ce543a8, which was reverted,
this implentation properly handle duplicates.
2024-01-16 15:54:12 +01:00
Julien Fontanet
cd753acff7 feat(xo-server): move plugin lookup paths to config 2024-01-16 15:51:45 +01:00
Julien Fontanet
8ff861e2be feat(xo-server): find plugins sequentially
This provides a deterministic order.

In case of duplicate plugins (with the same name), the first found plugin takes precedence.
2024-01-16 15:31:03 +01:00
Julien Fontanet
95ccb2e0ae feat(gitignore): ignore .tap/ 2024-01-16 14:02:33 +01:00
John P. Cooper
b0e5846ad1 feat(lite): introduce PWA manifest (#7291)
This implements the initial PWA manifest for XO Lite. I requested this several
months to a year ago, so decided to do it myself in the end.
2024-01-16 11:19:10 +01:00
OlivierFL
19fd456ccf fix(xo-web/metadata-restore-modal): add check to hide pool select when restoring xo config backup (#7287)
See https://xcp-ng.org/forum/topic/8130/xo-configbackup-restore
2024-01-16 11:13:01 +01:00
Julien Fontanet
7946a7db68 feat(xo-server/signin): uniformize sign in buttons
Make sign in with password button the same as external providers.
2024-01-16 10:36:04 +01:00
Julien Fontanet
6127e30574 feat(xo-server/signin): remember me with external providers
It works the same as password signin.
2024-01-16 10:36:04 +01:00
Julien Fontanet
4aad9d8e32 fix(xo-server-backup-reports): require Node>=15
Introduced by 2af74008b

Due to using AggregateError.
2024-01-16 10:10:42 +01:00
Julien Fontanet
78d15ddf96 chore: update dev deps 2024-01-16 09:59:16 +01:00
Pierre Donias
302f7fb85e fix(xo-web/new-vm): isDiskTemplate → _isDiskTemplate (#7311) 2024-01-15 16:51:55 +01:00
Thierry Goettelmann
ea19b0851f feat(lite): upgrade deps + root eslint config (#7292) 2024-01-15 11:12:53 +01:00
Julien Fontanet
b0c37df8d7 fix(xo-server/rest-api): /backup/log/<id>
Introduced by 037e1c1df

Fixes https://xcp-ng.org/forum/post/69426
2024-01-11 11:05:00 +01:00
Julien Fontanet
beba6f7e8d chore: format with Prettier 2024-01-11 09:57:28 +01:00
Julien Fontanet
9388b5500c chore(xo-server/signin): remove empty div 2024-01-10 17:17:42 +01:00
Julien Fontanet
bae8ad25e9 feat(xo-web/tasks): hide /rrd_updates by default
After an internal discussion with @Darkbeldin and @olivierlambert.
2024-01-10 16:50:03 +01:00
Julien Fontanet
c96b29fe96 docs(troubleshooting): explicit sudo with xo-server-recover-account 2024-01-10 16:48:34 +01:00
Julien Fontanet
9888013aff feat(xo-server/rest-api): add pool action emergency_shutdown
Fixes #7277
2024-01-10 15:55:14 +01:00
Julien Fontanet
0bbb0c289d feat(xapi/pool_emergencyShutdown): new method
Related to #7277
2024-01-10 15:55:14 +01:00
Julien Fontanet
80097ea777 fix(backups/RestoreMetadataBackup): fix data path resolution
Introduced by ad46bde30

Fixes https://xcp-ng.org/forum/post/68999
2024-01-10 15:39:41 +01:00
Julien Fontanet
be452a5d63 fix(xo-web/jobs/new): reset params on method change
Fixes https://xcp-ng.org/forum/post/69299
2024-01-10 14:05:02 +01:00
Julien Fontanet
bcc0452646 feat(CODE_OF_CONDUCT): update to Contributor Covenant 2.1 2024-01-09 16:36:29 +01:00
Julien Fontanet
9d9691c5a3 fix(xen-api/setFieldEntry): avoid unnecessary MAP_DUPLICATE_KEY error
Fixes https://xcp-ng.org/forum/post/68761
2024-01-09 15:10:37 +01:00
Julien Fontanet
e56edc70d5 feat(xo-cli): 0.24.0 2024-01-09 14:29:24 +01:00
Julien Fontanet
d7f4d0f5e0 feat(xo-cli rest get): support NDJSON responses
Fixes https://xcp-ng.org/forum/post/69326
2024-01-09 14:24:48 +01:00
Julien Fontanet
8c24dd1732 fix(xapi/host_smartReboot): disable the host before fetching resident VMs
Otherwise it might leads to race condition where new VMs appear on the
host but are ignored by this method.
2024-01-08 17:11:21 +01:00
Julien Fontanet
575a423edf fix(xapi/host_smartReboot): resume VMs even if host was originally disabled
The host will always be enabled after this method anyway.
2024-01-08 17:09:53 +01:00
Julien Fontanet
e311860bb5 fix(xapi/host/waitAgentRestart): wait for enabled status 2024-01-08 17:05:30 +01:00
Julien Fontanet
e6289ebc16 docs(rest-api): update TOC 2024-01-08 16:15:32 +01:00
Julien Fontanet
013e20aa0f docs(rest-api): task monitoring 2024-01-08 16:14:20 +01:00
Julien Fontanet
45a0a83fa4 chore(CHANGELOG.unreleased): sort packages 2024-01-08 14:46:17 +01:00
Guillaume de Lafond
ae518399fa docs(configuration): useForwardedHeaders (#7289) 2024-01-08 11:35:24 +01:00
Ronan Abhamon
d949112921 fix(load-balancer): bad comparison to evaluate migration in perf plan (#7288)
Memory is compared to CPU usage to migrate VM in performance plan context.

This condition can cause unwanted migrations.
2024-01-08 11:25:40 +01:00
Manon Mercier
bb19afc45c Update backups.md (#7283)
This change follows a discussion with Marc Pezin and Yannick on Mattermost.

As Yannick pointed out, the doc refers to a remote while there is no such option in XO GUI.
2024-01-06 15:25:51 +01:00
Julien Fontanet
7780cb176a fix(backups/_MixinXapiWriter#healthCheck): add_tag → add_tags
Fixes https://xcp-ng.org/forum/post/69156

Introduced by a5acc7d26
2024-01-06 15:16:51 +01:00
Julien Fontanet
74ff64dfb4 fix(xo-server/collection/redis#_extract): properly ignore missing entries
Introduced by d8280087a

Fixes #7281
2024-01-05 13:53:46 +01:00
Julien Fontanet
9be3c40ead feat(xo-server/collection/redis#_get): return undefined if missing
Related to #7281
2024-01-05 13:52:45 +01:00
OlivierFL
0f00c7e393 fix(lite): typings errors when running yarn type-check (#7278) 2024-01-04 11:33:30 +01:00
OlivierFL
95492f6f89 fix(xo-web/menu): don't subscribe to proxies if not admin (#7249) 2024-01-04 11:05:53 +01:00
Olivier Floch
046fa7282b feat(xo-web): open github issue url with query params when clicking on bug report button 2024-01-04 11:04:27 +01:00
Olivier Floch
6cd99c39f4 feat(github): add github issue form template 2024-01-04 11:04:27 +01:00
Julien Fontanet
48c3a65cc6 fix(xo-server): VM_import() returns ref, not record
Introduced by 70b0983
2024-01-04 09:36:42 +01:00
OlivierFL
8b0b2d7c31 fix(xo-web/menu): don't subscribe to unhealthy vdi chains if not admin (#7265) 2024-01-03 18:11:34 +01:00
Julien Fontanet
d8280087a4 fix(xo-server/collection/redis#_extract): don't ignore empty records 2024-01-03 17:11:50 +01:00
Julien Fontanet
c14261a0bc fix(xo-cli): close connection on sign in error
Otherwise the CLI does not stop.
2024-01-03 17:06:29 +01:00
Julien Fontanet
3d6defca37 fix(xo-server/emergencyShutdownhost): disable host first 2024-01-03 16:26:07 +01:00
Julien Fontanet
d062a5175a chore(xo-server/emergencyShutdownhost): unnecessary var 2024-01-03 16:25:12 +01:00
Julien Fontanet
f218874c4b fix(xo-server/_createProxyVm): {this → _app}.getObject
Fixes zammad#20646

Introduced by 70b0983
2024-01-03 10:58:19 +01:00
Julien Fontanet
b1e879ca2f feat: release 5.90.0 2023-12-29 11:03:07 +01:00
Julien Fontanet
c5010c2caa feat(xo-web): 5.133.0 2023-12-29 10:48:02 +01:00
Julien Fontanet
2c40b99d8b feat(xo-web): scoped tags (#7270)
Based on #7258 developed by @fbeauchamp.

- use inline blocks to respect all paddings/margins
- main settings are in easily modifiable variables
- text color is either black or white based on the background color luminance
- make sure tags and surrounding action buttons are aligned
- always display value in black on white
- delete button use tag color if dark, otherwise black
- Tag component accept color param
2023-12-28 23:10:35 +01:00
Mathieu
0d127f2b92 fix(lite): fix changelog entry (#7269) 2023-12-28 15:56:21 +01:00
Mathieu
0464886e80 feat(lite): 0.1.7 (#7268) 2023-12-28 15:49:09 +01:00
Mathieu
d655a3e222 feat: technical release (#7266) 2023-12-27 16:07:51 +01:00
b-Nollet
579f0b91d5 feat(xo-web,xo-server): restart VM to change memory (#7244)
Fixes #7069

Add modal to restart VM to increase memory.
2023-12-26 23:46:43 +01:00
Florent BEAUCHAMP
72b1878254 fix(vhd-lib/createStreamNbd): skip original table offset before overwriting (#7264)
Introduced by fc1357db93
2023-12-26 22:29:24 +01:00
MlssFrncJrg
74dd4c8db7 feat(lite/nav): display VM count in host when menu is minimized (#7185) 2023-12-26 13:30:23 +01:00
mathieuRA
ef4ecce572 feat(xo-server/PIF): add XO tasks for PIF.reconfigureIp 2023-12-26 11:22:35 +01:00
mathieuRA
1becccffbc feat(xo-web/host/network): display and edit the IPv6 PIF field 2023-12-26 11:22:35 +01:00
mathieuRA
b95b1622b1 feat(xo-server/PIF): PIF.reconfigureIp handle IPv6 2023-12-26 11:22:35 +01:00
Manon Mercier
36d6e3779d docs: XenServer → XCP-ng/XenServer (#7255)
I would like to replace every "XenServer" I find in the doc by "XCP-ng/XenServer".

This follows an internal conversation we had with Olivier and Yann.
2023-12-26 11:21:16 +01:00
Pierre Donias
b0e000328d feat(lite): XOA quick deploy (#7245) 2023-12-22 15:58:54 +01:00
Pierre Donias
cc080ec681 feat: technical release (#7259) 2023-12-22 15:05:17 +01:00
Julien Fontanet
0d4cf48410 feat(xo-cli rest): explicit error if not registered
Fixes https://xcp-ng.org/forum/post/68698
2023-12-22 11:33:08 +01:00
OlivierFL
2ec164c560 feat(xo-web/menu): add warning icon in proxies menu (#7237)
See Zammad#19126

Add a warning icon in Proxies menu if unable to check proxy upgrade
2023-12-22 09:53:00 +01:00
b-Nollet
d38dce9302 feat(xo-server/vm.stop): add forceShutdownDelay (#7247) 2023-12-22 09:13:36 +01:00
Florent BEAUCHAMP
4c775f6b86 fix(xo-server): missing data in mirror backup job (#7254)
Mirror Backup jobs weren't storing all the data necessary for sending the report
2023-12-21 17:39:39 +01:00
b-Nollet
dd6c858737 fix(xo-server): replacing wrong param name (#7256)
Introduced by 1da05e239d

When the `Task` class is imported from `@vates/tasks`, `Task.run()` parameter uses `properties` key instead of `data` . This is corrected in this PR.
2023-12-21 17:38:58 +01:00
Julien Fontanet
194db8d0dd fix(xo-server/Redis#{add,update}): return complete record
Introduced by 32afd5c46

Fixes https://xcp-ng.org/forum/post/68664

The returned record should not be serialized and should contain the identifier.
2023-12-21 15:47:11 +01:00
Julien Fontanet
5b00cf3ecd chore(xo-server/PluginMetadata#merge): don't return record 2023-12-21 15:47:11 +01:00
Julien Fontanet
afa957b305 chore(xo-server/updateCloudConfig): don't return record 2023-12-21 15:47:11 +01:00
Julien Fontanet
ea1921625e chore(xo-server/create{Group,User}): simplify code 2023-12-21 15:47:11 +01:00
Julien Fontanet
65a154a1b3 chore(xo-server/updateJob): don't return record 2023-12-21 15:47:11 +01:00
Julien Fontanet
2249c90be9 chore(xo-server/subjects): update accept array 2023-12-21 15:47:11 +01:00
Julien Fontanet
1b55d5e2b4 chore(xo-server/scheduling): use builtin (un)serialize 2023-12-21 15:47:11 +01:00
Julien Fontanet
9f5be8029a chore(xo-server/remotes): update accept array 2023-12-21 15:47:11 +01:00
Julien Fontanet
16458b953f chore(xo-server/jobs): use builtin (un)serialize 2023-12-21 15:47:11 +01:00
Julien Fontanet
d63a567a1c chore(xo-server/CloudConfigs): remove useless method 2023-12-21 15:47:11 +01:00
582 changed files with 15705 additions and 13850 deletions

View File

@@ -15,9 +15,10 @@ module.exports = {
overrides: [
{
files: ['cli.{,c,m}js', '*-cli.{,c,m}js', '**/*cli*/**/*.{,c,m}js'],
files: ['cli.{,c,m}js', '*-cli.{,c,m}js', '**/*cli*/**/*.{,c,m}js', '**/scripts/**.{,c,m}js'],
rules: {
'n/no-process-exit': 'off',
'n/shebang': 'off',
'no-console': 'off',
},
},
@@ -46,6 +47,57 @@ module.exports = {
],
},
},
{
files: ['@xen-orchestra/{web-core,lite,web}/**/*.{vue,ts}'],
parserOptions: {
sourceType: 'module',
},
plugins: ['import'],
extends: [
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:vue/vue3-recommended',
'@vue/eslint-config-typescript/recommended',
'@vue/eslint-config-prettier',
],
settings: {
'import/resolver': {
typescript: true,
'eslint-import-resolver-custom-alias': {
alias: {
'@': './src',
},
extensions: ['.ts'],
packages: ['@xen-orchestra/lite'],
},
},
},
rules: {
'no-void': 'off',
'n/no-missing-import': 'off', // using 'import' plugin instead to support TS aliases
'@typescript-eslint/no-explicit-any': 'off',
'vue/require-default-prop': 'off', // https://github.com/vuejs/eslint-plugin-vue/issues/2051
},
},
{
files: ['@xen-orchestra/{web-core,lite,web}/src/pages/**/*.vue'],
parserOptions: {
sourceType: 'module',
},
rules: {
'vue/multi-word-component-names': 'off',
},
},
{
files: ['@xen-orchestra/{web-core,lite,web}/typed-router.d.ts'],
parserOptions: {
sourceType: 'module',
},
rules: {
'eslint-comments/disable-enable-pair': 'off',
'eslint-comments/no-unlimited-disable': 'off',
},
},
],
parserOptions: {

View File

@@ -1,48 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'status: triaging :triangular_flag_on_post:, type: bug :bug:'
assignees: ''
---
1. ⚠️ **If you don't follow this template, the issue will be closed**.
2. ⚠️ **If your issue can't be easily reproduced, please report it [on the forum first](https://xcp-ng.org/forum/category/12/xen-orchestra)**.
Are you using XOA or XO from the sources?
If XOA:
- which release channel? (`stable` vs `latest`)
- please consider creating a support ticket in [your dedicated support area](https://xen-orchestra.com/#!/member/support)
If XO from the sources:
- Provide **your commit number**. If it's older than a week, we won't investigate
- Don't forget to [read this first](https://xen-orchestra.com/docs/community.html)
- As well as follow [this guide](https://xen-orchestra.com/docs/community.html#report-a-bug)
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Environment (please provide the following information):**
- Node: [e.g. 16.12.1]
- hypervisor: [e.g. XCP-ng 8.2.0]
**Additional context**
Add any other context about the problem here.

119
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@@ -0,0 +1,119 @@
name: Bug Report
description: Create a report to help us improve
labels: ['type: bug :bug:', 'status: triaging :triangular_flag_on_post:']
body:
- type: markdown
attributes:
value: |
1. ⚠️ **If you don't follow this template, the issue will be closed**.
2. ⚠️ **If your issue can't be easily reproduced, please report it [on the forum first](https://xcp-ng.org/forum/category/12/xen-orchestra)**.
- type: markdown
attributes:
value: '## Are you using XOA or XO from the sources?'
- type: dropdown
id: xo-origin
attributes:
label: Are you using XOA or XO from the sources?
options:
- XOA
- XO from the sources
- both
validations:
required: false
- type: markdown
attributes:
value: '### If XOA:'
- type: dropdown
id: xoa-channel
attributes:
label: Which release channel?
description: please consider creating a support ticket in [your dedicated support area](https://xen-orchestra.com/#!/member/support)
options:
- stable
- latest
- both
validations:
required: false
- type: markdown
attributes:
value: '### If XO from the sources:'
- type: markdown
attributes:
value: |
- Don't forget to [read this first](https://xen-orchestra.com/docs/community.html)
- As well as follow [this guide](https://xen-orchestra.com/docs/community.html#report-a-bug)
- type: input
id: xo-sources-commit-number
attributes:
label: Provide your commit number
description: If it's older than a week, we won't investigate
placeholder: e.g. 579f0
validations:
required: false
- type: markdown
attributes:
value: '## Bug description:'
- type: textarea
id: bug-description
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is
validations:
required: true
- type: textarea
id: error-message
attributes:
label: Error message
render: Text
validations:
required: false
- type: textarea
id: steps
attributes:
label: To reproduce
description: 'Steps to reproduce the behavior:'
value: |
1. Go to '...'
2. Click on '...'
3. Scroll down to '...'
4. See error
validations:
required: false
- type: textarea
id: expected-behavior
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen
validations:
required: false
- type: textarea
id: screenshots
attributes:
label: Screenshots
description: If applicable, add screenshots to help explain your problem
validations:
required: false
- type: markdown
attributes:
value: '## Environment (please provide the following information):'
- type: input
id: node-version
attributes:
label: Node
placeholder: e.g. 16.12.1
validations:
required: true
- type: input
id: hypervisor-version
attributes:
label: Hypervisor
placeholder: e.g. XCP-ng 8.2.0
validations:
required: true
- type: textarea
id: additional-context
attributes:
label: Additional context
description: Add any other context about the problem here
validations:
required: false

View File

@@ -24,8 +24,12 @@ jobs:
cache: 'yarn'
- name: Install project dependencies
run: yarn
- name: Ensure yarn.lock is up-to-date
run: git diff --exit-code yarn.lock
- name: Build the project
run: yarn build
- name: Unit tests
run: yarn test-unit
- name: Lint tests
run: yarn test-lint
- name: Integration tests

4
.gitignore vendored
View File

@@ -30,8 +30,12 @@ pnpm-debug.log.*
yarn-error.log
yarn-error.log.*
.env
*.tsbuildinfo
# code coverage
.nyc_output/
coverage/
.turbo/
# https://node-tap.org/dot-tap-folder/
.tap/

View File

@@ -1,3 +0,0 @@
@xen-orchestra/web
@xen-orchestra/web-core
@xen-orchestra/web-lite

View File

@@ -34,7 +34,6 @@
},
"devDependencies": {
"sinon": "^17.0.1",
"tap": "^16.3.0",
"test": "^3.2.1"
}
}

View File

@@ -62,6 +62,42 @@ decorateClass(Foo, {
})
```
### `decorateObject(object, map)`
Decorates an object the same way `decorateClass()` decorates a class:
```js
import { decorateObject } from '@vates/decorate-with'
const object = {
get bar() {
// body
},
set bar(value) {
// body
},
baz() {
// body
},
}
decorateObject(object, {
// getter and/or setter
bar: {
// without arguments
get: lodash.memoize,
// with arguments
set: [lodash.debounce, 150],
},
// method (with or without arguments)
baz: lodash.curry,
})
```
### `perInstance(fn, ...args)`
Helper to decorate the method by instance instead of for the whole class.

View File

@@ -80,6 +80,42 @@ decorateClass(Foo, {
})
```
### `decorateObject(object, map)`
Decorates an object the same way `decorateClass()` decorates a class:
```js
import { decorateObject } from '@vates/decorate-with'
const object = {
get bar() {
// body
},
set bar(value) {
// body
},
baz() {
// body
},
}
decorateObject(object, {
// getter and/or setter
bar: {
// without arguments
get: lodash.memoize,
// with arguments
set: [lodash.debounce, 150],
},
// method (with or without arguments)
baz: lodash.curry,
})
```
### `perInstance(fn, ...args)`
Helper to decorate the method by instance instead of for the whole class.

View File

@@ -14,10 +14,13 @@ function applyDecorator(decorator, value) {
}
exports.decorateClass = exports.decorateMethodsWith = function decorateClass(klass, map) {
const { prototype } = klass
return decorateObject(klass.prototype, map)
}
function decorateObject(object, map) {
for (const name of Object.keys(map)) {
const decorator = map[name]
const descriptor = getOwnPropertyDescriptor(prototype, name)
const descriptor = getOwnPropertyDescriptor(object, name)
if (typeof decorator === 'function' || Array.isArray(decorator)) {
descriptor.value = applyDecorator(decorator, descriptor.value)
} else {
@@ -30,10 +33,11 @@ exports.decorateClass = exports.decorateMethodsWith = function decorateClass(kla
}
}
defineProperty(prototype, name, descriptor)
defineProperty(object, name, descriptor)
}
return klass
return object
}
exports.decorateObject = decorateObject
exports.perInstance = function perInstance(fn, decorator, ...args) {
const map = new WeakMap()

View File

@@ -20,7 +20,7 @@
"url": "https://vates.fr"
},
"license": "ISC",
"version": "2.0.0",
"version": "2.1.0",
"engines": {
"node": ">=8.10"
},

View File

@@ -20,6 +20,9 @@ function assertListeners(t, event, listeners) {
}
t.beforeEach(function (t) {
// work around https://github.com/tapjs/tapjs/issues/998
t.context = {}
t.context.ee = new EventEmitter()
t.context.em = new EventListenersManager(t.context.ee)
})

View File

@@ -38,9 +38,9 @@
"version": "1.0.1",
"scripts": {
"postversion": "npm publish --access public",
"test": "tap --branches=72"
"test": "tap --allow-incomplete-coverage"
},
"devDependencies": {
"tap": "^16.2.0"
"tap": "^18.7.0"
}
}

28
@vates/fuse-vhd/.USAGE.md Normal file
View File

@@ -0,0 +1,28 @@
Mount a vhd generated by xen-orchestra to filesystem
### Library
```js
import { mount } from 'fuse-vhd'
// return a disposable, see promise-toolbox/Disposable
// unmount automatically when disposable is disposed
// in case of differencing VHD, it mounts the full chain
await mount(handler, diskId, mountPoint)
```
### cli
From the install folder :
```
cli.mjs <remoteUrl> <vhdPathInRemote> <mountPoint>
```
After installing the package
```
xo-fuse-vhd <remoteUrl> <vhdPathInRemote> <mountPoint>
```
remoteUrl can be found by using cli in `@xen-orchestra/fs` , for example a local remote will have a url like `file:///path/to/remote/root`

59
@vates/fuse-vhd/README.md Normal file
View File

@@ -0,0 +1,59 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @vates/fuse-vhd
[![Package Version](https://badgen.net/npm/v/@vates/fuse-vhd)](https://npmjs.org/package/@vates/fuse-vhd) ![License](https://badgen.net/npm/license/@vates/fuse-vhd) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@vates/fuse-vhd)](https://bundlephobia.com/result?p=@vates/fuse-vhd) [![Node compatibility](https://badgen.net/npm/node/@vates/fuse-vhd)](https://npmjs.org/package/@vates/fuse-vhd)
## Install
Installation of the [npm package](https://npmjs.org/package/@vates/fuse-vhd):
```sh
npm install --save @vates/fuse-vhd
```
## Usage
Mount a vhd generated by xen-orchestra to filesystem
### Library
```js
import { mount } from 'fuse-vhd'
// return a disposable, see promise-toolbox/Disposable
// unmount automatically when disposable is disposed
// in case of differencing VHD, it mounts the full chain
await mount(handler, diskId, mountPoint)
```
### cli
From the install folder :
```
cli.mjs <remoteUrl> <vhdPathInRemote> <mountPoint>
```
After installing the package
```
xo-fuse-vhd <remoteUrl> <vhdPathInRemote> <mountPoint>
```
remoteUrl can be found by using cli in `@xen-orchestra/fs` , for example a local remote will have a url like `file:///path/to/remote/root`
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

26
@vates/fuse-vhd/cli.mjs Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env node
import Disposable from 'promise-toolbox/Disposable'
import { getSyncedHandler } from '@xen-orchestra/fs'
import { mount } from './index.mjs'
async function* main([remoteUrl, vhdPathInRemote, mountPoint]) {
if (mountPoint === undefined) {
throw new TypeError('missing arg: cli <remoteUrl> <vhdPathInRemote> <mountPoint>')
}
const handler = yield getSyncedHandler({ url: remoteUrl })
const mounted = await mount(handler, vhdPathInRemote, mountPoint)
let disposePromise
process.on('SIGINT', async () => {
// ensure single dispose
if (!disposePromise) {
disposePromise = mounted.dispose()
}
await disposePromise
process.exit()
})
}
Disposable.wrap(main)(process.argv.slice(2))

View File

@@ -58,7 +58,7 @@ export const mount = Disposable.factory(async function* mount(handler, diskPath,
},
})
return new Disposable(
() => fromCallback(() => fuse.unmount()),
fromCallback(() => fuse.mount())
() => fromCallback(cb => fuse.unmount(cb)),
fromCallback(cb => fuse.mount(cb))
)
})

View File

@@ -1,6 +1,6 @@
{
"name": "@vates/fuse-vhd",
"version": "2.0.0",
"version": "2.1.0",
"license": "ISC",
"private": false,
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@vates/fuse-vhd",
@@ -19,10 +19,14 @@
},
"main": "./index.mjs",
"dependencies": {
"@xen-orchestra/fs": "^4.1.4",
"fuse-native": "^2.2.6",
"lru-cache": "^7.14.0",
"promise-toolbox": "^0.21.0",
"vhd-lib": "^4.8.0"
"vhd-lib": "^4.9.0"
},
"bin": {
"xo-fuse-vhd": "./cli.mjs"
},
"scripts": {
"postversion": "npm publish --access public"

View File

@@ -41,9 +41,7 @@ export default class MultiNbdClient {
}
if (connectedClients.length < this.#clients.length) {
warn(
`incomplete connection by multi Nbd, only ${connectedClients.length} over ${
this.#clients.length
} expected clients`
`incomplete connection by multi Nbd, only ${connectedClients.length} over ${this.#clients.length} expected clients`
)
this.#clients = connectedClients
}

View File

@@ -24,14 +24,14 @@
"@xen-orchestra/async-map": "^0.1.2",
"@xen-orchestra/log": "^0.6.0",
"promise-toolbox": "^0.21.0",
"xen-api": "^2.0.0"
"xen-api": "^2.0.1"
},
"devDependencies": {
"tap": "^16.3.0",
"tap": "^18.7.0",
"tmp": "^0.2.1"
},
"scripts": {
"postversion": "npm publish --access public",
"test-integration": "tap --lines 97 --functions 95 --branches 74 --statements 97 tests/*.integ.mjs"
"test-integration": "tap --allow-incomplete-coverage"
}
}

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'node:assert'
import { describe, it } from 'tap/mocha'
import test from 'test'
import {
generateHotp,
@@ -11,6 +11,8 @@ import {
verifyTotp,
} from './index.mjs'
const { describe, it } = test
describe('generateSecret', function () {
it('generates a string of 32 chars', async function () {
const secret = generateSecret()

View File

@@ -31,9 +31,9 @@
},
"scripts": {
"postversion": "npm publish --access public",
"test": "tap"
"test": "node--test"
},
"devDependencies": {
"tap": "^16.3.0"
"test": "^3.3.0"
}
}

View File

@@ -1,7 +1,7 @@
'use strict'
const assert = require('assert/strict')
const { describe, it } = require('tap').mocha
const { describe, it } = require('test')
const { every, not, some } = require('./')

View File

@@ -32,9 +32,9 @@
},
"scripts": {
"postversion": "npm publish --access public",
"test": "tap"
"test": "node--test"
},
"devDependencies": {
"tap": "^16.0.1"
"test": "^3.3.0"
}
}

View File

@@ -123,7 +123,7 @@ const onProgress = makeOnProgress({
onTaskUpdate(taskLog) {},
})
Task.run({ data: { name: 'my task' }, onProgress }, asyncFn)
Task.run({ properties: { name: 'my task' }, onProgress }, asyncFn)
```
It can also be fed event logs directly:

View File

@@ -139,7 +139,7 @@ const onProgress = makeOnProgress({
onTaskUpdate(taskLog) {},
})
Task.run({ data: { name: 'my task' }, onProgress }, asyncFn)
Task.run({ properties: { name: 'my task' }, onProgress }, asyncFn)
```
It can also be fed event logs directly:

View File

@@ -1,7 +1,7 @@
'use strict'
const assert = require('assert/strict')
const { afterEach, describe, it } = require('tap').mocha
const { afterEach, describe, it } = require('test')
const { AlteredRecordError, AuditCore, MissingRecordError, NULL_ID, Storage } = require('.')

View File

@@ -13,10 +13,10 @@
},
"scripts": {
"postversion": "npm publish --access public",
"test": "tap --lines 67 --functions 92 --branches 52 --statements 67"
"test": "node--test"
},
"dependencies": {
"@vates/decorate-with": "^2.0.0",
"@vates/decorate-with": "^2.1.0",
"@xen-orchestra/log": "^0.6.0",
"golike-defer": "^0.5.1",
"object-hash": "^2.0.1"
@@ -28,6 +28,6 @@
"url": "https://vates.fr"
},
"devDependencies": {
"tap": "^16.0.1"
"test": "^3.3.0"
}
}

View File

@@ -7,8 +7,8 @@
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
"dependencies": {
"@xen-orchestra/async-map": "^0.1.2",
"@xen-orchestra/backups": "^0.44.3",
"@xen-orchestra/fs": "^4.1.3",
"@xen-orchestra/backups": "^0.44.6",
"@xen-orchestra/fs": "^4.1.4",
"filenamify": "^6.0.0",
"getopts": "^2.2.5",
"lodash": "^4.17.15",

View File

@@ -191,7 +191,7 @@ export class ImportVmBackup {
async #decorateIncrementalVmMetadata() {
const { additionnalVmTag, mapVdisSrs, useDifferentialRestore } = this._importIncrementalVmSettings
const ignoredVdis = new Set(
Object.entries(mapVdisSrs)
.filter(([_, srUuid]) => srUuid === null)

View File

@@ -35,6 +35,8 @@ export const DIR_XO_CONFIG_BACKUPS = 'xo-config-backups'
export const DIR_XO_POOL_METADATA_BACKUPS = 'xo-pool-metadata-backups'
const IMMUTABILTY_METADATA_FILENAME = '/immutability.json'
const { debug, warn } = createLogger('xo:backups:RemoteAdapter')
const compareTimestamp = (a, b) => a.timestamp - b.timestamp
@@ -749,10 +751,37 @@ export class RemoteAdapter {
}
async readVmBackupMetadata(path) {
let json
let isImmutable = false
let remoteIsImmutable = false
// if the remote is immutable, check if this metadatas are also immutables
try {
// this file is not encrypted
await this._handler._readFile(IMMUTABILTY_METADATA_FILENAME)
remoteIsImmutable = true
} catch (error) {
if (error.code !== 'ENOENT') {
throw error
}
}
try {
// this will trigger an EPERM error if the file is immutable
json = await this.handler.readFile(path, { flag: 'r+' })
// s3 handler don't respect flags
} catch (err) {
// retry without triggerring immutbaility check ,only on immutable remote
if (err.code === 'EPERM' && remoteIsImmutable) {
isImmutable = true
json = await this._handler.readFile(path, { flag: 'r' })
} else {
throw err
}
}
// _filename is a private field used to compute the backup id
//
// it's enumerable to make it cacheable
const metadata = { ...JSON.parse(await this._handler.readFile(path)), _filename: path }
const metadata = { ...JSON.parse(json), _filename: path, isImmutable }
// backups created on XenServer < 7.1 via JSON in XML-RPC transports have boolean values encoded as integers, which make them unusable with more recent XAPIs
if (typeof metadata.vm.is_a_template === 'number') {

View File

@@ -21,7 +21,7 @@ export class RestoreMetadataBackup {
})
} else {
const metadata = JSON.parse(await handler.readFile(join(backupId, 'metadata.json')))
const dataFileName = resolve(backupId, metadata.data ?? 'data.json')
const dataFileName = resolve('/', backupId, metadata.data ?? 'data.json').slice(1)
const data = await handler.readFile(dataFileName)
// if data is JSON, sent it as a plain string, otherwise, consider the data as binary and encode it

View File

@@ -205,7 +205,7 @@ export class IncrementalRemoteWriter extends MixinRemoteWriter(AbstractIncrement
// TODO remove when this has been done before the export
await checkVhd(handler, parentPath)
}
// don't write it as transferSize += await async function
// since i += await asyncFun lead to race condition
// as explained : https://eslint.org/docs/latest/rules/require-atomic-updates

View File

@@ -58,7 +58,7 @@ export const MixinXapiWriter = (BaseClass = Object) =>
)
}
const healthCheckVm = xapi.getObject(healthCheckVmRef) ?? (await xapi.waitObject(healthCheckVmRef))
await healthCheckVm.add_tag('xo:no-bak=Health Check')
await healthCheckVm.add_tags('xo:no-bak=Health Check')
await new HealthCheckVmBackup({
restoredVm: healthCheckVm,
xapi,

View File

@@ -2,8 +2,21 @@ import mapValues from 'lodash/mapValues.js'
import { dirname } from 'node:path'
function formatVmBackup(backup) {
const { isVhdDifferencing } = backup
const { isVhdDifferencing, vmSnapshot } = backup
let differencingVhds
let dynamicVhds
// some backups don't use snapshots, therefore cannot be with memory
const withMemory = vmSnapshot !== undefined && vmSnapshot.suspend_VDI !== 'OpaqueRef:NULL'
// isVhdDifferencing is either undefined or an object
if (isVhdDifferencing !== undefined) {
differencingVhds = Object.values(isVhdDifferencing).filter(t => t).length
dynamicVhds = Object.values(isVhdDifferencing).filter(t => !t).length
if (withMemory) {
// the suspend VDI (memory) is always a dynamic
dynamicVhds -= 1
}
}
return {
disks:
backup.vhds === undefined
@@ -18,6 +31,7 @@ function formatVmBackup(backup) {
}),
id: backup.id,
isImmutable: backup.isImmutable,
jobId: backup.jobId,
mode: backup.mode,
scheduleId: backup.scheduleId,
@@ -28,9 +42,9 @@ function formatVmBackup(backup) {
name_label: backup.vm.name_label,
},
// isVhdDifferencing is either undefined or an object
differencingVhds: isVhdDifferencing && Object.values(isVhdDifferencing).filter(t => t).length,
dynamicVhds: isVhdDifferencing && Object.values(isVhdDifferencing).filter(t => !t).length,
differencingVhds,
dynamicVhds,
withMemory,
}
}

View File

@@ -8,7 +8,7 @@
"type": "git",
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"version": "0.44.3",
"version": "0.44.6",
"engines": {
"node": ">=14.18"
},
@@ -22,13 +22,13 @@
"@vates/async-each": "^1.0.0",
"@vates/cached-dns.lookup": "^1.0.0",
"@vates/compose": "^2.1.0",
"@vates/decorate-with": "^2.0.0",
"@vates/decorate-with": "^2.1.0",
"@vates/disposable": "^0.1.5",
"@vates/fuse-vhd": "^2.0.0",
"@vates/fuse-vhd": "^2.1.0",
"@vates/nbd-client": "^3.0.0",
"@vates/parse-duration": "^0.1.1",
"@xen-orchestra/async-map": "^0.1.2",
"@xen-orchestra/fs": "^4.1.3",
"@xen-orchestra/fs": "^4.1.4",
"@xen-orchestra/log": "^0.6.0",
"@xen-orchestra/template": "^0.1.0",
"app-conf": "^2.3.0",
@@ -44,8 +44,8 @@
"proper-lockfile": "^4.1.2",
"tar": "^6.1.15",
"uuid": "^9.0.0",
"vhd-lib": "^4.8.0",
"xen-api": "^2.0.0",
"vhd-lib": "^4.9.0",
"xen-api": "^2.0.1",
"yazl": "^2.5.1"
},
"devDependencies": {
@@ -56,7 +56,7 @@
"tmp": "^0.2.1"
},
"peerDependencies": {
"@xen-orchestra/xapi": "^4.1.0"
"@xen-orchestra/xapi": "^4.2.0"
},
"license": "AGPL-3.0-or-later",
"author": {

View File

@@ -18,7 +18,7 @@
"preferGlobal": true,
"dependencies": {
"golike-defer": "^0.5.1",
"xen-api": "^2.0.0"
"xen-api": "^2.0.1"
},
"scripts": {
"postversion": "npm publish"

View File

@@ -1,7 +1,7 @@
{
"private": false,
"name": "@xen-orchestra/fs",
"version": "4.1.3",
"version": "4.1.4",
"license": "AGPL-3.0-or-later",
"description": "The File System for Xen Orchestra backups.",
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@xen-orchestra/fs",
@@ -28,7 +28,7 @@
"@sindresorhus/df": "^3.1.1",
"@vates/async-each": "^1.0.0",
"@vates/coalesce-calls": "^0.1.0",
"@vates/decorate-with": "^2.0.0",
"@vates/decorate-with": "^2.1.0",
"@vates/read-chunk": "^1.2.0",
"@xen-orchestra/log": "^0.6.0",
"bind-property-descriptor": "^2.0.0",

View File

@@ -364,7 +364,7 @@ export default class RemoteHandlerAbstract {
let data
try {
// this file is not encrypted
data = await this._readFile(normalizePath(ENCRYPTION_DESC_FILENAME), 'utf-8')
data = await this._readFile(normalizePath(ENCRYPTION_DESC_FILENAME))
const json = JSON.parse(data)
encryptionAlgorithm = json.algorithm
} catch (error) {
@@ -377,7 +377,7 @@ export default class RemoteHandlerAbstract {
try {
this.#rawEncryptor = _getEncryptor(encryptionAlgorithm, this._remote.encryptionKey)
// this file is encrypted
const data = await this.__readFile(ENCRYPTION_METADATA_FILENAME, 'utf-8')
const data = await this.__readFile(ENCRYPTION_METADATA_FILENAME)
JSON.parse(data)
} catch (error) {
// can be enoent, bad algorithm, or broeken json ( bad key or algorithm)

View File

@@ -171,7 +171,12 @@ export default class LocalHandler extends RemoteHandlerAbstract {
}
}
async _readFile(file, options) {
async _readFile(file, { flags, ...options } = {}) {
// contrary to createReadStream, readFile expect singular `flag`
if (flags !== undefined) {
options.flag = flags
}
const filePath = this.getFilePath(file)
return await this.#addSyncStackTrace(retry, () => fs.readFile(filePath, options), this.#retriesOnEagain)
}

View File

@@ -0,0 +1,10 @@
### make a remote immutable
launch the `xo-immutable-remote` command. The configuration is stored in the config file.
This script must be kept running to make file immutable reliably.
### make file mutable
launch the `xo-lift-remote-immutability` cli. The configuration is stored in the config file .
If the config file have a `liftEvery`, this script will contiue to run and check regularly if there are files to update.

View File

@@ -0,0 +1 @@
../../scripts/npmignore

View File

@@ -0,0 +1,41 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @xen-orchestra/immutable-backups
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/immutable-backups)](https://npmjs.org/package/@xen-orchestra/immutable-backups) ![License](https://badgen.net/npm/license/@xen-orchestra/immutable-backups) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/immutable-backups)](https://bundlephobia.com/result?p=@xen-orchestra/immutable-backups) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/immutable-backups)](https://npmjs.org/package/@xen-orchestra/immutable-backups)
## Install
Installation of the [npm package](https://npmjs.org/package/@xen-orchestra/immutable-backups):
```sh
npm install --save @xen-orchestra/immutable-backups
```
## Usage
### make a remote immutable
launch the `xo-immutable-remote` command. The configuration is stored in the config file.
This script must be kept running to make file immutable reliably.
### make file mutable
launch the `xo-lift-remote-immutability` cli. The configuration is stored in the config file .
If the config file have a `liftEvery`, this script will contiue to run and check regularly if there are files to update.
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[AGPL-3.0-or-later](https://spdx.org/licenses/AGPL-3.0-or-later) © [Vates SAS](https://vates.fr)

View File

@@ -0,0 +1,10 @@
import fs from 'node:fs/promises'
import { dirname, join } from 'node:path'
import isBackupMetadata from './isBackupMetadata.mjs'
export default async path => {
if (isBackupMetadata(path)) {
// snipe vm metadata cache to force XO to update it
await fs.unlink(join(dirname(path), 'cache.json.gz'))
}
}

View File

@@ -0,0 +1,4 @@
import { dirname } from 'node:path'
// check if we are handling file directly under a vhd directory ( bat, headr, footer,..)
export default path => dirname(path).endsWith('.vhd')

View File

@@ -0,0 +1,46 @@
import { load } from 'app-conf'
import { homedir } from 'os'
import { join } from 'node:path'
import ms from 'ms'
const APP_NAME = 'xo-immutable-backups'
const APP_DIR = new URL('.', import.meta.url).pathname
export default async function loadConfig() {
const config = await load(APP_NAME, {
appDir: APP_DIR,
ignoreUnknownFormats: true,
})
if (config.remotes === undefined || config.remotes?.length < 1) {
throw new Error(
'No remotes are configured in the config file, please add at least one [remotes.<remoteid>] with a root property pointing to the absolute path of the remote to watch'
)
}
if (config.liftEvery) {
config.liftEvery = ms(config.liftEvery)
}
for (const [remoteId, { indexPath, immutabilityDuration, root }] of Object.entries(config.remotes)) {
if (!root) {
throw new Error(
`Remote ${remoteId} don't have a root property,containing the absolute path to the root of a backup repository `
)
}
if (!immutabilityDuration) {
throw new Error(
`Remote ${remoteId} don't have a immutabilityDuration property to indicate the minimal duration the backups should be protected by immutability `
)
}
if (ms(immutabilityDuration) < ms('1d')) {
throw new Error(
`Remote ${remoteId} immutability duration is smaller than the minimum allowed (1d), current : ${immutabilityDuration}`
)
}
if (!indexPath) {
const basePath = indexPath ?? process.env.XDG_DATA_HOME ?? join(homedir(), '.local', 'share')
const immutabilityIndexPath = join(basePath, APP_NAME, remoteId)
config.remotes[remoteId].indexPath = immutabilityIndexPath
}
config.remotes[remoteId].immutabilityDuration = ms(immutabilityDuration)
}
return config
}

View File

@@ -0,0 +1,14 @@
# how often does the lift immutability script will run to check if
# some files need to be made mutable
liftEvery = 1h
# you can add as many remote as you want, if you change the id ( here : remote1)
#[remotes.remote1]
#root = "/mnt/ssd/vhdblock/" # the absolute path of the root of the backup repository
#immutabilityDuration = 7d # mandatory
# optional, default value is false will scan and update the index on start, can be expensive
#rebuildIndexOnStart = true
# the index path is optional, default in XDG_DATA_HOME, or if this is not set, in ~/.local/share
#indexPath = "/var/lib/" # will add automatically the application name immutable-backup

View File

@@ -0,0 +1,33 @@
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import fs from 'node:fs/promises'
import path from 'node:path'
import { tmpdir } from 'node:os'
import * as Directory from './directory.mjs'
import { rimraf } from 'rimraf'
describe('immutable-backups/file', async () => {
it('really lock a directory', async () => {
const dir = await fs.mkdtemp(path.join(tmpdir(), 'immutable-backups-tests'))
const dataDir = path.join(dir, 'data')
await fs.mkdir(dataDir)
const immutDir = path.join(dir, '.immutable')
const filePath = path.join(dataDir, 'test')
await fs.writeFile(filePath, 'data')
await Directory.makeImmutable(dataDir, immutDir)
assert.strictEqual(await Directory.isImmutable(dataDir), true)
await assert.rejects(() => fs.writeFile(filePath, 'data'))
await assert.rejects(() => fs.appendFile(filePath, 'data'))
await assert.rejects(() => fs.unlink(filePath))
await assert.rejects(() => fs.rename(filePath, filePath + 'copy'))
await assert.rejects(() => fs.writeFile(path.join(dataDir, 'test2'), 'data'))
await assert.rejects(() => fs.rename(dataDir, dataDir + 'copy'))
await Directory.liftImmutability(dataDir, immutDir)
assert.strictEqual(await Directory.isImmutable(dataDir), false)
await fs.writeFile(filePath, 'data')
await fs.appendFile(filePath, 'data')
await fs.unlink(filePath)
await fs.rename(dataDir, dataDir + 'copy')
await rimraf(dir)
})
})

View File

@@ -0,0 +1,21 @@
import execa from 'execa'
import { unindexFile, indexFile } from './fileIndex.mjs'
export async function makeImmutable(dirPath, immutabilityCachePath) {
if (immutabilityCachePath) {
await indexFile(dirPath, immutabilityCachePath)
}
await execa('chattr', ['+i', '-R', dirPath])
}
export async function liftImmutability(dirPath, immutabilityCachePath) {
if (immutabilityCachePath) {
await unindexFile(dirPath, immutabilityCachePath)
}
await execa('chattr', ['-i', '-R', dirPath])
}
export async function isImmutable(path) {
const { stdout } = await execa('lsattr', ['-d', path])
return stdout[4] === 'i'
}

View File

@@ -0,0 +1,114 @@
# Imutability
the goal is to make a remote that XO can write, but not modify during the immutability duration set on the remote. That way, it's not possible for XO to delete or encrypt any backup during this period. It protects your backup agains ransomware, at least as long as the attacker does not have a root access to the remote server.
We target `governance` type of immutability, **the local root account of the remote server will be able to lift immutability**.
We use the file system capabilities, they are tested on the protection process start.
It is compatible with encryption at rest made by XO.
## Prerequisites
The commands must be run as root on the remote, or by a user with the `CAP_LINUX_IMMUTABLE` capability . On start, the protect process writes into the remote `imutability.json` file its status and the immutability duration.
the `chattr` and `lsattr` should be installed on the system
## Configuring
this package uses app-conf to store its config. The application name is `xo-immutable-backup`. A sample config file is provided in this package.
## Making a file immutable
when marking a file or a folder immutable, it create an alias file in the `<indexPath>/<DayOfFileCreation>/<sha256(fullpath)>`.
`indexPath` can be defined in the config file, otherwise `XDG_HOME` is used. If not available it goes to `~/.local/share`
This index is used when lifting the immutability of the remote, it will only look at the old enough `<indexPath>/<DayOfFileCreation>/` folders.
## Real time protecting
On start, the watcher will create the index if it does not exists.
It will also do a checkup to ensure immutability could work on this remote and handle the easiest issues.
The watching process depends on the backup type, since we don't want to make temporary files and cache immutable.
It won't protect files during upload, only when the files have been completly written on disk. Real time, in this case, means "protecting critical files as soon as possible after they are uploaded"
This can be alleviated by :
- Coupling immutability with encryption to ensure the file is not modified
- Making health check to ensure the data are exactly as the snapshot data
List of protected files :
```js
const PATHS = [
// xo configuration backupq
'xo-config-backups/*/*/data',
'xo-config-backups/*/*/data.json',
'xo-config-backups/*/*/metadata.json',
// pool backupq
'xo-pool-metadata-backups/*/metadata.json',
'xo-pool-metadata-backups/*/data',
// vm backups , xo-vm-backups/<vmuuid>/
'xo-vm-backups/*/*.json',
'xo-vm-backups/*/*.xva',
'xo-vm-backups/*/*.xva.checksum',
// xo-vm-backups/<vmuuid>/vdis/<jobid>/<vdiUuid>
'xo-vm-backups/*/vdis/*/*/*.vhd', // can be an alias or a vhd file
// for vhd directory :
'xo-vm-backups/*/vdis/*/*/data/*.vhd/bat',
'xo-vm-backups/*/vdis/*/*/data/*.vhd/header',
'xo-vm-backups/*/vdis/*/*/data/*.vhd/footer',
]
```
## Releasing protection on old enough files on a remote
the watcher will periodically check if some file must by unlocked
## Troubleshooting
### some files are still locked
add the `rebuildIndexOnStart` option to the config file
### make remote fully mutable again
- Update the immutability setting with a 0 duration
- launch the `liftProtection` cli.
- remove the `protectRemotes` service
### increasing the immutability duration
this will prolong immutable file, but won't protect files that are already out of immutability
### reducing the immutability duration
change the setting, and launch the `liftProtection` cli , or wait for next planed execution
### why are my incremental backups not marked as protected in XO ?
are not marked as protected in XO ?
For incremental backups to be marked as protected in XO, the entire chain must be under protection. To ensure at least 7 days of backups are protected, you need to set the immutability duration and retention at 14 days, the full backup interval at 7 days
That means that if the last backup chain is complete ( 7 backup ) it is completely under protection, and if not, the precedent chain is also under protection. K are key backups, and are delta
```
Kd Kdddddd Kdddddd K # 8 backups protected, 2 chains
K Kdddddd Kdddddd Kd # 9 backups protected, 2 chains
Kdddddd Kdddddd Kdd # 10 backups protected, 2 chains
Kddddd Kdddddd Kddd # 11 backups protected, 2 chains
Kdddd Kdddddd Kdddd # 12 backups protected, 2 chains
Kddd Kdddddd Kddddd # 13 backups protected, 2 chains
Kdd Kdddddd Kdddddd # 7 backups protected, 1 chain since precedent full is now mutable
Kd Kdddddd Kdddddd K # 8 backups protected, 2 chains
```
### Why doesn't the protect process start ?
- it should be run as root or by a user with the `CAP_LINUX_IMMUTABLE` capability
- the underlying file system should support immutability, especially the `chattr` and `lsattr` command
- logs are in journalctl

View File

@@ -0,0 +1,29 @@
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import fs from 'node:fs/promises'
import path from 'node:path'
import * as File from './file.mjs'
import { tmpdir } from 'node:os'
import { rimraf } from 'rimraf'
describe('immutable-backups/file', async () => {
it('really lock a file', async () => {
const dir = await fs.mkdtemp(path.join(tmpdir(), 'immutable-backups-tests'))
const immutDir = path.join(dir, '.immutable')
const filePath = path.join(dir, 'test.ext')
await fs.writeFile(filePath, 'data')
assert.strictEqual(await File.isImmutable(filePath), false)
await File.makeImmutable(filePath, immutDir)
assert.strictEqual(await File.isImmutable(filePath), true)
await assert.rejects(() => fs.writeFile(filePath, 'data'))
await assert.rejects(() => fs.appendFile(filePath, 'data'))
await assert.rejects(() => fs.unlink(filePath))
await assert.rejects(() => fs.rename(filePath, filePath + 'copy'))
await File.liftImmutability(filePath, immutDir)
assert.strictEqual(await File.isImmutable(filePath), false)
await fs.writeFile(filePath, 'data')
await fs.appendFile(filePath, 'data')
await fs.unlink(filePath)
await rimraf(dir)
})
})

View File

@@ -0,0 +1,24 @@
import execa from 'execa'
import { unindexFile, indexFile } from './fileIndex.mjs'
// this work only on linux like systems
// this could work on windows : https://4sysops.com/archives/set-and-remove-the-read-only-file-attribute-with-powershell/
export async function makeImmutable(path, immutabilityCachePath) {
if (immutabilityCachePath) {
await indexFile(path, immutabilityCachePath)
}
await execa('chattr', ['+i', path])
}
export async function liftImmutability(filePath, immutabilityCachePath) {
if (immutabilityCachePath) {
await unindexFile(filePath, immutabilityCachePath)
}
await execa('chattr', ['-i', filePath])
}
export async function isImmutable(path) {
const { stdout } = await execa('lsattr', ['-d', path])
return stdout[4] === 'i'
}

View File

@@ -0,0 +1,81 @@
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import fs from 'node:fs/promises'
import path from 'node:path'
import * as FileIndex from './fileIndex.mjs'
import * as Directory from './directory.mjs'
import { tmpdir } from 'node:os'
import { rimraf } from 'rimraf'
describe('immutable-backups/fileIndex', async () => {
it('index File changes', async () => {
const dir = await fs.mkdtemp(path.join(tmpdir(), 'immutable-backups-tests'))
const immutDir = path.join(dir, '.immutable')
const filePath = path.join(dir, 'test.ext')
await fs.writeFile(filePath, 'data')
await FileIndex.indexFile(filePath, immutDir)
await fs.mkdir(path.join(immutDir, 'NOTADATE'))
await fs.writeFile(path.join(immutDir, 'NOTADATE.file'), 'content')
let nb = 0
let index, target
for await ({ index, target } of FileIndex.listOlderTargets(immutDir, 0)) {
assert.strictEqual(true, false, 'Nothing should be eligible for deletion')
}
nb = 0
for await ({ index, target } of FileIndex.listOlderTargets(immutDir, -24 * 60 * 60 * 1000)) {
assert.strictEqual(target, filePath)
await fs.unlink(index)
nb++
}
assert.strictEqual(nb, 1)
await fs.rmdir(path.join(immutDir, 'NOTADATE'))
await fs.rm(path.join(immutDir, 'NOTADATE.file'))
for await ({ index, target } of FileIndex.listOlderTargets(immutDir, -24 * 60 * 60 * 1000)) {
// should remove the empty dir
assert.strictEqual(true, false, 'Nothing should have stayed here')
}
assert.strictEqual((await fs.readdir(immutDir)).length, 0)
await rimraf(dir)
})
it('fails correctly', async () => {
const dir = await fs.mkdtemp(path.join(tmpdir(), 'immutable-backups-tests'))
const immutDir = path.join(dir, '.immutable')
await fs.mkdir(immutDir)
const placeholderFile = path.join(dir, 'test.ext')
await fs.writeFile(placeholderFile, 'data')
await FileIndex.indexFile(placeholderFile, immutDir)
const filePath = path.join(dir, 'test2.ext')
await fs.writeFile(filePath, 'data')
await FileIndex.indexFile(filePath, immutDir)
await assert.rejects(() => FileIndex.indexFile(filePath, immutDir), { code: 'EEXIST' })
await Directory.makeImmutable(immutDir)
await assert.rejects(() => FileIndex.unindexFile(filePath, immutDir), { code: 'EPERM' })
await Directory.liftImmutability(immutDir)
await rimraf(dir)
})
it('handles bomb index files', async () => {
const dir = await fs.mkdtemp(path.join(tmpdir(), 'immutable-backups-tests'))
const immutDir = path.join(dir, '.immutable')
await fs.mkdir(immutDir)
const placeholderFile = path.join(dir, 'test.ext')
await fs.writeFile(placeholderFile, 'data')
await FileIndex.indexFile(placeholderFile, immutDir)
const indexDayDir = path.join(immutDir, '1980,11-28')
await fs.mkdir(indexDayDir)
await fs.writeFile(path.join(indexDayDir, 'big'), Buffer.alloc(2 * 1024 * 1024))
assert.rejects(async () => {
let index, target
for await ({ index, target } of FileIndex.listOlderTargets(immutDir, 0)) {
// should remove the empty dir
assert.strictEqual(true, false, `Nothing should have stayed here, got ${index} ${target}`)
}
})
await rimraf(dir)
})
})

View File

@@ -0,0 +1,88 @@
import { join } from 'node:path'
import { createHash } from 'node:crypto'
import fs from 'node:fs/promises'
import { dirname } from 'path'
const MAX_INDEX_FILE_SIZE = 1024 * 1024
function sha256(content) {
return createHash('sha256').update(content).digest('hex')
}
function formatDate(date) {
return date.toISOString().split('T')[0]
}
async function computeIndexFilePath(path, immutabilityIndexPath) {
const stat = await fs.stat(path)
const date = new Date(stat.birthtimeMs)
const day = formatDate(date)
const hash = sha256(path)
return join(immutabilityIndexPath, day, hash)
}
export async function indexFile(path, immutabilityIndexPath) {
const indexFilePath = await computeIndexFilePath(path, immutabilityIndexPath)
try {
await fs.writeFile(indexFilePath, path, { flag: 'wx' })
} catch (err) {
// missing dir: make it
if (err.code === 'ENOENT') {
await fs.mkdir(dirname(indexFilePath), { recursive: true })
await fs.writeFile(indexFilePath, path)
} else {
throw err
}
}
return indexFilePath
}
export async function unindexFile(path, immutabilityIndexPath) {
try {
const cacheFileName = await computeIndexFilePath(path, immutabilityIndexPath)
await fs.unlink(cacheFileName)
} catch (err) {
if (err.code !== 'ENOENT') {
throw err
}
}
}
export async function* listOlderTargets(immutabilityCachePath, immutabilityDuration) {
// walk all dir by day until the limit day
const limitDate = new Date(Date.now() - immutabilityDuration)
const limitDay = formatDate(limitDate)
const dir = await fs.opendir(immutabilityCachePath)
for await (const dirent of dir) {
if (dirent.isFile()) {
continue
}
// ensure we have a valid date
if (isNaN(new Date(dirent.name))) {
continue
}
// recent enough to be kept
if (dirent.name >= limitDay) {
continue
}
const subDirPath = join(immutabilityCachePath, dirent.name)
const subdir = await fs.opendir(subDirPath)
let nb = 0
for await (const hashFileEntry of subdir) {
const entryFullPath = join(subDirPath, hashFileEntry.name)
const { size } = await fs.stat(entryFullPath)
if (size > MAX_INDEX_FILE_SIZE) {
throw new Error(`Index file at ${entryFullPath} is too big, ${size} bytes `)
}
const targetPath = await fs.readFile(entryFullPath, { encoding: 'utf8' })
yield {
index: entryFullPath,
target: targetPath,
}
nb++
}
// cleanup older folder
if (nb === 0) {
await fs.rmdir(subDirPath)
}
}
}

View File

@@ -0,0 +1 @@
export default path => path.match(/xo-vm-backups\/[^/]+\/[^/]+\.json$/)

View File

@@ -0,0 +1,37 @@
#!/usr/bin/env node
import fs from 'node:fs/promises'
import * as Directory from './directory.mjs'
import { createLogger } from '@xen-orchestra/log'
import { listOlderTargets } from './fileIndex.mjs'
import cleanXoCache from './_cleanXoCache.mjs'
import loadConfig from './_loadConfig.mjs'
const { info, warn } = createLogger('xen-orchestra:immutable-backups:liftProtection')
async function liftRemoteImmutability(immutabilityCachePath, immutabilityDuration) {
for await (const { index, target } of listOlderTargets(immutabilityCachePath, immutabilityDuration)) {
await Directory.liftImmutability(target, immutabilityCachePath)
await fs.unlink(index)
await cleanXoCache(target)
}
}
async function liftImmutability(remotes) {
for (const [remoteId, { indexPath, immutabilityDuration }] of Object.entries(remotes)) {
liftRemoteImmutability(indexPath, immutabilityDuration).catch(err =>
warn('error during watchRemote', { err, remoteId, indexPath, immutabilityDuration })
)
}
}
const { liftEvery, remotes } = await loadConfig()
if (liftEvery > 0) {
info('setup watcher for immutability lifting')
setInterval(async () => {
liftImmutability(remotes)
}, liftEvery)
} else {
liftImmutability(remotes)
}

View File

@@ -0,0 +1,42 @@
{
"private": false,
"name": "@xen-orchestra/immutable-backups",
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@xen-orchestra/immutable-backups",
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
"repository": {
"directory": "@xen-orchestra/immutable-backups",
"type": "git",
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
},
"bin": {
"xo-immutable-remote": "./protectRemotes.mjs",
"xo-lift-remote-immutability": "./liftProtection.mjs"
},
"license": "AGPL-3.0-or-later",
"version": "1.0.1",
"engines": {
"node": ">=14.0.0"
},
"dependencies": {
"@vates/async-each": "^1.0.0",
"@xen-orchestra/backups": "^0.44.6",
"@xen-orchestra/log": "^0.6.0",
"app-conf": "^2.3.0",
"chokidar": "^3.5.3",
"execa": "^5.0.0",
"ms": "^2.1.3",
"vhd-lib": "^4.7.0"
},
"devDependencies": {
"rimraf": "^5.0.5",
"tap": "^18.6.1"
},
"scripts": {
"postversion": "npm publish --access public",
"test-integration": "tap *.integ.mjs"
}
}

View File

@@ -0,0 +1,191 @@
#!/usr/bin/env node
import fs from 'node:fs/promises'
import * as File from './file.mjs'
import * as Directory from './directory.mjs'
import assert from 'node:assert'
import { dirname, join, sep } from 'node:path'
import { createLogger } from '@xen-orchestra/log'
import chokidar from 'chokidar'
import { indexFile } from './fileIndex.mjs'
import cleanXoCache from './_cleanXoCache.mjs'
import loadConfig from './_loadConfig.mjs'
import isInVhdDirectory from './_isInVhdDirectory.mjs'
const { debug, info, warn } = createLogger('xen-orchestra:immutable-backups:remote')
async function test(remotePath, indexPath) {
await fs.readdir(remotePath)
const testPath = join(remotePath, '.test-immut')
// cleanup
try {
await File.liftImmutability(testPath, indexPath)
await fs.unlink(testPath)
} catch (err) {}
// can create , modify and delete a file
await fs.writeFile(testPath, `test immut ${new Date()}`)
await fs.writeFile(testPath, `test immut change 1 ${new Date()}`)
await fs.unlink(testPath)
// cannot modify or delete an immutable file
await fs.writeFile(testPath, `test immut ${new Date()}`)
await File.makeImmutable(testPath, indexPath)
await assert.rejects(fs.writeFile(testPath, `test immut change 2 ${new Date()}`), { code: 'EPERM' })
await assert.rejects(fs.unlink(testPath), { code: 'EPERM' })
// can modify and delete a file after lifting immutability
await File.liftImmutability(testPath, indexPath)
await fs.writeFile(testPath, `test immut change 3 ${new Date()}`)
await fs.unlink(testPath)
}
async function handleExistingFile(root, indexPath, path) {
try {
// a vhd block directory is completly immutable
if (isInVhdDirectory(path)) {
// this will trigger 3 times per vhd blocks
const dir = join(root, dirname(path))
if (Directory.isImmutable(dir)) {
await indexFile(dir, indexPath)
}
} else {
// other files are immutable a file basis
const fullPath = join(root, path)
if (File.isImmutable(fullPath)) {
await indexFile(fullPath, indexPath)
}
}
} catch (err) {
if (err.code !== 'EEXIST') {
// there can be a symbolic link in the tree
warn('handleExistingFile', err)
}
}
}
async function handleNewFile(root, indexPath, pendingVhds, path) {
// with awaitWriteFinish we have complete files here
// we can make them immutable
if (isInVhdDirectory(path)) {
// watching a vhd block
// wait for header/footer and BAT before making this immutable recursively
const splitted = path.split(sep)
const vmUuid = splitted[1]
const vdiUuid = splitted[4]
const uniqPath = `${vmUuid}/${vdiUuid}`
const { existing } = pendingVhds.get(uniqPath) ?? {}
if (existing === undefined) {
pendingVhds.set(uniqPath, { existing: 1, lastModified: Date.now() })
} else {
// already two of the key files,and we got the last one
if (existing === 2) {
await Directory.makeImmutable(join(root, dirname(path)), indexPath)
pendingVhds.delete(uniqPath)
} else {
// wait for the other
pendingVhds.set(uniqPath, { existing: existing + 1, lastModified: Date.now() })
}
}
} else {
const fullFilePath = join(root, path)
await File.makeImmutable(fullFilePath, indexPath)
await cleanXoCache(fullFilePath)
}
}
export async function watchRemote(remoteId, { root, immutabilityDuration, rebuildIndexOnStart = false, indexPath }) {
// create index directory
await fs.mkdir(indexPath, { recursive: true })
// test if fs and index directories are well configured
await test(root, indexPath)
// add duration and watch status in the metadata.json of the remote
const settingPath = join(root, 'immutability.json')
try {
// this file won't be made mutable by liftimmutability
await File.liftImmutability(settingPath)
} catch (error) {
// file may not exists, and it's not really a problem
info('lifting immutability on current settings', error)
}
await fs.writeFile(
settingPath,
JSON.stringify({
since: Date.now(),
immutable: true,
duration: immutabilityDuration,
})
)
// no index path in makeImmutable(): the immutability won't be lifted
File.makeImmutable(settingPath)
// we wait for footer/header AND BAT to be written before locking a vhd directory
// this map allow us to track the vhd with partial metadata
const pendingVhds = new Map()
// cleanup pending vhd map periodically
setInterval(
() => {
pendingVhds.forEach(({ lastModified, existing }, path) => {
if (Date.now() - lastModified > 60 * 60 * 1000) {
pendingVhds.delete(path)
warn(`vhd at ${path} is incomplete since ${lastModified}`, { existing, lastModified, path })
}
})
},
60 * 60 * 1000
)
// watch the remote for any new VM metadata json file
const PATHS = [
'xo-config-backups/*/*/data',
'xo-config-backups/*/*/data.json',
'xo-config-backups/*/*/metadata.json',
'xo-pool-metadata-backups/*/metadata.json',
'xo-pool-metadata-backups/*/data',
// xo-vm-backups/<vmuuid>/
'xo-vm-backups/*/*.json',
'xo-vm-backups/*/*.xva',
'xo-vm-backups/*/*.xva.checksum',
// xo-vm-backups/<vmuuid>/vdis/<jobid>/<vdiUuid>
'xo-vm-backups/*/vdis/*/*/*.vhd', // can be an alias or a vhd file
// for vhd directory :
'xo-vm-backups/*/vdis/*/*/data/*.vhd/bat',
'xo-vm-backups/*/vdis/*/*/data/*.vhd/header',
'xo-vm-backups/*/vdis/*/*/data/*.vhd/footer',
]
let ready = false
const watcher = chokidar.watch(PATHS, {
ignored: [
/(^|[/\\])\../, // ignore dotfiles
/\.lock$/,
],
cwd: root,
recursive: false, // vhd directory can generate a lot of folder, don't let chokidar choke on this
ignoreInitial: !rebuildIndexOnStart,
depth: 7,
awaitWriteFinish: true,
})
// Add event listeners.
watcher
.on('add', async path => {
debug(`File ${path} has been added ${path.split('/').length}`)
if (ready) {
await handleNewFile(root, indexPath, pendingVhds, path)
} else {
await handleExistingFile(root, indexPath, path)
}
})
.on('error', error => warn(`Watcher error: ${error}`))
.on('ready', () => {
ready = true
info('Ready for changes')
})
}
const { remotes } = await loadConfig()
for (const [remoteId, remote] of Object.entries(remotes)) {
watchRemote(remoteId, remote).catch(err => warn('error during watchRemote', { err, remoteId, remote }))
}

View File

@@ -1,29 +0,0 @@
/* eslint-env node */
require("@rushstack/eslint-patch/modern-module-resolution");
module.exports = {
globals: {
XO_LITE_GIT_HEAD: true,
XO_LITE_VERSION: true,
},
root: true,
env: {
node: true,
},
extends: [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/eslint-config-typescript/recommended",
"@vue/eslint-config-prettier",
],
plugins: ["@limegrass/import-alias"],
ignorePatterns: ["scripts/*.mjs"],
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
"@limegrass/import-alias/import-alias": [
"error",
{ aliasConfigPath: require("path").join(__dirname, "tsconfig.json") },
],
},
};

View File

@@ -1,4 +0,0 @@
// Keeping this file to prevent applying the global monorepo config for now
module.exports = {
trailingComma: "es5",
};

View File

@@ -2,12 +2,19 @@
## **next**
- Fix Typescript typings errors when running `yarn type-check` command (PR [#7278](https://github.com/vatesfr/xen-orchestra/pull/7278))
- Introduce PWA Json Manifest (PR [#7291](https://github.com/vatesfr/xen-orchestra/pull/7291))
## **0.1.7** (2023-12-28)
- [VM/Action] Ability to migrate a VM from its view (PR [#7164](https://github.com/vatesfr/xen-orchestra/pull/7164))
- Ability to override host address with `master` URL query param (PR [#7187](https://github.com/vatesfr/xen-orchestra/pull/7187))
- Added tooltip on CPU provisioning warning icon (PR [#7223](https://github.com/vatesfr/xen-orchestra/pull/7223))
- Add indeterminate state on FormToggle component (PR [#7230](https://github.com/vatesfr/xen-orchestra/pull/7230))
- Add new UiStatusPanel component (PR [#7227](https://github.com/vatesfr/xen-orchestra/pull/7227))
- XOA quick deploy (PR [#7245](https://github.com/vatesfr/xen-orchestra/pull/7245))
- Fix infinite loader when no stats on pool dashboard (PR [#7236](https://github.com/vatesfr/xen-orchestra/pull/7236))
- [Tree view] Display VMs count (PR [#7185](https://github.com/vatesfr/xen-orchestra/pull/7185))
## **0.1.6** (2023-11-30)

View File

@@ -48,18 +48,16 @@ Note: When reading Vue official doc, don't forget to set "API Preference" toggle
```vue
<script lang="ts" setup>
import { computed, ref } from "vue";
import { computed, ref } from 'vue'
const props = defineProps<{
greetings: string;
}>();
greetings: string
}>()
const firstName = ref("");
const lastName = ref("");
const firstName = ref('')
const lastName = ref('')
const fullName = computed(
() => `${props.greetings} ${firstName.value} ${lastName.value}`
);
const fullName = computed(() => `${props.greetings} ${firstName.value} ${lastName.value}`)
</script>
```
@@ -73,9 +71,9 @@ Vue variables can be interpolated with `v-bind`.
```vue
<script lang="ts" setup>
import { ref } from "vue";
import { ref } from 'vue'
const fontSize = ref("2rem");
const fontSize = ref('2rem')
</script>
<style scoped>
@@ -105,8 +103,8 @@ Use the `busy` prop to display a loader icon.
</template>
<script lang="ts" setup>
import UiIcon from "@/components/ui/icon/UiIcon.vue";
import { faDisplay } from "@fortawesome/free-solid-svg-icons";
import UiIcon from '@/components/ui/icon/UiIcon.vue'
import { faDisplay } from '@fortawesome/free-solid-svg-icons'
</script>
```
@@ -140,21 +138,21 @@ For a `foobar` store, create a `store/foobar.store.ts` then use `defineStore('fo
#### Example
```typescript
import { computed, ref } from "vue";
import { computed, ref } from 'vue'
export const useFoobarStore = defineStore("foobar", () => {
const aStateVar = ref(0);
const otherStateVar = ref(0);
const aGetter = computed(() => aStateVar.value * 2);
const anAction = () => (otherStateVar.value += 10);
export const useFoobarStore = defineStore('foobar', () => {
const aStateVar = ref(0)
const otherStateVar = ref(0)
const aGetter = computed(() => aStateVar.value * 2)
const anAction = () => (otherStateVar.value += 10)
return {
aStateVar,
otherStateVar,
aGetter,
anAction,
};
});
}
})
```
### I18n

View File

@@ -85,9 +85,9 @@ In your `.story.vue` file, import and use the `ComponentStory` component.
</template>
<script lang="ts" setup>
import MyComponent from "@/components/MyComponent.vue";
import ComponentStory from "@/components/component-story/ComponentStory.vue";
import { prop, event, model, slot, setting } from "@/libs/story/story-param";
import MyComponent from '@/components/MyComponent.vue'
import ComponentStory from '@/components/component-story/ComponentStory.vue'
import { prop, event, model, slot, setting } from '@/libs/story/story-param'
</script>
```
@@ -119,27 +119,27 @@ Let's take this Vue component:
<script lang="ts" setup>
withDefaults(
defineProps<{
imString: string;
imNumber: number;
imOptional?: string;
imOptionalWithDefault?: string;
modelValue?: string;
customModel?: number;
imString: string
imNumber: number
imOptional?: string
imOptionalWithDefault?: string
modelValue?: string
customModel?: number
}>(),
{ imOptionalWithDefault: "Hi World" }
);
{ imOptionalWithDefault: 'Hi World' }
)
const emit = defineEmits<{
(event: "click"): void;
(event: "clickWithArg", id: string): void;
(event: "update:modelValue", value: string): void;
(event: "update:customModel", value: number): void;
}>();
(event: 'click'): void
(event: 'clickWithArg', id: string): void
(event: 'update:modelValue', value: string): void
(event: 'update:customModel', value: number): void
}>()
const moonDistance = 384400;
const moonDistance = 384400
const handleClick = () => emit("click");
const handleClickWithArg = (id: string) => emit("clickWithArg", id);
const handleClick = () => emit('click')
const handleClickWithArg = (id: string) => emit('clickWithArg', id)
</script>
```
@@ -150,53 +150,33 @@ Here is how to document it with a Component Story:
<ComponentStory
v-slot="{ properties, settings }"
:params="[
prop('imString')
.str()
.required()
.preset('Example')
.widget()
.help('This is a required string prop'),
prop('imNumber')
.num()
.required()
.preset(42)
.widget()
.help('This is a required number prop'),
prop('imString').str().required().preset('Example').widget().help('This is a required string prop'),
prop('imNumber').num().required().preset(42).widget().help('This is a required number prop'),
prop('imOptional').str().widget().help('This is an optional string prop'),
prop('imOptionalWithDefault')
.str()
.default('Hi World')
.widget()
.default('My default value'),
model().prop((p) => p.str()),
model('customModel').prop((p) => p.num()),
prop('imOptionalWithDefault').str().default('Hi World').widget().default('My default value'),
model().prop(p => p.str()),
model('customModel').prop(p => p.num()),
event('click').help('Emitted when the user clicks the first button'),
event('clickWithArg')
.args({ id: 'string' })
.help('Emitted when the user clicks the second button'),
event('clickWithArg').args({ id: 'string' }).help('Emitted when the user clicks the second button'),
slot().help('This is the default slot'),
slot('namedSlot').help('This is a named slot'),
slot('namedScopedSlot')
.prop('moon-distance', 'number')
.help('This is a named slot'),
slot('namedScopedSlot').prop('moon-distance', 'number').help('This is a named slot'),
setting('contentExample').widget(text()).preset('Some content'),
]"
>
<MyComponent v-bind="properties">
{{ settings.contentExample }}
<template #named-slot>Named slot content</template>
<template #named-scoped-slot="{ moonDistance }">
Moon distance is {{ moonDistance }} meters.
</template>
<template #named-scoped-slot="{ moonDistance }"> Moon distance is {{ moonDistance }} meters. </template>
</MyComponent>
</ComponentStory>
</template>
<script lang="ts" setup>
import ComponentStory from "@/components/component-story/ComponentStory.vue";
import MyComponent from "@/components/MyComponent.vue";
import { event, model, prop, setting, slot } from "@/libs/story/story-param";
import { text } from "@/libs/story/story-widget";
import ComponentStory from '@/components/component-story/ComponentStory.vue'
import MyComponent from '@/components/MyComponent.vue'
import { event, model, prop, setting, slot } from '@/libs/story/story-param'
import { text } from '@/libs/story/story-widget'
</script>
```

View File

@@ -20,45 +20,45 @@ This will return an object with the following methods:
### Static modal
```ts
useModal(MyModal);
useModal(MyModal)
```
### Modal with props
```ts
useModal(MyModal, { message: "Hello world!" });
useModal(MyModal, { message: 'Hello world!' })
```
### Handle modal approval
```ts
const { onApprove } = useModal(MyModal, { message: "Hello world!" });
const { onApprove } = useModal(MyModal, { message: 'Hello world!' })
onApprove(() => console.log("Modal approved"));
onApprove(() => console.log('Modal approved'))
```
### Handle modal approval with payload
```ts
const { onApprove } = useModal(MyModal, { message: "Hello world!" });
const { onApprove } = useModal(MyModal, { message: 'Hello world!' })
onApprove((payload) => console.log("Modal approved with payload", payload));
onApprove(payload => console.log('Modal approved with payload', payload))
```
### Handle modal decline
```ts
const { onDecline } = useModal(MyModal, { message: "Hello world!" });
const { onDecline } = useModal(MyModal, { message: 'Hello world!' })
onDecline(() => console.log("Modal declined"));
onDecline(() => console.log('Modal declined'))
```
### Handle modal close
```ts
const { onClose } = useModal(MyModal, { message: "Hello world!" });
const { onClose } = useModal(MyModal, { message: 'Hello world!' })
onClose(() => console.log("Modal closed"));
onClose(() => console.log('Modal closed'))
```
## Modal controller
@@ -66,7 +66,7 @@ onClose(() => console.log("Modal closed"));
Inside the modal component, you can inject the modal controller with `inject(IK_MODAL)!`.
```ts
const modal = inject(IK_MODAL)!;
const modal = inject(IK_MODAL)!
```
You can then use the following properties and methods on the `modal` object:

View File

@@ -36,7 +36,7 @@ They are stored in `src/composables/xen-api-collection/*-collection.composable.t
```typescript
// src/composables/xen-api-collection/console-collection.composable.ts
export const useConsoleCollection = () => useXenApiCollection("console");
export const useConsoleCollection = () => useXenApiCollection('console')
```
If you want to allow the user to defer the subscription, you can propagate the options to `useXenApiCollection`.
@@ -44,19 +44,16 @@ If you want to allow the user to defer the subscription, you can propagate the o
```typescript
// console-collection.composable.ts
export const useConsoleCollection = <
Immediate extends boolean = true,
>(options?: {
immediate?: Immediate;
}) => useXenApiCollection("console", options);
export const useConsoleCollection = <Immediate extends boolean = true>(options?: { immediate?: Immediate }) =>
useXenApiCollection('console', options)
```
```typescript
// MyComponent.vue
const collection = useConsoleCollection({ immediate: false });
const collection = useConsoleCollection({ immediate: false })
setTimeout(() => collection.start(), 10000);
setTimeout(() => collection.start(), 10000)
```
## Alter the collection
@@ -68,10 +65,10 @@ You can alter the collection by overriding parts of it.
```typescript
// xen-api.ts
export interface XenApiConsole extends XenApiRecord<"console"> {
export interface XenApiConsole extends XenApiRecord<'console'> {
// ... existing props
someProp: string;
someOtherProp: number;
someProp: string
someOtherProp: number
}
```
@@ -79,27 +76,27 @@ export interface XenApiConsole extends XenApiRecord<"console"> {
// console-collection.composable.ts
export const useConsoleCollection = () => {
const collection = useXenApiCollection("console");
const collection = useXenApiCollection('console')
const records = computed(() => {
return collection.records.value.map((console) => ({
return collection.records.value.map(console => ({
...console,
someProp: "Some value",
someProp: 'Some value',
someOtherProp: 42,
}));
});
}))
})
return {
...collection,
records,
};
};
}
}
```
```typescript
const consoleCollection = useConsoleCollection();
const consoleCollection = useConsoleCollection()
consoleCollection.getByUuid("...").someProp; // "Some value"
consoleCollection.getByUuid('...').someProp // "Some value"
```
### Example 2: Adding props to the collection
@@ -108,17 +105,13 @@ consoleCollection.getByUuid("...").someProp; // "Some value"
// vm-collection.composable.ts
export const useVmCollection = () => {
const collection = useXenApiCollection("VM");
const collection = useXenApiCollection('VM')
return {
...collection,
runningVms: computed(() =>
collection.records.value.filter(
(vm) => vm.power_state === POWER_STATE.RUNNING
)
),
};
};
runningVms: computed(() => collection.records.value.filter(vm => vm.power_state === POWER_STATE.RUNNING)),
}
}
```
### Example 3, filtering and sorting the collection
@@ -127,18 +120,15 @@ export const useVmCollection = () => {
// vm-collection.composable.ts
export const useVmCollection = () => {
const collection = useXenApiCollection("VM");
const collection = useXenApiCollection('VM')
return {
...collection,
records: computed(() =>
collection.records.value
.filter(
(vm) =>
!vm.is_a_snapshot && !vm.is_a_template && !vm.is_control_domain
)
.filter(vm => !vm.is_a_snapshot && !vm.is_a_template && !vm.is_control_domain)
.sort((vm1, vm2) => vm1.name_label.localeCompare(vm2.name_label))
),
};
};
}
}
```

View File

@@ -2,5 +2,5 @@
/// <reference types="json-rpc-2.0/dist" />
/// <reference types="vite-plugin-pages/client" />
declare const XO_LITE_VERSION: string;
declare const XO_LITE_GIT_HEAD: string;
declare const XO_LITE_VERSION: string
declare const XO_LITE_GIT_HEAD: string

View File

@@ -2,7 +2,8 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<link rel="manifest" href="/manifest.webmanifest" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>XO Lite</title>
</head>

View File

@@ -1,43 +1,42 @@
{
"name": "@xen-orchestra/lite",
"version": "0.1.6",
"version": "0.1.7",
"type": "module",
"scripts": {
"dev": "GIT_HEAD=$(git rev-parse HEAD) vite",
"build": "run-p type-check build-only",
"preview": "vite preview --port 4173",
"release": "zx ./scripts/release.mjs",
"release": "./scripts/release.mjs",
"build-only": "yarn release --build",
"deploy": "yarn release --build --deploy",
"gh-release": "yarn release --build --tarball --gh-release",
"test": "yarn run type-check",
"type-check": "vue-tsc --noEmit"
"type-check": "vue-tsc --build --force tsconfig.type-check.json"
},
"devDependencies": {
"@csstools/postcss-global-data": "^2.1.1",
"@fontsource/poppins": "^5.0.8",
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-regular-svg-icons": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-regular-svg-icons": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/vue-fontawesome": "^3.0.5",
"@intlify/unplugin-vue-i18n": "^1.5.0",
"@limegrass/eslint-plugin-import-alias": "^1.1.0",
"@intlify/unplugin-vue-i18n": "^2.0.0",
"@novnc/novnc": "^1.4.0",
"@rushstack/eslint-patch": "^1.5.1",
"@tsconfig/node18": "^18.2.2",
"@types/d3-time-format": "^4.0.3",
"@types/file-saver": "^2.0.7",
"@types/lodash-es": "^4.17.11",
"@types/node": "^18.18.9",
"@vitejs/plugin-vue": "^4.4.0",
"@vue/eslint-config-prettier": "^8.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/tsconfig": "^0.4.0",
"@vueuse/core": "^10.5.0",
"@vueuse/math": "^10.5.0",
"@types/lodash-es": "^4.17.12",
"@types/node": "^18.19.7",
"@vitejs/plugin-vue": "^5.0.3",
"@vue/tsconfig": "^0.5.1",
"@vueuse/core": "^10.7.1",
"@vueuse/math": "^10.7.1",
"@vueuse/shared": "^10.7.1",
"@xen-orchestra/web-core": "*",
"complex-matcher": "^0.7.1",
"d3-time-format": "^4.1.0",
"decorator-synchronized": "^0.6.0",
"echarts": "^5.4.3",
"eslint-plugin-vue": "^9.18.1",
"file-saver": "^2.0.5",
"highlight.js": "^11.9.0",
"human-format": "^1.2.0",
@@ -48,19 +47,21 @@
"lodash-es": "^4.17.21",
"make-error": "^1.3.6",
"marked": "^9.1.5",
"minimist": "^1.2.8",
"npm-run-all": "^4.1.5",
"pinia": "^2.1.7",
"placement.js": "^1.0.0-beta.5",
"postcss": "^8.4.31",
"postcss": "^8.4.33",
"postcss-color-function": "^4.1.0",
"postcss-custom-media": "^10.0.2",
"postcss-nested": "^6.0.1",
"typescript": "^5.2.2",
"vite": "^4.5.0",
"vue": "^3.3.8",
"vue-echarts": "^6.6.1",
"vue-i18n": "^9.6.5",
"typescript": "~5.3.3",
"vite": "^5.0.11",
"vue": "^3.4.13",
"vue-echarts": "^6.6.8",
"vue-i18n": "^9.9.0",
"vue-router": "^4.2.5",
"vue-tsc": "^1.8.22",
"vue-tsc": "^1.8.27",
"zx": "^7.2.3"
},
"private": true,

View File

@@ -1,6 +0,0 @@
module.exports = {
plugins: {
"postcss-nested": {},
"postcss-custom-media": {},
},
};

View File

@@ -0,0 +1,10 @@
export default {
plugins: {
'@csstools/postcss-global-data': {
files: ['../web-core/lib/assets/css/.globals.pcss'],
},
'postcss-nested': {},
'postcss-custom-media': {},
'postcss-color-function': {},
},
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,14 @@
{
"name": "XO Lite",
"short_name": "XOLite",
"start_url": "/",
"display": "standalone",
"description": "Integrated local and lightweight solution to manage a local XCP-ng pool.",
"icons": [
{
"src": "favicon.svg",
"sizes": "any",
"type": "image/svg+xml"
}
]
}

281
@xen-orchestra/lite/scripts/release.mjs Normal file → Executable file
View File

@@ -1,53 +1,34 @@
#!/usr/bin/env zx
#!/usr/bin/env node
import argv from "minimist";
import { tmpdir } from "os";
import argv from 'minimist'
import { tmpdir } from 'os'
import { fileURLToPath, URL } from 'url'
import { $, cd, chalk, fs, path, question, within } from 'zx'
$.verbose = false;
$.verbose = false
const DEPLOY_SERVER = "www-xo.gpn.vates.fr";
const DEPLOY_SERVER = 'www-xo.gpn.vates.fr'
const { version: pkgVersion } = await fs.readJson("./package.json");
const { version: pkgVersion } = await fs.readJson('./package.json')
const opts = argv(process.argv, {
boolean: ["help", "build", "deploy", "ghRelease", "tarball"],
string: [
"base",
"dist",
"ghToken",
"tarballDest",
"tarballName",
"username",
"version",
],
boolean: ['help', 'build', 'deploy', 'ghRelease', 'tarball'],
string: ['base', 'dist', 'ghToken', 'tarballDest', 'tarballName', 'username', 'version'],
alias: {
u: "username",
h: "help",
"gh-release": "ghRelease",
"gh-token": "ghToken",
"tarball-dest": "tarballDest",
"tarball-name": "tarballName",
u: 'username',
h: 'help',
'gh-release': 'ghRelease',
'gh-token': 'ghToken',
'tarball-dest': 'tarballDest',
'tarball-name': 'tarballName',
},
default: {
dist: "dist",
dist: 'dist',
version: pkgVersion,
},
});
})
let {
base,
build,
deploy,
dist,
ghRelease,
ghToken,
help,
tarball,
tarballDest,
tarballName,
username,
version,
} = opts;
let { base, build, deploy, dist, ghRelease, ghToken, help, tarball, tarballDest, tarballName, username, version } = opts
const usage = () => {
console.log(
@@ -78,172 +59,164 @@ const usage = () => {
--username|-u <LDAP username>
]
`
);
};
if (help) {
usage();
process.exit(0);
)
}
const yes = async (q) =>
["y", "yes"].includes((await question(q + " [y/N] ")).toLowerCase());
if (help) {
usage()
process.exit(0)
}
const no = async (q) => !(await yes(q));
const yes = async q => ['y', 'yes'].includes((await question(q + ' [y/N] ')).toLowerCase())
const step = (s) => console.log(chalk.green.bold(`\n${s}\n`));
const no = async q => !(await yes(q))
const step = s => console.log(chalk.green.bold(`\n${s}\n`))
const stop = () => {
console.log(chalk.yellow("Stopping"));
process.exit(0);
};
console.log(chalk.yellow('Stopping'))
process.exit(0)
}
const ghApiCall = async (path, method = "GET", data) => {
const ghApiCall = async (path, method = 'GET', data) => {
const opts = {
method,
headers: {
Accept: "application/vnd.github+json",
Accept: 'application/vnd.github+json',
Authorization: `Bearer ${ghToken}`,
"X-GitHub-Api-Version": "2022-11-28",
'X-GitHub-Api-Version': '2022-11-28',
},
};
if (data !== undefined) {
opts.body = typeof data === "object" ? JSON.stringify(data) : data;
}
const res = await fetch(
"https://api.github.com/repos/vatesfr/xen-orchestra" + path,
opts
);
if (data !== undefined) {
opts.body = typeof data === 'object' ? JSON.stringify(data) : data
}
const res = await fetch('https://api.github.com/repos/vatesfr/xen-orchestra' + path, opts)
if (res.status === 404 || res.status === 422) {
return;
return
}
if (!res.ok) {
console.log(chalk.red(await res.text()));
throw new Error(`GitHub API error: ${res.statusText}`);
console.log(chalk.red(await res.text()))
throw new Error(`GitHub API error: ${res.statusText}`)
}
try {
// Return undefined if response is not JSON
return JSON.parse(await res.text());
return JSON.parse(await res.text())
} catch {}
};
}
const ghApiUploadReleaseAsset = async (releaseId, assetName, file) => {
const opts = {
method: "POST",
method: 'POST',
body: fs.createReadStream(file),
headers: {
Accept: "application/vnd.github+json",
Accept: 'application/vnd.github+json',
Authorization: `Bearer ${ghToken}`,
"Content-Length": (await fs.stat(file)).size,
"Content-Type": "application/vnd.cncf.helm.chart.content.v1.tar+gzip",
"X-GitHub-Api-Version": "2022-11-28",
'Content-Length': (await fs.stat(file)).size,
'Content-Type': 'application/vnd.cncf.helm.chart.content.v1.tar+gzip',
'X-GitHub-Api-Version': '2022-11-28',
},
};
}
const res = await fetch(
`https://uploads.github.com/repos/vatesfr/xen-orchestra/releases/${releaseId}/assets?name=${encodeURIComponent(
assetName
)}`,
opts
);
)
if (!res.ok) {
console.log(chalk.red(await res.text()));
throw new Error(`GitHub API error: ${res.statusText}`);
console.log(chalk.red(await res.text()))
throw new Error(`GitHub API error: ${res.statusText}`)
}
return JSON.parse(await res.text());
};
return JSON.parse(await res.text())
}
// Validate args and assign defaults -------------------------------------------
const headSha = (await $`git rev-parse HEAD`).stdout.trim();
const headSha = (await $`git rev-parse HEAD`).stdout.trim()
if (!build && !deploy && !tarball && !ghRelease) {
console.log(
chalk.yellow(
"Nothing to do! Use --build, --deploy, --tarball and/or --gh-release"
)
);
process.exit(0);
console.log(chalk.yellow('Nothing to do! Use --build, --deploy, --tarball and/or --gh-release'))
process.exit(0)
}
if (deploy && ghRelease) {
throw new Error("--deploy and --gh-release cannot be used together");
throw new Error('--deploy and --gh-release cannot be used together')
}
if (deploy && username === undefined) {
throw new Error("--username is required when --deploy is used");
throw new Error('--username is required when --deploy is used')
}
if (ghRelease && ghToken === undefined) {
throw new Error("--gh-token is required to upload a release to GitHub");
throw new Error('--gh-token is required to upload a release to GitHub')
}
if (base === undefined) {
base = deploy ? "https://lite.xen-orchestra.com/dist/" : "/";
base = deploy ? 'https://lite.xen-orchestra.com/dist/' : '/'
}
if (tarball) {
if (tarballDest === undefined) {
tarballDest = path.join(tmpdir(), `xo-lite-${new Date().toISOString()}`);
tarballDest = path.join(tmpdir(), `xo-lite-${new Date().toISOString()}`)
}
if (tarballName === undefined) {
tarballName = `xo-lite-${version}.tar.gz`;
tarballName = `xo-lite-${version}.tar.gz`
}
}
if (tarballDest !== undefined) {
tarballDest = path.resolve(tarballDest);
tarballDest = path.resolve(tarballDest)
}
if (ghRelease && (tarballDest === undefined || tarballName === undefined)) {
throw new Error(
"In order to release to GitHub, either use --tarball to generate the tarball or provide the tarball with --tarball-dest and --tarball-name"
);
'In order to release to GitHub, either use --tarball to generate the tarball or provide the tarball with --tarball-dest and --tarball-name'
)
}
let tarballPath;
let tarballExists = false;
let tarballPath
let tarballExists = false
if (tarballDest !== undefined && tarballName !== undefined) {
tarballPath = path.join(tarballDest, tarballName);
tarballPath = path.join(tarballDest, tarballName)
try {
if ((await fs.stat(tarballPath)).isFile()) {
tarballExists = true;
tarballExists = true
}
} catch (err) {
if (err.code !== "ENOENT") {
throw err;
if (err.code !== 'ENOENT') {
throw err
}
}
}
if (ghRelease && !tarball && !tarballExists) {
throw new Error(`No such file ${tarballPath}`);
throw new Error(`No such file ${tarballPath}`)
}
if (tarball && tarballExists) {
if (await no(`Tarball ${tarballPath} already exists. Overwrite?`)) {
stop();
stop()
}
}
const tag = `xo-lite-v${version}`;
const tag = `xo-lite-v${version}`
if (ghRelease) {
const remoteTag = await ghApiCall(`/git/ref/tags/${encodeURIComponent(tag)}`);
const remoteTag = await ghApiCall(`/git/ref/tags/${encodeURIComponent(tag)}`)
if (remoteTag === undefined) {
if ((await ghApiCall(`/commits/${headSha}`)) === undefined) {
throw new Error(
`Tag ${tag} and commit ${headSha} not found on GitHub. At least one needs to exist to use it as a release target.`
);
)
}
if (
@@ -251,7 +224,7 @@ if (ghRelease) {
`Tag ${tag} not found on GitHub. The GitHub release will be attached to the current commit and the tag will be created automatically when the release is published. Continue?`
)
) {
stop();
stop()
}
} else {
if (
@@ -260,17 +233,14 @@ if (ghRelease) {
`Commit SHA of tag ${tag} on GitHub (${remoteTag.object.sha}) is different from current commit SHA (${headSha}). Continue?`
))
) {
stop();
stop()
}
if (
!(await $`git tag --points-at HEAD`).stdout
.trim()
.split("\n")
.includes(tag) &&
!(await $`git tag --points-at HEAD`).stdout.trim().split('\n').includes(tag) &&
(await no(`Tag ${tag} not found on current commit. Continue?`))
) {
stop();
stop()
}
}
}
@@ -278,67 +248,62 @@ if (ghRelease) {
// Build -----------------------------------------------------------------------
if (build) {
step("Build");
step('Build')
console.log(`Building XO Lite ${version} into ${dist}`);
console.log(`Building XO Lite ${version} into ${dist}`)
$.verbose = true;
$.verbose = true
await within(async () => {
cd("../..");
await $`yarn`;
});
await $`GIT_HEAD=${headSha} vite build --base=${base}`;
$.verbose = false;
cd('../..')
await $`yarn`
})
await $`GIT_HEAD=${headSha} vite build --base=${base}`
$.verbose = false
}
// License and index.js --------------------------------------------------------
if (ghRelease || deploy) {
step("Prepare dist");
step('Prepare dist')
if (ghRelease) {
console.log(`Adding LICENSE file to ${dist}`);
await fs.copy(
path.join(__dirname, "agpl-3.0.txt"),
path.join(dist, "LICENSE")
);
console.log(`Adding LICENSE file to ${dist}`)
await fs.copy(fileURLToPath(new URL('agpl-3.0.txt', import.meta.url)), path.join(dist, 'LICENSE'))
}
if (deploy) {
console.log(`Adding index.js file to ${dist}`);
console.log(`Adding index.js file to ${dist}`)
// Concatenate a URL (absolute or relative) and paths
// e.g.: joinUrl('http://example.com/', 'foo/bar') => 'http://example.com/foo/bar
// `path.join` isn't made for URLs and deduplicates the slashes in URL
// schemes (http:// becomes http:/). `.replace()` reverts this.
const joinUrl = (...parts) =>
path.join(...parts).replace(/^(https?:\/)/, "$1/");
const joinUrl = (...parts) => path.join(...parts).replace(/^(https?:\/)/, '$1/')
// Use of document.write is discouraged but seems to work consistently.
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document.write()
await fs.writeFile(
path.join(dist, "index.js"),
path.join(dist, 'index.js'),
`(async () => {
document.open();
document.write(
await (await fetch("${joinUrl(base, "index.html")}")).text()
await (await fetch("${joinUrl(base, 'index.html')}")).text()
);
document.close();
})();
`
);
)
}
}
// Tarball ---------------------------------------------------------------------
if (tarball) {
step("Tarball");
step('Tarball')
console.log(`Generating tarball ${tarballPath}`);
console.log(`Generating tarball ${tarballPath}`)
await fs.mkdirp(tarballDest);
await fs.mkdirp(tarballDest)
// The file is called xo-lite-X.Y.Z.tar.gz by default
// The archive contains the following tree:
@@ -348,17 +313,15 @@ if (tarball) {
// ├ index.html
// ├ assets/
// └ ...
await $`tar -c -z -f ${tarballPath} --transform='s|^${dist}|xo-lite-${version}|' ${dist}`;
await $`tar -c -z -f ${tarballPath} --transform='s|^${dist}|xo-lite-${version}|' ${dist}`
}
// Create GitHub release -------------------------------------------------------
if (ghRelease) {
step("GitHub release");
step('GitHub release')
let release = (await ghApiCall("/releases")).find(
(release) => release.tag_name === tag
);
let release = (await ghApiCall('/releases')).find(release => release.tag_name === tag)
if (release !== undefined) {
if (
@@ -368,37 +331,33 @@ if (ghRelease) {
)}). Skip and proceed with upload?`
)
) {
stop();
stop()
}
} else {
release = await ghApiCall("/releases", "POST", {
release = await ghApiCall('/releases', 'POST', {
tag_name: tag,
target_commitish: headSha,
name: tag,
draft: true,
});
})
console.log(
`Created GitHub release ${tag}: ${chalk.blue(release.html_url)}`
);
console.log(`Created GitHub release ${tag}: ${chalk.blue(release.html_url)}`)
}
console.log(`Uploading tarball ${tarballPath} to GitHub`);
console.log(`Uploading tarball ${tarballPath} to GitHub`)
let asset = release.assets.find((asset) => asset.name === tarballName);
let asset = release.assets.find(asset => asset.name === tarballName)
if (
asset !== undefined &&
(await yes(
`An asset called ${tarballName} already exists on that release. Replace it?`
))
(await yes(`An asset called ${tarballName} already exists on that release. Replace it?`))
) {
await ghApiCall(`/releases/assets/${asset.id}`, "DELETE");
asset = undefined;
await ghApiCall(`/releases/assets/${asset.id}`, 'DELETE')
asset = undefined
}
if (asset === undefined) {
console.log("Uploading…");
asset = await ghApiUploadReleaseAsset(release.id, tarballName, tarballPath);
console.log('Uploading…')
asset = await ghApiUploadReleaseAsset(release.id, tarballName, tarballPath)
}
if (release.draft) {
@@ -406,18 +365,18 @@ if (ghRelease) {
chalk.yellow(
'The release is in DRAFT. To make it public, visit the release URL above, edit the release and click on "Publish release".'
)
);
)
}
}
// Deploy ----------------------------------------------------------------------
if (deploy) {
step("Deploy");
step('Deploy')
console.log(`Deploying XO Lite from ${dist} to ${DEPLOY_SERVER}`);
console.log(`Deploying XO Lite from ${dist} to ${DEPLOY_SERVER}`)
await $`rsync -r --delete ${dist}/ ${username}@${DEPLOY_SERVER}:xo-lite`;
await $`rsync -r --delete ${dist}/ ${username}@${DEPLOY_SERVER}:xo-lite`
console.log(`
XO Lite files sent to server
@@ -430,5 +389,5 @@ if (deploy) {
→ Then run the following command to move the files to the \`latest\` folder:
\trsync -r --delete /home/${username}/xo-lite/ /home/xo-lite/public/latest
`);
`)
}

View File

@@ -16,77 +16,56 @@
</template>
<script lang="ts" setup>
import favicon from "@/assets/favicon.svg";
import AppHeader from "@/components/AppHeader.vue";
import AppLogin from "@/components/AppLogin.vue";
import AppNavigation from "@/components/AppNavigation.vue";
import AppTooltips from "@/components/AppTooltips.vue";
import ModalList from "@/components/ui/modals/ModalList.vue";
import { useChartTheme } from "@/composables/chart-theme.composable";
import { useUnreachableHosts } from "@/composables/unreachable-hosts.composable";
import { useUiStore } from "@/stores/ui.store";
import { usePoolCollection } from "@/stores/xen-api/pool.store";
import { useXenApiStore } from "@/stores/xen-api.store";
import { useActiveElement, useMagicKeys, whenever } from "@vueuse/core";
import { logicAnd } from "@vueuse/math";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import AppHeader from '@/components/AppHeader.vue'
import AppLogin from '@/components/AppLogin.vue'
import AppNavigation from '@/components/AppNavigation.vue'
import AppTooltips from '@/components/AppTooltips.vue'
import ModalList from '@/components/ui/modals/ModalList.vue'
import { useChartTheme } from '@/composables/chart-theme.composable'
import { useUnreachableHosts } from '@/composables/unreachable-hosts.composable'
import { useUiStore } from '@/stores/ui.store'
import { usePoolCollection } from '@/stores/xen-api/pool.store'
import { useXenApiStore } from '@/stores/xen-api.store'
import { useActiveElement, useMagicKeys, whenever } from '@vueuse/core'
import { logicAnd } from '@vueuse/math'
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
let link = document.querySelector(
"link[rel~='icon']"
) as HTMLLinkElement | null;
if (link == null) {
link = document.createElement("link");
link.rel = "icon";
document.getElementsByTagName("head")[0].appendChild(link);
}
link.href = favicon;
const xenApiStore = useXenApiStore()
const xenApiStore = useXenApiStore();
const { pool } = usePoolCollection()
const { pool } = usePoolCollection();
useChartTheme();
const uiStore = useUiStore();
useChartTheme()
const uiStore = useUiStore()
if (import.meta.env.DEV) {
const { locale } = useI18n();
const activeElement = useActiveElement();
const { D, L } = useMagicKeys();
const { locale } = useI18n()
const activeElement = useActiveElement()
const { D, L } = useMagicKeys()
const canToggle = computed(() => {
if (activeElement.value == null) {
return true;
return true
}
return !["INPUT", "TEXTAREA"].includes(activeElement.value.tagName);
});
return !['INPUT', 'TEXTAREA'].includes(activeElement.value.tagName)
})
whenever(
logicAnd(D, canToggle),
() => (uiStore.colorMode = uiStore.colorMode === "dark" ? "light" : "dark")
);
whenever(logicAnd(D, canToggle), () => (uiStore.colorMode = uiStore.colorMode === 'dark' ? 'light' : 'dark'))
whenever(
logicAnd(L, canToggle),
() => (locale.value = locale.value === "en" ? "fr" : "en")
);
whenever(logicAnd(L, canToggle), () => (locale.value = locale.value === 'en' ? 'fr' : 'en'))
}
whenever(
() => pool.value?.$ref,
(poolRef) => {
xenApiStore.getXapi().startWatching(poolRef);
poolRef => {
xenApiStore.getXapi().startWatching(poolRef)
}
);
)
useUnreachableHosts();
useUnreachableHosts()
</script>
<style lang="postcss">
@import "@/assets/base.css";
</style>
<style lang="postcss" scoped>
.main {
overflow: auto;

View File

@@ -1,2 +0,0 @@
@custom-media --mobile (max-width: 1023px);
@custom-media --desktop (min-width: 1024px);

View File

@@ -1,100 +0,0 @@
@import "reset.css";
@import "theme.css";
@import "@fontsource/poppins/400.css";
@import "@fontsource/poppins/500.css";
@import "@fontsource/poppins/600.css";
@import "@fontsource/poppins/700.css";
@import "@fontsource/poppins/900.css";
@import "@fontsource/poppins/400-italic.css";
body {
min-height: 100vh;
font-size: 1.3rem;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: var(--color-blue-scale-100);
}
a {
color: var(--color-extra-blue-base);
}
code,
code * {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
"Courier New", monospace;
}
.card-view {
padding: 1.2rem;
display: flex;
gap: 2rem;
}
.link {
text-decoration: underline;
color: var(--color-extra-blue-base);
cursor: pointer;
}
.link:hover {
color: var(--color-extra-blue-d20);
}
.link:active,
.link.router-link-active {
color: var(--color-extra-blue-d40);
}
.link.router-link-active {
text-decoration: underline;
}
.context-color-success {
color: var(--color-green-infra-base);
}
.context-color-error {
color: var(--color-red-vates-base);
}
.context-color-warning {
color: var(--color-orange-world-base);
}
.context-color-info {
color: var(--color-extra-blue-base);
}
.context-background-color-success {
background-color: var(--background-color-green-infra);
}
.context-background-color-error {
background-color: var(--background-color-red-vates);
}
.context-background-color-warning {
background-color: var(--background-color-orange-world);
}
.context-background-color-info {
background-color: var(--background-color-extra-blue);
}
.context-border-color-success {
border-color: var(--color-green-infra-base);
}
.context-border-color-error {
border-color: var(--color-red-vates-base);
}
.context-border-color-warning {
border-color: var(--color-orange-world-base);
}
.context-border-color-info {
border-color: var(--color-extra-blue-base);
}

View File

@@ -1,38 +0,0 @@
html {
box-sizing: border-box;
font-size: 10px;
}
*,
*::before,
*::after {
box-sizing: inherit;
margin: 0;
position: relative;
font-family: Poppins, sans-serif;
}
body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
ol,
ul {
margin: 0;
padding: 0;
font-weight: normal;
}
ol,
ul {
list-style: none;
}
img {
max-width: 100%;
height: auto;
}

View File

@@ -1,91 +0,0 @@
:root {
--color-logo: #282467;
--color-blue-scale-000: #000000;
--color-blue-scale-100: #1a1b38;
--color-blue-scale-200: #595a6f;
--color-blue-scale-300: #9899a5;
--color-blue-scale-400: #e5e5e7;
--color-blue-scale-500: #ffffff;
--color-extra-blue-l60: #d1cefb;
--color-extra-blue-l40: #bbb5f9;
--color-extra-blue-l20: #a39df8;
--color-extra-blue-base: #8f84ff;
--color-extra-blue-d20: #716ac6;
--color-extra-blue-d40: #554f94;
--color-extra-blue-d60: #383563;
--color-green-infra-l60: #b5dbca;
--color-green-infra-l40: #91c9b0;
--color-green-infra-l20: #70b795;
--color-green-infra-base: #55a57b;
--color-green-infra-d20: #438463;
--color-green-infra-d40: #32634a;
--color-green-infra-d60: #214231;
--color-orange-world-l60: #f2cda8;
--color-orange-world-l40: #ebb57d;
--color-orange-world-l20: #e59d56;
--color-orange-world-base: #ef7f18;
--color-orange-world-d20: #bf6612;
--color-orange-world-d40: #864f1f;
--color-orange-world-d60: #5a3514;
--color-red-vates-l60: #dda5a7;
--color-red-vates-l40: #ce787c;
--color-red-vates-l20: #bf4f51;
--color-red-vates-base: #be1621;
--color-red-vates-d20: #8e2221;
--color-red-vates-d40: #6a1919;
--color-red-vates-d60: #471010;
--color-grayscale-200: #585757;
--background-color-primary: #ffffff;
--background-color-secondary: #f6f6f7;
--background-color-extra-blue: #f4f3fe;
--background-color-green-infra: #ecf5f2;
--background-color-orange-world: #fbf2e9;
--background-color-red-vates: #f5e8e9;
--shadow-100: 0 0.1rem 0.1rem rgba(20, 20, 30, 0.06);
--shadow-200: 0 0.1rem 0.3rem rgba(20, 20, 30, 0.1),
0 0.2rem 0.1rem rgba(20, 20, 30, 0.06),
0 0.1rem 0.1rem rgba(20, 20, 30, 0.08);
--shadow-300: 0 0.3rem 0.5rem rgba(20, 20, 30, 0.1),
0 0.1rem 1.8rem rgba(20, 20, 30, 0.06), 0 0.6rem 1rem rgba(20, 20, 30, 0.08);
--shadow-400: 0 1.1rem 1.5rem rgba(20, 20, 30, 0.1),
0 0.9rem 4.6rem rgba(20, 20, 30, 0.06),
0 2.4rem 3.8rem rgba(20, 20, 30, 0.04);
}
:root.dark {
color-scheme: dark;
--color-logo: #e5e5e7;
--color-blue-scale-000: #ffffff;
--color-blue-scale-100: #e5e5e7;
--color-blue-scale-200: #9899a5;
--color-blue-scale-300: #595a6f;
--color-blue-scale-400: #1a1b38;
--color-blue-scale-500: #000000;
--background-color-primary: #14141d;
--background-color-secondary: #17182a;
--background-color-extra-blue: #35335d;
--background-color-green-infra: #243b3d;
--background-color-orange-world: #493328;
--background-color-red-vates: #3c1a28;
--shadow-100: 0 0.1rem 0.1rem rgba(20, 20, 30, 0.12);
--shadow-200: 0 0.1rem 0.3rem rgba(20, 20, 30, 0.2),
0 0.2rem 0.1rem rgba(20, 20, 30, 0.12),
0 0.1rem 0.1rem rgba(20, 20, 30, 0.16);
--shadow-300: 0 0.3rem 0.5rem rgba(20, 20, 30, 0.2),
0 0.1rem 1.8rem rgba(20, 20, 30, 0.12), 0 0.6rem 1rem rgba(20, 20, 30, 0.16);
--shadow-400: 0 1.1rem 1.5rem rgba(20, 20, 30, 0.2),
0 0.9rem 4.6rem rgba(20, 20, 30, 0.12),
0 2.4rem 3.8rem rgba(20, 20, 30, 0.08);
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -6,54 +6,44 @@
<UiIcon :icon="faAngleDown" class="dropdown-icon" />
</button>
</template>
<MenuItem :icon="faGear" @click="openSettings">{{
$t("settings")
}}</MenuItem>
<MenuItem :icon="faGear" @click="openSettings">{{ $t('settings') }}</MenuItem>
<MenuItem :icon="faMessage" @click="openFeedbackUrl">
{{ $t("send-us-feedback") }}
{{ $t('send-us-feedback') }}
</MenuItem>
<MenuItem
:icon="faArrowRightFromBracket"
class="menu-item-logout"
@click="logout"
>
{{ $t("log-out") }}
<MenuItem :icon="faArrowRightFromBracket" class="menu-item-logout" @click="logout">
{{ $t('log-out') }}
</MenuItem>
</AppMenu>
</template>
<script lang="ts" setup>
import { nextTick } from "vue";
import { useRouter } from "vue-router";
import { nextTick } from 'vue'
import { useRouter } from 'vue-router'
import {
faAngleDown,
faArrowRightFromBracket,
faCircleUser,
faGear,
faMessage,
} from "@fortawesome/free-solid-svg-icons";
import AppMenu from "@/components/menu/AppMenu.vue";
import MenuItem from "@/components/menu/MenuItem.vue";
import UiIcon from "@/components/ui/icon/UiIcon.vue";
import { useXenApiStore } from "@/stores/xen-api.store";
} from '@fortawesome/free-solid-svg-icons'
import AppMenu from '@/components/menu/AppMenu.vue'
import MenuItem from '@/components/menu/MenuItem.vue'
import UiIcon from '@/components/ui/icon/UiIcon.vue'
import { useXenApiStore } from '@/stores/xen-api.store'
const router = useRouter();
const router = useRouter()
const logout = () => {
const xenApiStore = useXenApiStore();
xenApiStore.disconnect();
nextTick(() => router.push({ name: "home" }));
};
const xenApiStore = useXenApiStore()
xenApiStore.disconnect()
nextTick(() => router.push({ name: 'home' }))
}
const openFeedbackUrl = () => {
window.open(
"https://xcp-ng.org/forum/topic/4731/xen-orchestra-lite",
"_blank",
"noopener"
);
};
window.open('https://xcp-ng.org/forum/topic/4731/xen-orchestra-lite', '_blank', 'noopener')
}
const openSettings = () => router.push({ name: "settings" });
const openSettings = () => router.push({ name: 'settings' })
</script>
<style scoped>
@@ -61,14 +51,14 @@ const openSettings = () => router.push({ name: "settings" });
display: flex;
align-items: center;
padding: 1rem;
color: var(--color-blue-scale-100);
color: var(--color-grey-100);
border: none;
border-radius: 0.8rem;
background-color: var(--background-color-secondary);
gap: 0.8rem;
&:disabled {
color: var(--color-blue-scale-400);
color: var(--color-grey-500);
}
&:not(:disabled) {
@@ -82,7 +72,7 @@ const openSettings = () => router.push({ name: "settings" });
&:active,
&.active {
color: var(--color-extra-blue-base);
color: var(--color-purple-base);
}
}
}
@@ -96,6 +86,6 @@ const openSettings = () => router.push({ name: "settings" });
}
.menu-item-logout {
color: var(--color-red-vates-base);
color: var(--color-red-base);
}
</style>

View File

@@ -1,11 +1,6 @@
<template>
<header class="app-header">
<UiIcon
v-if="isMobile"
ref="navigationTrigger"
:icon="faBars"
class="toggle-navigation"
/>
<UiIcon v-if="isMobile" ref="navigationTrigger" :icon="faBars" class="toggle-navigation" />
<RouterLink :to="{ name: 'home' }">
<img v-if="isMobile" alt="XO Lite" src="../assets/logo.svg" />
<TextLogo v-else />
@@ -13,26 +8,35 @@
<slot />
<div class="right">
<PoolOverrideWarning as-tooltip />
<UiButton v-if="isDesktop" :icon="faDownload" @click="openXoaDeploy">
{{ $t('deploy-xoa') }}
</UiButton>
<AccountButton />
</div>
</header>
</template>
<script lang="ts" setup>
import AccountButton from "@/components/AccountButton.vue";
import PoolOverrideWarning from "@/components/PoolOverrideWarning.vue";
import TextLogo from "@/components/TextLogo.vue";
import UiIcon from "@/components/ui/icon/UiIcon.vue";
import { useNavigationStore } from "@/stores/navigation.store";
import { useUiStore } from "@/stores/ui.store";
import { faBars } from "@fortawesome/free-solid-svg-icons";
import { storeToRefs } from "pinia";
import AccountButton from '@/components/AccountButton.vue'
import PoolOverrideWarning from '@/components/PoolOverrideWarning.vue'
import TextLogo from '@/components/TextLogo.vue'
import UiButton from '@/components/ui/UiButton.vue'
import UiIcon from '@/components/ui/icon/UiIcon.vue'
import { useNavigationStore } from '@/stores/navigation.store'
import { useRouter } from 'vue-router'
import { useUiStore } from '@/stores/ui.store'
import { faBars, faDownload } from '@fortawesome/free-solid-svg-icons'
import { storeToRefs } from 'pinia'
const uiStore = useUiStore();
const { isMobile } = storeToRefs(uiStore);
const router = useRouter()
const navigationStore = useNavigationStore();
const { trigger: navigationTrigger } = storeToRefs(navigationStore);
const openXoaDeploy = () => router.push({ name: 'xoa.deploy' })
const uiStore = useUiStore()
const { isMobile, isDesktop } = storeToRefs(uiStore)
const navigationStore = useNavigationStore()
const { trigger: navigationTrigger } = storeToRefs(navigationStore)
</script>
<style lang="postcss" scoped>
@@ -42,7 +46,7 @@ const { trigger: navigationTrigger } = storeToRefs(navigationStore);
justify-content: space-between;
height: 5.5rem;
padding: 1rem;
border-bottom: 0.1rem solid var(--color-blue-scale-400);
border-bottom: 0.1rem solid var(--color-grey-500);
background-color: var(--background-color-secondary);
img {
@@ -62,5 +66,6 @@ const { trigger: navigationTrigger } = storeToRefs(navigationStore);
.right {
display: flex;
align-items: center;
gap: 2rem;
}
</style>

View File

@@ -5,7 +5,7 @@
<PoolOverrideWarning />
<p v-if="isHostIsSlaveErr(error)" class="error">
<UiIcon :icon="faExclamationCircle" />
{{ $t("login-only-on-master") }}
{{ $t('login-only-on-master') }}
<a :href="masterUrl.href">{{ masterUrl.hostname }}</a>
</p>
<template v-else>
@@ -13,10 +13,10 @@
<FormInput v-model="login" name="login" readonly type="text" />
</FormInputWrapper>
<FormInput
name="password"
ref="passwordRef"
type="password"
v-model="password"
name="password"
type="password"
:class="{ error: isInvalidPassword }"
:placeholder="$t('password')"
:readonly="isConnecting"
@@ -25,10 +25,10 @@
<LoginError :error="error" />
<label class="remember-me-label">
<FormCheckbox v-model="rememberMe" />
{{ $t("keep-me-logged") }}
{{ $t('keep-me-logged') }}
</label>
<UiButton type="submit" :busy="isConnecting">
{{ $t("login") }}
{{ $t('login') }}
</UiButton>
</template>
</form>
@@ -36,69 +36,68 @@
</template>
<script lang="ts" setup>
import { usePageTitleStore } from "@/stores/page-title.store";
import { storeToRefs } from "pinia";
import { onMounted, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useLocalStorage, whenever } from "@vueuse/core";
import { usePageTitleStore } from '@/stores/page-title.store'
import { storeToRefs } from 'pinia'
import { onMounted, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useLocalStorage, whenever } from '@vueuse/core'
import FormCheckbox from "@/components/form/FormCheckbox.vue";
import FormInput from "@/components/form/FormInput.vue";
import FormInputWrapper from "@/components/form/FormInputWrapper.vue";
import LoginError from "@/components/LoginError.vue";
import PoolOverrideWarning from "@/components/PoolOverrideWarning.vue";
import UiButton from "@/components/ui/UiButton.vue";
import UiIcon from "@/components/ui/icon/UiIcon.vue";
import type { XenApiError } from "@/libs/xen-api/xen-api.types";
import { faExclamationCircle } from "@fortawesome/free-solid-svg-icons";
import { useXenApiStore } from "@/stores/xen-api.store";
import FormCheckbox from '@/components/form/FormCheckbox.vue'
import FormInput from '@/components/form/FormInput.vue'
import FormInputWrapper from '@/components/form/FormInputWrapper.vue'
import LoginError from '@/components/LoginError.vue'
import PoolOverrideWarning from '@/components/PoolOverrideWarning.vue'
import UiButton from '@/components/ui/UiButton.vue'
import UiIcon from '@/components/ui/icon/UiIcon.vue'
import type { XenApiError } from '@/libs/xen-api/xen-api.types'
import { faExclamationCircle } from '@fortawesome/free-solid-svg-icons'
import { useXenApiStore } from '@/stores/xen-api.store'
const { t } = useI18n();
usePageTitleStore().setTitle(t("login"));
const xenApiStore = useXenApiStore();
const { isConnecting } = storeToRefs(xenApiStore);
const login = ref("root");
const password = ref("");
const error = ref<XenApiError>();
const passwordRef = ref<InstanceType<typeof FormInput>>();
const isInvalidPassword = ref(false);
const masterUrl = ref(new URL(window.origin));
const rememberMe = useLocalStorage("rememberMe", false);
const { t } = useI18n()
usePageTitleStore().setTitle(t('login'))
const xenApiStore = useXenApiStore()
const { isConnecting } = storeToRefs(xenApiStore)
const login = ref('root')
const password = ref('')
const error = ref<XenApiError>()
const passwordRef = ref<InstanceType<typeof FormInput>>()
const isInvalidPassword = ref(false)
const masterUrl = ref(new URL(window.origin))
const rememberMe = useLocalStorage('rememberMe', false)
const focusPasswordInput = () => passwordRef.value?.focus();
const isHostIsSlaveErr = (err: XenApiError | undefined) =>
err?.message === "HOST_IS_SLAVE";
const focusPasswordInput = () => passwordRef.value?.focus()
const isHostIsSlaveErr = (err: XenApiError | undefined) => err?.message === 'HOST_IS_SLAVE'
onMounted(() => {
if (rememberMe.value) {
xenApiStore.reconnect();
xenApiStore.reconnect()
} else {
focusPasswordInput();
focusPasswordInput()
}
});
})
watch(password, () => {
isInvalidPassword.value = false;
error.value = undefined;
});
isInvalidPassword.value = false
error.value = undefined
})
whenever(
() => isHostIsSlaveErr(error.value),
() => (masterUrl.value.hostname = error.value!.data)
);
)
async function handleSubmit() {
try {
await xenApiStore.connect(login.value, password.value);
await xenApiStore.connect(login.value, password.value)
} catch (err: any) {
if (err.message === "SESSION_AUTHENTICATION_FAILED") {
focusPasswordInput();
isInvalidPassword.value = true;
if (err.message === 'SESSION_AUTHENTICATION_FAILED') {
focusPasswordInput()
isInvalidPassword.value = true
} else {
console.error(error);
console.error(error)
}
error.value = err;
error.value = err
}
}
</script>
@@ -136,7 +135,7 @@ form {
background-color: var(--background-color-secondary);
.error {
color: var(--color-red-vates-base);
color: var(--color-red-base);
}
}
@@ -157,7 +156,7 @@ input {
max-width: 100%;
margin-bottom: 1rem;
padding: 1rem 1.5rem;
border: 1px solid var(--color-blue-scale-400);
border: 1px solid var(--color-grey-500);
border-radius: 0.8rem;
background-color: white;
}

View File

@@ -1,39 +1,40 @@
<template>
<!-- eslint-disable vue/no-v-html -->
<div ref="rootElement" class="app-markdown" v-html="html" />
<!-- eslint-enable vue/no-v-html -->
</template>
<script lang="ts" setup>
import markdown from "@/libs/markdown";
import { useEventListener } from "@vueuse/core";
import { computed, type Ref, ref } from "vue";
import markdown from '@/libs/markdown'
import { useEventListener } from '@vueuse/core'
import { computed, type Ref, ref } from 'vue'
const rootElement = ref() as Ref<HTMLElement>;
const rootElement = ref() as Ref<HTMLElement>
const props = defineProps<{
content: string;
}>();
content: string
}>()
const html = computed(() => markdown.parse(props.content ?? ""));
const html = computed(() => markdown.parse(props.content ?? ''))
useEventListener(
rootElement,
"click",
'click',
(event: MouseEvent) => {
const target = event.target as HTMLElement;
const target = event.target as HTMLElement
if (!target.classList.contains("copy-button")) {
return;
if (!target.classList.contains('copy-button')) {
return
}
const copyable =
target.parentElement!.querySelector<HTMLElement>(".copyable");
const copyable = target.parentElement!.querySelector<HTMLElement>('.copyable')
if (copyable !== null) {
navigator.clipboard.writeText(copyable.innerText);
navigator.clipboard.writeText(copyable.innerText)
}
},
{ capture: true }
);
)
</script>
<style lang="postcss" scoped>
@@ -59,7 +60,7 @@ useEventListener(
}
code:not(.hljs-code) {
background-color: var(--background-color-extra-blue);
background-color: var(--background-color-purple-10);
padding: 0.3rem 0.6rem;
border-radius: 0.6rem;
}
@@ -80,12 +81,12 @@ useEventListener(
}
thead th {
border-bottom: 2px solid var(--color-blue-scale-400);
border-bottom: 2px solid var(--color-grey-500);
background-color: var(--background-color-secondary);
}
tbody td {
border-bottom: 1px solid var(--color-blue-scale-400);
border-bottom: 1px solid var(--color-grey-500);
}
}
@@ -102,11 +103,11 @@ useEventListener(
background-color: transparent;
&:hover {
color: var(--color-extra-blue-base);
color: var(--color-purple-base);
}
&:active {
color: var(--color-extra-blue-d20);
color: var(--color-purple-d20);
}
}
}

View File

@@ -1,11 +1,6 @@
<template>
<transition name="slide">
<nav
v-if="isDesktop || isOpen"
ref="navElement"
:class="{ collapsible: isMobile }"
class="app-navigation"
>
<nav v-if="isDesktop || isOpen" ref="navElement" :class="{ collapsible: isMobile }" class="app-navigation">
<StoryMenu v-if="$route.meta.hasStoryNav" />
<InfraPoolList v-else />
</nav>
@@ -13,34 +8,34 @@
</template>
<script lang="ts" setup>
import StoryMenu from "@/components/component-story/StoryMenu.vue";
import InfraPoolList from "@/components/infra/InfraPoolList.vue";
import { useNavigationStore } from "@/stores/navigation.store";
import { useUiStore } from "@/stores/ui.store";
import { onClickOutside, whenever } from "@vueuse/core";
import { storeToRefs } from "pinia";
import { ref } from "vue";
import StoryMenu from '@/components/component-story/StoryMenu.vue'
import InfraPoolList from '@/components/infra/InfraPoolList.vue'
import { useNavigationStore } from '@/stores/navigation.store'
import { useUiStore } from '@/stores/ui.store'
import { onClickOutside, whenever } from '@vueuse/core'
import { storeToRefs } from 'pinia'
import { ref } from 'vue'
const uiStore = useUiStore();
const { isMobile, isDesktop } = storeToRefs(uiStore);
const uiStore = useUiStore()
const { isMobile, isDesktop } = storeToRefs(uiStore)
const navigationStore = useNavigationStore();
const { isOpen, trigger } = storeToRefs(navigationStore);
const navigationStore = useNavigationStore()
const { isOpen, trigger } = storeToRefs(navigationStore)
const navElement = ref();
const navElement = ref()
whenever(isOpen, () => {
const unregisterEvent = onClickOutside(
navElement,
() => {
isOpen.value = false;
unregisterEvent?.();
isOpen.value = false
unregisterEvent?.()
},
{
ignore: [trigger],
}
);
});
)
})
</script>
<style lang="postcss" scoped>
@@ -50,7 +45,7 @@ whenever(isOpen, () => {
max-width: 37rem;
height: calc(100vh - 5.5rem);
padding: 0.5rem;
border-right: 1px solid var(--color-blue-scale-400);
border-right: 1px solid var(--color-grey-500);
background-color: var(--background-color-primary);
&.collapsible {

View File

@@ -6,33 +6,31 @@
</template>
<script lang="ts" setup>
import type { TooltipOptions } from "@/stores/tooltip.store";
import { isString } from "lodash-es";
import place from "placement.js";
import { computed, ref, watchEffect } from "vue";
import type { TooltipOptions } from '@/stores/tooltip.store'
import { isString } from 'lodash-es'
import place from 'placement.js'
import { computed, ref, watchEffect } from 'vue'
const props = defineProps<{
target: HTMLElement;
options: TooltipOptions;
}>();
target: HTMLElement
options: TooltipOptions
}>()
const tooltipElement = ref<HTMLElement>();
const tooltipElement = ref<HTMLElement>()
const isDisabled = computed(() =>
isString(props.options.content)
? props.options.content.trim() === ""
: props.options.content === false
);
isString(props.options.content) ? props.options.content.trim() === '' : props.options.content === false
)
const placement = computed(() => props.options.placement ?? "top");
const placement = computed(() => props.options.placement ?? 'top')
watchEffect(() => {
if (tooltipElement.value) {
place(props.target, tooltipElement.value, {
placement: placement.value,
});
})
}
});
})
</script>
<style lang="postcss" scoped>
@@ -43,9 +41,9 @@ watchEffect(() => {
display: inline-flex;
padding: 0.3125em 0.5em;
pointer-events: none;
color: var(--color-blue-scale-500);
color: var(--color-grey-600);
border-radius: 0.5em;
background-color: var(--color-blue-scale-100);
background-color: var(--color-grey-100);
z-index: 2;
}
@@ -56,7 +54,7 @@ watchEffect(() => {
height: 1.875em;
}
[data-placement^="top"] {
[data-placement^='top'] {
margin-bottom: 0.625em;
.triangle {
@@ -65,7 +63,7 @@ watchEffect(() => {
}
}
[data-placement^="right"] {
[data-placement^='right'] {
margin-left: 0.625em;
.triangle {
@@ -74,7 +72,7 @@ watchEffect(() => {
}
}
[data-placement^="bottom"] {
[data-placement^='bottom'] {
margin-top: 0.625em;
.triangle {
@@ -82,7 +80,7 @@ watchEffect(() => {
}
}
[data-placement^="left"] {
[data-placement^='left'] {
margin-right: 0.625em;
.triangle {
@@ -91,51 +89,51 @@ watchEffect(() => {
}
}
[data-placement="top-start"] .triangle {
[data-placement='top-start'] .triangle {
left: 0;
}
[data-placement="top-center"] .triangle {
[data-placement='top-center'] .triangle {
left: 50%;
margin-left: -0.9375em;
}
[data-placement="top-end"] .triangle {
[data-placement='top-end'] .triangle {
right: 0;
}
[data-placement="left-start"] .triangle {
[data-placement='left-start'] .triangle {
top: -0.25em;
}
[data-placement="left-center"] .triangle {
[data-placement='left-center'] .triangle {
top: 50%;
margin-top: -0.9375em;
}
[data-placement="left-end"] .triangle {
[data-placement='left-end'] .triangle {
bottom: -0.25em;
}
[data-placement="right-start"] .triangle {
[data-placement='right-start'] .triangle {
top: -0.25em;
}
[data-placement="right-center"] .triangle {
[data-placement='right-center'] .triangle {
top: 50%;
margin-top: -0.9375em;
}
[data-placement="right-end"] .triangle {
[data-placement='right-end'] .triangle {
bottom: -0.25em;
}
[data-placement="bottom-center"] .triangle {
[data-placement='bottom-center'] .triangle {
left: 50%;
margin-left: -0.9375em;
}
[data-placement="bottom-end"] .triangle {
[data-placement='bottom-end'] .triangle {
right: 0;
}
@@ -144,9 +142,9 @@ watchEffect(() => {
width: 100%;
height: 100%;
margin-top: 1.875em;
content: "";
content: '';
transform: rotate(45deg) skew(20deg, 20deg);
border-radius: 0.3125em;
background-color: var(--color-blue-scale-100);
background-color: var(--color-grey-100);
}
</style>

View File

@@ -1,19 +1,14 @@
<template>
<AppTooltip
v-for="tooltip in tooltips"
:key="tooltip.key"
:options="tooltip.options"
:target="tooltip.target"
/>
<AppTooltip v-for="tooltip in tooltips" :key="tooltip.key" :options="tooltip.options" :target="tooltip.target" />
</template>
<script lang="ts" setup>
import { storeToRefs } from "pinia";
import AppTooltip from "@/components/AppTooltip.vue";
import { useTooltipStore } from "@/stores/tooltip.store";
import { storeToRefs } from 'pinia'
import AppTooltip from '@/components/AppTooltip.vue'
import { useTooltipStore } from '@/stores/tooltip.store'
const tooltipStore = useTooltipStore();
const { tooltips } = storeToRefs(tooltipStore);
const tooltipStore = useTooltipStore()
const { tooltips } = storeToRefs(tooltipStore)
</script>
<style scoped></style>

View File

@@ -1,33 +1,33 @@
<template>
<!-- eslint-disable vue/no-v-html -->
<pre class="code-highlight hljs"><code v-html="codeAsHtml"></code></pre>
<!-- eslint-enable vue/no-v-html -->
</template>
<script lang="ts" setup>
import { type AcceptedLanguage, highlight } from "@/libs/highlight";
import { computed } from "vue";
import { type AcceptedLanguage, highlight } from '@/libs/highlight'
import { computed } from 'vue'
const props = withDefaults(
defineProps<{
code?: any;
lang?: AcceptedLanguage;
code?: any
lang?: AcceptedLanguage
}>(),
{ lang: "typescript" }
);
{ lang: 'typescript' }
)
const codeAsText = computed(() => {
switch (typeof props.code) {
case "string":
return props.code;
case "function":
return String(props.code);
case 'string':
return props.code
case 'function':
return String(props.code)
default:
return JSON.stringify(props.code, undefined, 2);
return JSON.stringify(props.code, undefined, 2)
}
});
})
const codeAsHtml = computed(
() => highlight(codeAsText.value, { language: props.lang }).value
);
const codeAsHtml = computed(() => highlight(codeAsText.value, { language: props.lang }).value)
</script>
<style lang="postcss" scoped>

View File

@@ -10,42 +10,39 @@
</UiFilter>
<UiActionButton :icon="faPlus" class="add-filter" @click="openModal()">
{{ $t("add-filter") }}
{{ $t('add-filter') }}
</UiActionButton>
</UiFilterGroup>
</template>
<script lang="ts" setup>
import UiActionButton from "@/components/ui/UiActionButton.vue";
import UiFilter from "@/components/ui/UiFilter.vue";
import UiFilterGroup from "@/components/ui/UiFilterGroup.vue";
import { useModal } from "@/composables/modal.composable";
import type { Filters } from "@/types/filter";
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import UiActionButton from '@/components/ui/UiActionButton.vue'
import UiFilter from '@/components/ui/UiFilter.vue'
import UiFilterGroup from '@/components/ui/UiFilterGroup.vue'
import { useModal } from '@/composables/modal.composable'
import type { Filters } from '@/types/filter'
import { faPlus } from '@fortawesome/free-solid-svg-icons'
const props = defineProps<{
activeFilters: string[];
availableFilters: Filters;
}>();
activeFilters: string[]
availableFilters: Filters
}>()
const emit = defineEmits<{
(event: "addFilter", filter: string): void;
(event: "removeFilter", filter: string): void;
}>();
(event: 'addFilter', filter: string): void
(event: 'removeFilter', filter: string): void
}>()
const openModal = (editedFilter?: string) => {
const { onApprove } = useModal<string>(
() => import("@/components/modals/CollectionFilterModal.vue"),
{
availableFilters: props.availableFilters,
editedFilter,
}
);
const { onApprove } = useModal<string>(() => import('@/components/modals/CollectionFilterModal.vue'), {
availableFilters: props.availableFilters,
editedFilter,
})
if (editedFilter !== undefined) {
onApprove(() => emit("removeFilter", editedFilter));
onApprove(() => emit('removeFilter', editedFilter))
}
onApprove((newFilter) => emit("addFilter", newFilter));
};
onApprove(newFilter => emit('addFilter', newFilter))
}
</script>

View File

@@ -1,31 +1,21 @@
<template>
<div class="collection-filter-row">
<span class="or">{{ $t("or") }}</span>
<span class="or">{{ $t('or') }}</span>
<FormWidget v-if="newFilter.isAdvanced" class="form-widget-advanced">
<input v-model="newFilter.content" />
</FormWidget>
<template v-else>
<FormWidget :before="currentFilterIcon">
<select v-model="newFilter.builder.property">
<option v-if="!newFilter.builder.property" value="">
- {{ $t("property") }} -
</option>
<option
v-for="(filter, property) in availableFilters"
:key="property"
:value="property"
>
<option v-if="!newFilter.builder.property" value="">- {{ $t('property') }} -</option>
<option v-for="(filter, property) in availableFilters" :key="property" :value="property">
{{ filter.label ?? property }}
</option>
</select>
</FormWidget>
<FormWidget v-if="hasComparisonSelect">
<select v-model="newFilter.builder.comparison">
<option
v-for="(label, type) in comparisons"
:key="type"
:value="type"
>
<option v-for="(label, type) in comparisons" :key="type" :value="type">
{{ label }}
</option>
</select>
@@ -38,112 +28,88 @@
</option>
</select>
</FormWidget>
<FormWidget
v-else-if="hasValueInput"
:after="valueInputAfter"
:before="valueInputBefore"
>
<FormWidget v-else-if="hasValueInput" :after="valueInputAfter" :before="valueInputBefore">
<input v-model="newFilter.builder.value" />
</FormWidget>
</template>
<UiActionButton
v-if="!newFilter.isAdvanced"
:icon="faPencil"
@click="enableAdvancedMode"
/>
<UiActionButton v-if="!newFilter.isAdvanced" :icon="faPencil" @click="enableAdvancedMode" />
<UiActionButton :icon="faRemove" @click="emit('remove', newFilter.id)" />
</div>
</template>
<script lang="ts" setup>
import FormWidget from "@/components/FormWidget.vue";
import UiActionButton from "@/components/ui/UiActionButton.vue";
import { buildComplexMatcherNode } from "@/libs/complex-matcher.utils";
import { getFilterIcon } from "@/libs/utils";
import type {
Filter,
FilterComparisons,
FilterComparisonType,
Filters,
FilterType,
NewFilter,
} from "@/types/filter";
import { faPencil, faRemove } from "@fortawesome/free-solid-svg-icons";
import { useVModel } from "@vueuse/core";
import { computed, type Ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import FormWidget from '@/components/FormWidget.vue'
import UiActionButton from '@/components/ui/UiActionButton.vue'
import { buildComplexMatcherNode } from '@/libs/complex-matcher.utils'
import { getFilterIcon } from '@/libs/utils'
import type { Filter, FilterComparisons, FilterComparisonType, Filters, FilterType, NewFilter } from '@/types/filter'
import { faPencil, faRemove } from '@fortawesome/free-solid-svg-icons'
import { useVModel } from '@vueuse/core'
import { computed, type Ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
const props = defineProps<{
availableFilters: Filters;
modelValue: NewFilter;
}>();
availableFilters: Filters
modelValue: NewFilter
}>()
const emit = defineEmits<{
(event: "update:modelValue", value: NewFilter): void;
(event: "remove", filterId: number): void;
}>();
(event: 'update:modelValue', value: NewFilter): void
(event: 'remove', filterId: number): void
}>()
const { t } = useI18n();
const { t } = useI18n()
const newFilter: Ref<NewFilter> = useVModel(props, "modelValue", emit);
const newFilter: Ref<NewFilter> = useVModel(props, 'modelValue', emit)
const getDefaultComparisonType = () => {
const defaultTypes: { [key in FilterType]: FilterComparisonType } = {
string: "stringContains",
boolean: "booleanTrue",
number: "numberEquals",
enum: "enumIs",
};
string: 'stringContains',
boolean: 'booleanTrue',
number: 'numberEquals',
enum: 'enumIs',
}
return defaultTypes[
props.availableFilters[newFilter.value.builder.property].type
];
};
return defaultTypes[props.availableFilters[newFilter.value.builder.property].type]
}
watch(
() => newFilter.value.builder.property,
() => {
newFilter.value.builder.comparison = getDefaultComparisonType();
newFilter.value.builder.value = "";
newFilter.value.builder.comparison = getDefaultComparisonType()
newFilter.value.builder.value = ''
}
);
)
const currentFilter = computed<Filter>(
() => props.availableFilters[newFilter.value.builder.property]
);
const currentFilter = computed<Filter>(() => props.availableFilters[newFilter.value.builder.property])
const currentFilterIcon = computed(() => getFilterIcon(currentFilter.value));
const currentFilterIcon = computed(() => getFilterIcon(currentFilter.value))
const hasValueInput = computed(() =>
["string", "number"].includes(currentFilter.value?.type)
);
const hasValueInput = computed(() => ['string', 'number'].includes(currentFilter.value?.type))
const hasComparisonSelect = computed(
() => newFilter.value.builder.property !== ""
);
const hasComparisonSelect = computed(() => newFilter.value.builder.property !== '')
const enumChoices = computed(() => {
if (!newFilter.value.builder.property) {
return [];
return []
}
const availableFilter =
props.availableFilters[newFilter.value.builder.property];
const availableFilter = props.availableFilters[newFilter.value.builder.property]
if (availableFilter.type !== "enum") {
return [];
if (availableFilter.type !== 'enum') {
return []
}
return availableFilter.choices;
});
return availableFilter.choices
})
const generatedFilter = computed(() => {
if (newFilter.value.isAdvanced) {
return newFilter.value.content;
return newFilter.value.content
}
if (!newFilter.value.builder.comparison) {
return "";
return ''
}
try {
@@ -151,68 +117,64 @@ const generatedFilter = computed(() => {
newFilter.value.builder.comparison,
newFilter.value.builder.property,
newFilter.value.builder.value
);
)
if (node) {
return node.toString();
return node.toString()
}
return "";
return ''
} catch (e) {
return "";
return ''
}
});
})
const enableAdvancedMode = () => {
newFilter.value.content = generatedFilter.value;
newFilter.value.isAdvanced = true;
};
newFilter.value.content = generatedFilter.value
newFilter.value.isAdvanced = true
}
watch(generatedFilter, (value) => {
newFilter.value.content = value;
});
watch(generatedFilter, value => {
newFilter.value.content = value
})
const comparisons = computed<FilterComparisons>(() => {
const comparisonsByType = {
string: {
stringContains: t("filter.comparison.contains"),
stringEquals: t("filter.comparison.equals"),
stringStartsWith: t("filter.comparison.starts-with"),
stringEndsWith: t("filter.comparison.ends-with"),
stringMatchesRegex: t("filter.comparison.matches-regex"),
stringDoesNotContain: t("filter.comparison.not-contain"),
stringDoesNotEqual: t("filter.comparison.not-equal"),
stringDoesNotStartWith: t("filter.comparison.not-start-with"),
stringDoesNotEndWith: t("filter.comparison.not-end-with"),
stringDoesNotMatchRegex: t("filter.comparison.not-match-regex"),
stringContains: t('filter.comparison.contains'),
stringEquals: t('filter.comparison.equals'),
stringStartsWith: t('filter.comparison.starts-with'),
stringEndsWith: t('filter.comparison.ends-with'),
stringMatchesRegex: t('filter.comparison.matches-regex'),
stringDoesNotContain: t('filter.comparison.not-contain'),
stringDoesNotEqual: t('filter.comparison.not-equal'),
stringDoesNotStartWith: t('filter.comparison.not-start-with'),
stringDoesNotEndWith: t('filter.comparison.not-end-with'),
stringDoesNotMatchRegex: t('filter.comparison.not-match-regex'),
},
boolean: {
booleanTrue: t("filter.comparison.is-true"),
booleanFalse: t("filter.comparison.is-false"),
booleanTrue: t('filter.comparison.is-true'),
booleanFalse: t('filter.comparison.is-false'),
},
number: {
numberLessThan: "<",
numberLessThanOrEquals: "<=",
numberEquals: "=",
numberGreaterThanOrEquals: ">=",
numberGreaterThan: ">",
numberLessThan: '<',
numberLessThanOrEquals: '<=',
numberEquals: '=',
numberGreaterThanOrEquals: '>=',
numberGreaterThan: '>',
},
enum: {
enumIs: t("filter.comparison.is"),
enumIsNot: t("filter.comparison.is-not"),
enumIs: t('filter.comparison.is'),
enumIsNot: t('filter.comparison.is-not'),
},
};
}
return comparisonsByType[currentFilter.value.type];
});
return comparisonsByType[currentFilter.value.type]
})
const valueInputBefore = computed(() =>
newFilter.value.builder.comparison === "stringMatchesRegex" ? "/" : undefined
);
const valueInputBefore = computed(() => (newFilter.value.builder.comparison === 'stringMatchesRegex' ? '/' : undefined))
const valueInputAfter = computed(() =>
newFilter.value.builder.comparison === "stringMatchesRegex" ? "/i" : undefined
);
const valueInputAfter = computed(() => (newFilter.value.builder.comparison === 'stringMatchesRegex' ? '/i' : undefined))
</script>
<style lang="postcss" scoped>

View File

@@ -13,46 +13,39 @@
</UiFilter>
<UiActionButton :icon="faPlus" class="add-sort" @click="openModal()">
{{ $t("add-sort") }}
{{ $t('add-sort') }}
</UiActionButton>
</UiFilterGroup>
</template>
<script lang="ts" setup>
import UiIcon from "@/components/ui/icon/UiIcon.vue";
import UiActionButton from "@/components/ui/UiActionButton.vue";
import UiFilter from "@/components/ui/UiFilter.vue";
import UiFilterGroup from "@/components/ui/UiFilterGroup.vue";
import { useModal } from "@/composables/modal.composable";
import type { ActiveSorts, NewSort, Sorts } from "@/types/sort";
import {
faCaretDown,
faCaretUp,
faPlus,
} from "@fortawesome/free-solid-svg-icons";
import { computed } from "vue";
import UiIcon from '@/components/ui/icon/UiIcon.vue'
import UiActionButton from '@/components/ui/UiActionButton.vue'
import UiFilter from '@/components/ui/UiFilter.vue'
import UiFilterGroup from '@/components/ui/UiFilterGroup.vue'
import { useModal } from '@/composables/modal.composable'
import type { ActiveSorts, NewSort, Sorts } from '@/types/sort'
import { faCaretDown, faCaretUp, faPlus } from '@fortawesome/free-solid-svg-icons'
import { computed } from 'vue'
const props = defineProps<{
availableSorts: Sorts;
activeSorts: ActiveSorts<Record<string, any>>;
}>();
availableSorts: Sorts
activeSorts: ActiveSorts<Record<string, any>>
}>()
const emit = defineEmits<{
(event: "toggleSortDirection", property: string): void;
(event: "addSort", property: string, isAscending: boolean): void;
(event: "removeSort", property: string): void;
}>();
(event: 'toggleSortDirection', property: string): void
(event: 'addSort', property: string, isAscending: boolean): void
(event: 'removeSort', property: string): void
}>()
const openModal = () => {
const { onApprove } = useModal<NewSort>(
() => import("@/components/modals/CollectionSorterModal.vue"),
{ availableSorts: computed(() => props.availableSorts) }
);
const { onApprove } = useModal<NewSort>(() => import('@/components/modals/CollectionSorterModal.vue'), {
availableSorts: computed(() => props.availableSorts),
})
onApprove(({ property, isAscending }) =>
emit("addSort", property, isAscending)
);
};
onApprove(({ property, isAscending }) => emit('addSort', property, isAscending))
}
</script>
<style lang="postcss" scoped>

View File

@@ -39,59 +39,52 @@
</template>
<script generic="T extends XenApiRecord<any>" lang="ts" setup>
import CollectionFilter from "@/components/CollectionFilter.vue";
import CollectionSorter from "@/components/CollectionSorter.vue";
import UiTable from "@/components/ui/UiTable.vue";
import useCollectionFilter from "@/composables/collection-filter.composable";
import useCollectionSorter from "@/composables/collection-sorter.composable";
import useFilteredCollection from "@/composables/filtered-collection.composable";
import useMultiSelect from "@/composables/multi-select.composable";
import useSortedCollection from "@/composables/sorted-collection.composable";
import type { XenApiRecord } from "@/libs/xen-api/xen-api.types";
import type { Filters } from "@/types/filter";
import type { Sorts } from "@/types/sort";
import { computed, toRef, watch } from "vue";
import CollectionFilter from '@/components/CollectionFilter.vue'
import CollectionSorter from '@/components/CollectionSorter.vue'
import UiTable from '@/components/ui/UiTable.vue'
import useCollectionFilter from '@/composables/collection-filter.composable'
import useCollectionSorter from '@/composables/collection-sorter.composable'
import useFilteredCollection from '@/composables/filtered-collection.composable'
import useMultiSelect from '@/composables/multi-select.composable'
import useSortedCollection from '@/composables/sorted-collection.composable'
import type { XenApiRecord } from '@/libs/xen-api/xen-api.types'
import type { Filters } from '@/types/filter'
import type { Sorts } from '@/types/sort'
import { computed, toRef, watch } from 'vue'
const props = defineProps<{
modelValue?: T["$ref"][];
availableFilters?: Filters;
availableSorts?: Sorts;
collection: T[];
}>();
modelValue?: T['$ref'][]
availableFilters?: Filters
availableSorts?: Sorts
collection: T[]
}>()
const emit = defineEmits<{
(event: "update:modelValue", selectedRefs: T["$ref"][]): void;
}>();
(event: 'update:modelValue', selectedRefs: T['$ref'][]): void
}>()
const isSelectable = computed(() => props.modelValue !== undefined);
const isSelectable = computed(() => props.modelValue !== undefined)
const { filters, addFilter, removeFilter, predicate } = useCollectionFilter({
queryStringParam: "filter",
});
const { sorts, addSort, removeSort, toggleSortDirection, compareFn } =
useCollectionSorter<Record<string, any>>({ queryStringParam: "sort" });
queryStringParam: 'filter',
})
const { sorts, addSort, removeSort, toggleSortDirection, compareFn } = useCollectionSorter<Record<string, any>>({
queryStringParam: 'sort',
})
const filteredCollection = useFilteredCollection(
toRef(props, "collection"),
predicate
);
const filteredCollection = useFilteredCollection(toRef(props, 'collection'), predicate)
const filteredAndSortedCollection = useSortedCollection(
filteredCollection,
compareFn
);
const filteredAndSortedCollection = useSortedCollection(filteredCollection, compareFn)
const usableRefs = computed(() => props.collection.map((item) => item["$ref"]));
const usableRefs = computed(() => props.collection.map(item => item.$ref))
const selectableRefs = computed(() =>
filteredAndSortedCollection.value.map((item) => item["$ref"])
);
const selectableRefs = computed(() => filteredAndSortedCollection.value.map(item => item.$ref))
const { selected, areAllSelected } = useMultiSelect(usableRefs, selectableRefs);
const { selected, areAllSelected } = useMultiSelect(usableRefs, selectableRefs)
watch(selected, (selected) => emit("update:modelValue", selected), {
watch(selected, selected => emit('update:modelValue', selected), {
immediate: true,
});
})
</script>
<style lang="postcss" scoped>

View File

@@ -10,12 +10,12 @@
</template>
<script lang="ts" setup>
import UiIcon from "@/components/ui/icon/UiIcon.vue";
import type { IconDefinition } from "@fortawesome/fontawesome-common-types";
import UiIcon from '@/components/ui/icon/UiIcon.vue'
import type { IconDefinition } from '@fortawesome/fontawesome-common-types'
defineProps<{
icon?: IconDefinition;
}>();
icon?: IconDefinition
}>()
</script>
<style lang="postcss" scoped>

View File

@@ -26,18 +26,17 @@
</template>
<script lang="ts" setup>
import UiIcon from "@/components/ui/icon/UiIcon.vue";
import type { IconDefinition } from "@fortawesome/fontawesome-common-types";
import UiIcon from '@/components/ui/icon/UiIcon.vue'
import type { IconDefinition } from '@fortawesome/fontawesome-common-types'
defineProps<{
before?: IconDefinition | string | object; // "object" added as workaround
after?: IconDefinition | string | object; // See https://github.com/vuejs/core/issues/4294
label?: string;
inline?: boolean;
}>();
before?: IconDefinition | string | object // "object" added as workaround
after?: IconDefinition | string | object // See https://github.com/vuejs/core/issues/4294
label?: string
inline?: boolean
}>()
const isIcon = (maybeIcon: any): maybeIcon is IconDefinition =>
typeof maybeIcon === "object";
const isIcon = (maybeIcon: any): maybeIcon is IconDefinition => typeof maybeIcon === 'object'
</script>
<style lang="postcss" scoped>
@@ -55,14 +54,14 @@ const isIcon = (maybeIcon: any): maybeIcon is IconDefinition =>
align-items: stretch;
overflow: hidden;
padding: 0 0.7rem;
border: 1px solid var(--color-blue-scale-400);
border: 1px solid var(--color-grey-500);
border-radius: 0.8rem;
background-color: var(--color-blue-scale-500);
background-color: var(--color-grey-600);
box-shadow: var(--shadow-100);
gap: 0.1rem;
&:focus-within {
outline: 1px solid var(--color-extra-blue-l40);
outline: 1px solid var(--color-purple-l40);
}
}
@@ -72,7 +71,7 @@ const isIcon = (maybeIcon: any): maybeIcon is IconDefinition =>
}
.form-widget:hover .widget {
border-color: var(--color-extra-blue-l60);
border-color: var(--color-purple-l60);
}
.element {
@@ -94,8 +93,8 @@ const isIcon = (maybeIcon: any): maybeIcon is IconDefinition =>
font-size: inherit;
border: none;
outline: none;
color: var(--color-blue-scale-100);
background-color: var(--color-blue-scale-500);
color: var(--color-grey-100);
background-color: var(--color-grey-600);
flex: 1;
&:disabled {
@@ -103,7 +102,7 @@ const isIcon = (maybeIcon: any): maybeIcon is IconDefinition =>
}
}
:slotted(input[type="checkbox"]) {
:slotted(input[type='checkbox']) {
font: inherit;
display: grid;
flex: 1.5rem 0 0;
@@ -121,7 +120,7 @@ const isIcon = (maybeIcon: any): maybeIcon is IconDefinition =>
&::before {
width: 0.65em;
height: 0.65em;
content: "";
content: '';
transition: 120ms transform ease-in-out;
transform: scale(0);
transform-origin: center;
@@ -135,7 +134,7 @@ const isIcon = (maybeIcon: any): maybeIcon is IconDefinition =>
&:disabled {
cursor: not-allowed;
color: var(--color-blue-scale-200);
color: var(--color-grey-200);
}
}
</style>

View File

@@ -27,35 +27,35 @@
</template>
<script lang="ts" setup>
import UiCardSpinner from "@/components/ui/UiCardSpinner.vue";
import UiCounter from "@/components/ui/UiCounter.vue";
import UiSpinner from "@/components/ui/UiSpinner.vue";
import UiTable from "@/components/ui/UiTable.vue";
import type { XenApiPatchWithHostRefs } from "@/composables/host-patches.composable";
import { vTooltip } from "@/directives/tooltip.directive";
import { useUiStore } from "@/stores/ui.store";
import { computed } from "vue";
import UiCardSpinner from '@/components/ui/UiCardSpinner.vue'
import UiCounter from '@/components/ui/UiCounter.vue'
import UiSpinner from '@/components/ui/UiSpinner.vue'
import UiTable from '@/components/ui/UiTable.vue'
import type { XenApiPatchWithHostRefs } from '@/composables/host-patches.composable'
import { vTooltip } from '@/directives/tooltip.directive'
import { useUiStore } from '@/stores/ui.store'
import { computed } from 'vue'
const props = defineProps<{
patches: XenApiPatchWithHostRefs[];
hasMultipleHosts: boolean;
areAllLoaded: boolean;
areSomeLoaded: boolean;
}>();
patches: XenApiPatchWithHostRefs[]
hasMultipleHosts: boolean
areAllLoaded: boolean
areSomeLoaded: boolean
}>()
const sortedPatches = computed(() =>
[...props.patches].sort((patch1, patch2) => {
if (patch1.changelog == null) {
return 1;
return 1
} else if (patch2.changelog == null) {
return -1;
return -1
}
return patch1.changelog.date - patch2.changelog.date;
return patch1.changelog.date - patch2.changelog.date
})
);
)
const { isDesktop } = useUiStore();
const { isDesktop } = useUiStore()
</script>
<style lang="postcss" scoped>

View File

@@ -1,23 +1,23 @@
<template>
<div class="error" v-if="error !== undefined">
<div v-if="error !== undefined" class="error">
<UiIcon :icon="faExclamationCircle" />
<span v-if="error.message === 'SESSION_AUTHENTICATION_FAILED'">
{{ $t("password-invalid") }}
{{ $t('password-invalid') }}
</span>
<span v-else>
{{ $t("error-occurred") }}
{{ $t('error-occurred') }}
</span>
</div>
</template>
<script lang="ts" setup>
import UiIcon from "@/components/ui/icon/UiIcon.vue";
import type { XenApiError } from "@/libs/xen-api/xen-api.types";
import { faExclamationCircle } from "@fortawesome/free-solid-svg-icons";
import UiIcon from '@/components/ui/icon/UiIcon.vue'
import type { XenApiError } from '@/libs/xen-api/xen-api.types'
import { faExclamationCircle } from '@fortawesome/free-solid-svg-icons'
defineProps<{
error: XenApiError | undefined;
}>();
error: XenApiError | undefined
}>()
</script>
<style lang="postcss" scoped>
@@ -25,7 +25,7 @@ defineProps<{
font-size: 1.3rem;
line-height: 150%;
margin: 0.5rem 0;
color: var(--color-red-vates-base);
color: var(--color-red-base);
& svg {
margin-right: 0.5rem;

View File

@@ -1,7 +1,7 @@
<template>
<div class="no-data">
<img alt="No data" class="img" src="@/assets/undraw-bug-fixing.svg" />
<p class="text-error">{{ $t("error-no-data") }}</p>
<p class="text-error">{{ $t('error-no-data') }}</p>
</div>
</template>
@@ -25,6 +25,6 @@
font-weight: 500;
font-size: 1.25em;
line-height: 150%;
color: var(--color-red-vates-base);
color: var(--color-red-base);
}
</style>

View File

@@ -1,7 +1,7 @@
<template>
<div class="no-result">
<img alt="" class="img" src="@/assets/no-result.svg" />
<p class="text-info">{{ $t("no-result") }}</p>
<p class="text-info">{{ $t('no-result') }}</p>
</div>
</template>
@@ -27,6 +27,6 @@
font-weight: 500;
font-size: 2rem;
line-height: 150%;
color: var(--color-extra-blue-base);
color: var(--color-purple-base);
}
</style>

View File

@@ -12,85 +12,80 @@
</template>
<script generic="T extends ObjectType" lang="ts" setup>
import UiSpinner from "@/components/ui/UiSpinner.vue";
import type {
ObjectType,
ObjectTypeToRecord,
} from "@/libs/xen-api/xen-api.types";
import { useHostStore } from "@/stores/xen-api/host.store";
import { usePoolStore } from "@/stores/xen-api/pool.store";
import { useSrStore } from "@/stores/xen-api/sr.store";
import { useVmStore } from "@/stores/xen-api/vm.store";
import type { StoreDefinition } from "pinia";
import { computed, onUnmounted, watch } from "vue";
import type { RouteRecordName } from "vue-router";
import UiSpinner from '@/components/ui/UiSpinner.vue'
import type { ObjectType, ObjectTypeToRecord } from '@/libs/xen-api/xen-api.types'
import { useHostStore } from '@/stores/xen-api/host.store'
import { usePoolStore } from '@/stores/xen-api/pool.store'
import { useSrStore } from '@/stores/xen-api/sr.store'
import { useVmStore } from '@/stores/xen-api/vm.store'
import type { StoreDefinition } from 'pinia'
import { computed, onUnmounted, watch } from 'vue'
import type { RouteRecordName } from 'vue-router'
type HandledTypes = "host" | "vm" | "sr" | "pool";
type XRecord = ObjectTypeToRecord<T>;
type HandledTypes = 'host' | 'vm' | 'sr' | 'pool'
type XRecord = ObjectTypeToRecord<T>
type Config = Partial<
Record<
ObjectType,
{
useStore: StoreDefinition<any, any, any, any>;
routeName: RouteRecordName | undefined;
useStore: StoreDefinition<any, any, any, any>
routeName: RouteRecordName | undefined
}
>
>;
>
const props = defineProps<{
type: T;
uuid: XRecord["uuid"];
}>();
type: T
uuid: XRecord['uuid']
}>()
const config: Config = {
host: { useStore: useHostStore, routeName: "host.dashboard" },
vm: { useStore: useVmStore, routeName: "vm.console" },
host: { useStore: useHostStore, routeName: 'host.dashboard' },
vm: { useStore: useVmStore, routeName: 'vm.console' },
sr: { useStore: useSrStore, routeName: undefined },
pool: { useStore: usePoolStore, routeName: "pool.dashboard" },
} satisfies Record<HandledTypes, any>;
pool: { useStore: usePoolStore, routeName: 'pool.dashboard' },
} satisfies Record<HandledTypes, any>
const store = computed(() => config[props.type]?.useStore());
const store = computed(() => config[props.type]?.useStore())
const subscriptionId = Symbol();
const subscriptionId = Symbol('OBJECT_LINK_SUBSCRIPTION_ID')
watch(
store,
(nextStore, previousStore) => {
previousStore?.unsubscribe(subscriptionId);
nextStore?.subscribe(subscriptionId);
previousStore?.unsubscribe(subscriptionId)
nextStore?.subscribe(subscriptionId)
},
{ immediate: true }
);
)
onUnmounted(() => {
store.value?.unsubscribe(subscriptionId);
});
store.value?.unsubscribe(subscriptionId)
})
const record = computed<ObjectTypeToRecord<HandledTypes> | undefined>(
() => store.value?.getByUuid(props.uuid as any)
);
const record = computed<ObjectTypeToRecord<HandledTypes> | undefined>(() => store.value?.getByUuid(props.uuid as any))
const isReady = computed(() => {
return store.value?.isReady ?? true;
});
return store.value?.isReady ?? true
})
const objectRoute = computed(() => {
const { routeName } = config[props.type] ?? {};
const { routeName } = config[props.type] ?? {}
if (routeName === undefined) {
return;
return
}
return {
name: routeName,
params: { uuid: props.uuid },
};
});
}
})
</script>
<style lang="postcss" scoped>
.unknown {
color: var(--color-blue-scale-300);
color: var(--color-grey-300);
font-style: italic;
}
</style>

View File

@@ -6,30 +6,24 @@
<slot v-else />
</template>
<script
generic="T extends XenApiRecord<ObjectType>, I extends T['uuid']"
lang="ts"
setup
>
import UiSpinner from "@/components/ui/UiSpinner.vue";
import type { ObjectType, XenApiRecord } from "@/libs/xen-api/xen-api.types";
import ObjectNotFoundView from "@/views/ObjectNotFoundView.vue";
import { computed } from "vue";
import { useRouter } from "vue-router";
<script generic="T extends XenApiRecord<ObjectType>, I extends T['uuid']" lang="ts" setup>
import UiSpinner from '@/components/ui/UiSpinner.vue'
import type { ObjectType, XenApiRecord } from '@/libs/xen-api/xen-api.types'
import ObjectNotFoundView from '@/views/ObjectNotFoundView.vue'
import { computed } from 'vue'
import { useRouter } from 'vue-router'
const props = defineProps<{
isReady: boolean;
uuidChecker: (uuid: I) => boolean;
id?: I;
}>();
isReady: boolean
uuidChecker: (uuid: I) => boolean
id?: I
}>()
const { currentRoute } = useRouter();
const { currentRoute } = useRouter()
const id = computed(() => props.id ?? (currentRoute.value.params.uuid as I));
const id = computed(() => props.id ?? (currentRoute.value.params.uuid as I))
const isRecordNotFound = computed(
() => props.isReady && !props.uuidChecker(id.value)
);
const isRecordNotFound = computed(() => props.isReady && !props.uuidChecker(id.value))
</script>
<style scoped>
@@ -39,7 +33,7 @@ const isRecordNotFound = computed(
}
.spinner {
color: var(--color-extra-blue-base);
color: var(--color-purple-base);
display: flex;
margin: auto;
width: 10rem;

Some files were not shown because too many files have changed in this diff Show More