directus-extension-sql-query-panel 1.0.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/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/api.js +1 -0
- package/dist/app.js +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 BCC Code
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# SQL Query Panel
|
|
2
|
+
|
|
3
|
+
View the result of your SQL query in a tabular panel with Directus Insights.
|
|
4
|
+
|
|
5
|
+
## Supports
|
|
6
|
+
|
|
7
|
+
- Global Variables
|
|
8
|
+
- Static Queries
|
|
9
|
+
- `CALL` statements
|
|
10
|
+
- Downloading results as CSV
|
|
11
|
+
- Summary row with count, sum, average, count unique and count groups
|
|
12
|
+
- Columns can be made searchable, sortable and marked as numeric
|
|
13
|
+
- Actions can be added to an entire row or as buttons at the end of each row with support for adding values from result
|
|
14
|
+
- **Security** panel results can only be viewed by users with access to those panels, so you can adjust permissions on a per panel basis via Directus Access
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
### Via npm
|
|
20
|
+
|
|
21
|
+
`npm install @bcc-code/directus-extension-sql-query-panel`
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Add a new panel and select the `SQL Query panel` type.
|
|
26
|
+
|
|
27
|
+
Enter your SQL query, optionally adding global variables wrapped in `{{ }}` to make your query dynamic.
|
|
28
|
+
|
|
29
|
+
By default a table will be generated with the selected columns from your query, however you can manually add columns you want to display and configure them.
|
|
30
|
+
|
|
31
|
+
If you do not use variables, you can mark the panel as static.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Contributing
|
|
35
|
+
|
|
36
|
+
PRs are welcome!
|
package/dist/api.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=[],a=[{name:"insights",config:(e,{database:a,services:r})=>{const{PanelsService:n}=r;async function t(e,r){if(new RegExp(["delete","update","insert","execute","kill","drop"].map((e=>`\\b${e}\\b`)).join("|")).test(e.toLowerCase()))throw new Error("SQL query is blacklisted");const n=e.match(/{{\w+}}/g);if(n)throw new Error(`Missing query param: ${n.join(", ").replace(/{{|}}/g,"")}`);const t=await a.raw(e,r);switch(a.client.config.client){case"mysql":return(e=>{const[a,r]=e;return{items:2===a.length&&Array.isArray(a[0])?a.at(0):a,headers:(2===r.length&&Array.isArray(r[0])?r.at(0):r).map((e=>e.name))}})(t);case"pg":return(e=>({items:e.rows,headers:e.fields.map((e=>e.name))}))(t);default:throw new Error(`Unsupported database client: ${a.client.config.client}`)}}e.get("/query/:panelId",(async function(e,a){try{const{query:r,vars:s}=await async function(e){var a;const r=e.params.panelId;if(!r)throw new Error("Missing panelId");const t=new n({accountability:e.accountability,schema:e.schema}),s=await t.readOne(r),i=null!=(a=e.query)?a:{};i.dashboard=s.dashboard;let c=s.options.sql;for(const e in i){if(!e.match(/^[a-zA-Z0-9_]+$/))throw new Error(`Invalid variable name: ${e}`);c=c.replace(new RegExp(`{{${e}}}`,"g"),`:${e}`)}return{query:c,vars:i,panel:s}}(e),i=await t(r,s);return a.set("Cache-control","public, max-age=30"),a.json(i)}catch(e){return a.status(400).json({error:e.message})}}))}}],r=[];export{a as endpoints,e as hooks,r as operations};
|
package/dist/app.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useApi as e,useStores as t,definePanel as n}from"@directus/extensions-sdk";import{ref as a,computed as o,resolveComponent as r,resolveDirective as l,openBlock as i,createElementBlock as s,createElementVNode as d,normalizeClass as u,createVNode as c,withCtx as f,createCommentVNode as v,Fragment as m,renderList as p,normalizeStyle as h,createTextVNode as b,toDisplayString as g,createBlock as y,unref as w,renderSlot as k,withModifiers as x,withDirectives as _,toRefs as S,nextTick as q,watch as j,createSlots as C}from"vue";import{useRouter as $}from"vue-router";import{useI18n as A}from"vue-i18n";var L="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var T=NaN,D="[object Symbol]",B=/^\s+|\s+$/g,E=/^[-+]0x[0-9a-f]+$/i,I=/^0b[01]+$/i,N=/^0o[0-7]+$/i,U=parseInt,W="object"==typeof L&&L&&L.Object===Object&&L,H="object"==typeof self&&self&&self.Object===Object&&self,M=W||H||Function("return this")(),Q=Object.prototype.toString,V=Math.max,z=Math.min,F=function(){return M.Date.now()};function R(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Y(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&Q.call(e)==D}(e))return T;if(R(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=R(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(B,"");var n=I.test(e);return n||N.test(e)?U(e.slice(2),n?2:8):E.test(e)?T:+e}var Z=O((function(e,t,n){var a,o,r,l,i,s,d=0,u=!1,c=!1,f=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function v(t){var n=a,r=o;return a=o=void 0,d=t,l=e.apply(r,n)}function m(e){var n=e-s;return void 0===s||n>=t||n<0||c&&e-d>=r}function p(){var e=F();if(m(e))return h(e);i=setTimeout(p,function(e){var n=t-(e-s);return c?z(n,r-(e-d)):n}(e))}function h(e){return i=void 0,f&&a?v(e):(a=o=void 0,l)}function b(){var e=F(),n=m(e);if(a=arguments,o=this,s=e,n){if(void 0===i)return function(e){return d=e,i=setTimeout(p,t),u?v(e):l}(s);if(c)return i=setTimeout(p,t),v(s)}return void 0===i&&(i=setTimeout(p,t)),l}return t=Y(t)||0,R(n)&&(u=!!n.leading,r=(c="maxWait"in n)?V(Y(n.maxWait)||0,t):r,f="trailing"in n?!!n.trailing:f),b.cancel=function(){void 0!==i&&clearTimeout(i),d=0,a=s=o=i=void 0},b.flush=function(){return void 0===i?l:h(F())},b}));const G={sum:"Σ",avg:"μ",count:"#",count_unique:"#!"},J={sum:(e,t)=>e.reduce(((e,n)=>e+Number.parseInt(n[t])),0),avg:(e,t)=>Math.round(J.sum(e,t)/e.length),count:e=>e.length,count_unique:(e,t)=>new Set(e.map((e=>e[t]))).size,count_groups:(e,t)=>e.reduce(((e,n)=>{const a=n[t];return e[a]=(e[a]||0)+1,e}),{})};var P=[],K=[];function X(e,t){if(e&&"undefined"!=typeof document){var n,a=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,r="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var l=P.indexOf(r);-1===l&&(l=P.push(r)-1,K[l]={}),n=K[l]&&K[l][a]?K[l][a]:K[l][a]=i()}else n=i();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function i(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var l="prepend"===a?"afterbegin":"beforeend";return r.insertAdjacentElement(l,e),e}}X("\nbody {\n --v-table-color: var(--v-input-color);\n --v-table-background-color: var(--v-input-background-color);\n}\n.fast-table[data-v-ed2d49fd] {\n position: relative;\n height: var(--v-table-height);\n overflow-y: auto;\n}\ntable[data-v-ed2d49fd] {\n min-width: 100%;\n min-height: 100%;\n border-collapse: collapse;\n border-spacing: 0;\n background-color: var(--v-table-background-color);\n color: var(--v-table-color);\n}\ntable thead[data-v-ed2d49fd] {\n background-color: var(--background-normal);\n color: var(--foreground-normal);\n border-bottom: var(--border-width) solid var(--v-input-border-color);\n}\ntable thead.fixed[data-v-ed2d49fd] {\n position: sticky;\n top: 0;\n z-index: 3;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);\n}\ntable tr.headers th[data-v-ed2d49fd] {\n padding: 8px;\n font-weight: bold;\n min-width: 3rem;\n background-color: var(--background-normal);\n color: var(--foreground-normal);\n border-bottom: var(--border-width) solid var(--v-input-border-color);\n}\ntable tr.search th[data-v-ed2d49fd] {\n padding: 0;\n}\ntable tr.search th .search-input.v-input[data-v-ed2d49fd] {\n margin: 0;\n border: none;\n}\ntable th .sort-icon[data-v-ed2d49fd] {\n opacity: 0;\n}\ntable th:hover .sort-icon[data-v-ed2d49fd] {\n opacity: 0.5;\n}\ntable th .sort-icon.show[data-v-ed2d49fd] {\n opacity: 1;\n}\ntable th.select[data-v-ed2d49fd] {\n width: 2rem;\n}\ntable td[data-v-ed2d49fd] {\n padding: 8px;\n align: middle;\n border-bottom: var(--border-width) solid var(--v-input-border-color);\n}\ntable tbody[data-v-ed2d49fd] {\n display: contents;\n}\ntable tfoot tr[data-v-ed2d49fd] {\n position: sticky;\n bottom: 0;\n background-color: var(--background-normal);\n box-shadow: var(--card-shadow);\n}\ntable tfoot tr td[data-v-ed2d49fd] {\n padding: 8px;\n height: 44px;\n font-weight: bold;\n background-color: var(--background-normal);\n color: var(--foreground-normal);\n}\n",{});var ee=(e,t)=>{const n=e.__vccOpts||e;for(const[e,a]of t)n[e]=a;return n};const te={class:"fast-table"},ne={key:0,class:"search"},ae={colspan:"80%"},oe={class:"headers"},re=["onClick","align"],le={key:0},ie={key:1},se=["colspan"],de={key:0},ue={colspan:"100%"},ce={key:1},fe=["onClick"],ve={key:0},me={key:0,class:"v-text-overflow"},pe={__name:"FastTable",props:{loading:Boolean,headers:{type:Array,validator:e=>e.every((e=>e.value&&e.text)),required:!0},items:{type:Array,required:!0},sort:String,sortDesc:Boolean,fixedHeader:Boolean},emits:["update:sort","update:sortDesc","click:row"],setup(e,{emit:t}){const{t:n}=A(),S=e,q=a(""),j=o((()=>S.headers.filter((e=>e.searchable)))),C=o((()=>{const e=q.value?q.value.toLowerCase().trim():"";return e?S.items.filter((t=>j.value.some((n=>t[n.value]&&t[n.value].toLowerCase().includes(e))))):S.items})),$=o((()=>{const e=function(e,t){if(!t.some((e=>!!e.summarise)))return null;const n={};for(const a of t){if(!a.summarise)continue;const t=J[a.summarise];if(!t)throw new Error(`Summariser function for ${a.summarise} not found.`);const o=t(e,a.value);if("count_groups"===a.summarise){let e=JSON.stringify(o,null,1).replace("{\n","").replace("\n}","").replace(/[",]/g,"");n[a.value]=e}else n[a.value]=`${G[a.summarise]} ${o}`}return n}(S.items,S.headers);return e})),L=t;return(t,a)=>{const o=r("v-icon"),A=r("v-input"),O=r("v-progress-linear"),T=r("v-card-title"),D=r("v-card"),B=l("tooltip");return i(),s("div",te,[d("table",null,[d("thead",{class:u(["table-header",{fixed:e.fixedHeader}])},[j.value.length&&e.items.length>10?(i(),s("tr",ne,[d("th",ae,[c(A,{modelValue:q.value,"onUpdate:modelValue":a[0]||(a[0]=e=>q.value=e),small:"",trim:"",class:"search-input",rounded:"",placeholder:"Search"},{prepend:f((()=>[c(o,{name:"search"})])),_:1},8,["modelValue"])])])):v("v-if",!0),d("tr",oe,[(i(!0),s(m,null,p(e.headers,(n=>(i(),s("th",{style:h({minWidth:`${n.width||t.auto}ch`}),key:n.value,onClick:e=>function(e){e.sortable&&(L("update:sort",e.value),L("update:sortDesc",!S.sortDesc))}(n),align:n.align||"left"},[b(g(n.text)+" ",1),n.sortable?(i(),y(o,{key:0,name:"sort",small:"",class:u(["sort-icon",{show:e.sort===n.value}]),style:h(`transform: ${e.sortDesc?"rotateZ(0deg) rotateY(0deg)":"rotateZ(180deg) rotateY(180deg)"}; transition: .2s all ease`)},null,8,["class","style"])):v("v-if",!0)],12,re)))),128)),t.$slots["item-append"]?(i(),s("th",le,"#")):v("v-if",!0)]),e.loading?(i(),s("tr",ie,[d("td",{colspan:e.headers.length+1},[c(O,{indeterminate:""})],8,se)])):v("v-if",!0)],2),e.loading||e.items.length?(i(),s("tbody",ce,[k(t.$slots,"default",{items:C.value},(()=>[(i(!0),s(m,null,p(C.value,(n=>(i(),s("tr",{onClick:e=>L("click:row",{item:n,event:e})},[(i(!0),s(m,null,p(e.headers,(e=>(i(),s("td",{key:e.value,class:u(`align-${e.align}`)},g(n[e.value]),3)))),128)),t.$slots["item-append"]?(i(),s("td",{key:0,onClick:a[1]||(a[1]=x((()=>{}),["stop"]))},[k(t.$slots,"item-append",{item:n},void 0,!0)])):v("v-if",!0)],8,fe)))),256))]),!0)])):(i(),s("tbody",de,[d("tr",null,[d("td",ue,[c(D,{style:{padding:"2rem","--v-card-max-width":"100%"}},{default:f((()=>[c(T,null,{default:f((()=>[c(o,{name:"info",style:{"margin-right":"2rem"}}),b(" "+g(w(n)("no_items")),1)])),_:1})])),_:1})])])])),d("tfoot",null,[$.value?(i(),s("tr",ve,[(i(!0),s(m,null,p(e.headers,(e=>_((i(),s("td",{key:e.value},[$.value[e.value]?(i(),s("code",me,g($.value[e.value]),1)):v("v-if",!0)])),[[B,e.summarise]]))),128))])):v("v-if",!0)])])])}}};var he=ee(pe,[["__scopeId","data-v-ed2d49fd"],["__file","FastTable.vue"]]);X("\n.sql-panel-container {\n width: 100%;\n height: 100%;\n --v-table-height: 100%;\n}\n.sql-panel-container .v-text-overflow {\n user-select: text;\n white-space: pre-wrap;\n}\n.sql-panel-container .center {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n}\n.export-csv-button {\n position: absolute;\n right: 0;\n bottom: 0;\n z-index: 2;\n opacity: 0.8;\n}\n.export-csv-button .button {\n border-radius: var(--border-radius) 0 0 0 !important;\n}\n",{});const be={key:0,class:"center"},ge={key:0},ye={__name:"panel",props:{id:String,showHeader:{type:Boolean,default:!1},columns:Array,download:{type:Boolean,default:!0},is_static:{type:Boolean,default:!1},actions:Array},setup(n){const d=$(),h=n,{id:k,showHeader:x,download:A,is_static:L}=S(h),O=a(!1),T=a(""),D=a(null),B=a(null),E=e(),{useInsightsStore:I}=t(),N=I();if(L.value)q(M);else{const e=Z(M,1e3);j((()=>N.variables),(()=>{B.value||(O.value=!0),e()}),{immediate:!0})}const U=o((()=>h.columns?.length>0?h.columns.map((e=>({...e,text:e.text||e.value}))):D.value)),W=a({by:null,desc:!1});let H;async function M(){O.value=!0,T.value="",D.value=null,B.value=null;try{const e={};H=e;const{data:t}=await E.get(`insights/query/${k.value}`,{params:N.variables??{}});if(H!==e)return;if(t.error&&(T.value=t.error),t.headers&&t.items){const e=t.items.length>2;D.value=t.headers.map((function(t,n){const a=t.replace(/_/g," ").replace(/(?:^|\s)\S/g,(function(e){return e.toUpperCase()}));return{text:a,value:t,width:a.length+1,sortable:e}}));const n=h.columns&&h.columns.filter((e=>e.isNumber));B.value=n?t.items.map((e=>(n.forEach((t=>{e[t.value]=""!==e[t.value]?1*e[t.value]:null})),e))):t.items}}catch(e){T.value=e.response?.data?.error||e.message}O.value=!1}function Q(){if(U.value&&B.value){let e=Object.values(U.value).map((e=>e.text)).join(",");e+="\r\n",e+=function(){let e="";return B.value.forEach((t=>{for(let n in t)/[, ]/.test(t[n])?e+=`"${t[n].replace(/"/g,'\\"')}",`:e+=t[n]+",";e+="\r\n"})),e}();const t=(new Date).toISOString()+".csv"||"export.csv",n=new Blob([e],{type:"text/csv;charset=utf-8;"});if(navigator.msSaveBlob)navigator.msSaveBlob(n,t);else{const e=document.createElement("a");if(void 0!==e.download){const a=URL.createObjectURL(n);e.setAttribute("href",a),e.setAttribute("download",t),e.style.visibility="hidden",document.body.appendChild(e),e.click(),document.body.removeChild(e)}}}}function V(e,t){let n=e;for(let e in t)n=n.replace(new RegExp(`%${e}%`,"g"),t[e]);return n}function z({item:e}){const t=h.actions?.find((e=>e.row));t&&d.push(V(t.link,e))}return j(W,(({by:e,desc:t})=>{e&&(B.value=B.value.sort(((n,a)=>n[e]<a[e]?t?1:-1:n[e]>a[e]?t?-1:1:0)))}),{deep:!0}),(e,t)=>{const a=r("v-progress-circular"),o=r("v-notice"),d=r("v-icon"),h=r("v-button"),k=l("tooltip");return i(),s("div",{class:u(["sql-panel-container",{"has-header":w(x)}])},[O.value||T.value?(i(),s("div",be,[O.value?(i(),y(a,{key:0,indeterminate:""})):(i(),y(o,{key:1,type:"danger",center:""},{default:f((()=>[b(g(T.value),1)])),_:1}))])):U.value&&B.value?(i(),s(m,{key:1},[w(A)?(i(),y(h,{key:0,onClick:Q,icon:"",secondary:"",class:"export-csv-button"},{default:f((()=>[c(d,{name:"download-file"})])),_:1})):v("v-if",!0),c(he,{headers:U.value,items:B.value,"onClick:row":z,sort:W.value.by,"onUpdate:sort":t[0]||(t[0]=e=>W.value.by=e),sortDesc:W.value.desc,"onUpdate:sortDesc":t[1]||(t[1]=e=>W.value.desc=e),"fixed-header":""},C({_:2},[n.actions?.find((e=>!e.row))?{name:"item-append",fn:f((({item:e})=>[(i(!0),s(m,null,p(n.actions.filter((e=>!e.row)),(t=>_((i(),y(h,{outlined:"",to:V(t.link,e),icon:!t.show_label,"x-small":""},{default:f((()=>[c(d,{name:t.icon},null,8,["name"]),t.show_label?(i(),s("span",ge,g(t.label),1)):v("v-if",!0)])),_:2},1032,["to","icon"])),[[k,t.label]]))),256))])),key:"0"}:void 0]),1032,["headers","items","sort","sortDesc"])],64)):v("v-if",!0)],2)}}};const we=[],ke=[],xe=[],_e=[],Se=[n({id:"sql-query",name:"SQL Query panel",icon:"view_list",description:"Show result of a stored SQL query as a table",component:ee(ye,[["__file","panel.vue"]]),options:[{field:"sql",name:"SQL query",type:"string",meta:{note:"Supports variables in the format of {{variable_name}}. Don't quote string variables",interface:"input-code",width:"full",options:{language:"sql"}}},{field:"columns",name:"Columns",type:"json",special:"cast-json",meta:{width:"full",interface:"list",options:{addLabel:"Add column",label:"{{name}} - {{width}}",fields:[{field:"value",name:"Column Name",type:"string",note:"As returned by query",meta:{required:!0,width:"half",interface:"input",options:{trim:!0,softLength:100}}},{field:"text",name:"Label",type:"string",note:"What to display in the column header (Default is same as name)",meta:{width:"half",interface:"input",options:{trim:!0,softLength:100}}},{field:"width",name:"Width",type:"integer",meta:{required:!0,width:"half",interface:"input",options:{min:40,max:400}},schema:{default_value:100}},{field:"isNumber",name:"Is Numberic",type:"boolean",meta:{width:"half",interface:"boolean"}},{field:"sortable",name:"Sortable",type:"boolean",meta:{width:"half",interface:"boolean"}},{field:"searchable",name:"Searchable",type:"boolean",meta:{width:"half",interface:"boolean"}},{field:"summarise",name:"Summarise",type:"string",meta:{width:"half",interface:"select-dropdown",options:{choices:[{text:"Sum",value:"sum"},{text:"Average",value:"avg"},{text:"Count",value:"count"},{text:"Count Unique",value:"count_unique"},{text:"Count Groups",value:"count_groups"}]}}}]}}},{field:"download",name:"Download button",type:"boolean",meta:{width:"half",interface:"boolean",options:{label:"Show"}},schema:{default_value:!0}},{field:"is_static",name:"Is static",type:"boolean",meta:{width:"half",interface:"boolean",options:{label:"Yes"},note:"If the result will not be affect when variables are changed, you can check this box to improve performance."},schema:{default_value:!1}},{field:"actions",name:"Actions",type:"json",special:"cast-json",meta:{width:"full",interface:"list",options:{addLabel:"Add action",label:"{{{label}}",fields:[{field:"label",name:"Label",type:"string",meta:{required:!0,width:"half",interface:"input",options:{trim:!0,softLength:50}}},{field:"link",name:"Link",type:"string",meta:{required:!0,note:"Variables per row can be inserted as such %column_name%",width:"half",interface:"input",options:{trim:!0}}},{field:"row",name:"Activate on row click",type:"boolean",meta:{note:"If you don't want to show the action button, but want to activate the link on row click, check this box.",width:"full",interface:"boolean"}},{field:"icon",name:"Icon",type:"string",meta:{note:"Leave blank to not show an icon",width:"half",interface:"select-icon"}},{field:"show_label",name:"Show label",type:"boolean",meta:{width:"half",interface:"boolean"}}]}}}],minWidth:10,minHeight:10})],qe=[];export{ke as displays,we as interfaces,xe as layouts,_e as modules,qe as operations,Se as panels};
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "directus-extension-sql-query-panel",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Insights Panel for viewing results for dynamic sql queries",
|
|
6
|
+
"icon": "extension",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Gerard Lamusse"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"directus:extension": {
|
|
15
|
+
"host": "^10.1.14",
|
|
16
|
+
"type": "bundle",
|
|
17
|
+
"path": {
|
|
18
|
+
"app": "dist/app.js",
|
|
19
|
+
"api": "dist/api.js"
|
|
20
|
+
},
|
|
21
|
+
"entries": [
|
|
22
|
+
{
|
|
23
|
+
"type": "endpoint",
|
|
24
|
+
"name": "insights",
|
|
25
|
+
"source": "src/insights/index.ts"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "panel",
|
|
29
|
+
"name": "sql-query",
|
|
30
|
+
"source": "src/sql-query/index.ts"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"directus",
|
|
36
|
+
"directus-extension",
|
|
37
|
+
"directus-custom-bundle"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "directus-extension build",
|
|
41
|
+
"dev": "directus-extension build -w --no-minify",
|
|
42
|
+
"link": "directus-extension link",
|
|
43
|
+
"add": "directus-extension add"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@directus/extensions": "^0.1.1",
|
|
47
|
+
"@directus/extensions-sdk": "10.1.14",
|
|
48
|
+
"@types/node": "^20.8.10",
|
|
49
|
+
"typescript": "^5.2.2",
|
|
50
|
+
"vue": "^3.3.7"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@directus/types": "^11.0.1",
|
|
54
|
+
"lodash.debounce": "^4.0.8"
|
|
55
|
+
}
|
|
56
|
+
}
|