Skip to content

Commit

Permalink
more accurate error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Simonis, Matthias authored and Simonis, Matthias committed May 29, 2024
1 parent 735d0ee commit dabd7b2
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion js/Activity-DQDvjcjQ.mjs → js/Activity-9r8zgd5b.mjs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/Activity-9r8zgd5b.mjs.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion js/Activity-DQDvjcjQ.mjs.map

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("[data-v-bab8cf5b] .empty-content__icon span{background-size:64px;width:64px;height:64px}.activity__actions[data-v-bab8cf5b]{display:flex;flex-direction:column;width:100%}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
/*! third party licenses: js/vendor.LICENSE.txt */
import{n as r,g as c,c as l,b as u,e as f}from"./NcCheckboxRadioSwitch-BOl1O2zi-BqKsNleQ.mjs";import{d as v,r as p,o as d,g,f as y,t as o}from"./index-CmscAddx.mjs";import{A as m,a as h,b as _}from"./Activity-DQDvjcjQ.mjs";import{g as b,a as A,b as I}from"./api-D5L3rAZA.mjs";import{l as S}from"./logger-CcLDq3iB.mjs";import{l as w}from"./activity-sidebar.mjs";import"./_commonjsHelpers-BdswosdL.mjs";const x=v({__name:"ActivitySidebarPlugin",props:{plugin:null,fileInfo:null},emits:["reload-activities"],setup(t,{emit:i}){const n=t,a=p();return d(()=>{var s;return n.plugin.mount(a.value,{context:(s=g())==null?void 0:s.proxy,fileInfo:n.fileInfo,reload:()=>i("reload-activities")})}),y(()=>n.plugin.unmount()),{__sfc:!0,props:n,emit:i,attachTarget:a}}});var N=function(){var t=this,i=t._self._c;return t._self._setupProxy,i("div",{ref:"attachTarget"})},P=[],C=r(x,N,P,!1,null,null,null,null);const k=C.exports,E={name:"ActivityTab",components:{Activity:m,NcEmptyContent:h,NcIconSvgWrapper:c,NcLoadingIcon:l,ActivitySidebarPlugin:k},data(){return{error:"",loading:!0,fileInfo:null,activities:[],lightningBoltSVG:w,sidebarPlugins:[]}},mounted(){this.sidebarPlugins=b()},methods:{async update(t){this.fileInfo=t,this.resetState(),await this.getActivities()},async getActivities(){try{this.loading=!0;const t=await this.processActivities(await this.loadRealActivities()),i=await A({fileInfo:this.fileInfo});this.activities=[...t,...i].sort((n,a)=>a.timestamp-n.timestamp)}catch(t){this.error=o("activity","Unable to load the activity list"),console.error("Error loading the activity list",t)}finally{this.loading=!1}},resetState(){this.loading=!0,this.error="",this.activities=[]},async loadRealActivities(){try{const{data:t}=await u.get(f("apps/activity/api/v2/activity/filter"),{params:{format:"json",object_type:"files",object_id:this.fileInfo.id}});return t.ocs.data}catch(t){if(t.response!==void 0&&t.response.status===304)return[];throw e}},processActivities(t){t=t.map(n=>new _(n)),S.debug("Processed ".concat(t.length," activity(ies)"),{activities:t,fileInfo:this.fileInfo});const i=I();return t.filter(n=>!i||i.every(a=>a(n)))},t:o}};var j=function(){var t=this,i=t._self._c;return i("div",{class:{"icon-loading":t.loading}},[t.error?i("NcEmptyContent",{attrs:{name:t.error},scopedSlots:t._u([{key:"icon",fn:function(){return[i("NcIconSvgWrapper",{attrs:{svg:t.lightningBoltSVG}})]},proxy:!0}],null,!1,63559581)}):[t.sidebarPlugins.length>0?i("div",{staticClass:"activity__actions"},t._l(t.sidebarPlugins,function(n,a){return i("ActivitySidebarPlugin",{key:a,attrs:{plugin:n,"file-info":t.fileInfo},on:{"reload-activities":function(s){return t.getActivities()}}})}),1):t._e(),t.loading?i("NcEmptyContent",{attrs:{name:t.t("activity","Loading activities")},scopedSlots:t._u([{key:"icon",fn:function(){return[i("NcLoadingIcon")]},proxy:!0}],null,!1,3085876643)}):t.activities.length===0?i("NcEmptyContent",{attrs:{name:t.t("activity","No activity yet")},scopedSlots:t._u([{key:"icon",fn:function(){return[i("span",{staticClass:"icon-activity"})]},proxy:!0}])}):i("ul",t._l(t.activities,function(n){return i("Activity",{key:n.id,attrs:{activity:n,"show-previews":!1},on:{reload:function(a){return t.getActivities()}}})}),1)]],2)},L=[],T=r(E,j,L,!1,null,"bab8cf5b",null,null);const U=T.exports;export{U as default};
import{n as r,g as c,c as l,b as u,e as f}from"./NcCheckboxRadioSwitch-BOl1O2zi-BqKsNleQ.mjs";import{d as v,r as p,o as d,g,f as y,t as o}from"./index-CmscAddx.mjs";import{A as m,a as h,b as _}from"./Activity-9r8zgd5b.mjs";import{g as b,a as A,b as I}from"./api-D5L3rAZA.mjs";import{l as S}from"./logger-CcLDq3iB.mjs";import{l as w}from"./activity-sidebar.mjs";import"./_commonjsHelpers-BdswosdL.mjs";const x=v({__name:"ActivitySidebarPlugin",props:{plugin:null,fileInfo:null},emits:["reload-activities"],setup(t,{emit:i}){const n=t,a=p();return d(()=>{var s;return n.plugin.mount(a.value,{context:(s=g())==null?void 0:s.proxy,fileInfo:n.fileInfo,reload:()=>i("reload-activities")})}),y(()=>n.plugin.unmount()),{__sfc:!0,props:n,emit:i,attachTarget:a}}});var N=function(){var t=this,i=t._self._c;return t._self._setupProxy,i("div",{ref:"attachTarget"})},P=[],C=r(x,N,P,!1,null,null,null,null);const k=C.exports,E={name:"ActivityTab",components:{Activity:m,NcEmptyContent:h,NcIconSvgWrapper:c,NcLoadingIcon:l,ActivitySidebarPlugin:k},data(){return{error:"",loading:!0,fileInfo:null,activities:[],lightningBoltSVG:w,sidebarPlugins:[]}},mounted(){this.sidebarPlugins=b()},methods:{async update(t){this.fileInfo=t,this.resetState(),await this.getActivities()},async getActivities(){try{this.loading=!0;const t=await this.processActivities(await this.loadRealActivities()),i=await A({fileInfo:this.fileInfo});this.activities=[...t,...i].sort((n,a)=>a.timestamp-n.timestamp)}catch(t){this.error=o("activity","Unable to load the activity list"),console.error("Error loading the activity list",t)}finally{this.loading=!1}},resetState(){this.loading=!0,this.error="",this.activities=[]},async loadRealActivities(){try{const{data:t}=await u.get(f("apps/activity/api/v2/activity/filter"),{params:{format:"json",object_type:"files",object_id:this.fileInfo.id}});return t.ocs.data}catch(t){if(t.response!==void 0&&t.response.status===304)return[];throw e}},processActivities(t){t=t.map(n=>new _(n)),S.debug("Processed ".concat(t.length," activity(ies)"),{activities:t,fileInfo:this.fileInfo});const i=I();return t.filter(n=>!i||i.every(a=>a(n)))},t:o}};var j=function(){var t=this,i=t._self._c;return i("div",{class:{"icon-loading":t.loading}},[t.error?i("NcEmptyContent",{attrs:{name:t.error},scopedSlots:t._u([{key:"icon",fn:function(){return[i("NcIconSvgWrapper",{attrs:{svg:t.lightningBoltSVG}})]},proxy:!0}],null,!1,63559581)}):[t.sidebarPlugins.length>0?i("div",{staticClass:"activity__actions"},t._l(t.sidebarPlugins,function(n,a){return i("ActivitySidebarPlugin",{key:a,attrs:{plugin:n,"file-info":t.fileInfo},on:{"reload-activities":function(s){return t.getActivities()}}})}),1):t._e(),t.loading?i("NcEmptyContent",{attrs:{name:t.t("activity","Loading activities")},scopedSlots:t._u([{key:"icon",fn:function(){return[i("NcLoadingIcon")]},proxy:!0}],null,!1,3085876643)}):t.activities.length===0?i("NcEmptyContent",{attrs:{name:t.t("activity","No activity yet")},scopedSlots:t._u([{key:"icon",fn:function(){return[i("span",{staticClass:"icon-activity"})]},proxy:!0}])}):i("ul",t._l(t.activities,function(n){return i("Activity",{key:n.id,attrs:{activity:n,"show-previews":!1},on:{reload:function(a){return t.getActivities()}}})}),1)]],2)},L=[],T=r(E,j,L,!1,null,"bab8cf5b",null,null);const U=T.exports;export{U as default};

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/activity-app.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/activity-sidebar.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
__vite__mapDeps.viteFileDeps = [OC.filePath('activity', '', 'js/ActivityTab-DWGDsdsQ.mjs'),OC.filePath('activity', '', 'js/NcCheckboxRadioSwitch-BOl1O2zi-BqKsNleQ.mjs'),OC.filePath('activity', '', 'js/index-CmscAddx.mjs'),OC.filePath('activity', '', 'js/_commonjsHelpers-BdswosdL.mjs'),OC.filePath('activity', '', 'js/logger-CcLDq3iB.mjs'),OC.filePath('activity', '', 'js/Activity-DQDvjcjQ.mjs'),OC.filePath('activity', '', 'js/api-D5L3rAZA.mjs')]
__vite__mapDeps.viteFileDeps = [OC.filePath('activity', '', 'js/ActivityTab-C10j6op5.mjs'),OC.filePath('activity', '', 'js/NcCheckboxRadioSwitch-BOl1O2zi-BqKsNleQ.mjs'),OC.filePath('activity', '', 'js/index-CmscAddx.mjs'),OC.filePath('activity', '', 'js/_commonjsHelpers-BdswosdL.mjs'),OC.filePath('activity', '', 'js/logger-CcLDq3iB.mjs'),OC.filePath('activity', '', 'js/Activity-9r8zgd5b.mjs'),OC.filePath('activity', '', 'js/api-D5L3rAZA.mjs')]
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
/*! third party licenses: js/vendor.LICENSE.txt */
import{V as m,t as v,a as g}from"./index-CmscAddx.mjs";import"./_commonjsHelpers-BdswosdL.mjs";const E="modulepreload",b=function(e,l){return e[0]==="."?new URL(e,l).href:e},h={},y=function(e,l,c){let u=Promise.resolve();if(l&&l.length>0){const s=document.getElementsByTagName("link"),t=document.querySelector("meta[property=csp-nonce]"),f=(t==null?void 0:t.nonce)||(t==null?void 0:t.getAttribute("nonce"));u=Promise.all(l.map(r=>{if(r=b(r,c),r in h)return;h[r]=!0;const a=r.endsWith(".css"),w=a?'[rel="stylesheet"]':"";if(c)for(let d=s.length-1;d>=0;d--){const p=s[d];if(p.href===r&&(!a||p.rel==="stylesheet"))return}else if(document.querySelector('link[href="'.concat(r,'"]').concat(w)))return;const o=document.createElement("link");if(o.rel=a?"stylesheet":E,a||(o.as="script",o.crossOrigin=""),o.href=r,f&&o.setAttribute("nonce",f),document.head.appendChild(o),a)return new Promise((d,p)=>{o.addEventListener("load",d),o.addEventListener("error",()=>p(new Error("Unable to preload CSS for ".concat(r))))})}))}return u.then(()=>e()).catch(s=>{const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=s,window.dispatchEvent(t),!t.defaultPrevented)throw s})},_='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-lightning-bolt" viewBox="0 0 24 24"><path d="M11 15H6L13 1V9H18L11 23V15Z" /></svg>';m.prototype.t=v,m.prototype.n=g;let n=null,i=null;const A=new OCA.Files.Sidebar.Tab({id:"activity",name:v("activity","Activity"),iconSvg:_,async mount(e,l,c){if(n===null){const{default:u}=await y(()=>import("./ActivityTab-DWGDsdsQ.mjs"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url);n=n!=null?n:m.extend(u)}i&&i.$destroy(),i=new n({parent:c}),i.update(l),i.$mount(e)},update(e){i.update(e)},destroy(){i.$destroy(),i=null}});window.addEventListener("DOMContentLoaded",async function(){if(OCA.Files&&OCA.Files.Sidebar){OCA.Files.Sidebar.registerTab(A);const{default:e}=await y(()=>import("./ActivityTab-DWGDsdsQ.mjs"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url);n=n!=null?n:m.extend(e)}});export{_ as l};
import{V as m,t as v,a as g}from"./index-CmscAddx.mjs";import"./_commonjsHelpers-BdswosdL.mjs";const E="modulepreload",b=function(e,l){return e[0]==="."?new URL(e,l).href:e},h={},y=function(e,l,c){let u=Promise.resolve();if(l&&l.length>0){const s=document.getElementsByTagName("link"),t=document.querySelector("meta[property=csp-nonce]"),f=(t==null?void 0:t.nonce)||(t==null?void 0:t.getAttribute("nonce"));u=Promise.all(l.map(r=>{if(r=b(r,c),r in h)return;h[r]=!0;const a=r.endsWith(".css"),w=a?'[rel="stylesheet"]':"";if(c)for(let d=s.length-1;d>=0;d--){const p=s[d];if(p.href===r&&(!a||p.rel==="stylesheet"))return}else if(document.querySelector('link[href="'.concat(r,'"]').concat(w)))return;const o=document.createElement("link");if(o.rel=a?"stylesheet":E,a||(o.as="script",o.crossOrigin=""),o.href=r,f&&o.setAttribute("nonce",f),document.head.appendChild(o),a)return new Promise((d,p)=>{o.addEventListener("load",d),o.addEventListener("error",()=>p(new Error("Unable to preload CSS for ".concat(r))))})}))}return u.then(()=>e()).catch(s=>{const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=s,window.dispatchEvent(t),!t.defaultPrevented)throw s})},_='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-lightning-bolt" viewBox="0 0 24 24"><path d="M11 15H6L13 1V9H18L11 23V15Z" /></svg>';m.prototype.t=v,m.prototype.n=g;let n=null,i=null;const A=new OCA.Files.Sidebar.Tab({id:"activity",name:v("activity","Activity"),iconSvg:_,async mount(e,l,c){if(n===null){const{default:u}=await y(()=>import("./ActivityTab-C10j6op5.mjs"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url);n=n!=null?n:m.extend(u)}i&&i.$destroy(),i=new n({parent:c}),i.update(l),i.$mount(e)},update(e){i.update(e)},destroy(){i.$destroy(),i=null}});window.addEventListener("DOMContentLoaded",async function(){if(OCA.Files&&OCA.Files.Sidebar){OCA.Files.Sidebar.registerTab(A);const{default:e}=await y(()=>import("./ActivityTab-C10j6op5.mjs"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url);n=n!=null?n:m.extend(e)}});export{_ as l};
10 changes: 5 additions & 5 deletions src/models/ActivityModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ export default class ActivityModel {

// Sanity checks
if (typeof rawActivity.activity_id !== 'number') {
throw new Error('The activity_id argument is not a valid string')
throw new Error('The activity_id argument is not a number')
}
if (typeof rawActivity.type !== 'string' || rawActivity.type.trim() === '') {
throw new Error('The activity_id argument is not a valid string')
throw new Error('The type argument is not a valid string')
}
if (typeof rawActivity.subject !== 'string' || rawActivity.subject.trim() === '') {
throw new Error('The activity_id argument is not a valid string')
throw new Error('The subject argument is not a valid string')
}
if (typeof rawActivity.icon !== 'string' || rawActivity.icon.trim() === '') {
throw new Error('The activity_id argument is not a valid string')
throw new Error('The icon argument is not a valid string')
}
if (typeof rawActivity.datetime !== 'string' || rawActivity.datetime.trim() === '') {
throw new Error('The activity_id argument is not a valid string')
throw new Error('The datetime argument is not a valid string')
}

// store state
Expand Down

0 comments on commit dabd7b2

Please sign in to comment.