@@ -169,7 +220,7 @@ import InverterChannelInfo from "@/components/partials/InverterChannelInfo.vue";
import * as bootstrap from 'bootstrap';
import EventLog from '@/components/partials/EventLog.vue';
import DevInfo from '@/components/partials/DevInfo.vue';
-import LimitSettingsCurrent from '@/components/partials/LimitSettingsCurrent.vue';
+import BootstrapAlert from '@/components/partials/BootstrapAlert.vue';
declare interface Inverter {
serial: number,
@@ -184,7 +235,7 @@ export default defineComponent({
InverterChannelInfo,
EventLog,
DevInfo,
- LimitSettingsCurrent
+ BootstrapAlert,
},
data() {
return {
@@ -200,9 +251,22 @@ export default defineComponent({
devInfoView: {} as bootstrap.Modal,
devInfoList: {},
devInfoLoading: true,
+
limitSettingView: {} as bootstrap.Modal,
- limitSettingList: {},
+ limitSettingSerial: 0,
limitSettingLoading: true,
+
+ currentLimit: 0,
+ targetLimit: 0,
+ targetLimitMin: 10,
+ targetLimitMax: 100,
+ targetLimitTypeText: "Relative (%)",
+ targetLimitType: 1,
+ targetLimitPersistent: false,
+
+ alertMessageLimit: "",
+ alertTypeLimit: "info",
+ showAlertLimit: false,
};
},
created() {
@@ -214,6 +278,8 @@ export default defineComponent({
this.eventLogView = new bootstrap.Modal('#eventView');
this.devInfoView = new bootstrap.Modal('#devInfoView');
this.limitSettingView = new bootstrap.Modal('#limitSettingView');
+
+ (this.$refs.limitSettingView as HTMLElement).addEventListener("hide.bs.modal", this.onHideLimitSettings);
},
unmounted() {
this.closeSocket();
@@ -322,19 +388,75 @@ export default defineComponent({
this.devInfoView.show();
},
onHideLimitSettings() {
- this.limitSettingView.hide();
+ this.limitSettingSerial = 0;
+ this.targetLimit = 0;
+ this.targetLimitType = 1;
+ this.targetLimitTypeText = "Relative (%)";
+ this.showAlertLimit = false;
},
onShowLimitSettings(serial: number) {
this.limitSettingLoading = true;
fetch("/api/limit/status")
.then((response) => response.json())
.then((data) => {
- this.limitSettingList = data[serial];
+ this.currentLimit = data[serial].limit;
+ this.limitSettingSerial = serial;
this.limitSettingLoading = false;
});
this.limitSettingView.show();
},
+ onSubmitLimit(e: Event) {
+ e.preventDefault();
+
+ const data = {
+ serial: this.limitSettingSerial,
+ limit_value: this.targetLimit,
+ limit_type: (this.targetLimitPersistent ? 256 : 0) + this.targetLimitType,
+ };
+ const formData = new FormData();
+ formData.append("data", JSON.stringify(data));
+
+ console.log(data);
+
+ fetch("/api/limit/config", {
+ method: "POST",
+ body: formData,
+ })
+ .then(function (response) {
+ if (response.status != 200) {
+ throw response.status;
+ } else {
+ return response.json();
+ }
+ })
+ .then(
+ (response) => {
+ if (response.type == "success") {
+ this.limitSettingView.hide();
+ } else {
+ this.alertMessageLimit = response.message;
+ this.alertTypeLimit = response.type;
+ this.showAlertLimit = true;
+ }
+ }
+ )
+ },
+ onSetLimitSettings(setPersistent: boolean) {
+ this.targetLimitPersistent = setPersistent;
+ },
+ onSelectType(type: number) {
+ if (type == 1) {
+ this.targetLimitTypeText = "Relative (%)";
+ this.targetLimitMin = 10;
+ this.targetLimitMax = 100;
+ } else {
+ this.targetLimitTypeText = "Absolute (W)";
+ this.targetLimitMin = 10;
+ this.targetLimitMax = 1500;
+ }
+ this.targetLimitType = type;
+ },
},
});
\ No newline at end of file