-
Notifications
You must be signed in to change notification settings - Fork 4
Implemented charge windows instead of just picking random low price s… #951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 60 commits
f4aff26
f0cabe5
6ee0dd7
d77163b
62ca0a6
2f49ce8
56f2dbf
dfdbcbc
289a128
edee93d
cd6e37c
a05c30e
9970b35
abaa689
0ba6c3c
d6249df
eff4b93
e792fc0
2469fd9
8ec1159
e20c353
f283d3f
303905c
b7c3b2e
66d84c1
c2d4356
7d4afca
47b15e8
5640500
3cd204f
6f93098
98dee8f
55ab6e1
6cb27e4
2bf6ad5
2b65953
94a38f8
3184af2
4936876
8930668
1337dcb
240bff8
654fd5d
fcb1d3c
16ab507
3617fc9
2dd33b0
cac8348
8ead037
c3fddbb
c0f3761
26458af
c767ffe
770145f
ea2929b
c24027f
44b1f35
ae599de
2c474af
c2b0854
40e31e0
df20a04
562a1fe
79979ac
f49c50e
7acb956
868024c
060e327
7c89cc2
c0de92a
0eb6648
8e21af4
919cd96
02dc9b8
d3ce524
546683e
c54af20
dbafe90
0efc770
291bf84
84b18bf
58ed664
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,3 +23,4 @@ jobs: | |
| cache: 'npm' | ||
| - run: npm ci | ||
| - run: npm run build | ||
| - run: npm run test:node | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,15 @@ | ||
| <template> | ||
| <v-form ref="form"> | ||
| <v-row> | ||
| <v-col cols="12" sm="5" md="6" class="mt-2"> | ||
| <v-col cols="12" sm="4" md="5" class="mt-2"> | ||
| <v-list-item-title>{{ name }}</v-list-item-title> | ||
| <v-list-item-subtitle | ||
| class="font-light overline caption secondary--text text--lighten-2" | ||
| > | ||
| ({{ settings.locationID }}) | ||
| </v-list-item-subtitle> | ||
| </v-col> | ||
| <v-spacer /> | ||
| <v-col cols="6" sm="3" md="3"> | ||
| <v-col cols="6" sm="3" md="2"> | ||
| <v-text-field | ||
| v-model="directLevel" | ||
| :rules="[directLevelRules]" | ||
|
|
@@ -33,7 +32,25 @@ | |
| </template> | ||
| </v-text-field> | ||
| </v-col> | ||
| <v-col cols="6" sm="4" md="3"> | ||
| <v-col cols="6" sm="3" md="2"> | ||
| <v-select | ||
| v-model="splitCharge" | ||
| :items="splitChargeList" | ||
| label="Split charge window" | ||
| placeholder=" " | ||
| :loading="saving.splitCharge" | ||
| > | ||
| <template #append-outer> | ||
| <v-tooltip bottom max-width="18rem"> | ||
| <template #activator="{ on }"> | ||
| <v-icon v-on="on">mdi-help-circle-outline</v-icon> | ||
| </template> | ||
| Control if charging is allowed to split into multiple windows. | ||
| </v-tooltip> | ||
| </template> | ||
| </v-select> | ||
| </v-col> | ||
| <v-col cols="12" sm="4" md="3"> | ||
| <v-combobox | ||
| v-model="goal" | ||
| :items="goalCBList" | ||
|
|
@@ -62,7 +79,6 @@ | |
| v-model="focus" | ||
| active-class="selected-charge" | ||
| color="primary" | ||
| label="hej" | ||
| mandatory | ||
| > | ||
| <v-btn small>Low Cost</v-btn> | ||
|
|
@@ -77,9 +93,8 @@ | |
|
|
||
| <script lang="ts"> | ||
| import { Component, Vue, Prop } from "vue-property-decorator"; | ||
| import deepmerge from "deepmerge"; | ||
| import { GQLVehicle, GQLVehicleLocationSetting } from "@shared/sc-schema.js"; | ||
| import { SmartChargeGoal } from "@shared/sc-types.js"; | ||
| import { SmartChargeGoal, SplitCharge } from "@shared/sc-types.js"; | ||
| import { UpdateVehicleParams } from "@shared/sc-client.js"; | ||
|
|
||
| @Component({}) | ||
|
|
@@ -90,18 +105,25 @@ export default class EditVehicle extends Vue { | |
|
|
||
| saving!: { [key: string]: boolean }; | ||
| goalCBList!: { text: string; value: string }[]; | ||
| splitChargeList!: { text: string; value: string }[]; | ||
| data() { | ||
| return { | ||
| saving: { | ||
| directLevel: false, | ||
| goal: false, | ||
| splitCharge: false, | ||
| }, | ||
| goalCBList: [ | ||
| { text: "Low cost", value: SmartChargeGoal.Low }, | ||
| { text: "Balanced", value: SmartChargeGoal.Balanced }, | ||
| { text: "Full charge", value: SmartChargeGoal.Full }, | ||
| { text: "Custom", value: "%" }, | ||
| ], | ||
| splitChargeList: [ | ||
| { text: "Never", value: SplitCharge.Never }, | ||
| { text: "Auto", value: SplitCharge.Auto }, | ||
| { text: "Always", value: SplitCharge.Always }, | ||
| ], | ||
|
Comment on lines
96
to
+126
|
||
| }; | ||
| } | ||
|
|
||
|
|
@@ -153,19 +175,36 @@ export default class EditVehicle extends Vue { | |
| this.save("goal"); | ||
| } | ||
|
|
||
| get splitCharge(): string { | ||
| return this.settings.splitCharge || SplitCharge.Auto; | ||
| } | ||
|
Comment on lines
+178
to
+180
|
||
| set splitCharge(value: string) { | ||
| this.settings.splitCharge = value; | ||
| this.save("splitCharge"); | ||
| } | ||
|
|
||
| debounceTimer?: any; | ||
| touchedFields: any = {}; | ||
| clearSaving: any = {}; | ||
| saveTicketSeq = 0; | ||
| saveTickets: Record<string, number> = {}; | ||
| async save(field: string) { | ||
| delete this.clearSaving[field]; | ||
| const fieldTicket = ++this.saveTicketSeq; | ||
| this.saveTickets[field] = fieldTicket; | ||
| this.$set(this.saving, field, true); | ||
|
|
||
| if (this.debounceTimer) { | ||
| clearTimeout(this.debounceTimer); | ||
| } | ||
| this.debounceTimer = setTimeout(async () => { | ||
| const form: any = this.$refs.form; | ||
| if (form.validate && form.validate()) { | ||
| const fieldsInRequest = Object.entries(this.saving) | ||
| .filter(([, value]) => value) | ||
| .map(([key]) => key); | ||
| const requestTickets: Record<string, number> = {}; | ||
| for (const key of fieldsInRequest) { | ||
| requestTickets[key] = this.saveTickets[key] || 0; | ||
| } | ||
| if (!form.validate || form.validate()) { | ||
| const goal = this.settings.goal as any; | ||
| const update: UpdateVehicleParams = { | ||
| id: this.vehicle.id, | ||
|
|
@@ -174,16 +213,23 @@ export default class EditVehicle extends Vue { | |
| locationID: this.settings.locationID, | ||
| directLevel: this.settings.directLevel, | ||
| goal: goal.value || goal, | ||
| splitCharge: this.settings.splitCharge || SplitCharge.Auto, | ||
| } as GQLVehicleLocationSetting, | ||
|
Comment on lines
212
to
217
|
||
| ], | ||
| }; | ||
|
|
||
| this.clearSaving = deepmerge(this.clearSaving, this.saving); | ||
|
|
||
| await this.$scClient.updateVehicle(update); | ||
|
|
||
| for (const [key, value] of Object.entries(this.clearSaving)) { | ||
| if (value) { | ||
| try { | ||
| await this.$scClient.updateVehicle(update); | ||
| } finally { | ||
| for (const key of fieldsInRequest) { | ||
| if (this.saveTickets[key] === requestTickets[key]) { | ||
| this.$set(this.saving, key, false); | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+190
to
229
|
||
| } else { | ||
| for (const key of fieldsInRequest) { | ||
| if (this.saveTickets[key] === requestTickets[key]) { | ||
| this.$set(this.saving, key, false); | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.