|
1 | 1 | import { RouteMeta } from '@analogjs/router'; |
2 | | -import { AsyncPipe, TitleCasePipe } from '@angular/common'; |
| 2 | +import { AsyncPipe, NgIf, TitleCasePipe } from '@angular/common'; |
3 | 3 | import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; |
4 | 4 | import { ReactiveFormsModule, UntypedFormGroup } from '@angular/forms'; |
5 | 5 | import { ActivatedRoute, Router } from '@angular/router'; |
@@ -33,68 +33,72 @@ export const routeMeta: RouteMeta = { |
33 | 33 | ReactiveFormsModule, |
34 | 34 | FormlyForm, |
35 | 35 | AsyncPipe, |
36 | | - TitleCasePipe, |
| 36 | + NgIf, |
37 | 37 | LucideAngularModule, |
| 38 | + TitleCasePipe, |
38 | 39 | ], |
39 | | - template: ` @if (data$ | async; as data) { |
40 | | - <h1 class="text-4xl font-extrabold text-gray-800 mb-2"> |
41 | | - Add {{ data.type | titlecase }} Widget |
42 | | - </h1> |
43 | | - <p class="text-xl text-gray-500 mb-8"> |
44 | | - <a |
45 | | - href="/dashboards/{{ data.dashboard.id }}" |
46 | | - class="text-gray-500 hover:text-pastel-blue transition-colors mb-10 mt-2 flex items-center" |
47 | | - > |
48 | | - <i-lucide name="arrow-left" class="w-6 h-6 mr-0 lg:mr-2"></i-lucide> |
49 | | - <span class="hidden lg:inline text-lg font-medium" |
50 | | - >Dashboard "{{ data.dashboard.name }}"</span |
51 | | - > |
52 | | - </a> |
53 | | - Configure your new widget. |
54 | | - </p> |
| 40 | + template: ` |
| 41 | + @if (data$ | async; as data) { |
| 42 | + <h1 class="text-4xl font-extrabold text-gray-800 mb-2"> |
| 43 | + Add {{ data.type | titlecase }} Widget |
| 44 | + </h1> |
55 | 45 |
|
56 | | - <!-- Widget Configuration Panel --> |
57 | | - <div class="bg-white p-6 rounded-2xl long-shadow mb-8 space-y-4"> |
58 | | - @if (formFields$ | async; as formlyFields) { |
59 | | - <form |
60 | | - [formGroup]="form" |
61 | | - (ngSubmit)=" |
62 | | - onSubmit({ type: data.type, dashboardId: data.dashboard.id }) |
63 | | - " |
| 46 | + <p class="text-xl text-gray-500 mb-8"> |
| 47 | + <a |
| 48 | + href="/dashboards/{{ data.dashboard.id }}" |
| 49 | + class="text-gray-500 hover:text-pastel-blue transition-colors mb-10 mt-2 flex items-center" |
64 | 50 | > |
65 | | - <formly-form |
66 | | - [form]="form" |
67 | | - [fields]="formlyFields || []" |
68 | | - [(model)]="formModel" |
69 | | - ></formly-form> |
70 | | - <div class="flex gap-4"> |
71 | | - <a |
72 | | - href="/dashboards/{{ data.dashboard.id }}" |
73 | | - class="flex items-center text-lg font-bold py-3 px-6 rounded-xl text-white bg-gray-500 transition-all duration-300 transform hover:scale-[1.02] flat-btn-shadow mb-8 |
74 | | - bg-gradient-to-tr from-[#9CA3AF] to-[#6B7280] tracking-wide cursor-pointer" |
75 | | - > |
76 | | - <i-lucide name="x" class="w-5 h-5 mr-2"></i-lucide> |
77 | | - Cancel |
78 | | - </a> |
| 51 | + <i-lucide name="arrow-left" class="w-6 h-6 mr-0 lg:mr-2"></i-lucide> |
| 52 | + <span class="hidden lg:inline text-lg font-medium" |
| 53 | + >Dashboard "{{ data.dashboard.name }}"</span |
| 54 | + > |
| 55 | + </a> |
| 56 | + Configure your new widget. |
| 57 | + </p> |
79 | 58 |
|
80 | | - <button |
81 | | - type="submit" |
82 | | - class="flex items-center text-lg font-bold py-3 px-6 rounded-xl text-white bg-pastel-blue transition-all duration-300 transform hover:scale-[1.02] flat-btn-shadow mb-8 |
83 | | - bg-gradient-to-tr from-[#8A89F0] to-[#A2C0F5] tracking-wide cursor-pointer" |
84 | | - > |
85 | | - <i-lucide name="plus" class="w-5 h-5 mr-2"></i-lucide> |
86 | | - Add Widget |
87 | | - </button> |
88 | | - </div> |
89 | | - </form> |
90 | | - } |
91 | | - </div> |
92 | | - }`, |
| 59 | + <!-- Widget Configuration Panel --> |
| 60 | + <div class="bg-white p-6 rounded-2xl long-shadow mb-8 space-y-4"> |
| 61 | + @if (formFields$ | async; as formlyFields) { |
| 62 | + <form |
| 63 | + [formGroup]="form" |
| 64 | + (ngSubmit)=" |
| 65 | + onSubmit({ type: data.type, dashboardId: data.dashboard.id }) |
| 66 | + " |
| 67 | + > |
| 68 | + <formly-form |
| 69 | + [form]="form" |
| 70 | + [fields]="formlyFields || []" |
| 71 | + [(model)]="formModel" |
| 72 | + ></formly-form> |
| 73 | + <div class="flex gap-4"> |
| 74 | + <a |
| 75 | + href="/dashboards/{{ data.dashboard.id }}" |
| 76 | + class="flex items-center text-lg font-bold py-3 px-6 rounded-xl text-white bg-gray-500 transition-all duration-300 transform hover:scale-[1.02] flat-btn-shadow mb-8 |
| 77 | + bg-gradient-to-tr from-[#9CA3AF] to-[#6B7280] tracking-wide cursor-pointer" |
| 78 | + > |
| 79 | + <i-lucide name="x" class="w-5 h-5 mr-2"></i-lucide> |
| 80 | + Cancel |
| 81 | + </a> |
| 82 | +
|
| 83 | + <button |
| 84 | + type="submit" |
| 85 | + class="flex items-center text-lg font-bold py-3 px-6 rounded-xl text-white bg-pastel-blue transition-all duration-300 transform hover:scale-[1.02] flat-btn-shadow mb-8 |
| 86 | + bg-gradient-to-tr from-[#8A89F0] to-[#A2C0F5] tracking-wide flex items-center justify-center cursor-pointer" |
| 87 | + > |
| 88 | + <i-lucide name="plus" class="w-5 h-5 mr-2"></i-lucide> |
| 89 | + Create Widget |
| 90 | + </button> |
| 91 | + </div> |
| 92 | + </form> |
| 93 | + } |
| 94 | + </div> |
| 95 | + } |
| 96 | + `, |
93 | 97 | }) |
94 | 98 | export default class DashboardsWidgetsAddByTypePageComponent { |
95 | | - private readonly dashboardsService = inject(DashboardsService); |
96 | 99 | private readonly widgetsService = inject(WidgetsService); |
97 | 100 | private readonly errorHandlerService = inject(ErrorHandlerService); |
| 101 | + private readonly dashboardsService = inject(DashboardsService); |
98 | 102 | private readonly route = inject(ActivatedRoute); |
99 | 103 | private readonly router = inject(Router); |
100 | 104 | private readonly formHandlerService = inject(FormHandlerService); |
|
0 commit comments