@5minds/node-red-dashboard-2-processcube-dynamic-table 1.0.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/nodes/dynamic-table.html +1 -1
- package/package.json +1 -1
- package/ui/components/DynamicTable.vue +110 -113
package/nodes/dynamic-table.html
CHANGED
package/package.json
CHANGED
|
@@ -1,127 +1,124 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
{{ action.label }}
|
|
37
|
-
</v-btn>
|
|
38
|
-
</v-container>
|
|
2
|
+
<v-data-table
|
|
3
|
+
:headers="headers"
|
|
4
|
+
:items="tasks"
|
|
5
|
+
:search="search"
|
|
6
|
+
class="full-width-table"
|
|
7
|
+
>
|
|
8
|
+
<template v-slot:top>
|
|
9
|
+
<v-toolbar flat class="py-2">
|
|
10
|
+
<v-text-field
|
|
11
|
+
class="mx-3"
|
|
12
|
+
v-model="search"
|
|
13
|
+
label="Search"
|
|
14
|
+
prepend-inner-icon="mdi-magnify"
|
|
15
|
+
variant="outlined"
|
|
16
|
+
hide-details
|
|
17
|
+
single-line
|
|
18
|
+
></v-text-field>
|
|
19
|
+
</v-toolbar>
|
|
20
|
+
</template>
|
|
21
|
+
<template v-slot:item.actions="{ item }">
|
|
22
|
+
<v-container class="action-button-container">
|
|
23
|
+
<v-container
|
|
24
|
+
v-for="(action, index) in actions"
|
|
25
|
+
style="padding: 0px; display: inline; width: fit-content; margin: 0px"
|
|
26
|
+
>
|
|
27
|
+
<v-btn
|
|
28
|
+
style="margin: 0px 2px"
|
|
29
|
+
v-if="conditionCheck(action.condition, item)"
|
|
30
|
+
:key="index"
|
|
31
|
+
size="small"
|
|
32
|
+
@click="actionFn(action, item)"
|
|
33
|
+
>
|
|
34
|
+
{{ action.label }}
|
|
35
|
+
</v-btn>
|
|
39
36
|
</v-container>
|
|
40
|
-
</
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
Reload
|
|
47
|
-
</v-btn>
|
|
48
|
-
</template>
|
|
49
|
-
</v-data-table>
|
|
37
|
+
</v-container>
|
|
38
|
+
</template>
|
|
39
|
+
<template v-slot:no-data>
|
|
40
|
+
<v-alert text="No data"></v-alert>
|
|
41
|
+
</template>
|
|
42
|
+
</v-data-table>
|
|
50
43
|
</template>
|
|
51
44
|
|
|
52
45
|
<script>
|
|
53
|
-
import { mapState } from
|
|
46
|
+
import { mapState } from "vuex";
|
|
54
47
|
|
|
55
48
|
export default {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
name: "DynamicTable",
|
|
50
|
+
inject: ["$socket"],
|
|
51
|
+
props: {
|
|
52
|
+
/* do not remove entries from this - Dashboard's Layout Manager's will pass this data to your component */
|
|
53
|
+
id: { type: String, required: true },
|
|
54
|
+
props: { type: Object, default: () => ({}) },
|
|
55
|
+
/* state: { type: Object, default: () => ({ enabled: false, visible: false }) } // DEFAULT */
|
|
56
|
+
state: { type: Object, default: () => ({ enabled: true, visible: true }) },
|
|
57
|
+
},
|
|
58
|
+
data() {
|
|
59
|
+
return {
|
|
60
|
+
search: "",
|
|
61
|
+
actions: [],
|
|
62
|
+
tasks: [],
|
|
63
|
+
headers: [],
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
mounted() {
|
|
67
|
+
this.$socket.on("widget-load:" + this.id, (columns) => {
|
|
68
|
+
this.initialize(columns);
|
|
69
|
+
this.$store.commit("data/bind", {
|
|
70
|
+
widgetId: this.id,
|
|
71
|
+
columns,
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
this.$socket.on("msg-input:" + this.id, (columns) => {
|
|
75
|
+
this.initialize(columns);
|
|
76
|
+
this.$store.commit("data/bind", {
|
|
77
|
+
widgetId: this.id,
|
|
78
|
+
columns,
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
this.$socket.emit("widget-load", this.id);
|
|
82
|
+
},
|
|
83
|
+
unmounted() {
|
|
84
|
+
this.$socket?.off("widget-load" + this.id);
|
|
85
|
+
this.$socket?.off("msg-input:" + this.id);
|
|
86
|
+
},
|
|
87
|
+
methods: {
|
|
88
|
+
send(msg, index) {
|
|
89
|
+
const msgArr = [];
|
|
90
|
+
msgArr[index] = msg;
|
|
91
|
+
this.$socket.emit("widget-action", this.id, msgArr);
|
|
63
92
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
headers: [],
|
|
70
|
-
}
|
|
93
|
+
actionFn(action, item) {
|
|
94
|
+
this.send(
|
|
95
|
+
{ payload: item },
|
|
96
|
+
this.actions.findIndex((element) => element.label === action.label)
|
|
97
|
+
);
|
|
71
98
|
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.$store.commit('data/bind', {
|
|
76
|
-
widgetId: this.id,
|
|
77
|
-
columns
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
this.$socket.on('msg-input:' + this.id, (columns) => {
|
|
81
|
-
this.initialize(columns)
|
|
82
|
-
this.$store.commit('data/bind', {
|
|
83
|
-
widgetId: this.id,
|
|
84
|
-
columns
|
|
85
|
-
})
|
|
86
|
-
})
|
|
87
|
-
this.$socket.emit('widget-load', this.id)
|
|
88
|
-
},
|
|
89
|
-
unmounted () {
|
|
90
|
-
this.$socket?.off('widget-load' + this.id)
|
|
91
|
-
this.$socket?.off('msg-input:' + this.id)
|
|
92
|
-
},
|
|
93
|
-
methods: {
|
|
94
|
-
send (msg, index) {
|
|
95
|
-
const msgArr = []
|
|
96
|
-
msgArr[index] = msg
|
|
97
|
-
this.$socket.emit('widget-action', this.id, msgArr)
|
|
98
|
-
},
|
|
99
|
-
actionFn (action, item) {
|
|
100
|
-
this.send({ payload: item}, this.actions.findIndex(element => element.label === action.label))
|
|
101
|
-
},
|
|
102
|
-
initialize (tasks) {
|
|
103
|
-
this.tasks = tasks
|
|
104
|
-
this.actions = this.props.options
|
|
99
|
+
initialize(tasks) {
|
|
100
|
+
this.tasks = tasks;
|
|
101
|
+
this.actions = this.props.options;
|
|
105
102
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
103
|
+
this.headers = this.props.columns.map((item) => ({
|
|
104
|
+
title: item.label,
|
|
105
|
+
key: item.value,
|
|
106
|
+
}));
|
|
110
107
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
108
|
+
this.headers.push({ title: "Action", align: "center", key: "actions" });
|
|
109
|
+
},
|
|
110
|
+
conditionCheck(condition, row) {
|
|
111
|
+
if (condition == "") return true;
|
|
112
|
+
try {
|
|
113
|
+
const func = new Function("row", `return ${condition}`);
|
|
114
|
+
return func(row);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.error("Error evaluating condition:", error);
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
};
|
|
125
122
|
</script>
|
|
126
123
|
|
|
127
124
|
<style scoped>
|