server/dist/files-templates.js

3 lines
17 KiB
JavaScript
Raw Normal View History

/*! For license information please see files-templates.js.LICENSE.txt */
(()=>{"use strict";var e,n={91297:(e,n,a)=>{var i=a(17499),r=a(16453),l=a(9944),o=a(79753),s=a(22200);const c=function(){var e,t,n,a;const i=(null===(e=OCA)||void 0===e||null===(t=e.Files)||void 0===t||null===(n=t.App)||void 0===n||null===(a=n.currentFileList)||void 0===a?void 0:a.dirInfo)||{path:"/",name:""};return"".concat(i.path,"/").concat(i.name).replace(/\/\//gi,"/")};var d=a(4820),p=a(20144),A=a(62520),m=a(26932),u=a(97e3),h=a.n(u),v=a(47450),f=a.n(v);const C=256,g={name:"TemplatePreview",inheritAttrs:!1,props:{basename:{type:String,required:!0},checked:{type:Boolean,default:!1},fileid:{type:[String,Number],required:!0},filename:{type:String,required:!0},previewUrl:{type:String,default:null},hasPreview:{type:Boolean,default:!0},mime:{type:String,required:!0},ratio:{type:Number,default:null}},data:()=>({failedPreview:!1}),computed:{nameWithoutExt(){return this.basename.indexOf(".")>-1?this.basename.split(".").slice(0,-1).join("."):this.basename},id(){return"template-picker-".concat(this.fileid)},realPreviewUrl(){return this.failedPreview&&this.mimeIcon?this.mimeIcon:this.previewUrl?this.previewUrl:(0,s.getCurrentUser)()?(0,o.generateUrl)("/core/preview?fileId=".concat(this.fileid,"&x=").concat(C,"&y=").concat(C,"&a=1")):(0,o.generateUrl)("/apps/files_sharing/publicpreview/".concat(document.getElementById("sharingToken")&&document.getElementById("sharingToken").value,"?fileId=").concat(this.fileid,"&file=").concat(function(e){const t=(e.startsWith("/")?e:"/".concat(e)).split("/");let n="";return t.forEach((e=>{""!==e&&(n+="/"+encodeURIComponent(e))})),n}(this.filename),"&x=").concat(C,"&y=").concat(C,"&a=1"))},mimeIcon(){return OC.MimeType.getIconUrl(this.mime)}},methods:{onCheck(){this.$emit("check",this.fileid)},onFailure(){this.failedPreview=!0}}},b=g;var w=a(93379),_=a.n(w),y=a(78299);_()(y.Z,{insert:"head",singleton:!1}),y.Z.locals;var k=a(51900);const x=(0,k.Z)(b,(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("li",{staticClass:"template-picker__item"},[n("input",{staticClass:"radio",attrs:{id:e.id,type:"radio",name:"template-picker"},domProps:{checked:e.checked},on:{change:e.onCheck}}),e._v(" "),n("label",{staticClass:"template-picker__label",attrs:{for:e.id}},[n("div",{staticClass:"template-picker__preview",class:e.failedPreview?"template-picker__preview--failed":""},[n("img",{staticClass:"template-picker__image",attrs:{src:e.realPreviewUrl,alt:"",draggable:"false"},on:{error:e.onFailure}})]),e._v(" "),n("span",{staticClass:"template-picker__title"},[e._v("\n\t\t\t"+e._s(e.nameWithoutExt)+"\n\t\t")])])])}),[],!1,null,"440aea22",null).exports,E={name:"TemplatePicker",components:{EmptyContent:h(),Modal:f(),TemplatePreview:x},props:{logger:{type:Object,required:!0}},data:()=>({checked:-1,loading:!1,name:null,opened:!1,provider:null}),computed:{nameWithoutExt(){return this.name.indexOf(".")>-1?this.name.split(".").slice(0,-1).join("."):this.name},emptyTemplate(){var e,n;return{basename:t("files","Blank"),fileid:-1,filename:this.t("files","Blank"),hasPreview:!1,mime:(null===(e=this.provider)||void 0===e?void 0:e.mimetypes[0])||(null===(n=this.provider)||void 0===n?void 0:n.mimetypes)}},selectedTemplate(){return this.provider.templates.find((e=>e.fileid===this.checked))},style(){return{"--margin":"8px","--width":"160px","--border":"2px","--fullwidth":"180px","--height":this.provider.ratio?Math.round(160/this.provider.ratio)+"px":null}}},methods:{async open(e,t){this.checked=this.emptyTemplate.fileid,this.name=e,this.provider=t;const n=(await async function(){return(await d.default.get((0,o.generateOcsUrl)("apps/files/api/v1/templates"))).data.ocs.data}()).find((e=>e.app===t.app&&e.label===t.label));if(null===n)throw new Error("Failed to match provider in results");this.provider=n,0!==n.templates.length?this.opened=!0:this.onSubmit()},close(){this.checked=this.emptyTemplate.fileid,this.loading=!1,this.name=null,this.opened=!1,this.provider=null},onCheck(e){this.checked=e},async onSubmit(){var e,t,n;this.loading=!0;const a=c(),i=null===(e=OCA)||void 0===e||null===(t=e.Files)||void 0===t||null===(
//# sourceMappingURL=files-templates.js.map?v=eec350534c53941183ad