Files
2026-04-28 15:13:50 +02:00

2 lines
13 KiB
JavaScript

import{I,au as N,n as Y,w as O}from"./app-core.ae890a3f.js";import{u as x}from"./WpTable.65c7870f.js";import{C}from"./Table.199a0fd0.js";import{u as q}from"./PostTypes.bcb4ad24.js";import{C as K}from"./Tooltip.ae7a1028.js";import{L as j,a as M}from"./EditablePhrase.136366c7.js";import{_ as F}from"./Trash.d35f8063.js";import{_ as L}from"./_plugin-vue_export-helper.eefbdd86.js";import{_ as o,d as U}from"./vendor-other.7b559694.js";import{aq as d,f as S,i as B,Q as A,R as m,a0 as b,ae as R,U as u,j as i,M as V,u as E,P as T,T as D}from"./vendor-vue-ui.de3ab35f.js";import{S as z}from"./Caret.a017b70a.js";import{l as H}from"./Input.8918dec2.js";import{S as W}from"./External.934835f7.js";import"./vendor-lodash.8e35bd59.js";import"./ScrollTo.f4df02aa.js";import"./Index.52399193.js";import"./Close.098d4b76.js";import"./Button.a549093d.js";import"./Slide.e6618126.js";import"./Download.aee86410.js";import"./Index.ab3bcf62.js";import"./Editor.10fec9a8.js";import"./vendor-quill.fa67f709.js";import"./Plus.97dee933.js";import"./Pencil.405b16d2.js";const h="aioseo-pro",Q={emits:["updated"],setup(e,t){const{editPost:p,viewPost:a}=q(),n=v=>(y.setDomainsReportInnerPaginatedPage({domain:e.domain,page:w}),y.fetchDomainsReportInner({...v,additionalFilters:{domainIndex:e.activeDomain,domain:e.domain}}).then(()=>{r.value++,t.emit("updated")})),s="aioseo-domains-report-inner-",k=E(()=>s+String(U().valueOf())),{pageNumber:w,processPagination:_,refreshTable:f,resultsPerPage:P,searchTerm:l,wpTableKey:r,wpTableLoading:g}=x({changeItemsPerPageSlug:"aioseo-domains-report-inner",fetchData:n,resultsPerPage:5,tableId:k}),y=I();return{dateSqlToLocal:N,editPost:p,linkAssistantStore:y,pageNumber:w,processPagination:_,refreshTable:f,resultsPerPage:P,searchTerm:l,tableId:k,viewPost:a,wpTableKey:r,wpTableLoading:g}},components:{CoreTooltip:K,CoreWpTable:C,LinkAssistantConfirmationModal:M,LinkAssistantEditablePhrase:j,SvgTrash:F},props:{domain:{type:String,required:!0},rows:{type:Array,required:!0},activeDomain:{type:Number}},data(){return{activePost:-1,showModal:!1,action:"",selectedRows:null,bulkOptions:[{label:o("Delete",h),value:"delete"}],strings:{delete:o("Delete",h)},modalStrings:{areYouSureSingle:o("Are you sure you want to delete these links for this domain?",h),areYouSureMultiple:o("Are you sure you want to delete these links for this domain?",h),areYouSureAll:o("Are you sure you want to delete all links for this domain?",h),actionCannotBeUndone:o("This action cannot be undone.",h),yesSingle:o("Yes, I want to delete these links",h),yesMultiple:o("Yes, I want to delete these links",h),yesAll:o("Yes, I want to delete all links",h),noChangedMind:o("No, I changed my mind",h)}}},computed:{columns(){return[{slug:"post_title",label:o("Post Title",h)},{slug:"phrases",label:o("Phrases with Links",h)},{slug:"publish_date",label:o("Publish Date",h),width:"160px"},{slug:"delete",width:"50px"}]},shouldShowPagination(){return 1<this.rows[0]?.totals.pages},initialPageNumber(){if(this.linkAssistantStore.domainsReport.innerPagination===void 0||this.linkAssistantStore.domainsReport.innerPagination[this.domain]===void 0)return 1;const e=this.linkAssistantStore.domainsReport.innerPagination[this.domain];return e||1}},methods:{toggleShowMorePhrases(e){if(this.activePost===e){this.activePost=-1;return}this.activePost=e},deleteLink({postIndex:e,linkIndex:t}){this.wpTableLoading=!0,this.linkAssistantStore.domainsReportInnerLinkDelete({searchTerm:this.searchTerm,rows:this.rows,postIndex:e,linkIndex:t,offset:this.pageNumber===1?0:(this.pageNumber-1)*this.resultsPerPage}).finally(()=>{this.refreshTable().then(()=>{this.$emit("updated"),this.wpTableLoading=!1})})},saveModifiedPhrase(e){if(!this.linkAssistantStore.domainsReport.rows[this.activeDomain])return;const t=Object.keys(this.linkAssistantStore.domainsReport.rows[this.activeDomain])[0];!t||!this.linkAssistantStore.domainsReport.rows[this.activeDomain][t][e.postIndex]||!this.linkAssistantStore.domainsReport.rows[this.activeDomain][t][e.postIndex].links[e.phraseIndex]||this.linkAssistantStore.domainsReport.rows[this.activeDomain][t][e.postIndex].links[e.phraseIndex].phrase_html!==e.phraseHtml&&(this.linkAssistantStore.domainsReport.rows[this.activeDomain][t][e.postIndex].links[e.phraseIndex].phrase=e.phrase,this.linkAssistantStore.domainsReport.rows[this.activeDomain][t][e.postIndex].links[e.phraseIndex].phrase_html=e.phraseHtml,this.linkAssistantStore.domainsReport.rows[this.activeDomain][t][e.postIndex].links[e.phraseIndex].anchor=e.anchor,this.wpTableLoading=!0,this.linkAssistantStore.domainsReportInnerLinkUpdate({domain:t,link:this.linkAssistantStore.domainsReport.rows[this.activeDomain][t][e.postIndex].links[e.phraseIndex]}).then(this.refreshTable).then(()=>{this.wpTableKey++,this.$emit("updated")}).finally(()=>{this.wpTableLoading=!1}))},maybeDoBulkAction({action:e,selectedRows:t}){!e||!t.length||(this.action=e,this.selectedRows=t,this.showModal=!0)},doBulkAction(){if(this.showModal=!1,this.action==="delete")return this.wpTableLoading=!0,this.linkAssistantStore.domainsReportInnerBulk({searchTerm:this.searchTerm,action:this.action,domainIndex:this.activeDomain,linkIndexes:this.selectedRows,offset:this.pageNumber===1?0:(this.pageNumber-1)*this.resultsPerPage}).finally(()=>{this.refreshTable().then(()=>{this.$emit("updated"),this.wpTableLoading=!1})})}},created(){this.pageNumber=this.initialPageNumber}},G={key:0,class:"domains-report-inner"},J=["href"],X={class:"row-actions"},Z={class:"view"},$=["href"],ee={class:"edit"},te=["href"],se={class:"date"};function oe(e,t,p,a,n,s){const k=d("link-assistant-editable-phrase"),w=d("svg-trash"),_=d("core-tooltip"),f=d("core-wp-table"),P=d("link-assistant-confirmation-modal");return p.rows&&p.rows.length?(S(),B("div",G,[(S(),A(f,{class:"link-assistant-inner-table","bulk-options":n.bulkOptions,columns:s.columns,id:a.tableId,"initial-page-number":a.pageNumber,key:a.wpTableKey,loading:a.wpTableLoading,rows:p.rows,"show-pagination":s.shouldShowPagination,"show-search":!1,"show-table-footer":!1,totals:p.rows[0].totals,onPaginate:a.processPagination,onProcessBulkAction:s.maybeDoBulkAction},{post_title:m(({row:l})=>[i("strong",null,[i("a",{class:"edit-link",href:l.context.permalink,target:"_blank"},u(l.context.postTitle),9,J)]),i("div",X,[i("span",Z,[i("a",{href:l.context.permalink,target:"_blank"},u(a.viewPost(l.context.postType.singular)),9,$),t[1]||(t[1]=R(" | ",-1))]),i("span",ee,[i("a",{href:l.context.editLink,target:"_blank"},u(a.editPost(l.context.postType.singular)),9,te)])])]),phrases:m(({row:l,index:r})=>[b(k,{row:l,rowIndex:r,activeRow:n.activePost,domainsReport:"",onDelete:s.deleteLink,onToggleShowMorePhrases:s.toggleShowMorePhrases,onSaveModifiedPhrase:s.saveModifiedPhrase},null,8,["row","rowIndex","activeRow","onDelete","onToggleShowMorePhrases","onSaveModifiedPhrase"])]),publish_date:m(({row:l})=>[i("span",se,u(a.dateSqlToLocal(l.context.publishDate,"MMMM D, YYYY")),1)]),delete:m(({index:l})=>[b(_,{type:"action"},{tooltip:m(()=>[R(u(n.strings.delete),1)]),default:m(()=>[b(w,{onClick:r=>s.maybeDoBulkAction({action:"delete",selectedRows:[l]})},null,8,["onClick"])]),_:2},1024)]),_:1},8,["bulk-options","columns","id","initial-page-number","loading","rows","show-pagination","totals","onPaginate","onProcessBulkAction"])),b(P,{show:n.showModal,strings:n.modalStrings,selectedRows:n.selectedRows,onDoBulkAction:s.doBulkAction,onCloseModal:t[0]||(t[0]=l=>n.showModal=!1)},null,8,["show","strings","selectedRows","onDoBulkAction"])])):V("",!0)}const ne=L(Q,[["render",oe]]),c="aioseo-pro",ie={setup(){const e=I(),t="aioseo-link-assistant-domains-report-wp-table",{pageNumber:p,processChangeItemsPerPage:a,processFetchTableData:n,processPagination:s,processSearch:k,processSort:w,searchTerm:_,wpTableKey:f,wpTableLoading:P}=x({changeItemsPerPageSlug:"linkAssistantDomainsReport",fetchData:e.fetchDomainsReport,tableId:t});return{linkAssistantStore:e,pageNumber:p,processChangeItemsPerPage:a,processFetchTableData:n,processPagination:s,processSearch:k,processSort:w,searchTerm:_,settingsStore:O(),tableId:t,wpTableKey:f,wpTableLoading:P}},components:{CoreWpTable:C,DomainsReportInner:ne,LinkAssistantConfirmationModal:M,SvgCaret:z,SvgFile:H,SvgLinkExternal:W},data(){return{numbers:Y,innerTableKey:0,activeRow:-1,showModal:!1,selectedRows:null,action:null,bulkOptions:[{label:o("Delete",c),value:"delete"}],strings:{view:o("View",c),deleteAllLinks:o("Delete All Links",c)},modalStrings:{areYouSureSingle:o("Are you sure you want to delete all links for this domain?",c),areYouSureMultiple:o("Are you sure you want to delete all links for these domains?",c),areYouSureAll:o("Are you sure you want to delete all links for all domains?",c),actionCannotBeUndone:o("This action cannot be undone.",c),yesSingle:o("Yes, I want to delete this link",c),yesMultiple:o("Yes, I want to delete these links",c),yesAll:o("Yes, I want to delete all links",c),noChangedMind:o("No, I changed my mind",c)}}},computed:{columns(){return[{slug:"domain",label:o("Domain",c)},{slug:"posts",label:o("Posts",c),width:"90px"},{slug:"links",label:o("Links",c),width:"90px"},{slug:"toggle-button",label:"",width:"60px"}]}},methods:{postCount(e){const t=Object.keys(e)[0];return e[t][0]?.totals.total||0},linkCount(e){const t=Object.keys(e)[0];return e[t][0]?.totals.totalLinks||0},isRowActive(e){return e===this.activeRow},toggleRow(e){if(this.activeRow===e){this.activeRow=-1;return}this.activeRow=e},maybeDoBulkAction({action:e,selectedRows:t}){t===!1||!e||(this.action=e,this.selectedRows=t,this.showModal=!0)},doBulkAction(){return this.showModal=!1,this.wpTableLoading=!0,this.linkAssistantStore.domainsReportBulk({action:this.action,searchTerm:this.searchTerm,rowIndexes:this.selectedRows}).then(this.processFetchTableData).finally(()=>{this.activeRow=-1,this.wpTableLoading=!1,this.wpTableKey++})},getInnerDomain(e){return Object.keys(e)[0]},getInnerDomainRows(e){return e[this.getInnerDomain(e)]},doProcessPagination(e){this.processPagination(e),this.activeRow=-1},doProcessSearch(e){this.processSearch(e),this.activeRow=-1}},beforeMount(){this.$route.query&&(this.$route.query.hostname&&(this.searchTerm=this.$route.query.hostname,this.processSearch(this.$route.query.hostname)),this.$route.query.fullReport&&(this.searchTerm="",this.processPagination(1)))}},ae={class:"aioseo-link-assistant-domains-report"},re={class:"domain-name"},le=["onClick"],ce=["src"],he={class:"row-actions"},de=["href"],me=["onClick"],ue=["onClick"];function pe(e,t,p,a,n,s){const k=d("svg-file"),w=d("svg-link-external"),_=d("svg-caret"),f=d("domains-report-inner"),P=d("core-wp-table"),l=d("link-assistant-confirmation-modal");return S(),B("div",ae,[(S(),A(P,{ref:"table","bulk-options":n.bulkOptions,columns:s.columns,id:a.tableId,"initial-items-per-page":a.settingsStore.settings.tablePagination.linkAssistantDomainsReport,"initial-page-number":a.pageNumber,"initial-search-term":a.searchTerm,key:a.wpTableKey,loading:a.wpTableLoading,rows:a.linkAssistantStore.domainsReport.rows,totals:a.linkAssistantStore.domainsReport.totals,"show-items-per-page":"",onPaginate:s.doProcessPagination,onProcessBulkAction:s.maybeDoBulkAction,onProcessChangeItemsPerPage:a.processChangeItemsPerPage,onSearch:s.doProcessSearch,onSortColumn:a.processSort},{domain:m(({row:r,index:g,editRow:y})=>[i("div",re,[i("a",{href:"#",class:T({active:s.isRowActive(g)}),onClick:D(v=>{y(g),s.toggleRow(g)},["prevent"])},[i("img",{alt:"Domain Favicon",class:"favicon",src:`https://www.google.com/s2/favicons?sz=32&domain=${Object.keys(r)[0]}`},null,8,ce),i("span",null,u(Object.keys(r)[0]),1)],10,le)]),i("div",he,[i("span",null,[i("a",{class:"view",href:"https://"+Object.keys(r)[0],target:"_blank"},[i("span",null,u(n.strings.view),1)],8,de),t[2]||(t[2]=R(" | ",-1))]),i("span",null,[i("a",{class:"delete-all-links",href:"#",onClick:D(v=>s.maybeDoBulkAction({action:"delete",selectedRows:g}),["prevent"])},[i("span",null,u(n.strings.deleteAllLinks),1)],8,me)])])]),posts:m(({row:r})=>[i("div",null,[b(k),i("span",null,u(n.numbers.numberFormat(s.postCount(r))),1)])]),links:m(({row:r})=>[i("div",null,[b(w),i("span",null,u(n.numbers.numberFormat(s.linkCount(r))),1)])]),"toggle-button":m(({index:r,editRow:g})=>[i("button",{class:T(["toggle-row-button",{active:s.isRowActive(r)}]),onClick:y=>{g(r),s.toggleRow(r)}},[b(_)],10,ue)]),"edit-row":m(({row:r})=>[(S(),A(f,{key:n.innerTableKey,domain:s.getInnerDomain(r),rows:s.getInnerDomainRows(r),activeDomain:n.activeRow,onUpdated:t[0]||(t[0]=g=>n.innerTableKey++)},null,8,["domain","rows","activeDomain"]))]),_:1},8,["bulk-options","columns","id","initial-items-per-page","initial-page-number","initial-search-term","loading","rows","totals","onPaginate","onProcessBulkAction","onProcessChangeItemsPerPage","onSearch","onSortColumn"])),b(l,{show:n.showModal,strings:n.modalStrings,selectedRows:n.selectedRows,onDoBulkAction:s.doBulkAction,onCloseModal:t[1]||(t[1]=r=>n.showModal=!1)},null,8,["show","strings","selectedRows","onDoBulkAction"])])}const je=L(ie,[["render",pe]]);export{je as default};