123 |
- const __vite__fileDeps=["./chunks/SetStatusModal-BpnZubNp.mjs","./chunks/index-PaKKd09k.mjs","./core-common.mjs","./chunks/_plugin-vue2_normalizer-VrK6B12S-BQkexw0P.mjs","./chunks/statusOptionsService-D3gGoJHr.mjs","./chunks/index-DaZEPb_2.mjs","./chunks/icons-TElqpmA8.mjs","./chunks/vuex.esm-pSkZdmXO.mjs","./chunks/preload-helper-BG02UnR2.mjs","./chunks/index-DCgLaXhm.mjs"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
- /*! third party licenses: dist/vendor.LICENSE.txt */
- import{b$ as i,bR as c,F as w,ao as A,c0 as S,cg as b,bQ as l,bW as m,b_ as M,aV as p}from"./core-common.mjs";import{_ as F}from"./chunks/preload-helper-BG02UnR2.mjs";import{d as U}from"./chunks/index-DCgLaXhm.mjs";import{m as D,i as P,S as T}from"./chunks/vuex.esm-pSkZdmXO.mjs";import"./chunks/index-PaKKd09k.mjs";import{z as $}from"./chunks/_plugin-vue2_normalizer-VrK6B12S-BQkexw0P.mjs";import{n as O}from"./chunks/icons-TElqpmA8.mjs";import{m as k}from"./chunks/index-DaZEPb_2.mjs";const C=async s=>{const e=i("apps/user_status/api/v1/heartbeat?format=json");return(await c.put(e,{status:s?"away":"online"})).data.ocs.data},B={computed:{...D({statusType:s=>s.userStatus.status,statusIsUserDefined:s=>s.userStatus.statusIsUserDefined,customIcon:s=>s.userStatus.icon,customMessage:s=>s.userStatus.message}),visibleMessage(){if(this.customIcon&&this.customMessage)return"".concat(this.customIcon," ").concat(this.customMessage);if(this.customMessage)return this.customMessage;if(this.statusIsUserDefined)switch(this.statusType){case"online":return this.$t("user_status","Online");case"away":case"busy":return this.$t("user_status","Away");case"dnd":return this.$t("user_status","Do not disturb");case"invisible":return this.$t("user_status","Invisible");case"offline":return this.$t("user_status","Offline")}return this.$t("user_status","Set status")}},methods:{async changeStatus(s){try{await this.$store.dispatch("setStatus",{statusType:s})}catch(e){$(this.$t("user_status","There was an error saving the new status")),console.debug(e)}}}},L={name:"UserStatus",components:{NcButton:w,NcUserStatusIcon:A,SetStatusModal:()=>F(()=>import("./chunks/SetStatusModal-BpnZubNp.mjs"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]),import.meta.url)},mixins:[B],props:{inline:{type:Boolean,default:!1}},data(){return{heartbeatInterval:null,isAway:!1,isModalOpen:!1,mouseMoveListener:null,setAwayTimeout:null}},mounted(){this.$store.dispatch("loadStatusFromInitialState"),OC.config.session_keepalive&&(this.heartbeatInterval=setInterval(this._backgroundHeartbeat.bind(this),1e3*60*5),this.setAwayTimeout=()=>{this.isAway=!0},this.mouseMoveListener=U(()=>{const s=this.isAway;this.isAway=!1,clearTimeout(this.setAwayTimeout),setTimeout(this.setAwayTimeout,1e3*60*2),s&&this._backgroundHeartbeat()},1e3*2,!0),window.addEventListener("mousemove",this.mouseMoveListener,{capture:!0,passive:!0}),this._backgroundHeartbeat()),S("user_status:status.updated",this.handleUserStatusUpdated)},beforeDestroy(){window.removeEventListener("mouseMove",this.mouseMoveListener),clearInterval(this.heartbeatInterval),b("user_status:status.updated",this.handleUserStatusUpdated)},methods:{openModal(){this.isModalOpen=!0},closeModal(){this.isModalOpen=!1},async _backgroundHeartbeat(){var s;try{const e=await C(this.isAway);e!=null&&e.userId?this.$store.dispatch("setStatusFromHeartbeat",e):await this.$store.dispatch("reFetchStatusFromServer")}catch(e){console.debug("Failed sending heartbeat, got: "+((s=e.response)==null?void 0:s.status))}},handleUserStatusUpdated(s){OC.getCurrentUser().uid===s.userId&&this.$store.dispatch("setStatusFromObject",{status:s.status,icon:s.icon,message:s.message})}}};var j=function(){var s=this,e=s._self._c;return e(s.inline?"div":"li",{tag:"component"},[s.inline?e("NcButton",{on:{click:function(a){return a.stopPropagation(),s.openModal.apply(null,arguments)}},scopedSlots:s._u([{key:"icon",fn:function(){return[e("NcUserStatusIcon",{staticClass:"user-status-icon",attrs:{status:s.statusType,"aria-hidden":"true"}})]},proxy:!0}])},[s._v(" "+s._s(s.visibleMessage)+" ")]):e("button",{staticClass:"user-status-menu-item",on:{click:function(a){return a.stopPropagation(),s.openModal.apply(null,arguments)}}},[e("NcUserStatusIcon",{staticClass:"user-status-icon",attrs:{status:s.statusType,"aria-hidden":"true"}}),s._v(" "+s._s(s.visibleMessage)+" ")],1),s.isModalOpen?e("SetStatusModal",{attrs:{inline:s.inline},on:{close:s.closeModal}}):s._e()],1)},E=[],H=O(L,j,E,!1,null,"78cbe1b4");const y=H.exports,x=async()=>{const s=i("apps/user_status/api/v1/predefined_statuses?format=json");return(await c.get(s)).data.ocs.data},N={predefinedStatuses:[]},R={addPredefinedStatus(s,e){s.predefinedStatuses=[...s.predefinedStatuses,e]}},V={statusesHaveLoaded(s){return s.predefinedStatuses.length>0}},z={async loadAllPredefinedStatuses({state:s,commit:e}){if(s.predefinedStatuses.length>0)return;const a=await x();for(const u of a)e("addPredefinedStatus",u)}},Q={state:N,mutations:R,getters:V,actions:z},W=async()=>{const s=i("apps/user_status/api/v1/user_status");return(await c.get(s)).data.ocs.data},X=async s=>{const e=i("apps/user_status/api/v1/statuses/{userId}",{userId:"_"+s});return(await c.get(e)).data.ocs.data},q=async s=>{const e=i("apps/user_status/api/v1/user_status/status");await c.put(e,{statusType:s})},G=async(s,e=null)=>{const a=i("apps/user_status/api/v1/user_status/message/predefined?format=json");await c.put(a,{messageId:s,clearAt:e})},J=async(s,e=null,a=null)=>{const u=i("apps/user_status/api/v1/user_status/message/custom?format=json");await c.put(u,{message:s,statusIcon:e,clearAt:a})},K=async()=>{const s=i("apps/user_status/api/v1/user_status/message?format=json");await c.delete(s)},Y=async s=>{const e=i("apps/user_status/api/v1/user_status/revert/{messageId}",{messageId:s});return(await c.delete(e)).data.ocs.data},Z=()=>new Date,f=s=>{if(s===null)return null;const e=Z();if(s.type==="period")return e.setSeconds(e.getSeconds()+s.time),Math.floor(e.getTime()/1e3);if(s.type==="end-of")switch(s.time){case"day":case"week":return Number(k(e).endOf(s.time).format("X"))}return s.type==="_time"?s.time:null},ss={status:null,statusIsUserDefined:null,message:null,icon:null,clearAt:null,messageIsPredefined:null,messageId:null},ts={setStatus(s,{statusType:e}){s.status=e,s.statusIsUserDefined=!0},setPredefinedMessage(s,{messageId:e,clearAt:a,message:u,icon:o}){s.messageId=e,s.messageIsPredefined=!0,s.message=u,s.icon=o,s.clearAt=a},setCustomMessage(s,{message:e,icon:a,clearAt:u}){s.messageId=null,s.messageIsPredefined=!1,s.message=e,s.icon=a,s.clearAt=u},clearMessage(s){s.messageId=null,s.messageIsPredefined=!1,s.message=null,s.icon=null,s.clearAt=null},loadStatusFromServer(s,{status:e,statusIsUserDefined:a,message:u,icon:o,clearAt:r,messageIsPredefined:n,messageId:d}){s.status=e,s.message=u,s.icon=o,typeof a<"u"&&(s.statusIsUserDefined=a),typeof r<"u"&&(s.clearAt=r),typeof n<"u"&&(s.messageIsPredefined=n),typeof d<"u"&&(s.messageId=d)}},es={},as={async setStatus({commit:s,state:e},{statusType:a}){var u;await q(a),s("setStatus",{statusType:a}),l("user_status:status.updated",{status:e.status,message:e.message,icon:e.icon,clearAt:e.clearAt,userId:(u=m())==null?void 0:u.uid})},async setStatusFromObject({commit:s,state:e},a){s("loadStatusFromServer",a)},async setPredefinedMessage({commit:s,rootState:e,state:a},{messageId:u,clearAt:o}){var g;const r=f(o);await G(u,r);const n=e.predefinedStatuses.predefinedStatuses.find(v=>v.id===u),{message:d,icon:_}=n;s("setPredefinedMessage",{messageId:u,clearAt:r,message:d,icon:_}),l("user_status:status.updated",{status:a.status,message:a.message,icon:a.icon,clearAt:a.clearAt,userId:(g=m())==null?void 0:g.uid})},async setCustomMessage({commit:s,state:e},{message:a,icon:u,clearAt:o}){var n;const r=f(o);await J(a,u,r),s("setCustomMessage",{message:a,icon:u,clearAt:r}),l("user_status:status.updated",{status:e.status,message:e.message,icon:e.icon,clearAt:e.clearAt,userId:(n=m())==null?void 0:n.uid})},async clearMessage({commit:s,state:e}){var a;await K(),s("clearMessage"),l("user_status:status.updated",{status:e.status,message:e.message,icon:e.icon,clearAt:e.clearAt,userId:(a=m())==null?void 0:a.uid})},async reFetchStatusFromServer({commit:s}){const e=await W();s("loadStatusFromServer",e)},async setStatusFromHeartbeat({commit:s},e){s("loadStatusFromServer",e)},loadStatusFromInitialState({commit:s}){const e=M("user_status","status");s("loadStatusFromServer",e)}},us={state:ss,mutations:ts,getters:es,actions:as},rs={status:null,statusIsUserDefined:null,message:null,icon:null,clearAt:null,messageIsPredefined:null,messageId:null},ns={loadBackupStatusFromServer(s,{status:e,statusIsUserDefined:a,message:u,icon:o,clearAt:r,messageIsPredefined:n,messageId:d}){s.status=e,s.message=u,s.icon=o,typeof a<"u"&&(s.statusIsUserDefined=a),typeof r<"u"&&(s.clearAt=r),typeof n<"u"&&(s.messageIsPredefined=n),typeof d<"u"&&(s.messageId=d)}},os={},is={async fetchBackupFromServer({commit:s}){var e;try{const a=await X((e=m())==null?void 0:e.uid);s("loadBackupStatusFromServer",a)}catch{}},async revertBackupFromServer({commit:s},{messageId:e}){var u;const a=await Y(e);a&&(s("loadBackupStatusFromServer",{}),s("loadStatusFromServer",a),l("user_status:status.updated",{status:a.status,message:a.message,icon:a.icon,clearAt:a.clearAt,userId:(u=m())==null?void 0:u.uid}))}},cs={state:rs,mutations:ns,getters:os,actions:is};p.use(P);const I=new T({modules:{predefinedStatuses:Q,userStatus:us,userBackupStatus:cs},strict:!0});p.prototype.t=t,p.prototype.$t=t;const ds=document.getElementById("user_status-menu-entry"),h=()=>{const s=document.getElementById("user_status-menu-entry");new p({el:s,render:e=>e(y),store:I})};ds?h():S("core:user-menu:mounted",h),document.addEventListener("DOMContentLoaded",function(){OCA.Dashboard&&OCA.Dashboard.registerStatus("status",s=>{const e=p.extend(y);return new e({propsData:{inline:!0},store:I}).$mount(s)})});export{B as O,Z as d};
|