adminizer 4.3.0-build.80 → 4.3.0-build.82
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/assets/add-CZdDpNV2.js +1 -0
- package/assets/add-form-BjXOLDij.js +1 -0
- package/assets/add-group-form-BNmpvW8K.js +1 -0
- package/assets/add-group-urhA47Qf.js +1 -0
- package/assets/add-user-CzWUu7wG.js +1 -0
- package/assets/{add-user-form-yp020h4r.js → add-user-form-DrclnTOd.js} +1 -1
- package/assets/{app-CpGtjhxF.css → app-CSVBI-Lw.css} +1 -1
- package/assets/app-layout-CbyH1MDK.js +1 -0
- package/assets/{app-shell-xEVbINZV.js → app-shell-CHEYhVco.js} +1 -1
- package/assets/{app-sidebar-4lm9f_CG.js → app-sidebar-DeF8WNmW.js} +1 -1
- package/assets/app-sidebar-header-8KWnVpkN.js +1 -0
- package/assets/app.js +1628 -1628
- package/assets/breadcrumbs-C439DWrC.js +1 -0
- package/assets/catalog-CCSagWKW.js +6 -0
- package/assets/dashboard-DUNXib6b.js +3 -0
- package/assets/date-picker-DbJ8nHp5.js +1 -0
- package/assets/del-modal-_b3CSNHb.js +1 -0
- package/assets/{dynamic-controls-PxBg8yMz.js → dynamic-controls-BOYmRX_z.js} +1 -1
- package/assets/{field-renderer-CsBa_tMB.css → field-renderer-CRNLShJD.css} +1 -1
- package/assets/field-renderer-D0crIeQS.js +407 -0
- package/assets/{form-CSTeMDf5.js → form-B6LFaTgS.js} +1 -1
- package/assets/form-C8pRhEOA.js +1 -0
- package/assets/geo-json-uSUIgJf5.js +4 -0
- package/assets/{handsontable-D6MvFmcM.js → handsontable-PVakPtJV.js} +55 -55
- package/assets/home-D--JrFFj.js +2 -0
- package/assets/icon-DM49pZW3.js +1 -0
- package/assets/{init-user-L-oxFTOv.js → init-user-DNrB8Xt5.js} +1 -1
- package/assets/input-error--IOnWghB.js +1 -0
- package/assets/jsoneditor-D95dIAP2.js +3878 -0
- package/assets/list-CQivvagG.js +1 -0
- package/assets/{list-table-vIvydJV2.js → list-table-h_zXp43g.js} +4 -4
- package/assets/{login-DLMJ6l_r.js → login-6Xb8bcPq.js} +1 -1
- package/assets/manifest.json +259 -260
- package/assets/material-icon-BedgD2NE.js +1 -0
- package/assets/{media-manager-ASGJ4PcS.js → media-manager-Bms57WSN.js} +2 -2
- package/assets/module-DqrIORMW.js +1 -0
- package/assets/{monaco-B1uVVM7f.js → monaco-ICtx6xoc.js} +1 -1
- package/assets/{nav-footer-DbGCtmmN.js → nav-footer-BwkQkwow.js} +1 -1
- package/assets/{nav-main-BcWhl71g.js → nav-main-9Eb_A0rf.js} +1 -1
- package/assets/nav-user-CRAfyE-x.js +1 -0
- package/assets/notification-db0RD9I6.js +27 -0
- package/assets/{pagination-render-BceTnewI.js → pagination-render-D3UyVAlr.js} +1 -1
- package/assets/{register-C_W_hOmq.js → register-BIyjCy8M.js} +1 -1
- package/assets/tabs-BK_5wdPA.js +1 -0
- package/assets/theme-switcher-CKiJbMkh.js +1 -0
- package/assets/toast-editor-BZM5RHph.js +845 -0
- package/assets/{user-info-BrWerGLc.js → user-info-CcYdmjMZ.js} +1 -1
- package/assets/{user-menu-content-D61_auxX.js → user-menu-content-DbUk8ZeY.js} +1 -1
- package/assets/vanilla-picker-l5rcX3cq.js +8 -0
- package/assets/{vendor-DoC2WAmd.js → vendor-wzZzN_Jv.js} +2 -2
- package/assets/welcome-CZlWN4gM.js +1 -0
- package/controllers/add.js +1 -1
- package/controllers/catalog/FrontentCatalogAdapter.d.ts +4 -4
- package/controllers/edit.js +1 -15
- package/controllers/list.js +2 -2
- package/controllers/login.js +2 -2
- package/controllers/navigation/edit.js +1 -1
- package/controllers/notifications/NotificationController.d.ts +5 -5
- package/controllers/notifications/NotificationController.js +77 -78
- package/controllers/remove.js +1 -11
- package/controllers/view.js +1 -1
- package/helpers/configHelper.d.ts +1 -1
- package/helpers/fieldsHelper.d.ts +1 -1
- package/helpers/fieldsHelper.js +1 -1
- package/helpers/inertiaAddHelper.d.ts +1 -1
- package/helpers/translationHelper.d.ts +1 -1
- package/helpers/translationHelper.js +1 -1
- package/index.d.ts +14 -13
- package/index.js +14 -13
- package/interfaces/adminpanelConfig.d.ts +1 -1
- package/interfaces/global.d.ts +3 -3
- package/interfaces/types.d.ts +10 -1
- package/lib/Adminizer.d.ts +7 -7
- package/lib/Adminizer.js +7 -7
- package/lib/{v4/DataAccessor.d.ts → DataAccessor.d.ts} +4 -4
- package/lib/{v4/DataAccessor.js → DataAccessor.js} +3 -3
- package/lib/{v4/I18n.js → I18n.js} +2 -2
- package/lib/{v4/PolicyManager.d.ts → PolicyManager.d.ts} +1 -1
- package/lib/{v4/PolicyManager.js → PolicyManager.js} +2 -2
- package/lib/{v4/catalog → catalog}/AbstractCatalog.d.ts +1 -1
- package/lib/{v4/catalog → catalog}/Navigation.d.ts +2 -2
- package/lib/{v4/catalog → catalog}/Navigation.js +1 -1
- package/lib/{v4/controls → controls}/AbstractControls.d.ts +1 -1
- package/lib/{v4/controls → controls}/codeEditor/MonacoEditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/geojsoneditor/GeoEditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/jsoneditor/JsonEditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/markdown/ToastUiEditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/table/Handsontable.d.ts +1 -1
- package/lib/{v4/controls → controls}/wysiwyg/CKeditor.d.ts +1 -1
- package/lib/{v4/datatable → datatable}/NodeTable.d.ts +1 -1
- package/lib/{v4/model → model}/AbstractModel.d.ts +12 -0
- package/lib/model/AbstractModel.js +178 -0
- package/lib/{v4/model → model}/ModelHandler.js +1 -1
- package/lib/{v4/model → model}/adapter/sequelize.d.ts +2 -4
- package/lib/{v4/model → model}/adapter/sequelize.js +33 -13
- package/lib/{v4/notifications → notifications}/AbstractNotificationService.d.ts +14 -7
- package/lib/notifications/AbstractNotificationService.js +233 -0
- package/lib/{v4/notifications → notifications}/GeneralNotificationService.d.ts +1 -1
- package/lib/{v4/notifications → notifications}/GeneralNotificationService.js +4 -2
- package/lib/notifications/NotificationHandler.d.ts +27 -0
- package/lib/notifications/NotificationHandler.js +41 -0
- package/lib/{v4/notifications → notifications}/SystemNotificationService.d.ts +5 -4
- package/lib/notifications/SystemNotificationService.js +173 -0
- package/lib/{v4/widgets → widgets}/abstractCustom.d.ts +1 -1
- package/lib/{v4/widgets → widgets}/abstractLink.d.ts +1 -1
- package/lib/{v4/widgets → widgets}/abstractWidgetBase.d.ts +1 -1
- package/lib/{v4/widgets → widgets}/widgetHandler.d.ts +2 -2
- package/migrations/index.d.ts +3 -0
- package/migrations/index.js +4 -0
- package/migrations/umzug/0001.d.ts +7 -0
- package/migrations/umzug/0001.js +119 -0
- package/migrations/umzug.d.ts +2 -0
- package/migrations/umzug.js +8 -0
- package/models/NotificationAP.d.ts +8 -0
- package/models/NotificationAP.js +8 -0
- package/models/UserAP.d.ts +1 -1
- package/package.json +5 -4
- package/system/Router.js +4 -8
- package/system/bindControls.js +6 -6
- package/system/bindInertia.js +4 -3
- package/system/bindNavigation.js +1 -1
- package/system/bindNotifications.js +3 -3
- package/system/bindReqFunctions.js +8 -25
- package/system/defaults.js +1 -1
- package/ui/components/ui/table.d.ts +1 -1
- package/ui/components/ui/table.js +2 -2
- package/assets/add-DSapOiv0.js +0 -1
- package/assets/add-form-C04ZI5LT.js +0 -1
- package/assets/add-group-DWR7SBTO.js +0 -1
- package/assets/add-group-form-CyRwxTs3.js +0 -1
- package/assets/add-user-acATGxUL.js +0 -1
- package/assets/app-layout-BmT5KQwc.js +0 -1
- package/assets/app-sidebar-header-CxXmzszq.js +0 -1
- package/assets/breadcrumbs-livOfa2Z.js +0 -1
- package/assets/catalog-CG_EB2kz.js +0 -6
- package/assets/dashboard-CsmJfdLb.js +0 -3
- package/assets/date-picker-By3kj-Rx.js +0 -1
- package/assets/del-modal-DlcbcdR5.js +0 -1
- package/assets/field-renderer-Bp1lfm0v.js +0 -407
- package/assets/form-CxHRGp7p.js +0 -1
- package/assets/geo-json-CCgjEQfu.js +0 -4
- package/assets/home-D00XjLjD.js +0 -2
- package/assets/icon-ButfCBrt.js +0 -1
- package/assets/input-error-CHsDLcK0.js +0 -1
- package/assets/jsoneditor-CBqATVR0.js +0 -3833
- package/assets/list-4TOTsjqE.js +0 -1
- package/assets/material-icon-sXk4BK-N.js +0 -1
- package/assets/module-mxngd2cA.js +0 -1
- package/assets/nav-user-BN2veV3l.js +0 -1
- package/assets/notification-BEfA5sT6.js +0 -1
- package/assets/tabs-CgZW_LLn.js +0 -1
- package/assets/theme-switcher-D1G6OSMc.js +0 -1
- package/assets/toast-editor-CfgZXoQZ.js +0 -845
- package/assets/vanilla-picker-B6E6ObS_.js +0 -8
- package/assets/welcome-FHRCdke0.js +0 -1
- package/lib/v4/model/AbstractModel.js +0 -79
- package/lib/v4/notifications/AbstractNotificationService.js +0 -150
- package/lib/v4/notifications/NotificationHandler.d.ts +0 -69
- package/lib/v4/notifications/NotificationHandler.js +0 -127
- package/lib/v4/notifications/SystemNotificationService.js +0 -124
- package/migrations/db-migrate/20230303171134-adminpanel-init.js +0 -122
- package/migrations/db-migrate/20231223215835-add-widgets.js +0 -32
- package/migrations/db-migrate/20240804191001-added-navigationap.js +0 -53
- package/migrations/db-migrate/20241121184236-v4-init.js +0 -134
- /package/lib/{v4/I18n.d.ts → I18n.d.ts} +0 -0
- /package/lib/{v4/POWCaptcha.d.ts → POWCaptcha.d.ts} +0 -0
- /package/lib/{v4/POWCaptcha.js → POWCaptcha.js} +0 -0
- /package/lib/{v4/catalog → catalog}/AbstractCatalog.js +0 -0
- /package/lib/{v4/catalog → catalog}/CatalogHandler.d.ts +0 -0
- /package/lib/{v4/catalog → catalog}/CatalogHandler.js +0 -0
- /package/lib/{v4/controls → controls}/AbstractControls.js +0 -0
- /package/lib/{v4/controls → controls}/ControlsHandler.d.ts +0 -0
- /package/lib/{v4/controls → controls}/ControlsHandler.js +0 -0
- /package/lib/{v4/controls → controls}/codeEditor/MonacoEditor.js +0 -0
- /package/lib/{v4/controls → controls}/geojsoneditor/GeoEditor.js +0 -0
- /package/lib/{v4/controls → controls}/jsoneditor/JsonEditor.js +0 -0
- /package/lib/{v4/controls → controls}/markdown/ToastUiEditor.js +0 -0
- /package/lib/{v4/controls → controls}/table/Handsontable.js +0 -0
- /package/lib/{v4/controls → controls}/wysiwyg/CKeditor.js +0 -0
- /package/lib/{v4/datatable → datatable}/NodeTable.js +0 -0
- /package/lib/{v4/helper → helper}/jwt.d.ts +0 -0
- /package/lib/{v4/helper → helper}/jwt.js +0 -0
- /package/lib/{v4/inertia → inertia}/flash.d.ts +0 -0
- /package/lib/{v4/inertia → inertia}/flash.js +0 -0
- /package/lib/{v4/inertia → inertia}/inertiaAdapter.d.ts +0 -0
- /package/lib/{v4/inertia → inertia}/inertiaAdapter.js +0 -0
- /package/lib/{v4/model → model}/ModelHandler.d.ts +0 -0
- /package/lib/{v4/model → model}/adapter/waterline.d.ts +0 -0
- /package/lib/{v4/model → model}/adapter/waterline.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractAction.d.ts +0 -0
- /package/lib/{v4/widgets → widgets}/abstractAction.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractCustom.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractInfo.d.ts +0 -0
- /package/lib/{v4/widgets → widgets}/abstractInfo.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractLink.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractSwitch.d.ts +0 -0
- /package/lib/{v4/widgets → widgets}/abstractSwitch.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractWidgetBase.js +0 -0
- /package/lib/{v4/widgets → widgets}/widgetHandler.js +0 -0
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* vanilla-picker v2.12.3
|
|
3
|
-
* https://vanilla-picker.js.org
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2017-2024 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)
|
|
6
|
-
* Released under the ISC license.
|
|
7
|
-
*/var O=function(l,n){if(!(l instanceof n))throw new TypeError("Cannot call a class as a function")},R=function(){function l(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(n,e,t){return e&&l(n.prototype,e),t&&l(n,t),n}}(),y=function(){function l(n,e){var t=[],r=!0,i=!1,o=void 0;try{for(var c=n[Symbol.iterator](),a;!(r=(a=c.next()).done)&&(t.push(a.value),!(e&&t.length===e));r=!0);}catch(s){i=!0,o=s}finally{try{!r&&c.return&&c.return()}finally{if(i)throw o}}return t}return function(n,e){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return l(n,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();String.prototype.startsWith=String.prototype.startsWith||function(l){return this.indexOf(l)===0};String.prototype.padStart=String.prototype.padStart||function(l,n){for(var e=this;e.length<l;)e=n+e;return e};var I={cb:"0f8ff",tqw:"aebd7",q:"-ffff",qmrn:"7fffd4",zr:"0ffff",bg:"5f5dc",bsq:"e4c4",bck:"---",nch:"ebcd",b:"--ff",bvt:"8a2be2",brwn:"a52a2a",brw:"deb887",ctb:"5f9ea0",hrt:"7fff-",chcT:"d2691e",cr:"7f50",rnw:"6495ed",crns:"8dc",crms:"dc143c",cn:"-ffff",Db:"--8b",Dcn:"-8b8b",Dgnr:"b8860b",Dgr:"a9a9a9",Dgrn:"-64-",Dkhk:"bdb76b",Dmgn:"8b-8b",Dvgr:"556b2f",Drng:"8c-",Drch:"9932cc",Dr:"8b--",Dsmn:"e9967a",Dsgr:"8fbc8f",DsTb:"483d8b",DsTg:"2f4f4f",Dtrq:"-ced1",Dvt:"94-d3",ppnk:"1493",pskb:"-bfff",mgr:"696969",grb:"1e90ff",rbrc:"b22222",rwht:"af0",stg:"228b22",chs:"-ff",gnsb:"dcdcdc",st:"8f8ff",g:"d7-",gnr:"daa520",gr:"808080",grn:"-8-0",grnw:"adff2f",hnw:"0fff0",htpn:"69b4",nnr:"cd5c5c",ng:"4b-82",vr:"0",khk:"0e68c",vnr:"e6e6fa",nrb:"0f5",wngr:"7cfc-",mnch:"acd",Lb:"add8e6",Lcr:"08080",Lcn:"e0ffff",Lgnr:"afad2",Lgr:"d3d3d3",Lgrn:"90ee90",Lpnk:"b6c1",Lsmn:"a07a",Lsgr:"20b2aa",Lskb:"87cefa",LsTg:"778899",Lstb:"b0c4de",Lw:"e0",m:"-ff-",mgrn:"32cd32",nn:"af0e6",mgnt:"-ff",mrn:"8--0",mqm:"66cdaa",mmb:"--cd",mmrc:"ba55d3",mmpr:"9370db",msg:"3cb371",mmsT:"7b68ee","":"-fa9a",mtr:"48d1cc",mmvt:"c71585",mnLb:"191970",ntc:"5fffa",mstr:"e4e1",mccs:"e4b5",vjw:"dead",nv:"--80",c:"df5e6",v:"808-0",vrb:"6b8e23",rng:"a5-",rngr:"45-",rch:"da70d6",pgnr:"eee8aa",pgrn:"98fb98",ptrq:"afeeee",pvtr:"db7093",ppwh:"efd5",pchp:"dab9",pr:"cd853f",pnk:"c0cb",pm:"dda0dd",pwrb:"b0e0e6",prp:"8-080",cc:"663399",r:"--",sbr:"bc8f8f",rb:"4169e1",sbrw:"8b4513",smn:"a8072",nbr:"4a460",sgrn:"2e8b57",ssh:"5ee",snn:"a0522d",svr:"c0c0c0",skb:"87ceeb",sTb:"6a5acd",sTgr:"708090",snw:"afa",n:"-ff7f",stb:"4682b4",tn:"d2b48c",t:"-8080",thst:"d8bfd8",tmT:"6347",trqs:"40e0d0",vt:"ee82ee",whT:"5deb3",wht:"",hts:"5f5f5",w:"-",wgrn:"9acd32"};function A(l){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,e=n>0?l.toFixed(n).replace(/0+$/,"").replace(/\.$/,""):l.toString();return e||"0"}var N=function(){function l(n,e,t,r){O(this,l);var i=this;function o(a){if(a.startsWith("hsl")){var s=a.match(/([\-\d\.e]+)/g).map(Number),p=y(s,4),f=p[0],u=p[1],d=p[2],b=p[3];b===void 0&&(b=1),f/=360,u/=100,d/=100,i.hsla=[f,u,d,b]}else if(a.startsWith("rgb")){var m=a.match(/([\-\d\.e]+)/g).map(Number),h=y(m,4),v=h[0],g=h[1],E=h[2],k=h[3];k===void 0&&(k=1),i.rgba=[v,g,E,k]}else a.startsWith("#")?i.rgba=l.hexToRgb(a):i.rgba=l.nameToRgb(a)||l.hexToRgb(a)}if(n!==void 0)if(Array.isArray(n))this.rgba=n;else if(t===void 0){var c=n&&""+n;c&&o(c.toLowerCase())}else this.rgba=[n,e,t,r===void 0?1:r]}return R(l,[{key:"printRGB",value:function(e){var t=e?this.rgba:this.rgba.slice(0,3),r=t.map(function(i,o){return A(i,o===3?3:0)});return e?"rgba("+r+")":"rgb("+r+")"}},{key:"printHSL",value:function(e){var t=[360,100,100,1],r=["","%","%",""],i=e?this.hsla:this.hsla.slice(0,3),o=i.map(function(c,a){return A(c*t[a],a===3?3:1)+r[a]});return e?"hsla("+o+")":"hsl("+o+")"}},{key:"printHex",value:function(e){var t=this.hex;return e?t:t.substring(0,7)}},{key:"rgba",get:function(){if(this._rgba)return this._rgba;if(!this._hsla)throw new Error("No color is set");return this._rgba=l.hslToRgb(this._hsla)},set:function(e){e.length===3&&(e[3]=1),this._rgba=e,this._hsla=null}},{key:"rgbString",get:function(){return this.printRGB()}},{key:"rgbaString",get:function(){return this.printRGB(!0)}},{key:"hsla",get:function(){if(this._hsla)return this._hsla;if(!this._rgba)throw new Error("No color is set");return this._hsla=l.rgbToHsl(this._rgba)},set:function(e){e.length===3&&(e[3]=1),this._hsla=e,this._rgba=null}},{key:"hslString",get:function(){return this.printHSL()}},{key:"hslaString",get:function(){return this.printHSL(!0)}},{key:"hex",get:function(){var e=this.rgba,t=e.map(function(r,i){return i<3?r.toString(16):Math.round(r*255).toString(16)});return"#"+t.map(function(r){return r.padStart(2,"0")}).join("")},set:function(e){this.rgba=l.hexToRgb(e)}}],[{key:"hexToRgb",value:function(e){var t=(e.startsWith("#")?e.slice(1):e).replace(/^(\w{3})$/,"$1F").replace(/^(\w)(\w)(\w)(\w)$/,"$1$1$2$2$3$3$4$4").replace(/^(\w{6})$/,"$1FF");if(!t.match(/^([0-9a-fA-F]{8})$/))throw new Error("Unknown hex color; "+e);var r=t.match(/^(\w\w)(\w\w)(\w\w)(\w\w)$/).slice(1).map(function(i){return parseInt(i,16)});return r[3]=r[3]/255,r}},{key:"nameToRgb",value:function(e){var t=e.toLowerCase().replace("at","T").replace(/[aeiouyldf]/g,"").replace("ght","L").replace("rk","D").slice(-5,4),r=I[t];return r===void 0?r:l.hexToRgb(r.replace(/\-/g,"00").padStart(6,"f"))}},{key:"rgbToHsl",value:function(e){var t=y(e,4),r=t[0],i=t[1],o=t[2],c=t[3];r/=255,i/=255,o/=255;var a=Math.max(r,i,o),s=Math.min(r,i,o),p=void 0,f=void 0,u=(a+s)/2;if(a===s)p=f=0;else{var d=a-s;switch(f=u>.5?d/(2-a-s):d/(a+s),a){case r:p=(i-o)/d+(i<o?6:0);break;case i:p=(o-r)/d+2;break;case o:p=(r-i)/d+4;break}p/=6}return[p,f,u,c]}},{key:"hslToRgb",value:function(e){var t=y(e,4),r=t[0],i=t[1],o=t[2],c=t[3],a=void 0,s=void 0,p=void 0;if(i===0)a=s=p=o;else{var f=function(h,v,g){return g<0&&(g+=1),g>1&&(g-=1),g<.16666666666666666?h+(v-h)*6*g:g<.5?v:g<.6666666666666666?h+(v-h)*(.6666666666666666-g)*6:h},u=o<.5?o*(1+i):o+i-o*i,d=2*o-u;a=f(d,u,r+1/3),s=f(d,u,r),p=f(d,u,r-1/3)}var b=[a*255,s*255,p*255].map(Math.round);return b[3]=c,b}}]),l}(),z=function(){function l(){O(this,l),this._events=[]}return R(l,[{key:"add",value:function(e,t,r){e.addEventListener(t,r,!1),this._events.push({target:e,type:t,handler:r})}},{key:"remove",value:function(e,t,r){this._events=this._events.filter(function(i){var o=!0;return e&&e!==i.target&&(o=!1),t&&t!==i.type&&(o=!1),r&&r!==i.handler&&(o=!1),o&&l._doRemove(i.target,i.type,i.handler),!o})}},{key:"destroy",value:function(){this._events.forEach(function(e){return l._doRemove(e.target,e.type,e.handler)}),this._events=[]}}],[{key:"_doRemove",value:function(e,t,r){e.removeEventListener(t,r,!1)}}]),l}();function F(l){var n=document.createElement("div");return n.innerHTML=l,n.firstElementChild}function L(l,n,e){var t=!1;function r(a,s,p){return Math.max(s,Math.min(a,p))}function i(a,s,p){if(p&&(t=!0),!!t){a.preventDefault();var f=n.getBoundingClientRect(),u=f.width,d=f.height,b=s.clientX,m=s.clientY,h=r(b-f.left,0,u),v=r(m-f.top,0,d);e(h/u,v/d)}}function o(a,s){var p=a.buttons===void 0?a.which:a.buttons;p===1?i(a,a,s):t=!1}function c(a,s){a.touches.length===1?i(a,a.touches[0],s):t=!1}l.add(n,"mousedown",function(a){o(a,!0)}),l.add(n,"touchstart",function(a){c(a,!0)}),l.add(window,"mousemove",o),l.add(n,"touchmove",c),l.add(window,"mouseup",function(a){t=!1}),l.add(n,"touchend",function(a){t=!1}),l.add(n,"touchcancel",function(a){t=!1})}var U=`linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0 / 2em 2em,
|
|
8
|
-
linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em / 2em 2em`,B=360,P="keydown",x="mousedown",T="focusin";function _(l,n){return(n||document).querySelector(l)}function G(l){l.preventDefault(),l.stopPropagation()}function H(l,n,e,t,r){l.add(n,P,function(i){e.indexOf(i.key)>=0&&t(i)})}var K=function(){function l(n){O(this,l),this.settings={popup:"right",layout:"default",alpha:!0,editor:!0,editorFormat:"hex",cancelButton:!1,defaultColor:"#0cf"},this._events=new z,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(n)}return R(l,[{key:"setOptions",value:function(e){var t=this;if(!e)return;var r=this.settings;function i(s,p,f){for(var u in s)p[u]=s[u]}if(e instanceof HTMLElement)r.parent=e;else{r.parent&&e.parent&&r.parent!==e.parent&&(this._events.remove(r.parent),this._popupInited=!1),i(e,r),e.onChange&&(this.onChange=e.onChange),e.onDone&&(this.onDone=e.onDone),e.onOpen&&(this.onOpen=e.onOpen),e.onClose&&(this.onClose=e.onClose);var o=e.color||e.colour;o&&this._setColor(o)}var c=r.parent;if(c&&r.popup&&!this._popupInited){var a=function(p){return t.openHandler(p)};this._events.add(c,"click",a),H(this._events,c,[" ","Spacebar","Enter"],a),this._popupInited=!0}else e.parent&&!r.popup&&this.show()}},{key:"openHandler",value:function(e){if(this.show()){e&&e.preventDefault(),this.settings.parent.style.pointerEvents="none";var t=e&&e.type===P?this._domEdit:this.domElement;setTimeout(function(){return t.focus()},100),this.onOpen&&this.onOpen(this.colour)}}},{key:"closeHandler",value:function(e){var t=e&&e.type,r=!1;if(!e)r=!0;else if(t===x||t===T){var i=(this.__containedEvent||0)+100;e.timeStamp>i&&(r=!0)}else G(e),r=!0;r&&this.hide()&&(this.settings.parent.style.pointerEvents="",t!==x&&this.settings.parent.focus(),this.onClose&&this.onClose(this.colour))}},{key:"movePopup",value:function(e,t){this.closeHandler(),this.setOptions(e),t&&this.openHandler()}},{key:"setColor",value:function(e,t){this._setColor(e,{silent:t})}},{key:"_setColor",value:function(e,t){if(typeof e=="string"&&(e=e.trim()),!!e){t=t||{};var r=void 0;try{r=new N(e)}catch(o){if(t.failSilently)return;throw o}if(!this.settings.alpha){var i=r.hsla;i[3]=1,r.hsla=i}this.colour=this.color=r,this._setHSLA(null,null,null,null,t)}}},{key:"setColour",value:function(e,t){this.setColor(e,t)}},{key:"show",value:function(){var e=this.settings.parent;if(!e)return!1;if(this.domElement){var t=this._toggleDOM(!0);return this._setPosition(),t}var r=this.settings.template||'<div class="picker_wrapper" tabindex="-1"><div class="picker_arrow"></div><div class="picker_hue picker_slider"><div class="picker_selector"></div></div><div class="picker_sl"><div class="picker_selector"></div></div><div class="picker_alpha picker_slider"><div class="picker_selector"></div></div><div class="picker_editor"><input aria-label="Type a color name or hex value"/></div><div class="picker_sample"></div><div class="picker_done"><button>Ok</button></div><div class="picker_cancel"><button>Cancel</button></div></div>',i=F(r);return this.domElement=i,this._domH=_(".picker_hue",i),this._domSL=_(".picker_sl",i),this._domA=_(".picker_alpha",i),this._domEdit=_(".picker_editor input",i),this._domSample=_(".picker_sample",i),this._domOkay=_(".picker_done button",i),this._domCancel=_(".picker_cancel button",i),i.classList.add("layout_"+this.settings.layout),this.settings.alpha||i.classList.add("no_alpha"),this.settings.editor||i.classList.add("no_editor"),this.settings.cancelButton||i.classList.add("no_cancel"),this._ifPopup(function(){return i.classList.add("popup")}),this._setPosition(),this.colour?this._updateUI():this._setColor(this.settings.defaultColor),this._bindEvents(),!0}},{key:"hide",value:function(){return this._toggleDOM(!1)}},{key:"destroy",value:function(){this._events.destroy(),this.domElement&&this.settings.parent.removeChild(this.domElement)}},{key:"_bindEvents",value:function(){var e=this,t=this,r=this.domElement,i=this._events;function o(s,p,f){i.add(s,p,f)}o(r,"click",function(s){return s.preventDefault()}),L(i,this._domH,function(s,p){return t._setHSLA(s)}),L(i,this._domSL,function(s,p){return t._setHSLA(null,s,1-p)}),this.settings.alpha&&L(i,this._domA,function(s,p){return t._setHSLA(null,null,null,1-p)});var c=this._domEdit;o(c,"input",function(s){t._setColor(this.value,{fromEditor:!0,failSilently:!0})}),o(c,"focus",function(s){var p=this;p.selectionStart===p.selectionEnd&&p.select()}),this._ifPopup(function(){var s=function(u){return e.closeHandler(u)};o(window,x,s),o(window,T,s),H(i,r,["Esc","Escape"],s);var p=function(u){e.__containedEvent=u.timeStamp};o(r,x,p),o(r,T,p),o(e._domCancel,"click",s)});var a=function(p){e._ifPopup(function(){return e.closeHandler(p)}),e.onDone&&e.onDone(e.colour)};o(this._domOkay,"click",a),H(i,r,["Enter"],a)}},{key:"_setPosition",value:function(){var e=this.settings.parent,t=this.domElement;e!==t.parentNode&&e.appendChild(t),this._ifPopup(function(r){getComputedStyle(e).position==="static"&&(e.style.position="relative");var i=r===!0?"popup_right":"popup_"+r;["popup_top","popup_bottom","popup_left","popup_right"].forEach(function(o){o===i?t.classList.add(o):t.classList.remove(o)}),t.classList.add(i)})}},{key:"_setHSLA",value:function(e,t,r,i,o){o=o||{};var c=this.colour,a=c.hsla;[e,t,r,i].forEach(function(s,p){(s||s===0)&&(a[p]=s)}),c.hsla=a,this._updateUI(o),this.onChange&&!o.silent&&this.onChange(c)}},{key:"_updateUI",value:function(e){if(!this.domElement)return;e=e||{};var t=this.colour,r=t.hsla,i="hsl("+r[0]*B+", 100%, 50%)",o=t.hslString,c=t.hslaString,a=this._domH,s=this._domSL,p=this._domA,f=_(".picker_selector",a),u=_(".picker_selector",s),d=_(".picker_selector",p);function b(M,S,C){S.style.left=C*100+"%"}function m(M,S,C){S.style.top=C*100+"%"}b(a,f,r[0]),this._domSL.style.backgroundColor=this._domH.style.color=i,b(s,u,r[1]),m(s,u,1-r[2]),s.style.color=o,m(p,d,1-r[3]);var h=o,v=h.replace("hsl","hsla").replace(")",", 0)"),g="linear-gradient("+[h,v]+")";if(this._domA.style.background=g+", "+U,!e.fromEditor){var E=this.settings.editorFormat,k=this.settings.alpha,w=void 0;switch(E){case"rgb":w=t.printRGB(k);break;case"hsl":w=t.printHSL(k);break;default:w=t.printHex(k)}this._domEdit.value=w}this._domSample.style.color=c}},{key:"_ifPopup",value:function(e,t){this.settings.parent&&this.settings.popup?e&&e(this.settings.popup):t&&t()}},{key:"_toggleDOM",value:function(e){var t=this.domElement;if(!t)return!1;var r=e?"":"none",i=t.style.display!==r;return i&&(t.style.display=r),i}}]),l}();{var D=document.createElement("style");D.textContent='.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_wrapper.no_editor .picker_editor{position:absolute;z-index:-1;opacity:0}.picker_wrapper.no_cancel .picker_cancel{display:none}.layout_default.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em}.layout_default.picker_wrapper input,.layout_default.picker_wrapper button{font-size:1rem}.layout_default.picker_wrapper>*{margin:.5em}.layout_default.picker_wrapper::before{content:"";display:block;width:100%;height:0;order:1}.layout_default .picker_slider,.layout_default .picker_selector{padding:1em}.layout_default .picker_hue{width:100%}.layout_default .picker_sl{flex:1 1 auto}.layout_default .picker_sl::before{content:"";display:block;padding-bottom:100%}.layout_default .picker_editor{order:1;width:6.5rem}.layout_default .picker_editor input{width:100%;height:100%}.layout_default .picker_sample{order:1;flex:1 1 auto}.layout_default .picker_done,.layout_default .picker_cancel{order:1}.picker_wrapper{box-sizing:border-box;background:#f2f2f2;box-shadow:0 0 0 1px silver;cursor:default;font-family:sans-serif;color:#444;pointer-events:auto}.picker_wrapper:focus{outline:none}.picker_wrapper button,.picker_wrapper input{box-sizing:border-box;border:none;box-shadow:0 0 0 1px silver;outline:none}.picker_wrapper button:focus,.picker_wrapper button:active,.picker_wrapper input:focus,.picker_wrapper input:active{box-shadow:0 0 2px 1px #1e90ff}.picker_wrapper button{padding:.4em .6em;cursor:pointer;background-color:#f5f5f5;background-image:linear-gradient(0deg, gainsboro, transparent)}.picker_wrapper button:active{background-image:linear-gradient(0deg, transparent, gainsboro)}.picker_wrapper button:hover{background-color:#fff}.picker_selector{position:absolute;z-index:1;display:block;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);border:2px solid #fff;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);box-shadow:0 0 0 1px silver}.picker_sl{position:relative;box-shadow:0 0 0 1px silver;background-image:linear-gradient(180deg, white, rgba(255, 255, 255, 0) 50%),linear-gradient(0deg, black, rgba(0, 0, 0, 0) 50%),linear-gradient(90deg, #808080, rgba(128, 128, 128, 0))}.picker_alpha,.picker_sample{position:relative;background:linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0/2em 2em,linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em/2em 2em;box-shadow:0 0 0 1px silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_editor input{font-family:monospace;padding:.2em .4em}.picker_sample::before{content:"";position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_arrow{position:absolute;z-index:-1}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:"";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;-webkit-transform:skew(45deg);transform:skew(45deg);-webkit-transform-origin:0 100%;transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;-webkit-transform:rotate(90deg) scale(1, -1);transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;-webkit-transform:scale(-1, 1);transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}',document.documentElement.firstElementChild.appendChild(D),K.StyleElement=D}export{K as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{q as o,j as t}from"./app.js";import{A as p}from"./app-layout-BmT5KQwc.js";import"./jsoneditor-CBqATVR0.js";import"./vendor-DoC2WAmd.js";import"./monaco-B1uVVM7f.js";import"./handsontable-D6MvFmcM.js";import"./app-shell-xEVbINZV.js";import"./app-sidebar-4lm9f_CG.js";import"./nav-main-BcWhl71g.js";import"./material-icon-sXk4BK-N.js";import"./app-sidebar-header-CxXmzszq.js";import"./breadcrumbs-livOfa2Z.js";import"./nav-user-BN2veV3l.js";import"./user-info-BrWerGLc.js";import"./user-menu-content-D61_auxX.js";import"./theme-switcher-D1G6OSMc.js";import"./icon-ButfCBrt.js";const i=[];function N(){const r=o();return t.jsx(p,{breadcrumbs:i,children:t.jsxs("div",{className:"flex h-full flex-1 flex-col gap-4 rounded-xl p-4",children:[r.props.title&&t.jsx("div",{className:"text-3xl mb-8",children:r.props.title}),t.jsx("div",{className:"text-3xl mb-8",children:"Adminizer"}),r.props.text&&t.jsx("div",{dangerouslySetInnerHTML:{__html:r.props.text}})]})})}export{N as default};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { formatChanges, sanitizeForDiff } from "../../../helpers/diffHelpers";
|
|
2
|
-
export class AbstractModel {
|
|
3
|
-
modelname;
|
|
4
|
-
attributes;
|
|
5
|
-
primaryKey;
|
|
6
|
-
identity;
|
|
7
|
-
constructor(modelname, attributes, primaryKey, identity) {
|
|
8
|
-
this.modelname = modelname;
|
|
9
|
-
this.attributes = attributes;
|
|
10
|
-
this.primaryKey = primaryKey;
|
|
11
|
-
this.identity = identity;
|
|
12
|
-
}
|
|
13
|
-
async create(data, dataAccessor) {
|
|
14
|
-
let _data = await dataAccessor.setUserRelationAccess(dataAccessor.process(data));
|
|
15
|
-
let record = await this._create(_data);
|
|
16
|
-
// console.log(record.toJSON());
|
|
17
|
-
//Create diff
|
|
18
|
-
const cleanNewRecord = sanitizeForDiff(_data);
|
|
19
|
-
const formattedChanges = formatChanges({}, {}, cleanNewRecord, 'add');
|
|
20
|
-
// log system event notification с diff
|
|
21
|
-
await dataAccessor.adminizer.logSystemCreatedEvent('Created',
|
|
22
|
-
//@ts-ignore
|
|
23
|
-
`user ${dataAccessor.user.login} create ${dataAccessor.entity.name} ${record[this.primaryKey]}`, {
|
|
24
|
-
changes: formattedChanges,
|
|
25
|
-
summary: `Created ${formattedChanges.length} fields`
|
|
26
|
-
});
|
|
27
|
-
return dataAccessor.process(record);
|
|
28
|
-
}
|
|
29
|
-
async findOne(criteria, dataAccessor) {
|
|
30
|
-
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
31
|
-
let record = await this._findOne(criteria);
|
|
32
|
-
return record ? dataAccessor.process(record) : null;
|
|
33
|
-
}
|
|
34
|
-
async find(criteria, dataAccessor) {
|
|
35
|
-
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
36
|
-
let records = await this._find(criteria);
|
|
37
|
-
return records.map(record => dataAccessor.process(record));
|
|
38
|
-
}
|
|
39
|
-
async updateOne(criteria, data, dataAccessor) {
|
|
40
|
-
let _data = dataAccessor.process(data);
|
|
41
|
-
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
42
|
-
let record = await this._updateOne(criteria, _data);
|
|
43
|
-
return record ? dataAccessor.process(record) : null;
|
|
44
|
-
}
|
|
45
|
-
async update(criteria, data, dataAccessor) {
|
|
46
|
-
let _data = dataAccessor.process(data);
|
|
47
|
-
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
48
|
-
let records = await this._update(criteria, _data);
|
|
49
|
-
return records.map(record => dataAccessor.process(record));
|
|
50
|
-
}
|
|
51
|
-
async destroyOne(criteria, dataAccessor) {
|
|
52
|
-
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
53
|
-
let record = await this._destroyOne(criteria);
|
|
54
|
-
return record ? dataAccessor.process(record) : null;
|
|
55
|
-
}
|
|
56
|
-
async destroy(criteria, dataAccessor) {
|
|
57
|
-
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
58
|
-
let records = await this._destroy(criteria);
|
|
59
|
-
return records.map(record => dataAccessor.process(record));
|
|
60
|
-
}
|
|
61
|
-
async count(criteria, dataAccessor) {
|
|
62
|
-
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
63
|
-
return this._count(criteria);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export class AbstractAdapter {
|
|
67
|
-
orm;
|
|
68
|
-
ormType;
|
|
69
|
-
constructor(type, orm) {
|
|
70
|
-
this.ormType = type;
|
|
71
|
-
this.orm = orm;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* This method must ensure system models registration and throw an error in case of errors. We force all adapters to realize it
|
|
75
|
-
*/
|
|
76
|
-
static registerSystemModels(orm) {
|
|
77
|
-
throw new Error("Function 'registerSystemModels' must be implemented by subclass");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { Adminizer } from '../../Adminizer';
|
|
3
|
-
export class AbstractNotificationService extends EventEmitter {
|
|
4
|
-
clients = new Map();
|
|
5
|
-
adminizer;
|
|
6
|
-
constructor(adminizer) {
|
|
7
|
-
super();
|
|
8
|
-
this.adminizer = adminizer;
|
|
9
|
-
}
|
|
10
|
-
// Добавление клиента
|
|
11
|
-
// TODO - Проверить, что клиент имеет права на получение уведомлений
|
|
12
|
-
addClient(clientId, sendFn) {
|
|
13
|
-
this.clients.set(clientId, sendFn);
|
|
14
|
-
Adminizer.log.info(`[${this.notificationClass}] Client ${clientId} connected. Total: ${this.clients.size}`);
|
|
15
|
-
}
|
|
16
|
-
// Удаление клиента
|
|
17
|
-
removeClient(clientId) {
|
|
18
|
-
this.clients.delete(clientId);
|
|
19
|
-
Adminizer.log.info(`[${this.notificationClass}] Client ${clientId} disconnected. Total: ${this.clients.size}`);
|
|
20
|
-
}
|
|
21
|
-
// abstract getNotifications(userId?: number, limit?: number, unreadOnly?: boolean): Promise<INotification[]>;
|
|
22
|
-
// Рассылка события всем клиентам
|
|
23
|
-
broadcast(event) {
|
|
24
|
-
this.clients.forEach((sendFn, clientId) => {
|
|
25
|
-
try {
|
|
26
|
-
sendFn(event);
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
Adminizer.log.error(`[${this.notificationClass}] Error sending to client ${clientId}:`, error);
|
|
30
|
-
this.removeClient(clientId);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
// Отправка heartbeat
|
|
35
|
-
sendHeartbeat(clientId) {
|
|
36
|
-
const sendFn = this.clients.get(clientId);
|
|
37
|
-
if (sendFn) {
|
|
38
|
-
const heartbeatEvent = {
|
|
39
|
-
type: 'heartbeat',
|
|
40
|
-
data: 'ping'
|
|
41
|
-
};
|
|
42
|
-
sendFn(heartbeatEvent);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
// Генерация ID
|
|
46
|
-
generateId() {
|
|
47
|
-
return `${this.notificationClass}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
48
|
-
}
|
|
49
|
-
// Получение количества подключенных клиентов
|
|
50
|
-
getClientCount() {
|
|
51
|
-
return this.clients.size;
|
|
52
|
-
}
|
|
53
|
-
// Метод для создания записи в UserNotificationAP
|
|
54
|
-
async createUserNotification(notificationId, userId) {
|
|
55
|
-
if (this.adminizer.modelHandler.model.has('usernotificationap') && userId) {
|
|
56
|
-
try {
|
|
57
|
-
await this.adminizer.modelHandler.model.get('usernotificationap')["_create"]({
|
|
58
|
-
userId: userId,
|
|
59
|
-
notificationId: notificationId,
|
|
60
|
-
read: false
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
Adminizer.log.error(`Error creating user notification record:`, error);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// Метод для получения UserNotificationAP по ID уведомления и пользователя
|
|
69
|
-
async getUserNotification(notificationId, userId) {
|
|
70
|
-
if (this.adminizer.modelHandler.model.has('usernotificationap')) {
|
|
71
|
-
try {
|
|
72
|
-
return await this.adminizer.modelHandler.model.get('usernotificationap')["_findOne"]({
|
|
73
|
-
where: { notificationId: notificationId, userId: userId }
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
Adminizer.log.error(`Error getting user notification:`, error);
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
async getNotifications(userId, limit = 50, unreadOnly = false) {
|
|
84
|
-
if (!this.adminizer.modelHandler.model.has('notificationap')) {
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
try {
|
|
88
|
-
let query = { notificationClass: this.notificationClass };
|
|
89
|
-
// Если запрашиваются уведомления для конкретного пользователя
|
|
90
|
-
// Получаем ID уведомлений пользователя
|
|
91
|
-
const userNotifications = await this.adminizer.modelHandler.model.get('usernotificationap')["_find"]({
|
|
92
|
-
where: {
|
|
93
|
-
userId: userId
|
|
94
|
-
},
|
|
95
|
-
include: ['notificationap']
|
|
96
|
-
});
|
|
97
|
-
const notificationIds = userNotifications.map((un) => un.notificationId.id);
|
|
98
|
-
if (unreadOnly) {
|
|
99
|
-
// Только непрочитанные
|
|
100
|
-
query.id = userNotifications
|
|
101
|
-
.filter((un) => !un.read)
|
|
102
|
-
.map((un) => un.notificationId.id);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
query.id = notificationIds;
|
|
106
|
-
}
|
|
107
|
-
let notificationsDB;
|
|
108
|
-
if (query.id.length === 0)
|
|
109
|
-
return [];
|
|
110
|
-
notificationsDB = await this.adminizer.modelHandler.model.get('notificationap')["_find"]({
|
|
111
|
-
where: query,
|
|
112
|
-
sort: 'createdAt DESC',
|
|
113
|
-
limit: limit
|
|
114
|
-
});
|
|
115
|
-
let notifications = [];
|
|
116
|
-
for (const notification of notificationsDB) {
|
|
117
|
-
let readStatus = false;
|
|
118
|
-
// Получаем статус прочтения из UserNotificationAP
|
|
119
|
-
const userNotification = await this.getUserNotification(notification.id, userId);
|
|
120
|
-
readStatus = userNotification ? userNotification.read : false;
|
|
121
|
-
notifications.push({
|
|
122
|
-
...notification,
|
|
123
|
-
read: readStatus,
|
|
124
|
-
icon: {
|
|
125
|
-
icon: this.icon,
|
|
126
|
-
iconColor: this.iconColor
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return notifications;
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
Adminizer.log.error('Error fetching notifications:', error);
|
|
134
|
-
return [];
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
async markAsRead(userId, id) {
|
|
138
|
-
try {
|
|
139
|
-
const userNotification = await this.getUserNotification(id, userId);
|
|
140
|
-
if (userNotification) {
|
|
141
|
-
await this.adminizer.modelHandler.model.get('usernotificationap')["_update"]({
|
|
142
|
-
id: userNotification.id
|
|
143
|
-
}, { read: true });
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
Adminizer.log.error('Error marking notification as read:', error);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { AbstractNotificationService } from "./AbstractNotificationService";
|
|
3
|
-
import { INotification } from '../../../interfaces/types';
|
|
4
|
-
export declare class NotificationHandler extends EventEmitter {
|
|
5
|
-
private services;
|
|
6
|
-
constructor();
|
|
7
|
-
/**
|
|
8
|
-
* Register a new notification service
|
|
9
|
-
* @param service
|
|
10
|
-
*/
|
|
11
|
-
registerService(service: AbstractNotificationService): void;
|
|
12
|
-
/**
|
|
13
|
-
* Remove a notification service
|
|
14
|
-
* @param notificationClass
|
|
15
|
-
*/
|
|
16
|
-
removeService(notificationClass: string): void;
|
|
17
|
-
/**
|
|
18
|
-
* Get a notification service by class
|
|
19
|
-
* @param notificationClass
|
|
20
|
-
*/
|
|
21
|
-
getService(notificationClass: string): AbstractNotificationService | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Get all registered services
|
|
24
|
-
*/
|
|
25
|
-
getAllServices(): AbstractNotificationService[];
|
|
26
|
-
/**
|
|
27
|
-
* Dispatch a notification to a service
|
|
28
|
-
* @param notificationClass
|
|
29
|
-
* @param notification
|
|
30
|
-
*/
|
|
31
|
-
dispatchNotification(notificationClass: string, notification: Omit<INotification, 'id' | 'createdAt' | 'notificationClass' | 'icon'>): Promise<boolean>;
|
|
32
|
-
/**
|
|
33
|
-
* Get notifications by class
|
|
34
|
-
* @param notificationClass
|
|
35
|
-
* @param userId
|
|
36
|
-
* @param limit
|
|
37
|
-
* @param unreadOnly
|
|
38
|
-
*/
|
|
39
|
-
getNotifications(notificationClass: string, userId?: number, limit?: number, unreadOnly?: boolean): Promise<INotification[]>;
|
|
40
|
-
/**
|
|
41
|
-
* Get all notifications for a user
|
|
42
|
-
* @param user
|
|
43
|
-
* @param limit
|
|
44
|
-
* @param unreadOnly
|
|
45
|
-
*/
|
|
46
|
-
getUserNotifications(user: any, limit?: number, unreadOnly?: boolean): Promise<INotification[]>;
|
|
47
|
-
/**
|
|
48
|
-
* Mark a notification as read
|
|
49
|
-
* @param notificationClass
|
|
50
|
-
* @param id
|
|
51
|
-
* @param userId
|
|
52
|
-
*/
|
|
53
|
-
markAsRead(notificationClass: string, id: string, userId: number): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Check if user is admin
|
|
56
|
-
* @param user
|
|
57
|
-
* @private
|
|
58
|
-
*/
|
|
59
|
-
private isAdmin;
|
|
60
|
-
/**
|
|
61
|
-
* Get client count for a notification class
|
|
62
|
-
* @param notificationClass
|
|
63
|
-
*/
|
|
64
|
-
getClientCount(notificationClass: string): number;
|
|
65
|
-
/**
|
|
66
|
-
* Get total client count
|
|
67
|
-
*/
|
|
68
|
-
getTotalClientCount(): number;
|
|
69
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { Adminizer } from '../../Adminizer';
|
|
3
|
-
export class NotificationHandler extends EventEmitter {
|
|
4
|
-
services = new Map();
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Register a new notification service
|
|
10
|
-
* @param service
|
|
11
|
-
*/
|
|
12
|
-
registerService(service) {
|
|
13
|
-
this.services.set(service.notificationClass, service);
|
|
14
|
-
Adminizer.log.info(`Notification service registered: ${service.notificationClass}`);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Remove a notification service
|
|
18
|
-
* @param notificationClass
|
|
19
|
-
*/
|
|
20
|
-
removeService(notificationClass) {
|
|
21
|
-
if (this.services.has(notificationClass)) {
|
|
22
|
-
this.services.delete(notificationClass);
|
|
23
|
-
Adminizer.log.info(`Notification service removed: ${notificationClass}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Get a notification service by class
|
|
28
|
-
* @param notificationClass
|
|
29
|
-
*/
|
|
30
|
-
getService(notificationClass) {
|
|
31
|
-
return this.services.get(notificationClass);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Get all registered services
|
|
35
|
-
*/
|
|
36
|
-
getAllServices() {
|
|
37
|
-
return Array.from(this.services.values());
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Dispatch a notification to a service
|
|
41
|
-
* @param notificationClass
|
|
42
|
-
* @param notification
|
|
43
|
-
*/
|
|
44
|
-
async dispatchNotification(notificationClass, notification) {
|
|
45
|
-
const service = this.getService(notificationClass);
|
|
46
|
-
if (!service) {
|
|
47
|
-
throw new Error(`Notification service not found: ${notificationClass}`);
|
|
48
|
-
}
|
|
49
|
-
return service.dispatchNotification(notification);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Get notifications by class
|
|
53
|
-
* @param notificationClass
|
|
54
|
-
* @param userId
|
|
55
|
-
* @param limit
|
|
56
|
-
* @param unreadOnly
|
|
57
|
-
*/
|
|
58
|
-
async getNotifications(notificationClass, userId, limit, unreadOnly) {
|
|
59
|
-
const service = this.getService(notificationClass);
|
|
60
|
-
if (!service) {
|
|
61
|
-
throw new Error(`Notification service not found: ${notificationClass}`);
|
|
62
|
-
}
|
|
63
|
-
return service.getNotifications(userId, limit, unreadOnly);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get all notifications for a user
|
|
67
|
-
* @param user
|
|
68
|
-
* @param limit
|
|
69
|
-
* @param unreadOnly
|
|
70
|
-
*/
|
|
71
|
-
async getUserNotifications(user, limit = 50, unreadOnly = false) {
|
|
72
|
-
const allNotifications = [];
|
|
73
|
-
for (const service of this.getAllServices()) {
|
|
74
|
-
// Для системных уведомлений проверяем права админа
|
|
75
|
-
if (service.notificationClass === 'system') {
|
|
76
|
-
if (this.isAdmin(user)) {
|
|
77
|
-
const notifications = await service.getNotifications(user.id, limit, unreadOnly);
|
|
78
|
-
allNotifications.push(...notifications);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
// Для остальных уведомлений получаем по пользователю
|
|
83
|
-
const notifications = await service.getNotifications(user.id, limit, unreadOnly);
|
|
84
|
-
allNotifications.push(...notifications);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// Сортируем по дате создания
|
|
88
|
-
return allNotifications.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()).slice(0, limit);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Mark a notification as read
|
|
92
|
-
* @param notificationClass
|
|
93
|
-
* @param id
|
|
94
|
-
* @param userId
|
|
95
|
-
*/
|
|
96
|
-
async markAsRead(notificationClass, id, userId) {
|
|
97
|
-
const service = this.getService(notificationClass);
|
|
98
|
-
if (!service) {
|
|
99
|
-
throw new Error(`Notification service not found: ${notificationClass}`);
|
|
100
|
-
}
|
|
101
|
-
return service.markAsRead(userId, id);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Check if user is admin
|
|
105
|
-
* @param user
|
|
106
|
-
* @private
|
|
107
|
-
*/
|
|
108
|
-
isAdmin(user) {
|
|
109
|
-
if (!user)
|
|
110
|
-
return false;
|
|
111
|
-
return user.isAdministrator === true;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Get client count for a notification class
|
|
115
|
-
* @param notificationClass
|
|
116
|
-
*/
|
|
117
|
-
getClientCount(notificationClass) {
|
|
118
|
-
const service = this.getService(notificationClass);
|
|
119
|
-
return service ? service.getClientCount() : 0;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Get total client count
|
|
123
|
-
*/
|
|
124
|
-
getTotalClientCount() {
|
|
125
|
-
return this.getAllServices().reduce((total, service) => total + service.getClientCount(), 0);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { AbstractNotificationService } from './AbstractNotificationService';
|
|
2
|
-
import { Adminizer } from '../../Adminizer';
|
|
3
|
-
export class SystemNotificationService extends AbstractNotificationService {
|
|
4
|
-
notificationClass = 'system';
|
|
5
|
-
icon = 'settings';
|
|
6
|
-
iconColor = '#1eb707';
|
|
7
|
-
// Добавляем каналы для CRUD операций
|
|
8
|
-
crudChannels = new Map();
|
|
9
|
-
async dispatchNotification(notification) {
|
|
10
|
-
const fullNotification = {
|
|
11
|
-
...notification,
|
|
12
|
-
notificationClass: this.notificationClass,
|
|
13
|
-
channel: notification.channel ?? ''
|
|
14
|
-
};
|
|
15
|
-
let notificationDB;
|
|
16
|
-
// Сохраняем в базу
|
|
17
|
-
if (this.adminizer.modelHandler.model.has('notificationap')) {
|
|
18
|
-
try {
|
|
19
|
-
// Idia how to keep in DB notification raw data ['user %s created %s in model %s', user, instance.name, modelName] as print_f()
|
|
20
|
-
notificationDB = await this.adminizer.modelHandler.model.get('notificationap')["_create"](fullNotification);
|
|
21
|
-
const users = await this.adminizer.modelHandler.model.get('userap')["_find"]({ isAdministrator: 1 });
|
|
22
|
-
for (const user of users) {
|
|
23
|
-
try {
|
|
24
|
-
await this.createUserNotification(notificationDB.id, user.id);
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
Adminizer.log.error('Error creating UserNotificationAP:', error);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const event = {
|
|
31
|
-
type: 'notification',
|
|
32
|
-
data: {
|
|
33
|
-
...notificationDB,
|
|
34
|
-
icon: {
|
|
35
|
-
icon: this.icon,
|
|
36
|
-
iconColor: this.iconColor
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
notificationClass: this.notificationClass,
|
|
40
|
-
userId: notification.userId ?? null,
|
|
41
|
-
channel: notification.channel ?? 'system' // Добавляем информацию о канале
|
|
42
|
-
};
|
|
43
|
-
// Отправляем на все каналы или на конкретный канал
|
|
44
|
-
if (notification.channel) {
|
|
45
|
-
this.broadcastToChannel(notification.channel, event);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
this.broadcastToChannel('system', event);
|
|
49
|
-
}
|
|
50
|
-
Adminizer.log.info(`[System] Notification dispatched: ${fullNotification.title}`);
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
Adminizer.log.error('Error saving system notification to database:', error);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
// Метод для отправки на конкретный канал
|
|
60
|
-
broadcastToChannel(channel, event) {
|
|
61
|
-
const channelClients = this.crudChannels.get(channel);
|
|
62
|
-
if (channelClients) {
|
|
63
|
-
channelClients.forEach(clientId => {
|
|
64
|
-
const sendFn = this.clients.get(clientId);
|
|
65
|
-
if (sendFn) {
|
|
66
|
-
try {
|
|
67
|
-
sendFn(event);
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
Adminizer.log.error(`[${this.notificationClass}] Error sending to client ${clientId} on channel ${channel}:`, error);
|
|
71
|
-
this.removeClient(clientId);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// Добавляем клиента к каналу
|
|
78
|
-
addClientToChannel(clientId, channel) {
|
|
79
|
-
if (!this.crudChannels.has(channel)) {
|
|
80
|
-
this.crudChannels.set(channel, new Set());
|
|
81
|
-
}
|
|
82
|
-
this.crudChannels.get(channel).add(clientId);
|
|
83
|
-
Adminizer.log.info(`[${this.notificationClass}] Client ${clientId} added to channel ${channel}`);
|
|
84
|
-
}
|
|
85
|
-
// Удаляем клиента из канала
|
|
86
|
-
removeClientFromChannel(clientId, channel) {
|
|
87
|
-
const channelClients = this.crudChannels.get(channel);
|
|
88
|
-
if (channelClients) {
|
|
89
|
-
channelClients.delete(clientId);
|
|
90
|
-
Adminizer.log.info(`[${this.notificationClass}] Client ${clientId} removed from channel ${channel}`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
// Удаляем клиента из всех каналов
|
|
94
|
-
removeClientFromAllChannels(clientId) {
|
|
95
|
-
this.crudChannels.forEach((clients, channel) => {
|
|
96
|
-
clients.delete(clientId);
|
|
97
|
-
Adminizer.log.info(`[${this.notificationClass}] Client ${clientId} removed from channel ${channel}`);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
// Переопределяем removeClient для очистки каналов
|
|
101
|
-
removeClient(clientId) {
|
|
102
|
-
super.removeClient(clientId);
|
|
103
|
-
this.removeClientFromAllChannels(clientId);
|
|
104
|
-
}
|
|
105
|
-
// Специальный метод для системных событий с указанием канала
|
|
106
|
-
async logSystemEvent(title, message, channel, metadata) {
|
|
107
|
-
return this.dispatchNotification({
|
|
108
|
-
title: title,
|
|
109
|
-
message: message,
|
|
110
|
-
metadata: metadata,
|
|
111
|
-
channel: channel
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
// Методы для CRUD операций
|
|
115
|
-
async logCreatedEvent(title, message, metadata) {
|
|
116
|
-
return this.logSystemEvent(title, message, 'created', metadata);
|
|
117
|
-
}
|
|
118
|
-
async logUpdatedEvent(title, message, metadata) {
|
|
119
|
-
return this.logSystemEvent(title, message, 'updated', metadata);
|
|
120
|
-
}
|
|
121
|
-
async logDeletedEvent(title, message, metadata) {
|
|
122
|
-
return this.logSystemEvent(title, message, 'deleted', metadata);
|
|
123
|
-
}
|
|
124
|
-
}
|