forked from Ficodes/BAE-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusage-spec.component.html
More file actions
124 lines (116 loc) · 7.47 KB
/
usage-spec.component.html
File metadata and controls
124 lines (116 loc) · 7.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<div class="bg-secondary-50 dark:bg-secondary-100 border border-secondary-50 dark:border-gray-800 mt-4 p-4 md:p-8 rounded-lg w-full">
@if(formType === 'update'){
<h2 class="text-3xl font-bold text-primary-100 dark:text-white pb-4">
{{ 'USAGE_SPECS._update' | translate }}
</h2>
} @else {
<h2 class="text-3xl font-bold text-primary-100 dark:text-white pb-4">
{{ 'USAGE_SPECS._create' | translate }}
</h2>
}
@if(loadingData){
<div role="status" class="w-full h-full flex justify-center align-middle">
<svg aria-hidden="true" class="w-12 h-12 text-gray-200 animate-spin dark:text-gray-600 fill-secondary-400" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
</svg>
<span class="sr-only">Loading...</span>
</div>
} @else {
<!-- Stepper -->
<form [formGroup]="usageSpecForm">
<ol class="flex items-start w-full text-sm font-medium text-center text-gray-500 dark:text-gray-400">
@for (step of steps; track i; let i = $index) {
<li
(click)="handleStepClick(i)"
[class.cursor-not-allowed]="!canNavigate(i)"
[class.opacity-50]="!canNavigate(i)"
[class.text-primary-100]="currentStep === i"
class="flex-1 cursor-pointer">
<span class="flex items-center justify-center w-8 h-8 md:w-10 md:h-10 mx-auto border-2 border-primary-100 dark:border-primary-50 shrink-0 rounded-full"
[class.bg-primary-100]="currentStep === i"
[class.text-white]="currentStep === i">
{{ i + 1 }}
</span>
<span class="md:block mt-2 hidden">{{ step }}</span>
</li>
}
</ol>
<h3 class="block md:hidden mt-2 text-center text-2xl text-primary-100 dark:text-white pb-4">{{ this.steps[currentStep] }}</h3>
<div class="md:p-8">
<!-- Step Forms -->
@if (currentStep === 0) {
<usage-spec-general-info
[data]="usageSpec"
[formType]="formType"
[form]="usageSpecForm.controls['generalInfo']"
(formChange)="handleSubformChange($event)">
</usage-spec-general-info>
} @else if (currentStep === 1) {
<usage-spec-metrics
[data]="usageSpec"
[formType]="formType"
formControlName="metrics"
(formChange)="handleSubformChange($event)">
</usage-spec-metrics>
} @else if (currentStep === 2) {
<usage-spec-summary [usageSpecForm]="usageSpecForm"></usage-spec-summary>
}
</div>
<!-- Navigation Buttons -->
<div class="flex justify-end mt-6 space-x-4">
<button data-cy="usageSpecPrevious" (click)="goToStep(currentStep - 1)"
[disabled]="currentStep === 0"
[ngClass]="{
'text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-white': currentStep !== 0,
'text-gray-300 dark:text-gray-600 cursor-not-allowed': currentStep === 0
}"
class="px-4 py-2 flex items-center justify-center text-base font-medium rounded-lg bg-white border border-gray-300 dark:bg-gray-800 dark:border-gray-700 ">
<svg class="min-w-4 w-4 h-4 mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path fill="currentColor"
d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3
256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"/>
</svg>
{{ 'USAGE_SPECS._previous' | translate }}
</button>
<button data-cy="usageSpecNext" (click)="goToStep(currentStep + 1)"
[disabled]="currentStep === steps.length - 1 || (formType === 'create' && !validateCurrentStep()) || !canNavigate(currentStep)"
[ngClass]="{
'hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-white': currentStep !== steps.length - 1 && (formType !== 'create' || validateCurrentStep() || canNavigate(currentStep)),
'cursor-not-allowed opacity-50': currentStep === steps.length - 1 || (formType === 'create' && !validateCurrentStep() || !canNavigate(currentStep))
}"
class="px-4 py-2 flex items-center justify-center text-base font-medium rounded-lg text-gray-500 bg-white border border-gray-300 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400">
{{ 'USAGE_SPECS._next' | translate }}
<svg class="min-w-4 w-4 h-4 ml-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path fill="currentColor"
d="M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7
256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"/>
</svg>
</button>
@if(formType === 'create' && currentStep === 2 || formType === 'update'){
<button data-cy="btnCreateUsageSpec" (click)="submitForm()"
[disabled]="!usageSpecForm.controls['generalInfo'].valid"
[ngClass]="formType === 'update' && !usageSpecForm.controls['generalInfo'].valid ? 'opacity-50' : 'hover:bg-primary-50'"
class="px-4 py-2 text-base font-medium text-white rounded-lg bg-primary-100">
{{ formType === 'create' ? 'Create Usage Spec' : 'Update Usage Spec' }}
</button>
}
</div>
</form>
}
</div>
@if(showError){
<div class="flex justify-center items-center fixed w-fit top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-50">
<div id="alert-additional-content-2" class="p-4 mb-4 text-red-800 border border-red-300 rounded-lg bg-red-50 dark:bg-red-900 dark:border-red-900 dark:text-white" role="alert">
<div class="flex items-center">
<svg class="flex-shrink-0 w-4 h-4 me-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
</svg>
<h3 class="text-lg font-medium">Error</h3>
</div>
<div class="mt-2 mb-4 text-sm">
{{errorMessage}}
</div>
</div>
</div>
}