@5minds/node-red-dashboard-2-processcube-dynamic-table 1.0.8 → 1.1.1

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.
@@ -6,7 +6,7 @@
6
6
 
7
7
  RED.nodes.registerType('dynamic-table', {
8
8
  category: 'ProcessCube UI',
9
- color: '#00aed7',
9
+ color: '#4a7eb0',
10
10
  defaults: {
11
11
  name: { value: "" },
12
12
  tableName: { value: ""},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-dashboard-2-processcube-dynamic-table",
3
- "version": "1.0.8",
3
+ "version": "1.1.1",
4
4
  "description": "A ui component for showing dynamic Data with actions in a table",
5
5
  "keywords": [
6
6
  "processcube",
@@ -56,7 +56,7 @@
56
56
  "eslint-plugin-import": "^2.29.0",
57
57
  "eslint-plugin-n": "^16.3.1",
58
58
  "eslint-plugin-vue": "^9.18.1",
59
- "vite": "^5.0.13",
59
+ "vite": "^5.3.2",
60
60
  "vite-plugin-css-injected-by-js": "^3.3.0"
61
61
  },
62
62
  "engines": {
@@ -1,2 +1,3 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");a.appendChild(document.createTextNode("h1[data-v-a5302b6c]{margin-bottom:10px}h2[data-v-a5302b6c]{margin-top:1.5rem;margin-bottom:.75rem}h3[data-v-a5302b6c]{margin-top:1rem}p[data-v-a5302b6c]{margin-bottom:5px}ul li[data-v-a5302b6c]{list-style-type:circle;list-style-position:inside;margin-left:15px}pre[data-v-a5302b6c]{padding:12px;margin:12px;background-color:#eee}code[data-v-a5302b6c]{font-size:.825rem;color:#ae0000}input[data-v-a5302b6c]{padding:12px;margin:12px;background-color:#eee}.task-div[data-v-a5302b6c]{padding:8px;margin:16px;border:solid;border-radius:4px;border-color:#303030}.action-button-container[data-v-a5302b6c]{width:100%;display:flex;justify-content:center}")),document.head.appendChild(a)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- (function(i,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vuex"),require("vue")):typeof define=="function"&&define.amd?define(["exports","vuex","vue"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i["dynamic-table"]={},i.vuex,i.Vue))})(this,function(i,a,t){"use strict";const m=(e,n)=>{const o=e.__vccOpts||e;for(const[d,s]of n)o[d]=s;return o},f={name:"DynamicTable",inject:["$socket"],props:{id:{type:String,required:!0},props:{type:Object,default:()=>({})},state:{type:Object,default:()=>({enabled:!1,visible:!1})}},data(){return{search:"",actions:[],tasks:[],headers:[]}},mounted(){this.$socket.on("widget-load:"+this.id,e=>{this.initialize(e),this.$store.commit("data/bind",{widgetId:this.id,columns:e})}),this.$socket.on("msg-input:"+this.id,e=>{this.initialize(e),this.$store.commit("data/bind",{widgetId:this.id,columns:e})}),this.$socket.emit("widget-load",this.id)},unmounted(){var e,n;(e=this.$socket)==null||e.off("widget-load"+this.id),(n=this.$socket)==null||n.off("msg-input:"+this.id)},methods:{send(e,n){let o=[];o[n]=e,this.$socket.emit("widget-action",this.id,o)},actionFn(e,n){this.send({payload:n},this.actions.findIndex(o=>o.label===e.label))},initialize(e){this.tasks=e,this.actions=this.props.options,this.headers=this.props.columns.map(n=>({title:n.label,key:n.value})),this.headers.push({title:"Action",align:"center",key:"actions"})},conditionCheck(e,n){if(e=="")return!0;try{return new Function("row",`return ${e}`)(n)}catch(o){return console.error("Error evaluating condition:",o),!1}}}};function _(e,n,o,d,s,c){const k=t.resolveComponent("v-toolbar-title"),x=t.resolveComponent("v-spacer"),y=t.resolveComponent("v-text-field"),u=t.resolveComponent("v-toolbar"),p=t.resolveComponent("v-btn"),h=t.resolveComponent("v-container"),C=t.resolveComponent("v-data-table");return t.openBlock(),t.createBlock(C,{headers:s.headers,items:s.tasks,search:s.search,class:"full-width-table"},{top:t.withCtx(()=>[t.createVNode(u,{flat:"",class:"py-2"},{default:t.withCtx(()=>[t.createVNode(k,null,{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(o.props.tableName),1)]),_:1}),t.createVNode(x),t.createVNode(y,{class:"mx-3",modelValue:s.search,"onUpdate:modelValue":n[0]||(n[0]=r=>s.search=r),label:"Search","prepend-inner-icon":"mdi-magnify",variant:"outlined","hide-details":"","single-line":""},null,8,["modelValue"])]),_:1})]),"item.actions":t.withCtx(({item:r})=>[t.createVNode(h,{class:"action-button-container"},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.actions,(l,g)=>(t.openBlock(),t.createBlock(h,{style:{padding:"0px",display:"inline",width:"fit-content",margin:"0px"}},{default:t.withCtx(()=>[c.conditionCheck(l.condition,r)?(t.openBlock(),t.createBlock(p,{style:{margin:"0px 2px"},key:g,size:"small",onClick:w=>c.actionFn(l,r)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(l.label),1)]),_:2},1032,["onClick"])):t.createCommentVNode("",!0)]),_:2},1024))),256))]),_:2},1024)]),"no-data":t.withCtx(()=>[t.createVNode(p,{color:"primary",onClick:c.initialize},{default:t.withCtx(()=>[t.createTextVNode(" Reload ")]),_:1},8,["onClick"])]),_:1},8,["headers","items","search"])}const b=m(f,[["render",_],["__scopeId","data-v-a5302b6c"]]);i.DynamicTable=b,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("h1[data-v-6cc3f2ce]{margin-bottom:10px}h2[data-v-6cc3f2ce]{margin-top:1.5rem;margin-bottom:.75rem}h3[data-v-6cc3f2ce]{margin-top:1rem}p[data-v-6cc3f2ce]{margin-bottom:5px}ul li[data-v-6cc3f2ce]{list-style-type:circle;list-style-position:inside;margin-left:15px}pre[data-v-6cc3f2ce]{padding:12px;margin:12px;background-color:#eee}code[data-v-6cc3f2ce]{font-size:.825rem;color:#ae0000}input[data-v-6cc3f2ce]{padding:12px;margin:12px;background-color:#eee}.task-div[data-v-6cc3f2ce]{padding:8px;margin:16px;border:solid;border-radius:4px;border-color:#303030}.action-button-container[data-v-6cc3f2ce]{width:100%;display:flex;justify-content:center}")),document.head.appendChild(e)}}catch(c){console.error("vite-plugin-css-injected-by-js",c)}})();
2
+ (function(i,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vuex"),require("vue")):typeof define=="function"&&define.amd?define(["exports","vuex","vue"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i["dynamic-table"]={},i.vuex,i.Vue))})(this,function(i,a,e){"use strict";const h=(t,n)=>{const o=t.__vccOpts||t;for(const[l,s]of n)o[l]=s;return o},m={name:"DynamicTable",inject:["$socket"],props:{id:{type:String,required:!0},props:{type:Object,default:()=>({})},state:{type:Object,default:()=>({enabled:!0,visible:!0})}},data(){return{search:"",actions:[],tasks:[],headers:[]}},mounted(){this.$socket.on("widget-load:"+this.id,t=>{this.initialize(t),this.$store.commit("data/bind",{widgetId:this.id,columns:t})}),this.$socket.on("msg-input:"+this.id,t=>{this.initialize(t),this.$store.commit("data/bind",{widgetId:this.id,columns:t})}),this.$socket.emit("widget-load",this.id)},unmounted(){var t,n;(t=this.$socket)==null||t.off("widget-load"+this.id),(n=this.$socket)==null||n.off("msg-input:"+this.id)},methods:{send(t,n){const o=[];o[n]=t,this.$socket.emit("widget-action",this.id,o)},actionFn(t,n){this.send({payload:n},this.actions.findIndex(o=>o.label===t.label))},initialize(t){this.tasks=t,this.actions=this.props.options,this.headers=this.props.columns.map(n=>({title:n.label,key:n.value})),this.headers.push({title:"Action",align:"center",key:"actions"})},conditionCheck(t,n){if(t=="")return!0;try{return new Function("row",`return ${t}`)(n)}catch(o){return console.error("Error evaluating condition:",o),!1}}}};function f(t,n,o,l,s,d){const u=e.resolveComponent("v-text-field"),b=e.resolveComponent("v-toolbar"),k=e.resolveComponent("v-btn"),p=e.resolveComponent("v-container"),x=e.resolveComponent("v-alert"),y=e.resolveComponent("v-data-table");return e.openBlock(),e.createBlock(y,{headers:s.headers,items:s.tasks,search:s.search,class:"full-width-table"},{top:e.withCtx(()=>[e.createVNode(b,{flat:"",class:"py-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"mx-3",modelValue:s.search,"onUpdate:modelValue":n[0]||(n[0]=r=>s.search=r),label:"Search","prepend-inner-icon":"mdi-magnify",variant:"outlined","hide-details":"","single-line":""},null,8,["modelValue"])]),_:1})]),"item.actions":e.withCtx(({item:r})=>[e.createVNode(p,{class:"action-button-container"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.actions,(c,g)=>(e.openBlock(),e.createBlock(p,{style:{padding:"0px",display:"inline",width:"fit-content",margin:"0px"}},{default:e.withCtx(()=>[d.conditionCheck(c.condition,r)?(e.openBlock(),e.createBlock(k,{style:{margin:"0px 2px"},key:g,size:"small",onClick:C=>d.actionFn(c,r)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.label),1)]),_:2},1032,["onClick"])):e.createCommentVNode("v-if",!0)]),_:2},1024))),256))]),_:2},1024)]),"no-data":e.withCtx(()=>[e.createVNode(x,{text:"No data"})]),_:1},8,["headers","items","search"])}const _=h(m,[["render",f],["__scopeId","data-v-6cc3f2ce"],["__file","/Users/moellenbeck/projects/5minds/reps/node-red-dashboard-2-processcube-usertask-table/ui/components/DynamicTable.vue"]]);i.DynamicTable=_,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
3
+ //# sourceMappingURL=dynamic-table.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic-table.umd.js","sources":["../ui/components/DynamicTable.vue"],"sourcesContent":["<template>\n <v-data-table\n :headers=\"headers\"\n :items=\"tasks\"\n :search=\"search\"\n class=\"full-width-table\"\n >\n <template v-slot:top>\n <v-toolbar flat class=\"py-2\">\n <v-text-field\n class=\"mx-3\"\n v-model=\"search\"\n label=\"Search\"\n prepend-inner-icon=\"mdi-magnify\"\n variant=\"outlined\"\n hide-details\n single-line\n ></v-text-field>\n </v-toolbar>\n </template>\n <template v-slot:item.actions=\"{ item }\">\n <v-container class=\"action-button-container\">\n <v-container\n v-for=\"(action, index) in actions\"\n style=\"padding: 0px; display: inline; width: fit-content; margin: 0px\"\n >\n <v-btn\n style=\"margin: 0px 2px\"\n v-if=\"conditionCheck(action.condition, item)\"\n :key=\"index\"\n size=\"small\"\n @click=\"actionFn(action, item)\"\n >\n {{ action.label }}\n </v-btn>\n </v-container>\n </v-container>\n </template>\n <template v-slot:no-data>\n <v-alert text=\"No data\"></v-alert>\n </template>\n </v-data-table>\n</template>\n\n<script>\nimport { mapState } from \"vuex\";\n\nexport default {\n name: \"DynamicTable\",\n inject: [\"$socket\"],\n props: {\n /* do not remove entries from this - Dashboard's Layout Manager's will pass this data to your component */\n id: { type: String, required: true },\n props: { type: Object, default: () => ({}) },\n /* state: { type: Object, default: () => ({ enabled: false, visible: false }) } // DEFAULT */\n state: { type: Object, default: () => ({ enabled: true, visible: true }) },\n },\n data() {\n return {\n search: \"\",\n actions: [],\n tasks: [],\n headers: [],\n };\n },\n mounted() {\n this.$socket.on(\"widget-load:\" + this.id, (columns) => {\n this.initialize(columns);\n this.$store.commit(\"data/bind\", {\n widgetId: this.id,\n columns,\n });\n });\n this.$socket.on(\"msg-input:\" + this.id, (columns) => {\n this.initialize(columns);\n this.$store.commit(\"data/bind\", {\n widgetId: this.id,\n columns,\n });\n });\n this.$socket.emit(\"widget-load\", this.id);\n },\n unmounted() {\n this.$socket?.off(\"widget-load\" + this.id);\n this.$socket?.off(\"msg-input:\" + this.id);\n },\n methods: {\n send(msg, index) {\n const msgArr = [];\n msgArr[index] = msg;\n this.$socket.emit(\"widget-action\", this.id, msgArr);\n },\n actionFn(action, item) {\n this.send(\n { payload: item },\n this.actions.findIndex((element) => element.label === action.label)\n );\n },\n initialize(tasks) {\n this.tasks = tasks;\n this.actions = this.props.options;\n\n this.headers = this.props.columns.map((item) => ({\n title: item.label,\n key: item.value,\n }));\n\n this.headers.push({ title: \"Action\", align: \"center\", key: \"actions\" });\n },\n conditionCheck(condition, row) {\n if (condition == \"\") return true;\n try {\n const func = new Function(\"row\", `return ${condition}`);\n return func(row);\n } catch (error) {\n console.error(\"Error evaluating condition:\", error);\n return false;\n }\n },\n },\n};\n</script>\n\n<style scoped>\n/* CSS is auto scoped, but using named classes is still recommended */\n@import \"../stylesheets/dynamic-table.css\";\n</style>\n"],"names":["_sfc_main","columns","_a","_b","msg","index","msgArr","action","item","element","tasks","condition","row","error","_createBlock","_component_v_data_table","$data","_createVNode","_component_v_toolbar","_withCtx","_component_v_text_field","_cache","$event","_component_v_container","_openBlock","_createElementBlock","_Fragment","_renderList","$options","_component_v_btn","_createTextVNode","_toDisplayString","_createCommentVNode","_component_v_alert"],"mappings":"gXA+CKA,EAAU,CACb,KAAM,eACN,OAAQ,CAAC,SAAS,EAClB,MAAO,CAEL,GAAI,CAAE,KAAM,OAAQ,SAAU,EAAM,EACpC,MAAO,CAAE,KAAM,OAAQ,QAAS,KAAO,CAAE,EAAG,EAE5C,MAAO,CAAE,KAAM,OAAQ,QAAS,KAAO,CAAE,QAAS,GAAM,QAAS,EAAG,EAAM,CAC3E,EACD,MAAO,CACL,MAAO,CACL,OAAQ,GACR,QAAS,CAAE,EACX,MAAO,CAAE,EACT,QAAS,CAAE,EAEd,EACD,SAAU,CACR,KAAK,QAAQ,GAAG,eAAiB,KAAK,GAAKC,GAAY,CACrD,KAAK,WAAWA,CAAO,EACvB,KAAK,OAAO,OAAO,YAAa,CAC9B,SAAU,KAAK,GACf,QAAAA,CACF,CAAC,CACH,CAAC,EACD,KAAK,QAAQ,GAAG,aAAe,KAAK,GAAKA,GAAY,CACnD,KAAK,WAAWA,CAAO,EACvB,KAAK,OAAO,OAAO,YAAa,CAC9B,SAAU,KAAK,GACf,QAAAA,CACF,CAAC,CACH,CAAC,EACD,KAAK,QAAQ,KAAK,cAAe,KAAK,EAAE,CACzC,EACD,WAAY,UACVC,EAAA,KAAK,UAAL,MAAAA,EAAc,IAAI,cAAgB,KAAK,KACvCC,EAAA,KAAK,UAAL,MAAAA,EAAc,IAAI,aAAe,KAAK,GACvC,EACD,QAAS,CACP,KAAKC,EAAKC,EAAO,CACf,MAAMC,EAAS,CAAA,EACfA,EAAOD,CAAK,EAAID,EAChB,KAAK,QAAQ,KAAK,gBAAiB,KAAK,GAAIE,CAAM,CACnD,EACD,SAASC,EAAQC,EAAM,CACrB,KAAK,KACH,CAAE,QAASA,CAAM,EACjB,KAAK,QAAQ,UAAWC,GAAYA,EAAQ,QAAUF,EAAO,KAAK,EAErE,EACD,WAAWG,EAAO,CAChB,KAAK,MAAQA,EACb,KAAK,QAAU,KAAK,MAAM,QAE1B,KAAK,QAAU,KAAK,MAAM,QAAQ,IAAKF,IAAU,CAC/C,MAAOA,EAAK,MACZ,IAAKA,EAAK,KACX,EAAC,EAEF,KAAK,QAAQ,KAAK,CAAE,MAAO,SAAU,MAAO,SAAU,IAAK,SAAQ,CAAG,CACvE,EACD,eAAeG,EAAWC,EAAK,CAC7B,GAAID,GAAa,GAAI,MAAO,GAC5B,GAAI,CAEF,OADa,IAAI,SAAS,MAAO,UAAUA,CAAS,EAAE,EAC1CC,CAAG,CACf,OAAOC,EAAO,CACd,eAAQ,MAAM,8BAA+BA,CAAK,EAC3C,EACT,CACD,CACF,CACH,mQAvHEC,EAwCe,YAAAC,EAAA,CAvCZ,QAASC,EAAO,QAChB,MAAOA,EAAK,MACZ,OAAQA,EAAM,OACf,MAAM,qBAEW,cACf,IAUY,CAVZC,EAAAA,YAUYC,EAAA,CAVD,KAAA,GAAK,MAAM,SAR5B,QAAAC,EAAA,QASQ,IAQgB,CARhBF,EAAAA,YAQgBG,EAAA,CAPd,MAAM,OAVhB,WAWmBJ,EAAM,OAXzB,sBAAAK,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAAC,GAWmBN,EAAM,OAAAM,GACf,MAAM,SACN,qBAAmB,cACnB,QAAQ,WACR,eAAA,GACA,cAAA,6BAhBV,EAAA,MAoBqB,eAAYH,EAAA,QAC3B,CAec,CAhBiB,KAAAX,KAAI,CACnCS,EAAAA,YAecM,EAAA,CAfD,MAAM,yBAAyB,EAAA,CArBlD,QAAAJ,EAAA,QAuBU,IAAkC,EADpCK,EAAAA,UAAA,EAAA,EAAAC,EAAA,mBAacC,gBAnCtBC,EAuBoC,WAAAX,EAAA,QAvBpC,CAuBkBT,EAAQF,mBADlBS,EAac,YAAAS,EAAA,CAXZ,MAAA,CAAsE,QAAA,MAAA,QAAA,SAAA,MAAA,cAAA,OAAA,KAAA,GAAA,CAxBhF,QAAAJ,EAAA,QA0BU,IAQQ,CANAS,EAAA,eAAerB,EAAO,UAAWC,CAAI,iBAF7CM,EAQQ,YAAAe,EAAA,CAPN,MAAA,CAAuB,OAAA,SAAA,EAEtB,IAAKxB,EACN,KAAK,QACJ,QAAOiB,GAAAM,EAAA,SAASrB,EAAQC,CAAI,IA/BzC,QAAAW,EAAA,QAiCY,IAAkB,CAjC9BW,EAAAA,gBAiCeC,EAAAA,gBAAAxB,EAAO,KAAK,EAAA,CAAA,IAjC3B,EAAA,sBAAAyB,EAAA,mBAAA,OAAA,EAAA,IAAA,EAAA,mBAAA,EAAA,WAsCqB,oBACf,IAAkC,CAAlCf,EAAAA,YAAkCgB,EAAA,CAAzB,KAAK,SAAS,CAAA,IAvC7B,EAAA"}
@@ -1,127 +1,124 @@
1
1
  <template>
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
10
- flat
11
- class="py-2"
12
- >
13
- <v-toolbar-title>{{ props.tableName }}</v-toolbar-title>
14
- <v-spacer></v-spacer>
15
- <v-text-field
16
- class="mx-3"
17
- v-model="search"
18
- label="Search"
19
- prepend-inner-icon="mdi-magnify"
20
- variant="outlined"
21
- hide-details
22
- single-line
23
- ></v-text-field>
24
- </v-toolbar>
25
- </template>
26
- <template v-slot:item.actions="{ item }">
27
- <v-container class="action-button-container">
28
- <v-container v-for="(action, index) in actions" style="padding: 0px; display: inline; width: fit-content; margin: 0px">
29
- <v-btn
30
- style="margin: 0px 2px;"
31
- v-if="conditionCheck(action.condition, item)"
32
- :key="index"
33
- size="small"
34
- @click="actionFn(action, item)"
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
- </template>
41
- <template v-slot:no-data>
42
- <v-btn
43
- color="primary"
44
- @click="initialize"
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 'vuex'
46
+ import { mapState } from "vuex";
54
47
 
55
48
  export default {
56
- name: 'DynamicTable',
57
- inject: ['$socket'],
58
- props: {
59
- /* do not remove entries from this - Dashboard's Layout Manager's will pass this data to your component */
60
- id: { type: String, required: true },
61
- props: { type: Object, default: () => ({}) },
62
- state: { type: Object, default: () => ({ enabled: false, visible: false }) }
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
- data () {
65
- return {
66
- search: '',
67
- actions: [],
68
- tasks: [],
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
- mounted () {
73
- this.$socket.on('widget-load:' + this.id, (columns) => {
74
- this.initialize(columns)
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
- this.headers = this.props.columns.map(item => ({
107
- title: item.label,
108
- key: item.value
109
- }))
103
+ this.headers = this.props.columns.map((item) => ({
104
+ title: item.label,
105
+ key: item.value,
106
+ }));
110
107
 
111
- this.headers.push({ title: 'Action', align: 'center', key: 'actions'})
112
- },
113
- conditionCheck(condition, row) {
114
- if (condition == "") return true
115
- try {
116
- const func = new Function('row', `return ${condition}`);
117
- return func(row);
118
- } catch (error) {
119
- console.error('Error evaluating condition:', error);
120
- return false;
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>