+`;var{Component:d,Mixin:f}=Shopware;d.register("thumbnailprocessor-test",{template:l,props:["btnLabel"],inject:["thumbnailProcessorTest"],mixins:[f.getByName("notification")],data(){return{isLoading:!1,isSuccessful:!1}},computed:{pluginSalesChannelId(){let e=this.$parent;for(let t=0;t<20;t++){if(typeof e.currentSalesChannelId<"u")return e.currentSalesChannelId;e=e.$parent}throw"Can not get pluginConfigData"}},methods:{finish(){this.isSuccessful=!1},showError(e,t){this.isSuccessful=!1,t&&(e+=" sample url: "+t),this.createNotificationError({title:this.$tc("thumbnail-processor.test.title"),message:e})},saveAndCheck(){this.isLoading=!0,this.systemConfigSaveAll()},check(){let e=this;e.thumbnailProcessorTest.getUrl(this.pluginSalesChannelId).then(t=>{if(t.url){e.isSuccessful=!0;let s=document.createElement("img");s.width=200,s.height=200,s.onload=function(){s.naturalWidth!==200&&e.showError(e.$tc("thumbnail-processor.test.error.noResize"),t.url)},s.onerror=function(){e.showError(e.$tc("thumbnail-processor.test.error.general"),t.url)},s.src=t.url;let r=document.querySelector('[name="FroshPlatformThumbnailProcessor.config.test"]'),n=r.querySelector(".frosh-thumbnail-processor-testimage img");if(n)n.replaceWith(s);else{let i=document.createElement("p");i.classList.add("frosh-thumbnail-processor-testimage"),i.appendChild(s),r.appendChild(i)}}else e.showError(e.$tc("thumbnail-processor.test.error.general"));setTimeout(()=>{this.isLoading=!1},2500)})},systemConfigSaveAll(){let e=this,t=this.$parent;for(let s=0;s<30;s++){if(typeof t.$refs.systemConfig<"u")return t.$refs.systemConfig.saveAll().then(()=>{e.check()});t=t.$parent}throw"Can not get systemConfig"}}});var c=Shopware.Classes.ApiService,{Application:h}=Shopware,o=class extends c{constructor(t,s,r="thumbnail-processor-test"){super(t,s,r)}getUrl(t){let s=this.getBasicHeaders({});return this.httpClient.post(`_action/${this.getApiBasePath()}/get-sample-image`,{salesChannelId:t},{headers:s}).then(r=>c.handleResponse(r))}};h.addServiceProvider("thumbnailProcessorTest",e=>{let t=h.getContainer("init");return new o(t.httpClient,e.loginService)});})();
0 commit comments