Comparison loadDocumentDescription for every page

Hello, im using your Comparison .NET UI product and i edited it for my own purposes, specially to make it work with iframe and download links, i saw that angular sends requests for every page to loadDocumentDescription. I dont want that to happen, i just want it to send it for once because it basically does the same work. Here is my angular code app.component.ts code:

ngAfterViewInit() {
   let url = (<any>window).url;
   if (!url) {
       url = window.location.href;
   }
   if (url.indexOf('?ep=') > -1) {
       let ep = url.split('?ep=')[1];
       let fileName1 = ep.split('&')[0];
       let fileName2 = ep.split('&')[1];
       this.filePath = ep.split('&')[2];
       this.filePath2 = ep.split('&')[3];
       let isdowload = ep.split('&')[4];
       let isprint = ep.split('&')[5];

       var boolValueDown = (isdowload =="true");
       var boolValuePrint = (isprint =="true");
       this.comparisonConfig.download = boolValueDown;
       this.comparisonConfig.print = boolValuePrint;
       this.comparisonConfig.upload = false;
       this.comparisonConfig.browse = true;
       this.comparisonConfig.defaultDocument = this.filePath;
       this.resultTabDisabled = !1;
       
       this.activePanel = "first";
       this.activeTab = "files";
       this.browseFilesModal = "gd-browse-files";
       this.filesTab = "files";
       this.first = "first";
       this.loadingFirstPanel = true;
       this.loadingSecondPanel = false;
       this.resultTab = "result";
       this.resultTabDisabled = true;
       this.second = "second";

       let urlPrefix = null;
       if ("undefined" !== typeof((<any>window).__BASE_URL)) {
           urlPrefix = (<any>window).__BASE_URL + "comparison/comparison";
       }
       if (urlPrefix) {
           (<any>this.comparisonService)._config._apiEndpoint = urlPrefix;
       }
       if(this.filePath)
       {
           this.selectFirstDefaultFile(this.filePath, '').subscribe(file => {
               this.firstFileName = fileName1;
           });
       }
       if(this.filePath2)
       {
           this.selectSecondDefaultFile(this.filePath2, '');
           this.selectFirstDefaultFile(this.filePath, '').subscribe(file => {
               this.secondFileName = fileName2;
           });
       }

       
       this.changeDetectorRef.detectChanges();
     
   }
};

so this does seperates the download link from url and registers it to the ui. Hope you can help

@mtiryaki

To prevent multiple requests to loadDocumentDescription for each page in your Angular application, you can modify your code to ensure that this request is made only once. Here’s a suggested approach:

  1. Create a flag to track whether the document description has already been loaded.
  2. Check this flag before making the request to loadDocumentDescription. If it has already been loaded, skip the request.

Here’s how you can implement this in your ngAfterViewInit method:

ngAfterViewInit() {
    let url = (<any>window).url;
    if (!url) {
        url = window.location.href;
    }
    if (url.indexOf('?ep=') > -1) {
        let ep = url.split('?ep=')[1];
        let fileName1 = ep.split('&')[0];
        let fileName2 = ep.split('&')[1];
        this.filePath = ep.split('&')[2];
        this.filePath2 = ep.split('&')[3];
        let isdownload = ep.split('&')[4];
        let isprint = ep.split('&')[5];

        var boolValueDown = (isdownload == "true");
        var boolValuePrint = (isprint == "true");
        this.comparisonConfig.download = boolValueDown;
        this.comparisonConfig.print = boolValuePrint;
        this.comparisonConfig.upload = false;
        this.comparisonConfig.browse = true;
        this.comparisonConfig.defaultDocument = this.filePath;
        this.resultTabDisabled = false;

        this.activePanel = "first";
        this.activeTab = "files";
        this.browseFilesModal = "gd-browse-files";
        this.filesTab = "files";
        this.first = "first";
        this.loadingFirstPanel = true;
        this.loadingSecondPanel = false;
        this.resultTab = "result";
        this.resultTabDisabled = true;
        this.second = "second";

        let urlPrefix = null;
        if ("undefined" !== typeof((<any>window).__BASE_URL)) {
            urlPrefix = (<any>window).__BASE_URL + "comparison/comparison";
        }
        if (urlPrefix) {
            (<any>this.comparisonService)._config._apiEndpoint = urlPrefix;
        }

        // Flag to check if document description has been loaded
        if (!this.documentDescriptionLoaded) {
            if (this.filePath) {
                this.selectFirstDefaultFile(this.filePath, '').subscribe(file => {
                    this.firstFileName = fileName1;
                    this.loadDocumentDescription(); // Load document description here
                });
            }
            if (this.filePath2) {
                this.selectSecondDefaultFile(this.filePath2, '').subscribe(file => {
                    this.secondFileName = fileName2;
                });
            }
            this.documentDescriptionLoaded = true; // Set the flag to true after loading
        }

        this.changeDetectorRef.detectChanges();
    }
}

// Method to load document description
loadDocumentDescription() {
    // Call your service to load document description here
}

Key Changes:

  • Introduced a boolean flag documentDescriptionLoaded to track if the document description has been loaded.
  • The request to load the document description is made only if this flag is false.
  • After loading the document description, the flag is set to true to prevent further requests.

This approach should help you optimize the loading process and avoid unnecessary requests for each page.

Im not sure this would help, i’d like to have some human responses

@mtiryaki
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): GROUPDOCSAPP-964 

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.