diff --git a/src/app/_layout/footer/footer.component.html b/src/app/_layout/footer/footer.component.html
index 6a5fa9d..7e9abf0 100644
--- a/src/app/_layout/footer/footer.component.html
+++ b/src/app/_layout/footer/footer.component.html
@@ -13,7 +13,7 @@
href="https://allbestsistem.com/"
target="_blank"
style="background-color: #ffffff !important;"
- >Smart Building Management Systems (V@2024-08-27.2)
+ >Smart Building Management Systems (V@2024-08-28.1)
diff --git a/src/app/content/hemat-app/device/control-scheduler/control-scheduler.component.html b/src/app/content/hemat-app/device/control-scheduler/control-scheduler.component.html
index ee3e4af..c1c2411 100644
--- a/src/app/content/hemat-app/device/control-scheduler/control-scheduler.component.html
+++ b/src/app/content/hemat-app/device/control-scheduler/control-scheduler.component.html
@@ -80,7 +80,11 @@
}}
+
+ Please select at least one day.
+
+
diff --git a/src/app/content/hemat-app/device/control-scheduler/control-scheduler.component.ts b/src/app/content/hemat-app/device/control-scheduler/control-scheduler.component.ts
index 3a50203..7c28e77 100644
--- a/src/app/content/hemat-app/device/control-scheduler/control-scheduler.component.ts
+++ b/src/app/content/hemat-app/device/control-scheduler/control-scheduler.component.ts
@@ -85,6 +85,7 @@ export class ControlSchedulerComponent {
});
this.myForm = this.fb.group(controls);
+ this.myForm.setValidators(this.atLeastOneDaySelectedValidator());
}
editForm() {
@@ -105,6 +106,15 @@ export class ControlSchedulerComponent {
});
}
+ atLeastOneDaySelectedValidator() {
+ return (formGroup: FormGroup) => {
+ const selectedDays = this.daysOfWeek.some(
+ (day) => formGroup.get(day.value)?.value
+ );
+ return selectedDays ? null : { noDaySelected: true };
+ };
+ }
+
onDayChange(day: string, isChecked: boolean) {
if (isChecked) {
this.selectedDays.push(day);
@@ -114,46 +124,44 @@ export class ControlSchedulerComponent {
}
save() {
- const formValues = this.myForm.value;
-
- // Collect selected days' labels
- const selectedDays = this.daysOfWeek
- .filter((day) => formValues[day.value])
- .map((day) => day.value);
-
- // Construct the final output
- let result = {};
-
- if (this.mode === "add") {
- result = {
- name: formValues.name,
- device_id: formValues.device_id,
- timeset: formValues.timeset,
- recurring: formValues.recurring,
- active: formValues.active,
- switch: formValues.switch,
- days: selectedDays,
- };
- } else {
- result = {
- id: this.data.id,
- name: formValues.name,
- device_id: formValues.device_id,
- timeset: formValues.timeset,
- recurring: formValues.recurring,
- active: formValues.active,
- switch: formValues.switch,
- days: selectedDays,
- };
- }
-
if (this.myForm.valid) {
+ const formValues = this.myForm.value;
+
+ // Collect selected days' labels
+ const selectedDays = this.daysOfWeek
+ .filter((day) => formValues[day.value])
+ .map((day) => day.value);
+
+ // Construct the final output
+ let result = {};
+
+ if (this.mode === "add") {
+ result = {
+ name: formValues.name,
+ device_id: formValues.device_id,
+ timeset: formValues.timeset,
+ recurring: formValues.recurring,
+ active: formValues.active,
+ switch: formValues.switch,
+ days: selectedDays,
+ };
+ } else {
+ result = {
+ id: this.data.id,
+ name: formValues.name,
+ device_id: formValues.device_id,
+ timeset: formValues.timeset,
+ recurring: formValues.recurring,
+ active: formValues.active,
+ switch: formValues.switch,
+ days: selectedDays,
+ };
+ }
+
this.activeModal.close(result);
} else {
this.markFormGroupTouched(this.myForm);
}
-
- // console.log("Form Result: ", result);
}
markFormGroupTouched(formGroup: FormGroup) {
diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html
index d812386..bdfb12d 100644
--- a/src/app/login/login.component.html
+++ b/src/app/login/login.component.html
@@ -138,7 +138,7 @@
- (v@2024.08.27.2)
+ (v@2024.08.28.1)