aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/Message.vue10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/components/Message.vue b/src/components/Message.vue
index 5a1e0ea..df203ae 100644
--- a/src/components/Message.vue
+++ b/src/components/Message.vue
@@ -30,7 +30,8 @@ export default {
30 // Look for a new message if an endpoint is provided. 30 // Look for a new message if an endpoint is provided.
31 this.message = Object.assign({}, this.item); 31 this.message = Object.assign({}, this.item);
32 if (this.item && this.item.url) { 32 if (this.item && this.item.url) {
33 const fetchedMessage = await this.getMessage(this.item.url); 33 let fetchedMessage = await this.getMessage(this.item.url);
34 if (this.item.mapping) fetchedMessage = this.mapRemoteMessage(fetchedMessage);
34 // keep the original config value if no value is provided by the endpoint 35 // keep the original config value if no value is provided by the endpoint
35 for (const prop of ["title", "style", "content"]) { 36 for (const prop of ["title", "style", "content"]) {
36 if (prop in fetchedMessage && fetchedMessage[prop] !== null) { 37 if (prop in fetchedMessage && fetchedMessage[prop] !== null) {
@@ -49,6 +50,13 @@ export default {
49 return response.json(); 50 return response.json();
50 }); 51 });
51 }, 52 },
53
54 mapRemoteMessage: function (message) {
55 let mapped = {};
56 // map property from message into mapped according to mapping config (only if field has a value):
57 for (const prop in this.item.mapping) if (message[this.item.mapping[prop]]) mapped[prop] = message[this.item.mapping[prop]];
58 return mapped;
59 },
52 }, 60 },
53}; 61};
54</script> 62</script>