@tachybase/module-multi-app 1.3.25 → 1.5.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.
@@ -1,11 +1,11 @@
1
- (function(i,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("antd"),require("react-router-dom"),require("react-i18next"),require("react"),require("@tachybase/schema"),require("@tego/client"),require("@ant-design/icons")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","antd","react-router-dom","react-i18next","react","@tachybase/schema","@tego/client","@ant-design/icons"],t):(i=typeof globalThis!="undefined"?globalThis:i||self,t(i["@tachybase/module-multi-app"]={},i["@tachybase/client"],i.jsxRuntime,i.antd,i["react-router-dom"],i["react-i18next"],i.react,i["@tachybase/schema"],i["@tego/client"],i["@ant-design/icons"]))})(this,function(i,t,o,c,I,F,b,y,f,m){"use strict";var fe=Object.defineProperty,he=Object.defineProperties;var Ae=Object.getOwnPropertyDescriptors;var q=Object.getOwnPropertySymbols;var ge=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable;var E=(i,t,o)=>t in i?fe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[t]=o,A=(i,t)=>{for(var o in t||(t={}))ge.call(t,o)&&E(i,o,t[o]);if(q)for(var o of q(t))be.call(t,o)&&E(i,o,t[o]);return i},v=(i,t)=>he(i,Ae(t));var g=(i,t,o)=>new Promise((c,I)=>{var F=f=>{try{y(o.next(f))}catch(m){I(m)}},b=f=>{try{y(o.throw(f))}catch(m){I(m)}},y=f=>f.done?c(f.value):Promise.resolve(f.value).then(F,b);y((o=o.apply(i,t)).next())});const S="multi-app",K="subAppsChange",h="subAppsChange",C=()=>{const{t:e}=F.useTranslation([S,"core"]);return{t:e}},l=e=>`{{t("${e}", { ns: ["${S}", "client"] })}}`,_={type:"void","x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{app:{type:"void","x-component":"AppManager","x-component-props":{admin:!1}}}},M=()=>{const{insert:e}=t.useSchemaInitializer(),n=t.useSchemaInitializerItem(),r=b.useCallback(()=>e(_),[e]);return o.jsx(t.SchemaInitializerItem,v(A({},n),{onClick:r}))},U=e=>{const n=t.useApp(),r=e.value&&o.jsx("a",{target:"_blank",href:n.getRouteUrl(`/apps/${e.value}/admin`),rel:"noreferrer",children:e.value});return o.jsxs("div",{style:e.style,children:[e.addonBefore,e.prefix,r,e.suffix,e.addonAfter]})},j=y.connect(c.Input,y.mapReadPretty(U)),H=t.createStyles(({token:e})=>({button:{color:e.colorTextHeaderMenu+" !important"}})),G=()=>{const{styles:e}=H(),{data:n,run:r}=t.useRequest({resource:"applications",action:"listPinned"},{manual:!0}),{t:s}=C(),a=t.useApp(),d=[...((n==null?void 0:n.data)||[]).map(p=>{let u=a.getRouteUrl(`/apps/${p.name}/admin/`);return p.cname&&(u=`//${p.cname}`),{key:p.name,label:o.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:p.displayName||p.name})}}),{key:".manager",label:o.jsx(I.Link,{to:a.systemSettingsManager.getRoutePath("system-services."+S),children:s("Manage applications")})}];return o.jsx(c.Dropdown,{onOpenChange:p=>{r()},menu:{items:d},children:o.jsx(c.Button,{className:e.button,title:"Apps",icon:o.jsx(t.Icon,{type:"AppstoreOutlined"})})})},Y=e=>o.jsx(t.PinnedPluginListProvider,{items:{am:{order:201,component:"MultiAppManager",pin:!0,snippet:"pm.*",belongTo:"pinnedmenu"}},children:o.jsx(t.SchemaComponentOptions,{components:{MultiAppManager:G,AppNameInput:j,MultiAppBlockInitializer:M},children:e.children})});class W extends t.Plugin{load(){return g(this,null,function*(){this.app.use(Y)})}}const D={name:"applications",filterTargetKey:"name",targetKey:"name",fields:[{type:"uid",name:"name",primaryKey:!0,prefix:"a",interface:"input",uiSchema:{type:"string",title:l("App ID"),required:!0,"x-component":"Input","x-validator":"uid"}},{type:"string",name:"displayName",interface:"input",uiSchema:{type:"string",title:l("App display name"),required:!0,"x-component":"Input"}},{type:"string",name:"pinned",interface:"checkbox",uiSchema:{type:"boolean","x-content":l("Pin to menu"),"x-component":"Checkbox"}},{type:"string",name:"status",interface:"radioGroup",defaultValue:"pending",uiSchema:{type:"string",title:l("App status"),enum:[{label:l("Initializing"),value:"initializing"},{label:l("Initialized"),value:"initialized"},{label:l("Running"),value:"running"},{label:l("Commanding"),value:"commanding"},{label:l("Stopped"),value:"stopped"},{label:l("Error"),value:"error"},{label:l("Not found"),value:"not_found"}],"x-component":"Radio.Group"}},{type:"string",name:"isTemplate",interface:"checkbox",uiSchema:{type:"boolean","x-content":l("Is template"),"x-component":"Checkbox"}},{interface:"m2m",type:"belongsToMany",name:"partners",target:"users",through:"applicationsPartners",foreignKey:"applicationName",otherKey:"userId",collectionName:"applications",targetKey:"id",sourceKey:"name",uiSchema:{type:"array",title:l("Collaborator"),"x-component":"AssociationField","x-component-props":{service:{params:{fields:["id","username","nickname"]}},multiple:!0,fieldNames:{label:"username",value:"id"}}}}]},w={type:"void","x-component":"div",properties:{displayName:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":"{{ !createOnly }}","x-hidden":"{{ !admin }}"},cnamePrefix:{title:l("Custom domain prefix"),"x-component":"Input","x-decorator":"FormItem","x-validator":`{{(value) => {
1
+ (function(c,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("antd"),require("react-router-dom"),require("react-i18next"),require("react"),require("@tachybase/schema"),require("@tego/client"),require("@ant-design/icons")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","antd","react-router-dom","react-i18next","react","@tachybase/schema","@tego/client","@ant-design/icons"],t):(c=typeof globalThis!="undefined"?globalThis:c||self,t(c["@tachybase/module-multi-app"]={},c["@tachybase/client"],c.jsxRuntime,c.antd,c["react-router-dom"],c["react-i18next"],c.react,c["@tachybase/schema"],c["@tego/client"],c["@ant-design/icons"]))})(this,function(c,t,n,s,F,T,f,x,A,y){"use strict";var fe=Object.defineProperty,Ae=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var _=(c,t,n)=>t in c?fe(c,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[t]=n,b=(c,t)=>{for(var n in t||(t={}))be.call(t,n)&&_(c,n,t[n]);if(K)for(var n of K(t))ve.call(t,n)&&_(c,n,t[n]);return c},S=(c,t)=>Ae(c,ge(t));var h=(c,t,n)=>new Promise((s,F)=>{var T=A=>{try{x(n.next(A))}catch(y){F(y)}},f=A=>{try{x(n.throw(A))}catch(y){F(y)}},x=A=>A.done?s(A.value):Promise.resolve(A.value).then(T,f);x((n=n.apply(c,t)).next())});const k="multi-app",U="subAppsChange",g="subAppsChange",v=()=>{const{t:e}=T.useTranslation([k,"core"]);return{t:e}},l=e=>`{{t("${e}", { ns: ["${k}", "client"] })}}`,j={type:"void","x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{app:{type:"void","x-component":"AppManager","x-component-props":{admin:!1}}}},z=()=>{const{insert:e}=t.useSchemaInitializer(),o=t.useSchemaInitializerItem(),r=f.useCallback(()=>e(j),[e]);return n.jsx(t.SchemaInitializerItem,S(b({},o),{onClick:r}))},H=e=>{const o=t.useApp(),r=e.value&&n.jsx("a",{target:"_blank",href:o.getRouteUrl(`/apps/${e.value}/admin`),rel:"noreferrer",children:e.value});return n.jsxs("div",{style:e.style,children:[e.addonBefore,e.prefix,r,e.suffix,e.addonAfter]})},G=x.connect(s.Input,x.mapReadPretty(H)),Y=t.createStyles(({token:e})=>({button:{color:e.colorTextHeaderMenu+" !important"}})),W=()=>{const{styles:e}=Y(),{data:o,run:r}=t.useRequest({resource:"applications",action:"listPinned"},{manual:!0}),{t:p}=v(),a=t.useApp(),d=[...((o==null?void 0:o.data)||[]).map(i=>{let m=a.getRouteUrl(`/apps/${i.name}/admin/`);return i.cname&&(m=`//${i.cname}`),{key:i.name,label:n.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",children:i.displayName||i.name})}}),{key:".manager",label:n.jsx(F.Link,{to:a.systemSettingsManager.getRoutePath("system-services."+k),children:p("Manage applications")})}];return n.jsx(s.Dropdown,{onOpenChange:i=>{r()},menu:{items:d},children:n.jsx(s.Button,{className:e.button,title:"Apps",icon:n.jsx(t.Icon,{type:"AppstoreOutlined"})})})},J=e=>n.jsx(t.PinnedPluginListProvider,{items:{am:{order:201,component:"MultiAppManager",pin:!0,snippet:"pm.*",belongTo:"pinnedmenu"}},children:n.jsx(t.SchemaComponentOptions,{components:{MultiAppManager:W,AppNameInput:G,MultiAppBlockInitializer:z},children:e.children})});class Q extends t.Plugin{load(){return h(this,null,function*(){this.app.use(J)})}}const D={name:"applications",filterTargetKey:"name",targetKey:"name",fields:[{type:"uid",name:"name",primaryKey:!0,prefix:"a",interface:"input",uiSchema:{type:"string",title:l("App ID"),required:!0,"x-component":"Input","x-validator":"uid"}},{type:"string",name:"displayName",interface:"input",uiSchema:{type:"string",title:l("App display name"),required:!0,"x-component":"Input"}},{type:"string",name:"pinned",interface:"checkbox",uiSchema:{type:"boolean","x-content":l("Pin to menu"),"x-component":"Checkbox"}},{type:"string",name:"status",interface:"radioGroup",defaultValue:"pending",uiSchema:{type:"string",title:l("App status"),enum:[{label:l("Initializing"),value:"initializing"},{label:l("Initialized"),value:"initialized"},{label:l("Running"),value:"running"},{label:l("Commanding"),value:"commanding"},{label:l("Stopped"),value:"stopped"},{label:l("Error"),value:"error"},{label:l("Not found"),value:"not_found"}],"x-component":"Radio.Group"}},{type:"string",name:"isTemplate",interface:"checkbox",uiSchema:{type:"boolean","x-content":l("Is template"),"x-component":"Checkbox"}},{interface:"m2m",type:"belongsToMany",name:"partners",target:"users",through:"applicationsPartners",foreignKey:"applicationName",otherKey:"userId",collectionName:"applications",targetKey:"id",sourceKey:"name",uiSchema:{type:"array",title:l("Collaborator"),"x-component":"AssociationField","x-component-props":{service:{params:{fields:["id","username","nickname"]}},multiple:!0,fieldNames:{label:"username",value:"id"}}}}]},P={type:"void","x-component":"div",properties:{displayName:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":"{{ !createOnly }}","x-hidden":"{{ !admin }}"},cnamePrefix:{title:l("Custom domain prefix"),"x-component":"Input","x-decorator":"FormItem","x-validator":`{{(value) => {
2
2
  if (!value) {
3
3
  return null;
4
4
  }
5
5
  if (!/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/.test(value)) {
6
6
  return t("Custom domain prefix must be 1-63 characters, lowercase letters, numbers, or hyphens (-), and cannot start or end with a hyphen (-)");
7
7
  }
8
- }}}`,"x-component-props":{addonAfter:`.${window.location.hostname}`},"x-reactions":[{dependencies:["cname"],fulfill:{state:{value:'{{ ($deps[0] && $deps[0].replace(new RegExp("\\."+window.location.hostname+"$"), "")) || "" }}'}}}]},cname:{"x-hidden":!0,"x-component":"Input","x-decorator":"FormItem","x-read-pretty":!0,"x-reactions":{dependencies:["cnamePrefix"],fulfill:{state:{value:`{{$deps[0] ? $deps[0] + ".${window.location.hostname}" : null}}`}}}},tmpl:{title:l("Template"),"x-component":"RemoteSelect","x-component-props":{placeholder:l("Can be empty, or selected from the template library or personal applications"),fieldNames:{label:"displayName",value:"name"},service:{resource:"applications",params:{filter:{$or:[{isTemplate:!0},{createdById:"{{ userId }}"}]}}}},"x-decorator":"FormItem","x-disabled":"{{ !createOnly }}"},"options.startEnvs":{type:"string",title:l("Start environment variables"),"x-component":"Input.TextArea","x-decorator":"FormItem","x-hidden":!0},pinned:{"x-component":"CollectionField","x-decorator":"FormItem","x-hidden":"{{ !admin }}"},isTemplate:{"x-component":"CollectionField","x-decorator":"FormItem","x-hidden":"{{ !admin }}"},icon:{type:"string",title:'{{ t("Icon") }}',"x-component":"IconPicker","x-decorator":"FormItem"},color:{type:"string",title:'{{ t("Color") }}',"x-component":"ColorPicker","x-decorator":"FormItem",default:"#e5e5e5"}}},B={properties:{view:{type:"void","x-component":"AppVisitor","x-component-props":{admin:"{{ admin }}"}},update:{type:"void",title:'{{t("Edit")}}',"x-component":"Action.Link",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Edit")}}',properties:{formSchema:w,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useMultiAppUpdateAction","x-component-props":{type:"primary"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},share:{type:"void",title:'{{t("Share")}}',"x-component":"Action.Link",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Share")}}',properties:{partners:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"applications.partners"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useMultiAppUpdateAction","x-component-props":{type:"primary"}}}}}}}}}},J={type:"void",properties:{applicationsTable:{type:"void","x-decorator":"TableBlockProvider","x-decorator-props":{collection:D,action:"list",params:{pageSize:20,sort:["-createdAt"],appends:["partners.id","partners.username"],filter:"{{ admin ? {} : { '$or': [ { createdById: userId }, { 'partners.id': { '$in': [userId] } } ] } }}"},rowKey:"name"},properties:{GlobalNotificationHandler:{type:"void","x-component":"GlobalNotificationHandler"},actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{fuzzySearch:{type:"void","x-component":"FuzzySearchInput","x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action","x-decorator":"ACLActionProvider","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-hidden":"{{ !admin }}"},startAll:{type:"void",title:'{{ t("Start all") }}',"x-component":"Action","x-use-component-props":"useStartAllAction","x-component-props":{icon:"FastForwardOutlined",danger:!0,confirm:{title:l("Start all"),content:l("Starting all sub-applications may cause lag. The more applications you have, the longer the waiting time")}},"x-hidden":"{{ !admin }}"},stopAll:{type:"void",title:'{{ t("Stop all") }}',"x-component":"Action","x-use-component-props":"useStopAllAction","x-component-props":{icon:"StopOutlined",danger:!0,confirm:{title:l("Stop all"),content:l("All sub-applications have stopped serving, unless you restart them")}},"x-hidden":"{{ !admin }}"},create:{type:"void",title:'{{t("Add new")}}',"x-decorator":e=>b.createElement(t.SchemaComponentOptions,v(A({},e),{scope:{createOnly:!0}})),"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(e){const n=t.useActionContext();return t.useRequest(()=>Promise.resolve({data:{name:`a_${y.uid()}`}}),v(A({},e),{refreshDeps:[n.visible]}))}},title:'{{t("Add new")}}',properties:{formSchema:w,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateDatabaseConnectionAction","x-component-props":{type:"primary"}}}}}}}}}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"}},properties:{displayName:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{displayName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},pinned:{type:"void",title:l("Pin to menu"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{pinned:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},isTemplate:{type:"void",title:l("Is template"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{isTemplate:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{status:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:A({type:"void","x-component":"Space","x-component-props":{split:"|"}},B)}}}}}}}},Q=()=>{const e=y.useForm(),n=y.useField(),r=t.useActionContext(),s=t.useDataBlockRequest(),a=t.useDataBlockResource();return{onClick(){return g(this,null,function*(){try{yield e.submit(),n.data=n.data||{},n.data.loading=!0,yield a.create({values:e.values}),r.setVisible(!1),yield e.reset(),n.data.loading=!1,s.refresh()}catch(p){n.data&&(n.data.loading=!1)}})}}},z=e=>{const{t:n}=C(),r=t.useAPIClient(),s=b.useMemo(()=>r.resource("applications"),[r]);return{handleStart:()=>g(null,null,function*(){try{c.notification.info({key:h,message:o.jsxs("span",{children:[n("Processing..."),"    ",o.jsx(c.Spin,{indicator:o.jsx(m.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0});const p=yield s.start({filterByTk:e.name});(p==null?void 0:p.status)===205&&c.notification.info({key:h,message:n("App is already running")})}catch(p){c.notification.error({key:h,message:n("Failed to start app")})}}),handleStop:()=>{s.stop({filterByTk:e.name}).then(()=>{c.notification.info({key:h,message:o.jsxs("span",{children:[n("Processing..."),"    ",o.jsx(c.Spin,{indicator:o.jsx(m.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0})})}}},V=e=>{const n=y.useField(),r=y.useForm(),s=t.useActionContext(),a=t.useDataBlockRequest(),d=t.useDataBlockResource(),p=t.useCollectionRecordData(),{record:u}=t.useRecord(),x=(p==null?void 0:p.name)||(u==null?void 0:u.name);return{onClick(){return g(this,null,function*(){var T;yield r.submit(),n.data=n.data||{},n.data.loading=!0;try{const k=yield d.update({filterByTk:x,values:r.values});s.setVisible(!1),yield r.reset(),a.refresh(),e==null||e(x,(T=k==null?void 0:k.data)==null?void 0:T.data)}catch(k){console.error(k)}finally{n.data.loading=!1}})}}};function N({name:e,cname:n}){const r=t.useApp();return n?`//${n}`:r.getRouteUrl(`/apps/${e}/admin/`)}const O=()=>{const e=t.useDataBlockResource(),{t:n}=C();return{onClick(){return g(this,null,function*(){var a,d;const s=yield e.startAll();c.notification.info({key:h,message:o.jsxs("span",{children:[n("Processing..."),"    ",o.jsx(c.Spin,{indicator:o.jsx(m.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0}),((d=(a=s==null?void 0:s.data)==null?void 0:a.data)==null?void 0:d.all)===0&&c.notification.info({key:h,message:`${n("Start count")}: 0/0!`})})}}},$=()=>{const e=t.useDataBlockResource(),{t:n}=C();return{onClick(){return g(this,null,function*(){var a,d;const s=yield e.stopAll();if(((d=(a=s==null?void 0:s.data)==null?void 0:a.data)==null?void 0:d.all)===0){c.notification.info({key:h,message:`${n("Stop count")}: 0/0!`});return}c.notification.info({key:h,message:o.jsxs("span",{children:[n("Processing..."),"    ",o.jsx(c.Spin,{indicator:o.jsx(m.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0})})}}},X=()=>{const e=t.useCollectionRecordData();return N({name:e.name,cname:e.cname})},Z=()=>{const{t:e}=C(),n=X(),r=t.useCollectionRecordData(),{handleStart:s,handleStop:a}=z(r);return o.jsxs(c.Space,{split:o.jsx(c.Divider,{type:"horizontal"}),children:[o.jsx(t.TrackingLink,{href:n,target:"_blank",rel:"noreferrer",trackingKey:"multiapp_linkView",children:e("View",{ns:S})}),r.status!=="running"&&o.jsx("a",{onClick:()=>s(),children:e("Start",{ns:S})}),r.status!=="stopped"&&o.jsx("a",{onClick:()=>a(),children:e("Stop",{ns:S})})]})},R=e=>{const{data:n,mutate:r,refresh:s}=t.useDataBlockRequest();return t.useNoticeSub(K,a=>{const d=c.notification[a.level]||c.notification.info;if(a.message?d({key:h,message:a.message}):a.status!=="commanding"&&a.status!=="initializing"&&c.notification.destroy(h),!(n!=null&&n.data)||a.refresh){s();return}if(!a.app&&!a.status||!n.data.some(x=>x.name===a.app))return;const u=[...n.data];u.find(x=>x.name===a.app).status=a.status,r(v(A({},n),{data:u}))}),null},L=e=>{var d,p;const{admin:n=!0}=e,r=t.useCurrentUserContext(),s=(p=(d=r==null?void 0:r.data)==null?void 0:d.data)==null?void 0:p.id,{t:a}=C();return o.jsx(c.Card,{bordered:!1,children:o.jsx(t.ExtendCollectionsProvider,{collections:[D],children:o.jsx(t.SchemaComponent,{schema:J,scope:{admin:n,userId:s,useCreateDatabaseConnectionAction:Q,useMultiAppUpdateAction:V,useStartAllAction:O,useStopAllAction:$,t:a,uid:f.uid},components:{AppVisitor:Z,GlobalNotificationHandler:R}})})})};class ee extends t.Plugin{load(){return g(this,null,function*(){this.app.systemSettingsManager.add(`system-services.${S}`,{title:l("Multi-app manager"),icon:"AppstoreOutlined",Component:L,aclSnippet:"pm.multi-app.applications"})})}}const te={type:"void","x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{app:{type:"void","x-component":"ViewMultiAppPane","x-component-props":{admin:!1}}}},oe=()=>{const{insert:e}=t.useSchemaInitializer(),n=t.useSchemaInitializerItem(),r=b.useCallback(()=>e(te),[e]);return o.jsx(t.SchemaInitializerItem,v(A({},n),{onClick:r}))},ne={type:"void",properties:{update:{type:"void","x-component":"Action","x-component-props":{icon:"editoutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Edit")}}',properties:{formSchema:w,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useMultiAppUpdateAction","x-component-props":{type:"primary"}}}}}}}},delete:{type:"void","x-component":"Action","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"deleteoutlined",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}},re={type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{create:{type:"void",title:'{{t("Add new")}}',"x-decorator":e=>b.createElement(t.SchemaComponentOptions,v(A({},e),{scope:{createOnly:!0}})),"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(e){const n=t.useActionContext();return t.useRequest(()=>Promise.resolve({data:{name:`a_${f.uid()}`}}),v(A({},e),{refreshDeps:[n.visible]}))}},title:'{{t("Add new")}}',properties:{formSchema:w,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateDatabaseConnectionAction","x-component-props":{type:"primary"}}}}}}}}}},ae=t.createStyles(({css:e,token:n})=>({appAction:e`
8
+ }}}`,"x-component-props":{addonAfter:`.${window.location.hostname}`},"x-reactions":[{dependencies:["cname"],fulfill:{state:{value:'{{ ($deps[0] && $deps[0].replace(new RegExp("\\."+window.location.hostname+"$"), "")) || "" }}'}}}]},cname:{"x-hidden":!0,"x-component":"Input","x-decorator":"FormItem","x-read-pretty":!0,"x-reactions":{dependencies:["cnamePrefix"],fulfill:{state:{value:`{{$deps[0] ? $deps[0] + ".${window.location.hostname}" : null}}`}}}},tmpl:{title:l("Template"),"x-component":"RemoteSelect","x-component-props":{placeholder:l("Can be empty, or selected from the template library or personal applications"),fieldNames:{label:"displayName",value:"name"},service:{resource:"applications",params:{filter:{$or:[{isTemplate:!0},{createdById:"{{ userId }}"}]}}}},"x-decorator":"FormItem","x-disabled":"{{ !createOnly }}"},"options.startEnvs":{type:"string",title:l("Start environment variables"),"x-component":"Input.TextArea","x-decorator":"FormItem","x-hidden":!0},pinned:{"x-component":"CollectionField","x-decorator":"FormItem","x-hidden":"{{ !admin }}"},isTemplate:{"x-component":"CollectionField","x-decorator":"FormItem","x-hidden":"{{ !admin }}"},icon:{type:"string",title:'{{ t("Icon") }}',"x-component":"IconPicker","x-decorator":"FormItem"},color:{type:"string",title:'{{ t("Color") }}',"x-component":"ColorPicker","x-decorator":"FormItem",default:"#e5e5e5"}}},V={properties:{view:{type:"void","x-component":"AppVisitor","x-component-props":{admin:"{{ admin }}"}},update:{type:"void",title:'{{t("Edit")}}',"x-component":"Action.Link",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Edit")}}',properties:{formSchema:P,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useMultiAppUpdateAction","x-component-props":{type:"primary"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},share:{type:"void",title:'{{t("Share")}}',"x-component":"Action.Link",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Add partners")}}',properties:{partners:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"applications.partners"},byPhone:{title:'{{t("Add by Phone Number")}}',"x-decorator":"FormItem","x-component":"AddByPhone"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useMultiAppUpdateAction","x-component-props":{type:"primary"}}}}}}}}}},X={type:"void",properties:{applicationsTable:{type:"void","x-decorator":"TableBlockProvider","x-decorator-props":{collection:D,action:"list",params:{pageSize:20,sort:["-createdAt"],appends:["partners.id","partners.username"],filter:"{{ admin ? {} : { '$or': [ { createdById: userId }, { 'partners.id': { '$in': [userId] } } ] } }}"},rowKey:"name"},properties:{GlobalNotificationHandler:{type:"void","x-component":"GlobalNotificationHandler"},actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{fuzzySearch:{type:"void","x-component":"FuzzySearchInput","x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action","x-decorator":"ACLActionProvider","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-hidden":"{{ !admin }}"},startAll:{type:"void",title:'{{ t("Start all") }}',"x-component":"Action","x-use-component-props":"useStartAllAction","x-component-props":{icon:"FastForwardOutlined",danger:!0,confirm:{title:l("Start all"),content:l("Starting all sub-applications may cause lag. The more applications you have, the longer the waiting time")}},"x-hidden":"{{ !admin }}"},stopAll:{type:"void",title:'{{ t("Stop all") }}',"x-component":"Action","x-use-component-props":"useStopAllAction","x-component-props":{icon:"StopOutlined",danger:!0,confirm:{title:l("Stop all"),content:l("All sub-applications have stopped serving, unless you restart them")}},"x-hidden":"{{ !admin }}"},create:{type:"void",title:'{{t("Add new")}}',"x-decorator":e=>f.createElement(t.SchemaComponentOptions,S(b({},e),{scope:{createOnly:!0}})),"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(e){const o=t.useActionContext();return t.useRequest(()=>Promise.resolve({data:{name:`a_${x.uid()}`}}),S(b({},e),{refreshDeps:[o.visible]}))}},title:'{{t("Add new")}}',properties:{formSchema:P,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateDatabaseConnectionAction","x-component-props":{type:"primary"}}}}}}}}}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"}},properties:{displayName:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{displayName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},pinned:{type:"void",title:l("Pin to menu"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{pinned:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},isTemplate:{type:"void",title:l("Is template"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{isTemplate:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{status:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:b({type:"void","x-component":"Space","x-component-props":{split:"|"}},V)}}}}}}}},Z=()=>{const e=x.useForm(),o=t.useAPIClient(),{t:r}=v(),[p,a]=f.useState(!1),d=i=>h(null,null,function*(){var m;if(!/^1[3-9]\d{9}$/.test(i)){s.message.warning(r("Not a valid cellphone number, please re-enter"));return}a(!0);try{const{data:u}=yield o.resource("users").list({filter:{phone:i}}),w=(u==null?void 0:u.data)||[];if(!w.length){s.message.info(r("PhoneNumber not found"));return}const I=((m=e.values)==null?void 0:m.partners)||[],C=[...I,...w.filter(M=>!I.some(B=>B.id===M.id))];yield e.setValuesIn("partners",C),s.message.success(r("User already exist"))}catch(u){console.error(u)}finally{a(!1)}});return n.jsx(s.Input.Search,{placeholder:r("Enter phone number please"),onSearch:d,loading:p,enterButton:r("Add user")})},R=()=>{const e=x.useForm(),o=x.useField(),r=t.useActionContext(),p=t.useDataBlockRequest(),a=t.useDataBlockResource();return{onClick(){return h(this,null,function*(){try{yield e.submit(),o.data=o.data||{},o.data.loading=!0,yield a.create({values:e.values}),r.setVisible(!1),yield e.reset(),o.data.loading=!1,p.refresh()}catch(i){o.data&&(o.data.loading=!1)}})}}},N=e=>{const{t:o}=v(),r=t.useAPIClient(),p=f.useMemo(()=>r.resource("applications"),[r]);return{handleStart:()=>h(null,null,function*(){try{s.notification.info({key:g,message:n.jsxs("span",{children:[o("Processing..."),"    ",n.jsx(s.Spin,{indicator:n.jsx(y.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0});const i=yield p.start({filterByTk:e.name});(i==null?void 0:i.status)===205&&s.notification.info({key:g,message:o("App is already running")})}catch(i){s.notification.error({key:g,message:o("Failed to start app")})}}),handleStop:()=>{p.stop({filterByTk:e.name}).then(()=>{s.notification.info({key:g,message:n.jsxs("span",{children:[o("Processing..."),"    ",n.jsx(s.Spin,{indicator:n.jsx(y.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0})})}}},O=e=>{const o=x.useField(),r=x.useForm(),p=t.useActionContext(),a=t.useDataBlockRequest(),d=t.useDataBlockResource(),i=t.useCollectionRecordData(),{record:m}=t.useRecord(),u=(i==null?void 0:i.name)||(m==null?void 0:m.name);return{onClick(){return h(this,null,function*(){var I;yield r.submit(),o.data=o.data||{},o.data.loading=!0;try{const C=yield d.update({filterByTk:u,values:r.values});p.setVisible(!1),yield r.reset(),a.refresh(),e==null||e(u,(I=C==null?void 0:C.data)==null?void 0:I.data)}catch(C){console.error(C)}finally{o.data.loading=!1}})}}};function $({name:e,cname:o}){const r=t.useApp();return o?`//${o}`:r.getRouteUrl(`/apps/${e}/admin/`)}const L=()=>{const e=t.useDataBlockResource(),{t:o}=v();return{onClick(){return h(this,null,function*(){var a,d;const p=yield e.startAll();s.notification.info({key:g,message:n.jsxs("span",{children:[o("Processing..."),"    ",n.jsx(s.Spin,{indicator:n.jsx(y.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0}),((d=(a=p==null?void 0:p.data)==null?void 0:a.data)==null?void 0:d.all)===0&&s.notification.info({key:g,message:`${o("Start count")}: 0/0!`})})}}},q=()=>{const e=t.useDataBlockResource(),{t:o}=v();return{onClick(){return h(this,null,function*(){var a,d;const p=yield e.stopAll();if(((d=(a=p==null?void 0:p.data)==null?void 0:a.data)==null?void 0:d.all)===0){s.notification.info({key:g,message:`${o("Stop count")}: 0/0!`});return}s.notification.info({key:g,message:n.jsxs("span",{children:[o("Processing..."),"    ",n.jsx(s.Spin,{indicator:n.jsx(y.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0})})}}},ee=()=>{const e=t.useCollectionRecordData();return $({name:e.name,cname:e.cname})},te=()=>{const{t:e}=v(),o=ee(),r=t.useCollectionRecordData(),{handleStart:p,handleStop:a}=N(r);return n.jsxs(s.Space,{split:n.jsx(s.Divider,{type:"horizontal"}),children:[n.jsx(t.TrackingLink,{href:o,target:"_blank",rel:"noreferrer",trackingKey:"multiapp_linkView",children:e("View",{ns:k})}),r.status!=="running"&&n.jsx("a",{onClick:()=>p(),children:e("Start",{ns:k})}),r.status!=="stopped"&&n.jsx("a",{onClick:()=>a(),children:e("Stop",{ns:k})})]})},oe=e=>{const{data:o,mutate:r,refresh:p}=t.useDataBlockRequest();return t.useNoticeSub(U,a=>{const d=s.notification[a.level]||s.notification.info;if(a.message?d({key:g,message:a.message}):a.status!=="commanding"&&a.status!=="initializing"&&s.notification.destroy(g),!(o!=null&&o.data)||a.refresh){p();return}if(!a.app&&!a.status||!o.data.some(u=>u.name===a.app))return;const m=[...o.data];m.find(u=>u.name===a.app).status=a.status,r(S(b({},o),{data:m}))}),null},E=e=>{var d,i;const{admin:o=!0}=e,r=t.useCurrentUserContext(),p=(i=(d=r==null?void 0:r.data)==null?void 0:d.data)==null?void 0:i.id,{t:a}=v();return n.jsx(s.Card,{bordered:!1,children:n.jsx(t.ExtendCollectionsProvider,{collections:[D],children:n.jsx(t.SchemaComponent,{schema:X,scope:{admin:o,userId:p,useCreateDatabaseConnectionAction:R,useMultiAppUpdateAction:O,useStartAllAction:L,useStopAllAction:q,t:a,uid:A.uid},components:{AppVisitor:te,GlobalNotificationHandler:oe,AddByPhone:Z}})})})};class ne extends t.Plugin{load(){return h(this,null,function*(){this.app.systemSettingsManager.add(`system-services.${k}`,{title:l("Multi-app manager"),icon:"AppstoreOutlined",Component:E,aclSnippet:"pm.multi-app.applications"})})}}const re={type:"void","x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{app:{type:"void","x-component":"ViewMultiAppPane","x-component-props":{admin:!1}}}},ae=()=>{const{insert:e}=t.useSchemaInitializer(),o=t.useSchemaInitializerItem(),r=f.useCallback(()=>e(re),[e]);return n.jsx(t.SchemaInitializerItem,S(b({},o),{onClick:r}))},ie={type:"void",properties:{update:{type:"void","x-component":"Action","x-component-props":{icon:"editoutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Edit")}}',properties:{formSchema:P,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useMultiAppUpdateAction","x-component-props":{type:"primary"}}}}}}}},delete:{type:"void","x-component":"Action","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"deleteoutlined",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}},se={type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{create:{type:"void",title:'{{t("Add new")}}',"x-decorator":e=>f.createElement(t.SchemaComponentOptions,S(b({},e),{scope:{createOnly:!0}})),"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(e){const o=t.useActionContext();return t.useRequest(()=>Promise.resolve({data:{name:`a_${A.uid()}`}}),S(b({},e),{refreshDeps:[o.visible]}))}},title:'{{t("Add new")}}',properties:{formSchema:P,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateDatabaseConnectionAction","x-component-props":{type:"primary"}}}}}}}}}},pe=t.createStyles(({css:e,token:o})=>({appAction:e`
9
9
  width: 100%;
10
10
  display: flex;
11
11
  justify-content: flex-end;
@@ -16,7 +16,7 @@
16
16
  .media-card {
17
17
  position: relative;
18
18
  transition: background-color 0.3s ease;
19
- border-radius: ${`${n.borderRadius}px`};
19
+ border-radius: ${`${o.borderRadius}px`};
20
20
  overflow: hidden;
21
21
  .media-actions {
22
22
  width: 100%;
@@ -47,4 +47,4 @@
47
47
  visibility: visible;
48
48
  }
49
49
  }
50
- `})),ie=()=>{C();const{styles:e}=ae(),n=t.useTableBlockContext(),r=n==null?void 0:n.service,{data:s,loading:a,run:d}=r||{},[p,u]=b.useState(!1);if(a)return o.jsx(c.Spin,{});const{data:x}=s||{};return o.jsxs(c.Card,{style:{backgroundColor:"transparent",border:"none",boxShadow:"none"},children:[o.jsx("div",{className:e.appAction,children:o.jsx(t.SchemaComponent,{schema:re})}),o.jsx("div",{className:e.appListStyle,children:x==null?void 0:x.map(P=>o.jsx(se,v(A({},P),{service:r,appStatus:p,setAppStatus:u}),P.name))})]})},se=e=>{const{name:n,cname:r,displayName:s,icon:a,color:d,status:p,service:u,appStatus:x,setAppStatus:P}=e,{t:T}=C(),k=N({name:n,cname:r}),ue=b.useCallback(()=>{window&&p==="running"?window.open(k,"_blank"):c.message.warning(T("App is not running"))},[r,p]),{handleStart:me,handleStop:xe}=z(e),ye=()=>{p==="running"?xe():me(),P(!x),u.refresh()};return o.jsx("div",{className:"media-card",children:o.jsxs(t.RecordProvider,{record:e,children:[o.jsxs("div",{className:"media-actions",children:[o.jsx(c.Button,{icon:p==="running"?o.jsx(m.StopOutlined,{}):o.jsx(m.CheckCircleOutlined,{}),onClick:ye}),o.jsx(t.SchemaComponent,{schema:ne,scope:{useMultiAppUpdateAction:V,useStartAllAction:O,useStopAllAction:$}})]}),o.jsx(t.MediaCard,{layout:"vertical",title:s,icon:a,color:p==="running"?d:void 0,needHover:!1,onClick:ue})]})})},pe={type:"void",properties:{multiApp:{"x-decorator":"TableBlockProvider","x-decorator-props":{collection:D,action:"list",params:{pageSize:20,sort:["-createdAt"],filter:"{{ admin ? {} : { '$or': [ { createdById: userId }, { 'partners.id': { '$in': [userId] } } ] } }}"},rowKey:"name"},"x-component":"AppList"}}},ce=()=>{var r,s;const e=t.useCurrentUserContext(),n=(s=(r=e==null?void 0:e.data)==null?void 0:r.data)==null?void 0:s.id;return o.jsx(t.SchemaComponent,{schema:pe,scope:{userId:n,admin:!1},components:{AppList:ie}})};class le extends t.Plugin{load(){return g(this,null,function*(){this.app.addComponents({AppManager:L,ViewMultiAppPane:ce});const n=this.app.schemaInitializerManager.get("page:addBlock");n.add("otherBlocks.multiApp",{name:"multiApp",title:l("Multi-app manager"),icon:o.jsx(m.AppstoreOutlined,{}),Component:M}),n.add("otherBlocks.showMultiApp",{name:"showMultiApp",title:l("Multi-app display"),icon:o.jsx(m.WindowsOutlined,{}),Component:oe})})}}class de extends t.Plugin{afterAdd(){return g(this,null,function*(){yield this.app.pm.add(W),yield this.app.pm.add(le),yield this.app.pm.add(ee)})}}i.default=de,i.formSchema=w,i.tableActionColumnSchema=B,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
50
+ `})),ce=()=>{v();const{styles:e}=pe(),o=t.useTableBlockContext(),r=o==null?void 0:o.service,{data:p,loading:a,run:d}=r||{},[i,m]=f.useState(!1);if(a)return n.jsx(s.Spin,{});const{data:u}=p||{};return n.jsxs(s.Card,{style:{backgroundColor:"transparent",border:"none",boxShadow:"none"},children:[n.jsx("div",{className:e.appAction,children:n.jsx(t.SchemaComponent,{schema:se})}),n.jsx("div",{className:e.appListStyle,children:u==null?void 0:u.map(w=>n.jsx(le,S(b({},w),{service:r,appStatus:i,setAppStatus:m}),w.name))})]})},le=e=>{const{name:o,cname:r,displayName:p,icon:a,color:d,status:i,service:m,appStatus:u,setAppStatus:w}=e,{t:I}=v(),C=$({name:o,cname:r}),M=f.useCallback(()=>{window&&i==="running"?window.open(C,"_blank"):s.message.warning(I("App is not running"))},[r,i]),{handleStart:B,handleStop:ye}=N(e),he=()=>{i==="running"?ye():B(),w(!u),m.refresh()};return n.jsx("div",{className:"media-card",children:n.jsxs(t.RecordProvider,{record:e,children:[n.jsxs("div",{className:"media-actions",children:[n.jsx(s.Button,{icon:i==="running"?n.jsx(y.StopOutlined,{}):n.jsx(y.CheckCircleOutlined,{}),onClick:he}),n.jsx(t.SchemaComponent,{schema:ie,scope:{useMultiAppUpdateAction:O,useStartAllAction:L,useStopAllAction:q}})]}),n.jsx(t.MediaCard,{layout:"vertical",title:p,icon:a,color:i==="running"?d:void 0,needHover:!1,onClick:M})]})})},de={type:"void",properties:{multiApp:{"x-decorator":"TableBlockProvider","x-decorator-props":{collection:D,action:"list",params:{pageSize:20,sort:["-createdAt"],filter:"{{ admin ? {} : { '$or': [ { createdById: userId }, { 'partners.id': { '$in': [userId] } } ] } }}"},rowKey:"name"},"x-component":"AppList"}}},ue=()=>{var r,p;const e=t.useCurrentUserContext(),o=(p=(r=e==null?void 0:e.data)==null?void 0:r.data)==null?void 0:p.id;return n.jsx(t.SchemaComponent,{schema:de,scope:{userId:o,admin:!1},components:{AppList:ce}})};class me extends t.Plugin{load(){return h(this,null,function*(){this.app.addComponents({AppManager:E,ViewMultiAppPane:ue});const o=this.app.schemaInitializerManager.get("page:addBlock");o.add("otherBlocks.multiApp",{name:"multiApp",title:l("Multi-app manager"),icon:n.jsx(y.AppstoreOutlined,{}),Component:z}),o.add("otherBlocks.showMultiApp",{name:"showMultiApp",title:l("Multi-app display"),icon:n.jsx(y.WindowsOutlined,{}),Component:ae})})}}class xe extends t.Plugin{afterAdd(){return h(this,null,function*(){yield this.app.pm.add(Q),yield this.app.pm.add(me),yield this.app.pm.add(ne)})}}c.default=xe,c.formSchema=P,c.tableActionColumnSchema=V,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,4 +1,4 @@
1
1
  export declare const usePluginUtils: () => {
2
- t: import("i18next").TFunction<[string, string], undefined>;
2
+ t: import("i18next").TFunction<readonly ["multi-app", "core"], undefined>;
3
3
  };
4
4
  export declare const i18nText: (text: any) => string;
@@ -0,0 +1 @@
1
+ export declare const AddByPhone: () => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  module.exports = {
2
- "react-i18next": "15.2.0",
3
- "@tachybase/client": "1.3.25",
2
+ "react-i18next": "16.2.1",
3
+ "@tachybase/client": "1.5.0",
4
4
  "@tego/server": "1.3.52",
5
5
  "lodash": "4.17.21",
6
6
  "mysql2": "3.14.3",
@@ -9,6 +9,6 @@ module.exports = {
9
9
  "@tachybase/schema": "1.3.52",
10
10
  "antd": "5.22.5",
11
11
  "react-router-dom": "6.28.1",
12
- "@ant-design/icons": "5.6.1",
13
- "@tego/client": "1.3.52"
12
+ "@tego/client": "1.3.52",
13
+ "@ant-design/icons": "5.6.1"
14
14
  };
@@ -1,4 +1,7 @@
1
1
  {
2
+ "Add by Phone Number": "通过手机添加",
3
+ "Add partners": "添加协作者",
4
+ "Add user": "添加用户",
2
5
  "All sub-applications have stopped serving, unless you restart them": "所有子应用停止服务,除非你重新打开",
3
6
  "App ID": "应用标识",
4
7
  "App already started": "应用已启动",
@@ -15,6 +18,7 @@
15
18
  "Custom domain": "自定义域名",
16
19
  "Custom domain prefix": "自定义域名前缀",
17
20
  "Custom domain prefix must be 1-63 characters, lowercase letters, numbers, or hyphens (-), and cannot start or end with a hyphen (-)": "自定义域名前缀必须为1-63位小写字母、数字或短横线(-),且不能以短横线(-)开头或结尾",
21
+ "Enter phone number please": "请输入手机号",
18
22
  "Error": "错误",
19
23
  "Failed to start app": "启动应用失败",
20
24
  "Initialized": "初始化完成",
@@ -23,7 +27,9 @@
23
27
  "Manage applications": "管理应用",
24
28
  "Multi-app display": "多应用展示",
25
29
  "Multi-app manager": "多应用管理",
30
+ "Not a valid cellphone number, please re-enter": "不是有效的手机号,请重新输入",
26
31
  "Not found": "未找到",
32
+ "PhoneNumber not found": "未找到该手机用户",
27
33
  "Pin to menu": "在菜单上显示",
28
34
  "Please enter a valid custom domain prefix": "请输入有效的自定义域名前缀",
29
35
  "Preset": "预设",
@@ -47,5 +53,6 @@
47
53
  "Template is in use": "模板正在使用",
48
54
  "Template not exists": "模板不存在",
49
55
  "This database does not support to create application using template": "该数据库不支持使用模板创建应用程序",
56
+ "User already exist": "用户已存在",
50
57
  "View": "访问"
51
58
  }
@@ -1 +1 @@
1
- {"name":"mariadb","version":"2.5.6","description":"fast mariadb/mysql connector.","main":"promise.js","types":"types/index.d.ts","directories":{"lib":"lib","test":"test"},"private":false,"scripts":{"test":"npm run test:types-prettier && npm run test:prettier && npm run test:types && npm run test:lint && npm run test:base","test:base":"mocha --no-parallel --timeout 5000 \"test/**/*.js\" ","test:lint":"eslint \"{lib,test}/**/*.js\" ","test:types":"eslint \"types/*.ts\" ","test:types-prettier":"prettier --write \"types/*.ts\"","test:prettier":"prettier --write \"{tools,lib,test,benchmarks}/**/*.js\"","coverage":"npm run coverage:test && npm run coverage:report","coverage:test":"nyc mocha --no-parallel --timeout 5000 \"test/**/*.js\"","coverage:report":"nyc report --reporter=text-lcov > coverage.lcov && codecov","benchmark":"node ./benchmarks/benchmarks.js","generate":"node ./tools/generate-mariadb.js"},"repository":{"type":"git","url":"git+https://github.com/mariadb-corporation/mariadb-connector-nodejs.git"},"keywords":["mariadb","mysql","client","driver","connector"],"files":["lib","types/index.d.ts","promise.js","callback.js"],"engines":{"node":">= 10.13"},"author":"Diego Dupin <diego.dupin@mariadb.com>","license":"LGPL-2.1-or-later","dependencies":{"@types/geojson":"^7946.0.8","@types/node":"^17.0.10","denque":"^2.0.1","iconv-lite":"^0.6.3","long":"^5.2.0","moment-timezone":"^0.5.34","please-upgrade-node":"^3.2.0"},"devDependencies":{"@typescript-eslint/eslint-plugin":"^5.10.0","@typescript-eslint/parser":"^5.10.0","benchmark":"^2.1.4","chai":"^4.3.4","codecov":"^3.8.2","chalk":"^4.1.2","dom-parser":"^0.1.6","error-stack-parser":"^2.0.6","eslint":"^8.7.0","eslint-config-prettier":"^8.3.0","eslint-plugin-markdown":"^2.2.1","eslint-plugin-prettier":"^4.0.0","mocha":"^9.2.0","mocha-lcov-reporter":"^1.3.0","nyc":"^15.1.0","prettier":"^2.5.1","typescript":"^4.5.5"},"bugs":{"url":"https://jira.mariadb.org/projects/CONJS/"},"homepage":"https://github.com/mariadb-corporation/mariadb-connector-nodejs#readme","_lastModified":"2025-09-02T09:52:00.467Z"}
1
+ {"name":"mariadb","version":"2.5.6","description":"fast mariadb/mysql connector.","main":"promise.js","types":"types/index.d.ts","directories":{"lib":"lib","test":"test"},"private":false,"scripts":{"test":"npm run test:types-prettier && npm run test:prettier && npm run test:types && npm run test:lint && npm run test:base","test:base":"mocha --no-parallel --timeout 5000 \"test/**/*.js\" ","test:lint":"eslint \"{lib,test}/**/*.js\" ","test:types":"eslint \"types/*.ts\" ","test:types-prettier":"prettier --write \"types/*.ts\"","test:prettier":"prettier --write \"{tools,lib,test,benchmarks}/**/*.js\"","coverage":"npm run coverage:test && npm run coverage:report","coverage:test":"nyc mocha --no-parallel --timeout 5000 \"test/**/*.js\"","coverage:report":"nyc report --reporter=text-lcov > coverage.lcov && codecov","benchmark":"node ./benchmarks/benchmarks.js","generate":"node ./tools/generate-mariadb.js"},"repository":{"type":"git","url":"git+https://github.com/mariadb-corporation/mariadb-connector-nodejs.git"},"keywords":["mariadb","mysql","client","driver","connector"],"files":["lib","types/index.d.ts","promise.js","callback.js"],"engines":{"node":">= 10.13"},"author":"Diego Dupin <diego.dupin@mariadb.com>","license":"LGPL-2.1-or-later","dependencies":{"@types/geojson":"^7946.0.8","@types/node":"^17.0.10","denque":"^2.0.1","iconv-lite":"^0.6.3","long":"^5.2.0","moment-timezone":"^0.5.34","please-upgrade-node":"^3.2.0"},"devDependencies":{"@typescript-eslint/eslint-plugin":"^5.10.0","@typescript-eslint/parser":"^5.10.0","benchmark":"^2.1.4","chai":"^4.3.4","codecov":"^3.8.2","chalk":"^4.1.2","dom-parser":"^0.1.6","error-stack-parser":"^2.0.6","eslint":"^8.7.0","eslint-config-prettier":"^8.3.0","eslint-plugin-markdown":"^2.2.1","eslint-plugin-prettier":"^4.0.0","mocha":"^9.2.0","mocha-lcov-reporter":"^1.3.0","nyc":"^15.1.0","prettier":"^2.5.1","typescript":"^4.5.5"},"bugs":{"url":"https://jira.mariadb.org/projects/CONJS/"},"homepage":"https://github.com/mariadb-corporation/mariadb-connector-nodejs#readme","_lastModified":"2025-11-11T06:39:55.465Z"}
@@ -1 +1 @@
1
- {"name":"qs","description":"A querystring parser that supports nesting and arrays, with a depth limit","homepage":"https://github.com/ljharb/qs","version":"6.14.0","repository":{"type":"git","url":"https://github.com/ljharb/qs.git"},"funding":{"url":"https://github.com/sponsors/ljharb"},"main":"lib/index.js","sideEffects":false,"contributors":[{"name":"Jordan Harband","email":"ljharb@gmail.com","url":"http://ljharb.codes"}],"keywords":["querystring","qs","query","url","parse","stringify"],"engines":{"node":">=0.6"},"dependencies":{"side-channel":"^1.1.0"},"devDependencies":{"@browserify/envify":"^6.0.0","@browserify/uglifyify":"^6.0.0","@ljharb/eslint-config":"^21.1.1","browserify":"^16.5.2","bundle-collapser":"^1.4.0","common-shakeify":"~1.0.0","eclint":"^2.8.1","es-value-fixtures":"^1.7.0","eslint":"=8.8.0","evalmd":"^0.0.19","for-each":"^0.3.3","glob":"=10.3.7","has-bigints":"^1.1.0","has-override-mistake":"^1.0.1","has-property-descriptors":"^1.0.2","has-proto":"^1.2.0","has-symbols":"^1.1.0","iconv-lite":"^0.5.1","in-publish":"^2.0.1","jackspeak":"=2.1.1","mkdirp":"^0.5.5","mock-property":"^1.1.0","module-deps":"^6.2.3","npmignore":"^0.3.1","nyc":"^10.3.2","object-inspect":"^1.13.3","qs-iconv":"^1.0.4","safe-publish-latest":"^2.0.0","safer-buffer":"^2.1.2","tape":"^5.9.0","unassertify":"^3.0.1"},"scripts":{"prepack":"npmignore --auto --commentLines=autogenerated && npm run dist","prepublishOnly":"safe-publish-latest","prepublish":"not-in-publish || npm run prepublishOnly","pretest":"npm run --silent readme && npm run --silent lint","test":"npm run tests-only","tests-only":"nyc tape 'test/**/*.js'","posttest":"npx npm@'>=10.2' audit --production","readme":"evalmd README.md","postlint":"eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git' | grep -v dist/)","lint":"eslint --ext=js,mjs .","dist":"mkdirp dist && browserify --standalone Qs -g unassertify -g @browserify/envify -g [@browserify/uglifyify --mangle.keep_fnames --compress.keep_fnames --format.indent_level=1 --compress.arrows=false --compress.passes=4 --compress.typeofs=false] -p common-shakeify -p bundle-collapser/plugin lib/index.js > dist/qs.js"},"license":"BSD-3-Clause","publishConfig":{"ignore":["!dist/*","bower.json","component.json",".github/workflows","logos","tea.yaml"]},"_lastModified":"2025-09-02T09:52:01.035Z"}
1
+ {"name":"qs","description":"A querystring parser that supports nesting and arrays, with a depth limit","homepage":"https://github.com/ljharb/qs","version":"6.14.0","repository":{"type":"git","url":"https://github.com/ljharb/qs.git"},"funding":{"url":"https://github.com/sponsors/ljharb"},"main":"lib/index.js","sideEffects":false,"contributors":[{"name":"Jordan Harband","email":"ljharb@gmail.com","url":"http://ljharb.codes"}],"keywords":["querystring","qs","query","url","parse","stringify"],"engines":{"node":">=0.6"},"dependencies":{"side-channel":"^1.1.0"},"devDependencies":{"@browserify/envify":"^6.0.0","@browserify/uglifyify":"^6.0.0","@ljharb/eslint-config":"^21.1.1","browserify":"^16.5.2","bundle-collapser":"^1.4.0","common-shakeify":"~1.0.0","eclint":"^2.8.1","es-value-fixtures":"^1.7.0","eslint":"=8.8.0","evalmd":"^0.0.19","for-each":"^0.3.3","glob":"=10.3.7","has-bigints":"^1.1.0","has-override-mistake":"^1.0.1","has-property-descriptors":"^1.0.2","has-proto":"^1.2.0","has-symbols":"^1.1.0","iconv-lite":"^0.5.1","in-publish":"^2.0.1","jackspeak":"=2.1.1","mkdirp":"^0.5.5","mock-property":"^1.1.0","module-deps":"^6.2.3","npmignore":"^0.3.1","nyc":"^10.3.2","object-inspect":"^1.13.3","qs-iconv":"^1.0.4","safe-publish-latest":"^2.0.0","safer-buffer":"^2.1.2","tape":"^5.9.0","unassertify":"^3.0.1"},"scripts":{"prepack":"npmignore --auto --commentLines=autogenerated && npm run dist","prepublishOnly":"safe-publish-latest","prepublish":"not-in-publish || npm run prepublishOnly","pretest":"npm run --silent readme && npm run --silent lint","test":"npm run tests-only","tests-only":"nyc tape 'test/**/*.js'","posttest":"npx npm@'>=10.2' audit --production","readme":"evalmd README.md","postlint":"eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git' | grep -v dist/)","lint":"eslint --ext=js,mjs .","dist":"mkdirp dist && browserify --standalone Qs -g unassertify -g @browserify/envify -g [@browserify/uglifyify --mangle.keep_fnames --compress.keep_fnames --format.indent_level=1 --compress.arrows=false --compress.passes=4 --compress.typeofs=false] -p common-shakeify -p bundle-collapser/plugin lib/index.js > dist/qs.js"},"license":"BSD-3-Clause","publishConfig":{"ignore":["!dist/*","bower.json","component.json",".github/workflows","logos","tea.yaml"]},"_lastModified":"2025-11-11T06:39:55.771Z"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/module-multi-app",
3
3
  "displayName": "Multi-app manager",
4
- "version": "1.3.25",
4
+ "version": "1.5.0",
5
5
  "description": "Dynamically create multiple apps without separate deployments.",
6
6
  "keywords": [
7
7
  "System management"
@@ -22,9 +22,9 @@
22
22
  "pg": "^8.16.3",
23
23
  "qs": "^6.14.0",
24
24
  "react": "18.3.1",
25
- "react-i18next": "15.2.0",
25
+ "react-i18next": "16.2.1",
26
26
  "react-router-dom": "6.28.1",
27
- "@tachybase/client": "1.3.25"
27
+ "@tachybase/client": "1.5.0"
28
28
  },
29
29
  "description.zh-CN": "无需单独部署即可动态创建多个应用。",
30
30
  "displayName.zh-CN": "多应用管理器",