Skip to content

Commit 80a81c8

Browse files
committed
formatting
1 parent 1fc8a8e commit 80a81c8

File tree

277 files changed

+3014
-9191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+3014
-9191
lines changed

src/App.vue

Lines changed: 20 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ export default {
4747
connection: {
4848
protocol: location.protocol == "https:" ? "wss" : "ws",
4949
host: location.hostname,
50-
port:
51-
parseInt(location.port) ||
52-
(location.protocol == "https:" ? 443 : 80),
50+
port: parseInt(location.port) || (location.protocol == "https:" ? 443 : 80),
5351
endpoint: "/ws",
5452
connectTimeout: 4000,
5553
reconnectPeriod: 4000,
@@ -85,25 +83,20 @@ export default {
8583
*/
8684
async saveValues(topicsToSave = undefined) {
8785
function sleep(milliseconds) {
88-
return new Promise((resolve) =>
89-
setTimeout(resolve, milliseconds),
90-
);
86+
return new Promise((resolve) => setTimeout(resolve, milliseconds));
9187
}
9288
9389
console.debug("saving values...");
9490
this.$store.state.local.savingData = true;
9591
// collect data
9692
let topics = {};
9793
if (topicsToSave === undefined) {
98-
console.debug(
99-
"no topics defined, so save everything we have in store",
100-
);
94+
console.debug("no topics defined, so save everything we have in store");
10195
topics = this.$store.state.mqtt;
10296
} else {
10397
if (Array.isArray(topicsToSave)) {
10498
topicsToSave.forEach((topicToSave) => {
105-
topics[topicToSave] =
106-
this.$store.state.mqtt[topicToSave];
99+
topics[topicToSave] = this.$store.state.mqtt[topicToSave];
107100
});
108101
} else {
109102
console.error("expected array, got ", typeof topicsToSave);
@@ -143,11 +136,7 @@ export default {
143136
* @param {Object} event - Command object to send
144137
*/
145138
sendCommand(event) {
146-
this.doPublish(
147-
"openWB/set/command/" + this.client.options.clientId + "/todo",
148-
event,
149-
false,
150-
);
139+
this.doPublish("openWB/set/command/" + this.client.options.clientId + "/todo", event, false);
151140
},
152141
/**
153142
* Establishes a connection to the configured broker
@@ -160,8 +149,7 @@ export default {
160149
// mqtts encrypted TCP connection
161150
// wxs WeChat mini app connection
162151
// alis Alipay mini app connection
163-
const { protocol, host, port, endpoint, ...options } =
164-
this.connection;
152+
const { protocol, host, port, endpoint, ...options } = this.connection;
165153
const connectUrl = `${protocol}://${host}:${port}${endpoint}`;
166154
console.debug("connecting to broker:", connectUrl);
167155
try {
@@ -170,10 +158,7 @@ export default {
170158
console.error("mqtt.connect error", error);
171159
}
172160
this.client.on("connect", () => {
173-
console.debug(
174-
"Connection succeeded! ClientId: ",
175-
this.client.options.clientId,
176-
);
161+
console.debug("Connection succeeded! ClientId: ", this.client.options.clientId);
177162
// required for route guards
178163
this.doSubscribe(["openWB/system/usage_terms_acknowledged"]);
179164
this.doSubscribe(["openWB/system/installAssistantDone"]);
@@ -190,11 +175,7 @@ export default {
190175
try {
191176
myPayload = JSON.parse(message.toString());
192177
} catch (error) {
193-
console.debug(
194-
"Json parsing failed, fallback to string: ",
195-
topic,
196-
error,
197-
);
178+
console.debug("Json parsing failed, fallback to string: ", topic, error);
198179
myPayload = message.toString();
199180
}
200181
this.$store.commit("updateTopic", {
@@ -216,10 +197,7 @@ export default {
216197
this.$store.commit("addSubscription", topic);
217198
if (this.$store.getters.subscriptionCount(topic) == 1) {
218199
if (topic.includes("#") || topic.includes("+")) {
219-
console.debug(
220-
"skipping init of wildcard topic:",
221-
topic,
222-
);
200+
console.debug("skipping init of wildcard topic:", topic);
223201
} else {
224202
this.$store.commit("addTopic", {
225203
topic: topic,
@@ -249,18 +227,10 @@ export default {
249227
});
250228
if (topic.includes("#") || topic.includes("+")) {
251229
console.debug("expanding wildcard topic:", topic);
252-
Object.keys(this.getWildcardTopics(topic)).forEach(
253-
(wildcardTopic) => {
254-
console.debug(
255-
"removing wildcardTopic:",
256-
wildcardTopic,
257-
);
258-
this.$store.commit(
259-
"removeTopic",
260-
wildcardTopic,
261-
);
262-
},
263-
);
230+
Object.keys(this.getWildcardTopics(topic)).forEach((wildcardTopic) => {
231+
console.debug("removing wildcardTopic:", wildcardTopic);
232+
this.$store.commit("removeTopic", wildcardTopic);
233+
});
264234
} else {
265235
console.debug("removing topic:", topic);
266236
this.$store.commit("removeTopic", topic);
@@ -275,25 +245,16 @@ export default {
275245
qos: qos,
276246
retain: retain,
277247
};
278-
this.client.publish(
279-
topic,
280-
JSON.stringify(payload),
281-
options,
282-
(error) => {
283-
if (error) {
284-
console.error("Publish error", error);
285-
}
286-
},
287-
);
248+
this.client.publish(topic, JSON.stringify(payload), options, (error) => {
249+
if (error) {
250+
console.error("Publish error", error);
251+
}
252+
});
288253
},
289254
postClientMessage(message, type = "secondary") {
290255
console.debug("postMessage:", message, type);
291256
const timestamp = Date.now();
292-
const topic =
293-
"openWB/command/" +
294-
this.mqttClientId +
295-
"/messages/" +
296-
timestamp;
257+
const topic = "openWB/command/" + this.mqttClientId + "/messages/" + timestamp;
297258
this.$store.commit({
298259
type: "addTopic",
299260
topic: topic,
@@ -312,12 +273,7 @@ export default {
312273
if (!isRegex) {
313274
// build a valid regex based on the provided wildcard topic
314275
baseTopicRegex =
315-
"^" +
316-
baseTopic
317-
.replaceAll("/", "\\/")
318-
.replaceAll("+", "[^+/]+")
319-
.replaceAll("#", "[^#/]+") +
320-
"$";
276+
"^" + baseTopic.replaceAll("/", "\\/").replaceAll("+", "[^+/]+").replaceAll("#", "[^#/]+") + "$";
321277
}
322278
// filter and return all topics matching our regex
323279
return Object.keys(this.$store.state.mqtt)

src/components/OpenwbBaseAlert.vue

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,7 @@ export default {
1313
props: {
1414
subtype: {
1515
validator: function (value) {
16-
return (
17-
[
18-
"info",
19-
"success",
20-
"warning",
21-
"danger",
22-
"primary",
23-
"secondary",
24-
"light",
25-
"dark",
26-
].indexOf(value) !== -1
27-
);
16+
return ["info", "success", "warning", "danger", "primary", "secondary", "light", "dark"].indexOf(value) !== -1;
2817
},
2918
default: "secondary",
3019
},

src/components/OpenwbBaseArrayInput.vue

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,11 @@
3131
class="form-control"
3232
v-bind="$attrs"
3333
@keyup.enter="addTag"
34-
>
34+
/>
3535
<div class="input-group-append">
3636
<div
3737
class="input-group-text"
38-
:class="
39-
newTagValid
40-
? 'bg-success clickable'
41-
: 'not-clickable'
42-
"
38+
:class="newTagValid ? 'bg-success clickable' : 'not-clickable'"
4339
@click="addTag"
4440
>
4541
<slot name="input-add">
@@ -92,12 +88,7 @@ import {
9288
} from "@fortawesome/free-solid-svg-icons";
9389
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
9490
95-
library.add(
96-
fasTag,
97-
fasTimesCircle,
98-
fasPlus,
99-
fasInfoCircle,
100-
);
91+
library.add(fasTag, fasTimesCircle, fasPlus, fasInfoCircle);
10192
10293
export default {
10394
name: "OpenwbArrayInput",
@@ -139,10 +130,7 @@ export default {
139130
},
140131
newTagValid: {
141132
get() {
142-
return (
143-
this.newTag.length > 0 &&
144-
!this.value.includes(this.newTag)
145-
);
133+
return this.newTag.length > 0 && !this.value.includes(this.newTag);
146134
},
147135
},
148136
},

src/components/OpenwbBaseButtonGroupInput.vue

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,21 @@
1717
v-for="button in buttons"
1818
:key="button.value"
1919
class="btn"
20-
:class="[
21-
value == button.buttonValue ? 'active' : '',
22-
button.class ? button.class : 'btn-outline-info',
23-
]"
20+
:class="[value == button.buttonValue ? 'active' : '', button.class ? button.class : 'btn-outline-info']"
2421
>
2522
<input
2623
v-model="value"
2724
type="radio"
2825
:value="button.buttonValue"
2926
v-bind="$attrs"
30-
>
27+
/>
3128
<slot :name="'label-' + button.buttonValue">
3229
{{ button.text }}
3330
</slot>
3431
<font-awesome-icon
3532
fixed-width
3633
:icon="['fas', 'check']"
37-
:style="[
38-
value == button.buttonValue
39-
? 'visibility: visible'
40-
: 'visibility: hidden',
41-
]"
34+
:style="[value == button.buttonValue ? 'visibility: visible' : 'visibility: hidden']"
4235
/>
4336
</label>
4437
</div>

src/components/OpenwbBaseButtonInput.vue

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,7 @@ export default {
4242
subtype: {
4343
type: String,
4444
validator: function (value) {
45-
return (
46-
[
47-
"info",
48-
"success",
49-
"warning",
50-
"danger",
51-
"primary",
52-
"secondary",
53-
"light",
54-
"dark",
55-
].indexOf(value) !== -1
56-
);
45+
return ["info", "success", "warning", "danger", "primary", "secondary", "light", "dark"].indexOf(value) !== -1;
5746
},
5847
default: "secondary",
5948
},

src/components/OpenwbBaseCard.vue

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@
3333
<font-awesome-icon
3434
v-if="collapsible"
3535
fixed-width
36-
:icon="
37-
isCollapsed
38-
? ['fas', 'chevron-right']
39-
: ['fas', 'chevron-down']
40-
"
36+
:icon="isCollapsed ? ['fas', 'chevron-right'] : ['fas', 'chevron-down']"
4137
/>
4238
</span>
4339
</div>
@@ -59,10 +55,7 @@
5955

6056
<script>
6157
import { library } from "@fortawesome/fontawesome-svg-core";
62-
import {
63-
faChevronRight as fasChevronRight,
64-
faChevronDown as fasChevronDown,
65-
} from "@fortawesome/free-solid-svg-icons";
58+
import { faChevronRight as fasChevronRight, faChevronDown as fasChevronDown } from "@fortawesome/free-solid-svg-icons";
6659
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
6760
6861
library.add(fasChevronRight, fasChevronDown);
@@ -78,17 +71,8 @@ export default {
7871
subtype: {
7972
validator: function (value) {
8073
return (
81-
[
82-
"info",
83-
"success",
84-
"warning",
85-
"danger",
86-
"primary",
87-
"secondary",
88-
"light",
89-
"dark",
90-
"pink",
91-
].indexOf(value) !== -1
74+
["info", "success", "warning", "danger", "primary", "secondary", "light", "dark", "pink"].indexOf(value) !==
75+
-1
9276
);
9377
},
9478
default: "secondary",

src/components/OpenwbBaseCheckboxInput.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class="form-control"
1919
type="checkbox"
2020
v-bind="$attrs"
21-
>
21+
/>
2222
</div>
2323
</template>
2424
</openwb-base-setting-element>

src/components/OpenwbBaseCopyToClipboard.vue

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515

1616
<script>
1717
import { library } from "@fortawesome/fontawesome-svg-core";
18-
import {
19-
faClipboard as fasClipboard,
20-
faClipboardCheck as fasClipboardCheck,
21-
} from "@fortawesome/free-solid-svg-icons";
18+
import { faClipboard as fasClipboard, faClipboardCheck as fasClipboardCheck } from "@fortawesome/free-solid-svg-icons";
2219
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
2320
2421
library.add(fasClipboard, fasClipboardCheck);
@@ -42,20 +39,16 @@ export default {
4239
// event.target may be our icon, so we use a ref here
4340
console.debug(this.$refs["slot-wrapper"].innerText);
4441
if (this.clipboardApiAvailable) {
45-
navigator.clipboard
46-
.writeText(this.$refs["slot-wrapper"].innerText)
47-
.then(
48-
() => {
49-
this.isCopied = true;
50-
},
51-
() => {
52-
console.error("copy to clipboard failed");
53-
},
54-
);
55-
} else {
56-
console.debug(
57-
"clipboard api not supported/enabled, fallback to select",
42+
navigator.clipboard.writeText(this.$refs["slot-wrapper"].innerText).then(
43+
() => {
44+
this.isCopied = true;
45+
},
46+
() => {
47+
console.error("copy to clipboard failed");
48+
},
5849
);
50+
} else {
51+
console.debug("clipboard api not supported/enabled, fallback to select");
5952
if (window.getSelection) {
6053
console.debug("using 'window.getSelection'");
6154
const selection = window.getSelection();

0 commit comments

Comments
 (0)