zibri-cli 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/assets/public/assets.svg +3 -1
  2. package/assets/public/home.svg +3 -0
  3. package/assets/public/lib/chartjs-adapter-date-fns.js +7 -0
  4. package/assets/public/metrics.svg +3 -0
  5. package/assets/public/style.css +4 -127
  6. package/dist/commands/new/new.command.js +164 -26
  7. package/dist/commands/new/new.command.js.map +1 -1
  8. package/dist/encapsulation/fs.utilities.js +13 -3
  9. package/dist/encapsulation/fs.utilities.js.map +1 -1
  10. package/package.json +2 -2
  11. package/templates/components/base-page.tsx.tpl +24 -0
  12. package/templates/components/button.tsx.tpl +34 -0
  13. package/templates/components/card.tsx.tpl +13 -0
  14. package/templates/components/chart.tsx.tpl +19 -0
  15. package/templates/components/checkbox.tsx.tpl +24 -0
  16. package/templates/components/dialog.tsx.tpl +14 -0
  17. package/templates/components/empty-page.tsx.tpl +34 -0
  18. package/templates/components/file-entry.tsx.tpl +31 -0
  19. package/templates/components/form.tsx.tpl +17 -0
  20. package/templates/components/heading.tsx.tpl +19 -0
  21. package/templates/components/link.tsx.tpl +29 -0
  22. package/templates/components/metrics-status.tsx.tpl +92 -0
  23. package/templates/components/navbar.tsx.tpl +31 -0
  24. package/templates/components/network-chart.tsx.tpl +99 -0
  25. package/templates/components/request-duration-chart.tsx.tpl +83 -0
  26. package/templates/components/requests-per-second-chart.tsx.tpl +167 -0
  27. package/templates/components/resource-usage-chart.tsx.tpl +121 -0
  28. package/templates/components/textarea.tsx.tpl +23 -0
  29. package/templates/pages/assets.tsx.tpl +23 -0
  30. package/templates/pages/error.tsx.tpl +42 -0
  31. package/templates/pages/home.tsx.tpl +44 -0
  32. package/templates/pages/mailing-list-preferences.tsx.tpl +149 -0
  33. package/templates/pages/mailing-list-unsubscribe-confirmation.tsx.tpl +40 -0
  34. package/templates/pages/metrics.tsx.tpl +82 -0
  35. package/assets/public/socket.io.js +0 -4908
  36. package/templates/pages/assets.hbs +0 -25
  37. package/templates/pages/base-page.hbs +0 -15
  38. package/templates/pages/error.hbs +0 -41
  39. package/templates/pages/index.hbs +0 -20
  40. package/templates/pages/mailing-list-preferences.hbs +0 -152
  41. package/templates/pages/mailing-list-unsubscribe.hbs +0 -25
  42. package/templates/pages/metrics.hbs +0 -443
@@ -0,0 +1,40 @@
1
+ import { MailingList, MailingListSubscriber, MaskUtilities, PreactComponent } from 'zibri';
2
+
3
+ import { Card } from '../components/card';
4
+ import { EmptyPage } from '../components/empty-page';
5
+ import { Heading } from '../components/heading';
6
+
7
+ type Props = {
8
+ subscriber: MailingListSubscriber,
9
+ mailingList: MailingList
10
+ };
11
+
12
+ export const MailingListUnsubscribeConfirmationPage: PreactComponent<Props> = ({ subscriber, mailingList }) => {
13
+ const email: string = MaskUtilities.mask(subscriber.email);
14
+
15
+ return (
16
+ <EmptyPage title='Unsubscribed successfully'>
17
+ <Card className='text-center flex flex-col gap-6'>
18
+ <img className="block mx-auto" src="/assets/logo.jpg" width="200px" height="200px"/>
19
+ <p>{email}</p>
20
+ <Heading className="my-2">
21
+ You've unsubscribed from
22
+ <br/>
23
+ {mailingList.name}
24
+ </Heading>
25
+ <p className="mb-4">
26
+ We are sad to see you go 😕
27
+ </p>
28
+ <div>
29
+ <hr/>
30
+ </div>
31
+ <p>
32
+ Unsubscribed by accident?
33
+ <br/>
34
+ {/* TODO */}
35
+ <a href="">Subscribe again</a> or <a href="/mailing-lists/preferences">manage other email preferences</a>
36
+ </p>
37
+ </Card>
38
+ </EmptyPage>
39
+ );
40
+ };
@@ -0,0 +1,82 @@
1
+ import { Chart } from 'chart.js?client';
2
+ import { MetricsSnapshot, onClient, PreactComponent } from 'zibri';
3
+
4
+ import { BasePage } from '../components/base-page';
5
+ import { Heading } from '../components/heading';
6
+ import { MetricsStatus } from '../components/metrics-status';
7
+ import { NetworkChart } from '../components/network-chart';
8
+ import { RequestDurationChart } from '../components/request-duration-chart';
9
+ import { RequestsPerSecondChart } from '../components/requests-per-second-chart';
10
+ import { ResourceUsageChart } from '../components/resource-usage-chart';
11
+
12
+ export type MetricsEvent = CustomEvent<{
13
+ snaps: MetricsSnapshot[]
14
+ }>;
15
+
16
+ type Props = {
17
+ version: string,
18
+ primary: string,
19
+ secondary: string
20
+ };
21
+
22
+ export const MetricsPage: PreactComponent<Props> = ({ version, primary, secondary }) => {
23
+ Chart.defaults.color = 'whitesmoke';
24
+ Chart.defaults.borderColor = 'whitesmoke';
25
+ Chart.defaults.scale.grid.color = 'rgba(200, 200, 200, 0.3)';
26
+
27
+ let snaps: MetricsSnapshot[] = [];
28
+ let automaticReload: boolean = true;
29
+
30
+ onClient(() => {
31
+ window.addEventListener('load', () => {
32
+ void loadSnapshots();
33
+ setInterval(() => void loadSnapshots(), 1000);
34
+ });
35
+ });
36
+
37
+ async function loadSnapshots(): Promise<void> {
38
+ if (!automaticReload) {
39
+ return;
40
+ }
41
+ try {
42
+ const resp: Response = await fetch('/metrics');
43
+ // eslint-disable-next-line typescript/no-unsafe-assignment
44
+ snaps = await resp.json();
45
+ document.dispatchEvent(new CustomEvent('metrics:update', { detail: { snaps } }));
46
+ }
47
+ catch (error) {
48
+ console.error('failed to load metrics', error);
49
+ }
50
+ }
51
+
52
+ return (
53
+ <>
54
+ <BasePage title='Metrics'
55
+ activeRoute='/metrics/dashboard'
56
+ scripts={['/assets/lib/chartjs-adapter-date-fns.js']}
57
+ className="flex flex-col gap-4 py-8"
58
+ >
59
+ <Heading className="text-center">Metrics</Heading>
60
+ <div className="w-full px-10 flex flex-col gap-5">
61
+ <div className="grid grid-cols-5 gap-5">
62
+ <div className="col-span-2 flex flex-col gap-5">
63
+ <MetricsStatus
64
+ automaticReloadChecked={automaticReload}
65
+ onReloadChange={() => automaticReload = !automaticReload}
66
+ version={version}
67
+ className="flex-1"
68
+ >
69
+ </MetricsStatus>
70
+ <RequestDurationChart className="flex-1" secondary={secondary}></RequestDurationChart>
71
+ </div>
72
+ <RequestsPerSecondChart secondary={secondary} className="col-span-3"></RequestsPerSecondChart>
73
+ </div>
74
+ <div className="grid grid-cols-2 gap-5">
75
+ <ResourceUsageChart primary={primary} secondary={secondary}></ResourceUsageChart>
76
+ <NetworkChart primary={primary} secondary={secondary}></NetworkChart>
77
+ </div>
78
+ </div>
79
+ </BasePage>
80
+ </>
81
+ );
82
+ };