expressa 1.1.3 → 1.2.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/README.md +4 -3
- package/controllers/collections.js +53 -32
- package/db/cached.js +3 -0
- package/db/file.js +3 -0
- package/db/memory.js +3 -0
- package/db/mongo.js +7 -8
- package/db/postgres.js +13 -0
- package/index.js +3 -1
- package/modules/admin/dist/index.html +1 -1
- package/modules/admin/dist/static/css/chunk-318c.ffb0d81e.css +1 -0
- package/modules/admin/dist/static/css/{chunk-d0cd.97323951.css → chunk-621e.97323951.css} +0 -0
- package/modules/admin/dist/static/css/{chunk-418a.5ee55031.css → chunk-6644.69ccf1a7.css} +1 -1
- package/modules/admin/dist/static/css/{chunk-787e.1d849865.css → chunk-e375.1d849865.css} +0 -0
- package/modules/admin/dist/static/js/{app.4c984719.js → app.03e8afa3.js} +1 -1
- package/modules/admin/dist/static/js/chunk-318c.03fa0032.js +1 -0
- package/modules/admin/dist/static/js/chunk-621e.a9ed86e2.js +1 -0
- package/modules/admin/dist/static/js/chunk-6644.9c6f5c7b.js +1 -0
- package/modules/admin/dist/static/js/chunk-e375.089d85cd.js +1 -0
- package/modules/admin/src/components/JSONEditor.vue +180 -181
- package/modules/admin/src/views/ListDocuments2.vue +309 -309
- package/package.json +1 -1
- package/test/collections.js +2 -3
- package/test/collections.querying.js +18 -4
- package/test/test.js +4 -0
- package/util.js +19 -0
- package/modules/admin/dist/static/css/chunk-1059.220d4af5.css +0 -1
- package/modules/admin/dist/static/js/chunk-1059.e6aa7b61.js +0 -1
- package/modules/admin/dist/static/js/chunk-418a.e0987b3c.js +0 -1
- package/modules/admin/dist/static/js/chunk-787e.3ee96fce.js +0 -1
- package/modules/admin/dist/static/js/chunk-d0cd.1781b9dd.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-6644","chunk-318c"],{"1GvH":function(t,e,n){n("5w6Y"),t.exports=n("VSTI").Object.keys},"5w6Y":function(t,e,n){var r=n("CYMq"),o=n("mHY4");n("czaS")("keys",(function(){return function(t){return o(r(t))}}))},GQeE:function(t,e,n){t.exports={default:n("1GvH"),__esModule:!0}},"GxU+":function(t,e,n){"use strict";var r=n("fn8H");n.n(r).a},Iab2:function(t,e,n){(function(n){var r,o,a;o=[],void 0===(a="function"==typeof(r=function(){"use strict";function e(t,e,n){var r=new XMLHttpRequest;r.open("GET",t),r.responseType="blob",r.onload=function(){s(r.response,e,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(t){var e=new XMLHttpRequest;e.open("HEAD",t,!1);try{e.send()}catch(t){}return 200<=e.status&&299>=e.status}function o(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(n){var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(e)}}var a="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n&&n.global===n?n:void 0,i=a.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),s=a.saveAs||("object"!=typeof window||window!==a?function(){}:"download"in HTMLAnchorElement.prototype&&!i?function(t,n,i){var s=a.URL||a.webkitURL,u=document.createElement("a");n=n||t.name||"download",u.download=n,u.rel="noopener","string"==typeof t?(u.href=t,u.origin===location.origin?o(u):r(u.href)?e(t,n,i):o(u,u.target="_blank")):(u.href=s.createObjectURL(t),setTimeout((function(){s.revokeObjectURL(u.href)}),4e4),setTimeout((function(){o(u)}),0))}:"msSaveOrOpenBlob"in navigator?function(t,n,a){if(n=n||t.name||"download","string"!=typeof t)navigator.msSaveOrOpenBlob(function(t,e){return void 0===e?e={autoBom:!1}:"object"!=typeof e&&(console.warn("Deprecated: Expected third argument to be a object"),e={autoBom:!e}),e.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob(["\ufeff",t],{type:t.type}):t}(t,a),n);else if(r(t))e(t,n,a);else{var i=document.createElement("a");i.href=t,i.target="_blank",setTimeout((function(){o(i)}))}}:function(t,n,r,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof t)return e(t,n,r);var s="application/octet-stream"===t.type,u=/constructor/i.test(a.HTMLElement)||a.safari,c=/CriOS\/[\d]+/.test(navigator.userAgent);if((c||s&&u||i)&&"undefined"!=typeof FileReader){var l=new FileReader;l.onloadend=function(){var t=l.result;t=c?t:t.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=t:location=t,o=null},l.readAsDataURL(t)}else{var f=a.URL||a.webkitURL,d=f.createObjectURL(t);o?o.location=d:location.href=d,o=null,setTimeout((function(){f.revokeObjectURL(d)}),4e4)}});a.saveAs=s.saveAs=s,t.exports=s})?r.apply(e,o):r)||(t.exports=a)}).call(this,n("yLpj"))},LYKQ:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=c(n("14Xm")),o=c(n("D3Ub")),a=c(n("QbLZ")),i=n("L2JU"),s=c(n("t3Un")),u=c(n("VqTb"));function c(t){return t&&t.__esModule?t:{default:t}}e.default={name:"Dashboard",components:{ListDocuments2:u.default},data:function(){return{statusInfo:{listeners:{}}}},computed:(0,a.default)({},(0,i.mapGetters)(["email","roles"])),mounted:function(){this.update()},methods:{update:function(){var t=this;return(0,o.default)(r.default.mark((function e(){return r.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,s.default)({url:"/status/"});case 2:t.statusInfo=e.sent.data;case 3:case"end":return e.stop()}}),e,t)})))()}}}},N4c9:function(t,e,n){n("wYM1");var r=n("VSTI").Object;t.exports=function(t,e,n){return r.defineProperty(t,e,n)}},Qxpe:function(t,e,n){"use strict";n.d(e,"a",(function(){return r})),n.d(e,"b",(function(){return o}));var r=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"dashboard-container"},[n("div",{staticClass:"dashboard-text"},[t._v("\n Welcome: "+t._s(t.email)+"\n ")]),t._v(" "),n("div",{staticClass:"dashboard-text"},[t._v("\n roles: "),t._l(t.roles,(function(e){return n("span",{key:e},[t._v(t._s(e))])}))],2),t._v(" "),n("div",{staticClass:"dashboard-text"},[t._v("\n listeners: "+t._s(t.statusInfo.listeners.length)+" active\n ")]),t._v(" "),n("br"),t._v(" "),n("div",{staticClass:"dashboard-text"},[t._v("\n uptime: "+t._s(t.statusInfo.uptime)+"\n ")]),t._v(" "),n("div",{staticClass:"dashboard-text"},[t._v("\n Node.js version: "+t._s(t.statusInfo.nodeVersion)+"\n ")]),t._v(" "),n("div",{staticClass:"dashboard-text"},[t._v("\n environment: "+t._s(t.statusInfo.env)+"\n "),n("router-link",{attrs:{id:"settings-link",to:"/edit/settings/"+t.statusInfo.env}},[t._v("\n (edit settings)\n ")])],1),t._v(" "),n("br"),t._v(" "),n("br"),t._v(" "),n("h3",[t._v("Recent API Requests")]),t._v(" "),n("ListDocuments2",{attrs:{"show-paginate-on-bottom":!1,"show-add-button":!1,filter:{limit:5,query:{method:{$ne:"OPTIONS"}}},columns:["method","url","user","res.message","res.statusCode"],"collection-name":"requestlog"}})],1)},o=[]},SEkw:function(t,e,n){t.exports={default:n("N4c9"),__esModule:!0}},VqTb:function(t,e,n){"use strict";n.r(e);var r=n("sqkz"),o=n("sw1Y");for(var a in o)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return o[t]}))}(a);n("tDlW");var i=n("KHd+"),s=Object(i.a)(o.default,r.a,r.b,!1,null,"0dfa1359",null);s.options.__file="ListDocuments2.vue",e.default=s.exports},YEIV:function(t,e,n){"use strict";e.__esModule=!0;var r,o=n("SEkw"),a=(r=o)&&r.__esModule?r:{default:r};e.default=function(t,e,n){return e in t?(0,a.default)(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}},boci:function(t,e,n){var r,o,a;!function(n,i){"use strict";"object"==typeof t.exports?t.exports=i():(o=[],void 0===(a="function"==typeof(r=i)?r.apply(e,o):r)||(t.exports=a))}(0,(function(){"use strict";var t=Object.prototype.toString;function e(t,e){return null!=t&&Object.prototype.hasOwnProperty.call(t,e)}function n(t){if(!t)return!0;if(o(t)&&0===t.length)return!0;if("string"!=typeof t){for(var n in t)if(e(t,n))return!1;return!0}return!1}function r(e){return t.call(e)}var o=Array.isArray||function(e){return"[object Array]"===t.call(e)};function a(t){var e=parseInt(t);return e.toString()===t?e:t}function i(t){var i,s,u=function(t){return Object.keys(u).reduce((function(e,n){return"create"===n||"function"==typeof u[n]&&(e[n]=u[n].bind(u,t)),e}),{})};function c(t,e){if(i(t,e))return t[e]}function l(t,e,n,r){if("number"==typeof e&&(e=[e]),!e||0===e.length)return t;if("string"==typeof e)return l(t,e.split(".").map(a),n,r);var o=e[0],i=s(t,o);return 1===e.length?(void 0!==i&&r||(t[o]=n),i):(void 0===i&&("number"==typeof e[1]?t[o]=[]:t[o]={}),l(t[o],e.slice(1),n,r))}return i=(t=t||{}).includeInheritedProps?function(){return!0}:function(t,n){return"number"==typeof n&&Array.isArray(t)||e(t,n)},s=t.includeInheritedProps?function(t,e){"string"!=typeof e&&"number"!=typeof e&&(e=String(e));var n=c(t,e);if("__proto__"===e||"prototype"===e||"constructor"===e&&"function"==typeof n)throw new Error("For security reasons, object's magic properties cannot be set");return n}:function(t,e){return c(t,e)},u.has=function(n,r){if("number"==typeof r?r=[r]:"string"==typeof r&&(r=r.split(".")),!r||0===r.length)return!!n;for(var i=0;i<r.length;i++){var s=a(r[i]);if(!("number"==typeof s&&o(n)&&s<n.length||(t.includeInheritedProps?s in Object(n):e(n,s))))return!1;n=n[s]}return!0},u.ensureExists=function(t,e,n){return l(t,e,n,!0)},u.set=function(t,e,n,r){return l(t,e,n,r)},u.insert=function(t,e,n,r){var a=u.get(t,e);r=~~r,o(a)||(a=[],u.set(t,e,a)),a.splice(r,0,n)},u.empty=function(t,e){var a,s;if(!n(e)&&(null!=t&&(a=u.get(t,e)))){if("string"==typeof a)return u.set(t,e,"");if(function(t){return"boolean"==typeof t||"[object Boolean]"===r(t)}(a))return u.set(t,e,!1);if("number"==typeof a)return u.set(t,e,0);if(o(a))a.length=0;else{if(!function(t){return"object"==typeof t&&"[object Object]"===r(t)}(a))return u.set(t,e,null);for(s in a)i(a,s)&&delete a[s]}}},u.push=function(t,e){var n=u.get(t,e);o(n)||(n=[],u.set(t,e,n)),n.push.apply(n,Array.prototype.slice.call(arguments,2))},u.coalesce=function(t,e,n){for(var r,o=0,a=e.length;o<a;o++)if(void 0!==(r=u.get(t,e[o])))return r;return n},u.get=function(t,e,n){if("number"==typeof e&&(e=[e]),!e||0===e.length)return t;if(null==t)return n;if("string"==typeof e)return u.get(t,e.split("."),n);var r=a(e[0]),o=s(t,r);return void 0===o?n:1===e.length?o:u.get(t[r],e.slice(1),n)},u.del=function(t,e){if("number"==typeof e&&(e=[e]),null==t)return t;if(n(e))return t;if("string"==typeof e)return u.del(t,e.split("."));var r=a(e[0]);return s(t,r),i(t,r)?1!==e.length?u.del(t[r],e.slice(1)):(o(t)?t.splice(r,1):delete t[r],t):t},u}var s=i();return s.create=i,s.withInheritedProps=i({includeInheritedProps:!0}),s}))},czaS:function(t,e,n){var r=n("USwo"),o=n("VSTI"),a=n("S4vA");t.exports=function(t,e){var n=(o.Object||{})[t]||Object[t],i={};i[t]=e(n),r(r.S+r.F*a((function(){n(1)})),"Object",i)}},"etR+":function(t,e,n){"use strict";n.r(e);var r=n("LYKQ"),o=n.n(r);for(var a in r)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return r[t]}))}(a);e.default=o.a},fn8H:function(t,e,n){},ixEQ:function(t,e,n){},sqkz:function(t,e,n){"use strict";n.d(e,"a",(function(){return r})),n.d(e,"b",(function(){return o}));var r=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"px-3"},[n("div",{staticClass:"d-flex align-items-center py-2"},[n("h3",{staticClass:"mb-0 text-capitalize"},[t._v("\n "+t._s(t.collectionName)+"\n ")]),t._v(" "),n("span",{staticClass:"mx-auto"}),t._v(" "),n("el-checkbox",{staticClass:"mb-0 mr-4",model:{value:t.isFiltersVisible,callback:function(e){t.isFiltersVisible=e},expression:"isFiltersVisible"}},[t._v("\n Show Filters\n ")]),t._v(" "),n("el-pagination",{attrs:{"page-size":t.pageSize,total:t.count,"page-sizes":t.pageSizes,"current-page":t.page,layout:"sizes, prev, pager, next"},on:{"update:currentPage":function(e){t.page=e},"current-change":function(e){t.update()},"size-change":function(e){t.pageSize=e,t.update()}}})],1),t._v(" "),n("el-table",{attrs:{data:t.tableRows,"element-loading-text":"Loading",border:"",fit:"","highlight-current-row":""}},t._l(t.listedProperties,(function(e,r){return n("el-table-column",{key:e,attrs:{label:e,align:"center"},scopedSlots:t._u([{key:"default",fn:function(o){return[0===o.$index&&t.isFiltersVisible?n("div",{staticClass:"text-left"},[n("el-input",{attrs:{placeholder:"Search by "+e,type:"number"===t.getFieldType(e)?"number":"text"},on:{change:function(e){t.update()}},model:{value:t.searchFilters[e],callback:function(n){t.$set(t.searchFilters,e,n)},expression:"searchFilters[name]"}}),t._v(" "),n("el-checkbox",{staticClass:"mt-3",attrs:{disabled:"number"===t.getFieldType(e)},on:{change:function(e){t.update()}},model:{value:t.exactSearches[e],callback:function(n){t.$set(t.exactSearches,e,n)},expression:"exactSearches[name]"}},[t._v("\n Exact match\n ")])],1):[0===r&&"requestlog"!==t.collectionName?n("router-link",{attrs:{to:"/edit/"+t.collectionName+"/"+o.row._id}},[t._v("\n "+t._s(t.getPath(o.row,e))+"\n ")]):t._e(),t._v(" "),0===r&&"requestlog"===t.collectionName?n("router-link",{attrs:{to:"/dev/viewrequest/"+o.row._id}},[t._v("\n "+t._s(t.getPath(o.row,e))+"\n ")]):t._e(),t._v(" "),0!==r?n("span",[t._v(t._s(t.getPath(o.row,e)))]):t._e()]]}}])})}))),t._v(" "),n("div",{staticClass:"d-flex align-items-center my-3"},[t.showAddButton?n("router-link",{staticClass:"mr-2",attrs:{to:"/edit/"+t.collectionName+"/create"}},[n("button",{staticClass:"btn btn-primary"},[t._v("\n Add\n ")])]):t._e(),t._v(" "),n("button",{staticClass:"btn btn-secondary download-button mr-2",on:{click:function(e){t.downloadCSV()}}},[t._v("\n Download\n ")]),t._v(" "),n("button",{staticClass:"btn btn-secondary download-button",on:{click:function(e){t.downloadAllCSV()}}},[t._v("\n Download All\n ")]),t._v(" "),n("span",{staticClass:"mx-auto"}),t._v(" "),n("el-pagination",{attrs:{"page-size":t.pageSize,total:t.count,"page-sizes":t.pageSizes,"current-page":t.page,layout:"sizes, prev, pager, next"},on:{"update:currentPage":function(e){t.page=e},"current-change":function(e){t.update()},"size-change":function(e){t.pageSize=e,t.update()}}})],1)],1)},o=[]},sw1Y:function(t,e,n){"use strict";n.r(e);var r=n("vRIL"),o=n.n(r);for(var a in r)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return r[t]}))}(a);e.default=o.a},tDlW:function(t,e,n){"use strict";var r=n("ixEQ");n.n(r).a},"u1G+":function(t,e,n){"use strict";n.r(e);var r=n("Qxpe"),o=n("etR+");for(var a in o)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return o[t]}))}(a);n("GxU+");var i=n("KHd+"),s=Object(i.a)(o.default,r.a,r.b,!1,null,"5d163182",null);s.options.__file="Home.vue",e.default=s.exports},vRIL:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=d(n("14Xm")),o=d(n("D3Ub")),a=d(n("YEIV")),i=d(n("QbLZ")),s=d(n("GQeE")),u=d(n("m1cH")),c=d(n("t3Un")),l=d(n("Iab2")),f=d(n("boci"));function d(t){return t&&t.__esModule?t:{default:t}}var p=[25,50,100,500];e.default={name:"ListDocuments",props:{collectionName:{type:String,default:"collection"},filter:{type:Object,default:function(){}},columns:{type:Array,default:function(){}},showAddButton:{type:Boolean,default:!0},showPaginateOnBottom:{type:Boolean,default:!0}},data:function(){return{start:0,page:1,count:0,data:[],schema:{},exactSearches:{},searchFilters:{},listedProperties:[],pageSizes:p,pageSize:p[0],isFiltersVisible:!0}},computed:{tableRows:function(){return this.isFiltersVisible?[{}].concat((0,u.default)(this.data)):this.data},appliedSearchFilters:function(){var t=this;return(0,s.default)(this.searchFilters).reduce((function(e,n){var r=t.searchFilters[n],o=t.getFieldType(n);if(!r||"custom"===o)return e;var s=t.getQueryBuilder(o);return(0,i.default)({},e,(0,a.default)({},n,s({fieldName:n,searchKeyword:r})))}),{})},allFilters:function(){var t=(0,i.default)({page:this.page,limit:this.pageSize,orderby:'{"meta.created":-1}'},this.filter,{query:(0,i.default)({},this.appliedSearchFilters)}),e=this.columns||this.collection.admin&&this.collection.admin.columns;return e&&(t.fields=e.reduce((function(t,e){return t[e]=1,t}),{})),t}},watch:{collectionName:{handler:"update"},"$route.params.collectionName":{handler:"resetFilters"}},mounted:function(){this.update()},methods:{getPath:function(t,e,n){var r=String.prototype.split.call(e,/[,[\].]+?/).filter(Boolean).reduce((function(t,e){return null!=t?t[e]:t}),t);return void 0===r||r===t?n:r},update:function(){var t=this;return(0,o.default)(r.default.mark((function e(){var n,o,a;return r.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.$route.params.collectionName&&(t.collectionName=t.$route.params.collectionName),t.collection&&t.collection._id===t.collectionName){e.next=6;break}return e.next=4,(0,c.default)({url:"/collection/"+t.collectionName});case 4:t.collection=e.sent.data,t.schema=t.collection.schema;case 6:return n=(0,i.default)({},t.allFilters),o=t.columns||t.collection.admin&&t.collection.admin.columns,e.next=10,(0,c.default)({url:"/"+t.collectionName+"/",params:n});case 10:a=e.sent.data,t.count=a.itemsTotal,t.data=t.applyCustomColumnFilter(a.data),t.listedProperties=o||(0,s.default)(t.schema.properties);case 14:case"end":return e.stop()}}),e,t)})))()},applyCustomColumnFilter:function(t){var e=this,n=(0,s.default)(this.searchFilters).filter((function(t){return"custom"===e.getFieldType(t)}));return t.filter((function(t){return n.every((function(n){var r=e.searchFilters[n];if(!r)return!0;var o=t[n].toString();return e.exactSearches[n]?o===r:o.toLowerCase().includes(r.toLowerCase())}))}))},downloadCSV:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.data,n=this.collectionName,r=this.listedProperties.map((function(t){return'"'+t+'"'})).join(",")+"\n";if(e){r+=e.map((function(e){return t.listedProperties.map((function(t){return'"'+String(f.default.get(e,t)||"").replace(/"/g,'""')+'"'}))})).join("\n"),console.log(r);var o=new Blob([r],{type:"text/plain;charset=utf-8"});(0,l.default)(o,n+".csv")}},downloadAllCSV:function(){var t=this;return(0,o.default)(r.default.mark((function e(){var n,o,a,s;return r.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=[],o=1;case 2:if(!(t.count>n.length)){e.next=11;break}return a=(0,i.default)({},t.allFilters,{page:o,limit:500}),e.next=6,(0,c.default)({url:"/"+t.collectionName+"/",params:a});case 6:s=e.sent.data,n=[].concat((0,u.default)(s.data),(0,u.default)(n)),o+=1,e.next=2;break;case 11:t.downloadCSV(t.applyCustomColumnFilter(n));case 12:case"end":return e.stop()}}),e,t)})))()},getFieldType:function(t){return this.schema.properties[t]&&this.schema.properties[t].type||"custom"},getQueryBuilder:function(t){return{string:this.getStringSearchQuery,number:function(t){return parseInt(t.searchKeyword)}}[t]||this.getStringSearchQuery},getStringSearchQuery:function(t){var e=t.fieldName,n=t.searchKeyword,r={$regex:n,$options:"i"};return this.exactSearches[e]?n:r},resetFilters:function(){this.exactSearches={},this.searchFilters={}}}}},wYM1:function(t,e,n){var r=n("USwo");r(r.S+r.F*!n("C61u"),"Object",{defineProperty:n("GhSp").f})}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-e375"],{"3FMA":function(t,e,n){"use strict";var a=n("ID0Q");n.n(a).a},"3j9E":function(t,e,n){"use strict";n.d(e,"a",(function(){return a})),n.d(e,"b",(function(){return i}));var a=function(){var t=this.$createElement;this._self._c;return this._m(0)},i=[function(){var t=this.$createElement,e=this._self._c||t;return e("div",[e("div",{staticClass:"jsoneditor-vue"})])}]},GZHj:function(t,e,n){"use strict";n.d(e,"a",(function(){return a})),n.d(e,"b",(function(){return i}));var a=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[n("div",{staticClass:"container"},[n("div",{staticClass:"error-message"},[t._v("\n "+t._s(t.error)+"\n ")]),t._v(" "),t.ready?[t.ready?n("JSONEditor",{attrs:{schema:t.schema},model:{value:t.data,callback:function(e){t.data=e},expression:"data"}}):t._e(),t._v(" "),n("div",[n("button",{staticClass:"btn btn-primary",on:{click:t.save}},[t._v("\n Save\n ")]),t._v(" "),n("button",{staticClass:"btn btn-danger",on:{click:t.del}},[t._v("\n Delete\n ")])])]:t._e()],2)])},i=[]},ID0Q:function(t,e,n){},KJ4A:function(t,e,n){"use strict";var a=n("d9An");n.n(a).a},O0nT:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=c(n("Yz+Y")),i=c(n("iCc5")),r=c(n("V7oC")),o=c(n("FYw3")),s=c(n("tfYw")),u=c(n("mRg0"));function c(t){return t&&t.__esModule?t:{default:t}}n("drU8");var l=n("0fIc").JSONEditor;e.default={props:{value:{type:Object,default:function(){}},schema:{type:Object,default:function(){}}},data:function(){return{editor:null,error:!1,json:this.value,internalChange:!1}},watch:{},mounted:function(){this.update()},methods:{update:function(){var t=this,e={schema:this.schema,startval:this.value,theme:"bootstrap4",iconlib:"materialicons",required_by_default:!0};this.editor&&this.editor.destroy(),this.editor=new l(this.$el.querySelector(".jsoneditor-vue"),e);var n=!0;this.editor.on("change",(function(){n?n=!1:t.$emit("input",t.editor.getValue())}));var a;(a=document.querySelector(".je-modal .je-edit-json--textarea")).classList.remove("je-edit-json--textarea"),a.classList.add("expandable-textarea")},onSave:function(){this.$emit("json-save",this.json)}}},l&&(l.defaults.resolvers.unshift((function(t){if("object"===t.type&&"schema"===t.format)return"schema"})),l.defaults.editors.schema=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(e.__proto__||(0,a.default)(e)).apply(this,arguments))}return(0,u.default)(e,t),(0,r.default)(e,[{key:"setValue",value:function(t,e){this.value=t,this.schemaeditor.setValue(t),this.onChange()}},{key:"getValue",value:function(){return void 0!==this.schemaeditor?this.schemaeditor.getValue():{}}},{key:"register",value:function(){(0,s.default)(e.prototype.__proto__||(0,a.default)(e.prototype),"register",this).call(this),this.input&&this.input.setAttribute("name",this.formname)}},{key:"unregister",value:function(){(0,s.default)(e.prototype.__proto__||(0,a.default)(e.prototype),"unregister",this).call(this),this.input&&this.input.removeAttribute("name")}},{key:"getNumColumns",value:function(){return 12}},{key:"build",value:function(){var t=this;this.options.compact||(this.label=this.header=this.theme.getFormInputLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.options.compact&&(this.container.className+=" compact"),this.input=document.createElement("div"),this.control=this.theme.getFormControl(this.label,this.input,this.description),(this.schema.readOnly||this.schema.readonly)&&(this.always_disabled=!0,this.input.disabled=!0),this.container.appendChild(this.control),this.schemaeditor=new window.JSONSchemaEditor(this.input,{startval:{}}),this.schemaeditor.on("change",(function(){t.onChange(!0)}))}},{key:"enable",value:function(){this.always_disabled||(this.input.disabled=!1),(0,s.default)(e.prototype.__proto__||(0,a.default)(e.prototype),"enable",this).call(this)}},{key:"disable",value:function(){this.input.disabled=!0,(0,s.default)(e.prototype.__proto__||(0,a.default)(e.prototype),"disable",this).call(this)}},{key:"destroy",value:function(){this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),(0,s.default)(e.prototype.__proto__||(0,a.default)(e.prototype),"destroy",this).call(this)}}]),e}(l.AbstractEditor))},TYEE:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a,i=c(n("14Xm")),r=c(n("D3Ub")),o=c(n("t3Un")),s=c(n("fKSE")),u=c(n("Q2AE"));function c(t){return t&&t.__esModule?t:{default:t}}e.default={name:"CollectionTable",components:{JSONEditor:s.default},props:{collectionName:{type:String,default:""},id:{type:String,default:""}},data:function(){return{data:{},collectionName:"",id:"",error:"",options:{mode:"text"},schema:{},ready:!1}},watch:{"$route.path":{handler:"update"}},mounted:(a=(0,r.default)(i.default.mark((function t(){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.update();case 1:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)}),methods:{update:function(){var t=this;return(0,r.default)(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.ready=!1,t.$route.params.collectionName&&(t.collectionName=t.$route.params.collectionName),t.$route.params.id&&(t.id=t.$route.params.id),e.prev=3,"create"===t.id){e.next=10;break}return e.next=7,(0,o.default)({url:"/"+t.collectionName+"/"+t.id});case 7:t.data=e.sent.data,e.next=11;break;case 10:t.data={};case 11:return e.next=13,(0,o.default)({url:"/"+t.collectionName+"/schema"});case 13:t.schema=e.sent.data,t.ready=!0,e.next=20;break;case 17:e.prev=17,e.t0=e.catch(3),t.error=e.t0.error||e.t0;case 20:case"end":return e.stop()}}),e,t,[[3,17]])})))()},save:function(){var t=this;return(0,r.default)(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("create"!==t.id){e.next=5;break}return e.next=3,(0,o.default)({method:"post",url:"/"+t.collectionName,data:t.data});case 3:e.next=7;break;case 5:return e.next=7,(0,o.default)({method:"put",url:"/"+t.collectionName+"/"+t.id,data:t.data});case 7:if("collection"!==t.collectionName){e.next=12;break}return e.next=10,(0,o.default)({url:"/status/"});case 10:t.statusInfo=e.sent.data,u.default.dispatch("StatusInfo",t.statusInfo);case 12:"users"===t.collectionName?t.$router.push("/users/list"):"settings"===t.collectionName?t.$router.push("/home"):t.$router.push("/list/"+t.collectionName+"/");case 13:case"end":return e.stop()}}),e,t)})))()},del:function(){var t=this;return(0,r.default)(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,o.default)({method:"delete",url:"/"+t.collectionName+"/"+t.id});case 2:t.$router.push("/list/"+t.collectionName+"/");case 3:case"end":return e.stop()}}),e,t)})))()}}}},XZgb:function(t,e,n){"use strict";n.r(e);var a=n("O0nT"),i=n.n(a);for(var r in a)["default"].indexOf(r)<0&&function(t){n.d(e,t,(function(){return a[t]}))}(r);e.default=i.a},ZoMo:function(t,e,n){"use strict";n.r(e);var a=n("GZHj"),i=n("tPw9");for(var r in i)["default"].indexOf(r)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(r);n("KJ4A");var o=n("KHd+"),s=Object(o.a)(i.default,a.a,a.b,!1,null,null,null);s.options.__file="EditDocument.vue",e.default=s.exports},d9An:function(t,e,n){},fKSE:function(t,e,n){"use strict";n.r(e);var a=n("3j9E"),i=n("XZgb");for(var r in i)["default"].indexOf(r)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(r);n("3FMA");var o=n("KHd+"),s=Object(o.a)(i.default,a.a,a.b,!1,null,null,null);s.options.__file="JSONEditor.vue",e.default=s.exports},tPw9:function(t,e,n){"use strict";n.r(e);var a=n("TYEE"),i=n.n(a);for(var r in a)["default"].indexOf(r)<0&&function(t){n.d(e,t,(function(){return a[t]}))}(r);e.default=i.a}}]);
|
|
@@ -1,181 +1,180 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div class="jsoneditor-vue" />
|
|
4
|
-
</div>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
const { JSONEditor } = require('@json-editor/json-editor/dist/jsoneditor')
|
|
9
|
-
import 'json-schema-editor'
|
|
10
|
-
export default {
|
|
11
|
-
props: {
|
|
12
|
-
value: {
|
|
13
|
-
type: Object,
|
|
14
|
-
default: () => {}
|
|
15
|
-
},
|
|
16
|
-
schema: {
|
|
17
|
-
type: Object,
|
|
18
|
-
default: () => {}
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
data() {
|
|
22
|
-
return {
|
|
23
|
-
editor: null,
|
|
24
|
-
error: false,
|
|
25
|
-
json: this.value,
|
|
26
|
-
internalChange: false
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
watch: {
|
|
30
|
-
/* value: {
|
|
31
|
-
handler: 'update'
|
|
32
|
-
} */
|
|
33
|
-
},
|
|
34
|
-
mounted() {
|
|
35
|
-
this.update()
|
|
36
|
-
},
|
|
37
|
-
methods: {
|
|
38
|
-
update() {
|
|
39
|
-
var options = {
|
|
40
|
-
schema: this.schema,
|
|
41
|
-
startval: this.value,
|
|
42
|
-
theme: 'bootstrap4',
|
|
43
|
-
iconlib: 'materialicons',
|
|
44
|
-
required_by_default: true,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
textarea.classList.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.value
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (this.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (this.
|
|
145
|
-
if (this.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
min-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
border:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
margin-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="jsoneditor-vue" />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
const { JSONEditor } = require('@json-editor/json-editor/dist/jsoneditor')
|
|
9
|
+
import 'json-schema-editor'
|
|
10
|
+
export default {
|
|
11
|
+
props: {
|
|
12
|
+
value: {
|
|
13
|
+
type: Object,
|
|
14
|
+
default: () => {}
|
|
15
|
+
},
|
|
16
|
+
schema: {
|
|
17
|
+
type: Object,
|
|
18
|
+
default: () => {}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
data() {
|
|
22
|
+
return {
|
|
23
|
+
editor: null,
|
|
24
|
+
error: false,
|
|
25
|
+
json: this.value,
|
|
26
|
+
internalChange: false
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
watch: {
|
|
30
|
+
/* value: {
|
|
31
|
+
handler: 'update'
|
|
32
|
+
} */
|
|
33
|
+
},
|
|
34
|
+
mounted() {
|
|
35
|
+
this.update()
|
|
36
|
+
},
|
|
37
|
+
methods: {
|
|
38
|
+
update() {
|
|
39
|
+
var options = {
|
|
40
|
+
schema: this.schema,
|
|
41
|
+
startval: this.value,
|
|
42
|
+
theme: 'bootstrap4',
|
|
43
|
+
iconlib: 'materialicons',
|
|
44
|
+
required_by_default: true,
|
|
45
|
+
}
|
|
46
|
+
if (this.editor) {
|
|
47
|
+
this.editor.destroy()
|
|
48
|
+
}
|
|
49
|
+
this.editor = new JSONEditor(this.$el.querySelector('.jsoneditor-vue'), options)
|
|
50
|
+
let first = true
|
|
51
|
+
this.editor.on('change', () => {
|
|
52
|
+
if (first) {
|
|
53
|
+
first = false
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
this.$emit('input', this.editor.getValue())
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const makeEditJsonTextAreaExpandable = () => {
|
|
60
|
+
const textarea = document.querySelector('.je-modal .je-edit-json--textarea')
|
|
61
|
+
textarea.classList.remove('je-edit-json--textarea') // INFO: Had to remove this class to remove height and width property
|
|
62
|
+
textarea.classList.add('expandable-textarea')
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
makeEditJsonTextAreaExpandable()
|
|
66
|
+
},
|
|
67
|
+
onSave() {
|
|
68
|
+
this.$emit('json-save', this.json)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (JSONEditor) {
|
|
74
|
+
JSONEditor.defaults.resolvers.unshift(function(schema) {
|
|
75
|
+
if (schema.type === 'object' && schema.format === 'schema') {
|
|
76
|
+
return 'schema'
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// If no valid editor is returned, the next resolver function will be used
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
JSONEditor.defaults.editors.schema = class schema extends JSONEditor.AbstractEditor {
|
|
83
|
+
setValue(value, initial) {
|
|
84
|
+
this.value = value
|
|
85
|
+
this.schemaeditor.setValue(value)
|
|
86
|
+
this.onChange()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
getValue() {
|
|
90
|
+
if (typeof this.schemaeditor !== 'undefined') { return this.schemaeditor.getValue() } else { return {} }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
register() {
|
|
94
|
+
super.register()
|
|
95
|
+
if (!this.input) return
|
|
96
|
+
this.input.setAttribute('name', this.formname)
|
|
97
|
+
}
|
|
98
|
+
unregister() {
|
|
99
|
+
super.unregister()
|
|
100
|
+
if (!this.input) return
|
|
101
|
+
this.input.removeAttribute('name')
|
|
102
|
+
}
|
|
103
|
+
getNumColumns() {
|
|
104
|
+
return 12
|
|
105
|
+
}
|
|
106
|
+
build() {
|
|
107
|
+
var self = this
|
|
108
|
+
if (!this.options.compact) {
|
|
109
|
+
this.label = this.header = this.theme.getFormInputLabel(this.getTitle())
|
|
110
|
+
}
|
|
111
|
+
if (this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description)
|
|
112
|
+
if (this.options.compact) this.container.className += ' compact'
|
|
113
|
+
|
|
114
|
+
this.input = document.createElement('div')
|
|
115
|
+
this.control = this.theme.getFormControl(this.label, this.input, this.description)
|
|
116
|
+
|
|
117
|
+
if (this.schema.readOnly || this.schema.readonly) {
|
|
118
|
+
this.always_disabled = true
|
|
119
|
+
this.input.disabled = true
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
this.container.appendChild(this.control)
|
|
123
|
+
|
|
124
|
+
this.schemaeditor = new window.JSONSchemaEditor(this.input, {
|
|
125
|
+
startval: {}
|
|
126
|
+
})
|
|
127
|
+
this.schemaeditor.on('change', function() {
|
|
128
|
+
self.onChange(true)
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
enable() {
|
|
132
|
+
if (!this.always_disabled) {
|
|
133
|
+
this.input.disabled = false
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
super.enable()
|
|
137
|
+
}
|
|
138
|
+
disable() {
|
|
139
|
+
this.input.disabled = true
|
|
140
|
+
super.disable()
|
|
141
|
+
}
|
|
142
|
+
destroy() {
|
|
143
|
+
if (this.label && this.label.parentNode) this.label.parentNode.removeChild(this.label)
|
|
144
|
+
if (this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description)
|
|
145
|
+
if (this.input && this.input.parentNode) this.input.parentNode.removeChild(this.input)
|
|
146
|
+
super.destroy()
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
</script>
|
|
152
|
+
|
|
153
|
+
<style>
|
|
154
|
+
.expandable-textarea {
|
|
155
|
+
display: block;
|
|
156
|
+
min-height: 250px;
|
|
157
|
+
min-width: 250px;
|
|
158
|
+
resize: both !important;
|
|
159
|
+
}
|
|
160
|
+
.jsoneditor-vue img {
|
|
161
|
+
border: 1px solid #ddd;
|
|
162
|
+
border-radius: 4px;
|
|
163
|
+
padding: 5px;
|
|
164
|
+
width: 150px;
|
|
165
|
+
}
|
|
166
|
+
.jsoneditor-vue img:hover {
|
|
167
|
+
box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);
|
|
168
|
+
}
|
|
169
|
+
.jsoneditor-vue button.btn {
|
|
170
|
+
font-size: 14px !important;
|
|
171
|
+
padding: 3px;
|
|
172
|
+
}
|
|
173
|
+
.jsoneditor-vue .form-control-label, label {
|
|
174
|
+
font-weight: bold;
|
|
175
|
+
}
|
|
176
|
+
.jsoneditor-vue input[type="checkbox"] {
|
|
177
|
+
margin-right: 5px;
|
|
178
|
+
margin-top: 3px;
|
|
179
|
+
}
|
|
180
|
+
</style>
|