4 lines
6.6 KiB
JavaScript
4 lines
6.6 KiB
JavaScript
/*! third party licenses: js/vendor.LICENSE.txt */
|
|
import{n as c,N as d,a as h,b as m,c as u,d as b,l as p,s as l,V as a}from"./_plugin-vue2_normalizer-CBCAj2XU.chunk.mjs";import{t as s,a as w}from"./translation-DoG5ZELJ-DKBzIEvm.chunk.mjs";import{c as v}from"./index-C0mkXnFg.chunk.mjs";import{g as S,l as r}from"./index-Anv74-sp.chunk.mjs";import"./index-Bn0s6V7w.chunk.mjs";import"./vendor-BeFBwUwf.chunk.mjs";import"./index-vg7q3Iku.chunk.mjs";const g={name:"AdminSettings",components:{NcTextField:b,NcButton:u,NcLoadingIcon:m,NcNoteCard:h,NcSettingsSection:d},data(){return{serverUrl:r("whiteboard","url",""),secret:r("whiteboard","secret",""),maxFileSize:r("whiteboard","maxFileSize",10),wsMaxUploadFileSizeBytes:null,validConnection:void 0,connectionError:void 0,loadingSettings:!1,loadingSocket:!1,setupCheck:null}},computed:{loading(){return this.loadingSettings||this.loadingSocket},wsLimitMb(){return this.wsMaxUploadFileSizeBytes?this.wsMaxUploadFileSizeBytes/1e6:null},maxFileSizeHelperText(){return s("whiteboard","Per image added to the board (original file size).")},wsLimitHelperText(){return this.wsLimitMb?s("whiteboard","WebSocket payload cap: {limit} MB (MAX_UPLOAD_FILE_SIZE on collaboration server).",{limit:this.wsLimitMb.toFixed(1)}):this.serverUrl?s("whiteboard","WebSocket payload cap set by MAX_UPLOAD_FILE_SIZE on the collaboration server."):null},maxFileSizeNotice(){const e=Number(this.maxFileSize);return!Number.isFinite(e)||e<=0?{type:"error",message:s("whiteboard","Enter a positive number of MB.")}:this.wsMaxUploadFileSizeBytes&&this.wsLimitMb&&e>this.wsLimitMb?{type:"error",message:s("whiteboard","Exceeds WebSocket payload limit ({limit} MB). Images may not sync.",{limit:this.wsLimitMb.toFixed(1)})}:null}},mounted(){this.callSettings({serverUrl:this.serverUrl}),this.verifyConnection({jwt:r("whiteboard","jwt","")}),this.fetchWebsocketLimits()},methods:{async submit(){const e=await this.callSettings({serverUrl:this.serverUrl,secret:this.secret,maxFileSize:this.maxFileSize});await this.verifyConnection(e),await this.fetchWebsocketLimits()},async saveMaxFileSize(){const e=Number(this.maxFileSize);if(!Number.isFinite(e)||e<=0){l(s("whiteboard","Max image size must be a positive number."));return}if(this.wsLimitMb&&e>this.wsLimitMb){l(s("whiteboard","Max image size exceeds the WebSocket payload limit ({limit} MB).",{limit:this.wsLimitMb.toFixed(1)}));return}await this.callSettings({maxFileSize:this.maxFileSize})},async callSettings(e={}){this.loadingSettings=!0;const{data:t}=await v.post(S("/apps/whiteboard/settings"),e);return t.check&&(this.setupCheck=t.check.severity!=="success"?t.check:null),this.loadingSettings=!1,t},async fetchWebsocketLimits(){if(!this.serverUrl){this.wsMaxUploadFileSizeBytes=null;return}let e;try{const t=new URL(this.serverUrl),i=t.pathname.replace(/\/$/,"");e=`${t.protocol==="wss:"?"https:":t.protocol==="ws:"?"http:":t.protocol}//${t.host}${i}/status`}catch{this.wsMaxUploadFileSizeBytes=null;return}try{const t=await fetch(e,{method:"GET",mode:"cors",credentials:"omit"});if(!t.ok)throw new Error(`Status ${t.status}`);const i=await t.json();this.wsMaxUploadFileSizeBytes=i?.config?.maxUploadFileSizeBytes??null}catch{this.wsMaxUploadFileSizeBytes=null}},async verifyConnection(e){if(!e.jwt)return;const t=new URL(this.serverUrl),i=t.pathname.replace(/\/$/,"")+"/socket.io";this.loadingSocket=!0;const o=p(t.origin,{path:i,withCredentials:!0,auth:{secret:e.jwt},transports:["websocket"],timeout:5e3});o.on("connect",()=>{this.validConnection=!0,this.connectionError=void 0,this.loadingSocket=!1}),o.on("connect_error",n=>{this.validConnection=n.message==="Connection verified",this.connectionError=this.validConnection===!1?n.message:void 0,o.close(),this.loadingSocket=!1}),o.connect()},t:s}};var x=function(){var e=this,t=e._self._c;return t("div",[t("NcSettingsSection",{attrs:{name:e.t("whiteboard","Real-time collaboration server")}},[!e.loading&&e.setupCheck!==null?t("NcNoteCard",{attrs:{type:e.setupCheck.severity}},[e._v(" "+e._s(e.setupCheck.description)+" ")]):!e.loading&&e.validConnection===!0?t("NcNoteCard",{attrs:{type:"success"}},[e._v(" "+e._s(e.t("whiteboard","WebSocket server for real-time collaboration is configured and connected."))+" ")]):!e.loading&&e.validConnection===!1?t("NcNoteCard",{attrs:{type:"error"}},[e._v(" "+e._s(e.t("whiteboard","Failed to verify the connection:"))+" "+e._s(e.connectionError)+" ")]):t("NcNoteCard",{attrs:{type:"info",text:e.t("whiteboard","Verifying connection…")},scopedSlots:e._u([{key:"icon",fn:function(){return[t("NcLoadingIcon")]},proxy:!0}])}),t("p",[e._v(" "+e._s(e.t("whiteboard","The WebSocket server handles real-time collaboration sessions between users. Basic whiteboard functionality works without it, but real-time collaboration requires this server to be running and accessible from users' browsers."))+" ")]),t("p",[t("a",{staticClass:"external",attrs:{href:"https://github.com/nextcloud/whiteboard?tab=readme-ov-file#websocket-server-for-real-time-collaboration",rel:"noreferrer noopener",target:"_blank"}},[e._v(e._s(e.t("whiteboard","See the documentation on how to install and configure the WebSocket server.")))])]),t("form",{on:{submit:function(i){return i.preventDefault(),e.submit.apply(null,arguments)}}},[t("p",[t("NcTextField",{attrs:{label:e.t("whiteboard","WebSocket server URL"),value:e.serverUrl,"helper-text":e.t("whiteboard","URL where the WebSocket server for real-time collaboration is running. Must be accessible from users' browsers.")},on:{"update:value":function(i){e.serverUrl=i}}})],1),t("p",[t("NcTextField",{attrs:{label:e.t("whiteboard","Shared secret"),value:e.secret,"helper-text":e.t("whiteboard","JWT secret key shared between Nextcloud and the WebSocket server for secure authentication.")},on:{"update:value":function(i){e.secret=i}}})],1),t("p",[t("NcButton",{attrs:{type:"submit",disabled:!e.serverUrl||e.loading},on:{click:function(i){return i.preventDefault(),e.submit.apply(null,arguments)}}},[e._v(" "+e._s(e.t("whiteboard","Save settings"))+" ")])],1)])],1),t("NcSettingsSection",{attrs:{name:e.t("whiteboard","Advanced settings")}},[t("p",[t("NcTextField",{attrs:{label:e.t("whiteboard","Max image size (MB)"),value:e.maxFileSize,"helper-text":e.maxFileSizeHelperText},on:{"update:value":function(i){e.maxFileSize=i},blur:e.saveMaxFileSize}})],1),e.wsLimitHelperText?t("p",{staticClass:"settings-help"},[e._v(" "+e._s(e.wsLimitHelperText)+" ")]):e._e(),e.maxFileSizeNotice?t("NcNoteCard",{attrs:{type:e.maxFileSizeNotice.type}},[e._v(" "+e._s(e.maxFileSizeNotice.message)+" ")]):e._e()],1)],1)},f=[],y=c(g,x,f,!1,null,"f043a826");const F=y.exports;a.prototype.t=s,a.prototype.n=w,new a({render:e=>e(F,{})}).$mount("#admin-vue");
|
|
//# sourceMappingURL=whiteboard-settings.mjs.map
|