From 3529008e1613ae5e5a417b0fe68bd275f223d09f Mon Sep 17 00:00:00 2001 From: Gaurav Kumar Date: Sat, 31 May 2025 20:47:28 +0530 Subject: [PATCH] Update wireframe-renderer.component.ts --- .../wireframe-renderer.component.ts | 104 ++++++++++++++---- 1 file changed, 80 insertions(+), 24 deletions(-) diff --git a/visaproject-front-f/authsec_angular/frontend/angular-clarity-master/src/app/modules/main/fnd/SiteTreeBuilder/WireframesUi/wireframe-renderer.component.ts b/visaproject-front-f/authsec_angular/frontend/angular-clarity-master/src/app/modules/main/fnd/SiteTreeBuilder/WireframesUi/wireframe-renderer.component.ts index 17e6001..5a77b97 100644 --- a/visaproject-front-f/authsec_angular/frontend/angular-clarity-master/src/app/modules/main/fnd/SiteTreeBuilder/WireframesUi/wireframe-renderer.component.ts +++ b/visaproject-front-f/authsec_angular/frontend/angular-clarity-master/src/app/modules/main/fnd/SiteTreeBuilder/WireframesUi/wireframe-renderer.component.ts @@ -1998,23 +1998,62 @@ async generateJson(data: { jsonStructure: any, sectionType: string }): Promise = {}; - for (const sectionKey of orderedSectionKeys) { - if (this.sectionHtmls[pageName][sectionKey]) { - reorderedSectionHtmls[sectionKey] = this.sectionHtmls[pageName][sectionKey]; - } +// // Update the sectionHtmls order to match orderedSectionKeys +// const reorderedSectionHtmls: Record = {}; +// for (const sectionKey of orderedSectionKeys) { +// if (this.sectionHtmls[pageName][sectionKey]) { +// reorderedSectionHtmls[sectionKey] = this.sectionHtmls[pageName][sectionKey]; +// } +// } +// console.log('📦 Original sectionHtmls:', this.sectionHtmls[pageName]); +// console.log('📦 Section order:', orderedSectionKeys); +// console.log('📦 FullPage HTML:', this.pageSections[pageName]?.FullPage); + +// this.sectionHtmls[pageName] = reorderedSectionHtmls; + +// console.log('page data ',reorderedSectionHtmls) +// // Now update the full page HTML with correct order +// // this.updateFullPageHtml(pageName); + +// // const fullHtml = this.pageSections[pageName].FullPage.toString(); +// const fullHtml = this.pageSections[pageName].FullPage; // must be plain string + +// if (!fullHtml || typeof fullHtml !== 'string' || fullHtml.trim() === '') { +// alert(`⚠️ No content available for page "${pageName}". Please generate HTML first.`); +// console.error('❌ FullPage content missing or empty for:', pageName); +// return; +// } +// const blob = new Blob([fullHtml], { type: 'text/html' }); +// const url = window.URL.createObjectURL(blob); +// const link = document.createElement('a'); +// link.href = url; +// link.download = `${pageName}.html`; +// link.click(); +// window.URL.revokeObjectURL(url); +// } + // Upload HTML files + + + + + downloadHtml(pageName: string) { + console.log(pageName, ' downloading ..'); + + const fullHtml = this.pageSections[pageName]?.FullPage; + + if (!fullHtml || typeof fullHtml !== 'string' || fullHtml.trim() === '') { + alert(`⚠️ No content available for page "${pageName}". Please generate HTML first.`); + console.error('❌ FullPage content missing or empty for:', pageName); + return; } - this.sectionHtmls[pageName] = reorderedSectionHtmls; - - // Now update the full page HTML with correct order - this.updateFullPageHtml(pageName); - - const fullHtml = this.pageSections[pageName].FullPage.toString(); + + console.log('📦 FullPage HTML:', fullHtml); + const blob = new Blob([fullHtml], { type: 'text/html' }); const url = window.URL.createObjectURL(blob); const link = document.createElement('a'); @@ -2023,7 +2062,7 @@ downloadHtml(pageName: string) { link.click(); window.URL.revokeObjectURL(url); } - // Upload HTML files + buildWireframe(projId: number) { const pageHtmlMap: Record = {}; @@ -2551,16 +2590,32 @@ setCurrentPage(index: number): void { } // Copy specific page to clipboard +// copyPageToClipboard(pageName?: string): void { +// const pageToSelect = pageName || this.getCurrentPageName(); +// const html = this.mapofPageAndHtmlBody[pageToSelect]; + +// if (html) { +// navigator.clipboard.writeText(html).then(() => { +// this.toastr.success(`${pageToSelect} copied to clipboard!`); +// }).catch(() => { +// this.toastr.error('Failed to copy to clipboard'); +// }); +// } +// } copyPageToClipboard(pageName?: string): void { const pageToSelect = pageName || this.getCurrentPageName(); - const html = this.mapofPageAndHtmlBody[pageToSelect]; - - if (html) { + const html = this.mapofPageAndHtmlBody?.[pageToSelect] || this.pageSections?.[pageToSelect]?.FullPage; + + if (html && typeof html === 'string' && html.trim() !== '') { navigator.clipboard.writeText(html).then(() => { this.toastr.success(`${pageToSelect} copied to clipboard!`); - }).catch(() => { + }).catch((err) => { + console.error('❌ Clipboard error:', err); this.toastr.error('Failed to copy to clipboard'); }); + } else { + console.warn(`⚠️ No HTML content found for: ${pageToSelect}`); + this.toastr.error(`Nothing to copy for page "${pageToSelect}"`); } } @@ -2568,6 +2623,7 @@ copyPageToClipboard(pageName?: string): void { + getAllSectionLists(): HTMLElement[] { return Array.from(document.querySelectorAll('.connected-sections')) as HTMLElement[]; } @@ -2810,10 +2866,10 @@ endPan(): void { // }); // } -downloadCurrentPage(): void { - const currentPage = this.getCurrentPageName(); - this.downloadHtml(currentPage); -} +// downloadCurrentPage(): void { +// const currentPage = this.getCurrentPageName(); +// this.downloadHtml(currentPage); +// } // Update existing download method handleDirectContentEdit(event: Event, page: string, section: string) {