Clarity

Expand all | Collapse all

HTML content getting Downloaded from knowledge store

  • 1.  HTML content getting Downloaded from knowledge store

    Posted Jan 30, 2018 12:30 AM

    In 15.3, all the files from knowledge store are getting downloaded. Is there any way to stop downloading all these files as they are being used in HTML portlets.



  • 2.  Re: HTML content getting Downloaded from knowledge store

    Posted Jan 30, 2018 02:37 AM

    Are files getting downloaded whenever you access an HTML portlet? A few screenshots would be helpful to better understand this.



  • 3.  Re: HTML content getting Downloaded from knowledge store

    Broadcom Employee
    Posted Jan 30, 2018 02:27 PM

    Hi Kritika,

    Can you give more details on what is happening?  What are you doing or trying to do when all of the files get downloaded?




  • 4.  Re: HTML content getting Downloaded from knowledge store

    Posted Feb 02, 2018 03:37 AM

    Hi Jeevan.B and Jeanne Gaskill,

    Please find below the screenshot for that:

    The HTML content should be rendered and displayed here. But, the file is getting downloaded.

    Any idea??



  • 5.  Re: HTML content getting Downloaded from knowledge store

    Posted Feb 02, 2018 04:44 AM

    What exactly are you trying to do?

     

    Are you creating the HTML for a portlet and storing that in an HTML file and storing that in the knowledge base and then double clicking it to open it?

    That is not how you preview an HTML portlet.

    Put the portlet on a new page or on a tab on an existing page (eg. Overview) navigate to the page/tab and the portlet shoul open.



  • 6.  Re: HTML content getting Downloaded from knowledge store

    Posted Feb 02, 2018 05:53 AM

    Hi urmas

    This is just an example of what I am actually trying to achieve. HTML file is needed to show the data. 

    I am using an HTML file which is in knowledge store, that file path is being used in the lookup.

    Earlier, it used to display data. Now, it is downloading the file.



  • 7.  Re: HTML content getting Downloaded from knowledge store

    Posted Feb 02, 2018 07:41 AM

    When I double click an HTML file in the knowledge store I am presented with

    Selecting Do this automatically should skip this and open it from now on.
    In my case it does not. Maybe it is because of the Windows user rights or changed FF functionality as the option is already set to open HTML with Firefox.

     

    I think you have lost me. Are you saying that instead of getting your screenshot you should like to the page at

    to open directly?

     

    Recently I did a trial to get a hyperlink in Collaboration Manager, but I think the Knowledge store behaviour is the same.

    See the last post in

    Can you modify the Collaboration Document Manager to support the addition of hyperlinks? 



  • 8.  Re: HTML content getting Downloaded from knowledge store

    Posted Feb 02, 2018 09:04 AM

    So, there is an HTML portlet that shows data - before, it used to show data when the portlet was accessed - now, when the portlet is accessed, it is downloading the content from the knowledgestore - correct?

     

    This is the same issue that we are facing as well

     

    NJ



  • 9.  Re: HTML content getting Downloaded from knowledge store

    Posted Feb 02, 2018 09:10 AM

    Is this the same underlying reason as mentioned here (Marc's comment)  ; Is URL redirect working in 15.2 and later 

    (I have no answer/insight, just recalled that other thread)



  • 10.  Re: HTML content getting Downloaded from knowledge store

    Posted Feb 02, 2018 01:30 PM

    Yes, the post by  Prashank.Singh  says that

    any web page file in Knowledge store is getting downloaded in 15.2 and above, even after removing download parameter from url.

     

    However, I put the same document in the Knowledge store in 14.4 and  13.3 and it works the same ie. download. There mus be more to it.



  • 11.  Re: HTML content getting Downloaded from knowledge store

    Posted Feb 03, 2018 08:15 AM

    Hi urmas 

     

    At present, i won’t have 14.4 version with me, so i have tested this again with 14.2

    Please follow screen shot as below:

     

    Step1: CA Clarity PPM 14.2 

     

     

    Step2: A webpage in KS (a static one), now im planning to render this webpage via HTML Portlet or via Lookup

     


    Step3: 
    HTML Portlet using iframe to display html content

     

    Use KS URL (highlighted as bold):

     

    http://ServerAndPort/niku/app?action=dms.viewFile&RhXm0r7tSeUqEr=true&fileId=5021638&fileName=FirstWebPage.html&filedownload=filedownload&RhXm0r7tSeUqEr=true

     

     

    Step4: Preview this HTML Portlet and it worked fine instead of getting downloaded.

     

    If we try to achieve this same in 15.2 or 15.3, html page is getting downloaded. I have heard that this can be solved by adding some tag or setting some attribute in html header.

     

    Let me know if you find something which stop newer version from downloading webpages while accessing them from KS.



  • 12.  Re: HTML content getting Downloaded from knowledge store

    Posted Feb 03, 2018 08:20 AM

    Yes navzjoshi00 , this is same issue. Web contents stored in CA PPM's KS are getting downloaded while accessing from HTML Portlet and this is really a pain to move all these web content to Server.



  • 13.  Re: HTML content getting Downloaded from knowledge store
    Best Answer

    Posted Feb 05, 2018 11:20 PM

    I suspect that the document manager is now adding a content-type header (Content-Type: application/octet-stream) in the response which is telling the browser to download the the contents and let the OS decide what to do with it.  I suspect if you associate .html to say notepad++ it would open you knowledge html in that application.

     

    I have been thinking about this and I noticed in this post

     

    OBS Portlet - D3js 

     

    Andrew has his html file in /niku/ui/images/Visuals.  I am not sure how he got his html file there -- Andrew?

     

    So I have been thinking about a way to work around this long term.  A way that will survive major upgrade to major upgrade.

     

    If one created a custom object -- say HtmlPages with a couple of large string attributes and one or two attributes to be able to identify a given html portlet along with the code for a given query which would be used to get any dynamic data.

     

    Then in a html portlet you have some javascript/jquery that does a xog query to get the html/js resources from the custom object, another xog query for the dynamic part of the portlet base on the code return from the first query. 

     

    A little jquery to build up the html contents.  Once the contents are built, just add to a DIV.replaceWith(contents).

     

    Just thoughts,
    Gene



  • 14.  Re: HTML content getting Downloaded from knowledge store

    Posted Feb 06, 2018 03:57 AM

    Hi Gene Greiff, 

    I will try that.



  • 15.  Re: HTML content getting Downloaded from knowledge store

    Posted Feb 06, 2018 08:06 PM

    I have been very successful building dynamic html portlets with jQuery.

     

    My approach has been to define the html template first in the html portlet window, for example:

     

    <div class='ppm_filter_section'>
    <div style='height: 350px; margin-left: 80px '>
        <div id='requestDivYes' style="display: none">
            <br/><br/>
            <table id="requestTable" class='ppm_grid'>
                <thead>
                <tr>
                    <td style="text-align: center">Request Type</td>
                </tr>
                </thead>
                <tbody class='ppm_grid_content'>
                </tbody>
            </table>
        </div>
        <div id='requestDivNo' style='display: none; width: 680px; margin-left: 80px'>
            <br/><br/>
            Sorry, it appears that you do not have any authorization for Excel Requests.<br/><br/>
            If you feel this is not correct, please contact Support.
        </div>
        <div id="requestDivSubmit" style='display: none; width: 680px; margin-left: 80px'>
            <br/><br/>
            The following Excel Request have been submitted:<br/>
            <br/>
            <ol id="requestItems"></ol>
            <br/>
            The requested item(s) will be sent to <a id='emailLink' href="mailto:name@example.com">example.com</a>
            <br/><br/>
            Please allow up to 10 mins for processing and delivery.
            <br/>
        </div>
    </div>
    </div>

     

    After the template I define a number of helper functions.

     

      <script type="text/javascript">

            function pmatRequest(){

                var requestTypesUrl = requestUrl + '/' + currentSession;

                var queryRequest = getQueryRequest(currentSession);
                var queryOptions = {url: ppmUrl, type: 'POST', data: queryRequest, contentType: 'text/xml;charset=UTF-8'};
                var requestOptions = {url: requestTypesUrl, type: 'GET', contentType: ' application/json; charset=utf-8'};
                jQuery.when(jQuery.ajax(queryOptions), jQuery.ajax(requestOptions)).then(processSuccess, processError);
            }


            function processError(data, textStatus, jqXhr) {
                var error = data.responseText;
                var i = 0;
            }

            function processSuccess(queryResults, requestResults) {
                try {
                    var queryType = queryResults[0];
                    requestType = requestResults[0];
                    var authorizedRequests = {};
                    authorizedRequests.requests = [];

                    var records = jQuery(queryType).find('Record');
                    if (records == null || records.length == 0){

                        jQuery('#requestDivNo').show();
                        return;
                    }

                    for (var i = 0; i < records.length; i++) {
                        var token = jQuery(records[i]).find('token').text();
                        if (token != currentSession) continue;

                        requestType.UserId = jQuery(records[i]).find('user_name').text();
                        requestType.FirstName = jQuery(records[i]).find('first_name').text();
                        requestType.LastName = jQuery(records[i]).find('last_name').text();
                        requestType.Email = jQuery(records[i]).find('email_address').text();
                        authorizedRequests.distroString = jQuery(records[i]).find('mhs_summary_distro').text();

                        if (!isEmpty(authorizedRequests.distroString)) {
                            var distroList = authorizedRequests.distroString.split(";");
                            for (var k = 0; k < distroList.length; k++) {
                                var distro = distroList[k].trim();
                                for (var j = 0; j < requestType.Item.length; j++) {
                                    if (distro != requestType.Item[j].Token) continue;
                                    authorizedRequests.requests.push(jQuery.extend(true, {}, requestType.Item[j]));
                                    break;
                                }
                            }
                        }
                        break;
                    }

                    if (authorizedRequests.requests.length == 0) {

                        //todo so sad no request available
                        jQuery('#requestDivNo').show();
                        return;
                    }

                    jQuery('#requestDivYes').show();
                    var tbody = jQuery('#requestTable').find('tbody');
                    for (var i = 0; i < authorizedRequests.requests.length; i++) {
                        var id = 'pmatRequestRadio_' + i;
                        var displayName = authorizedRequests.requests[i].DisplayName;
                        var token = authorizedRequests.requests[i].Token;

                        var tr = jQuery('<tr>');
                        var td = jQuery('<td>', {style: 'width="600px'});
                        td.append(jQuery('<input>', {type: "radio", alt: 'pmatRequestRadio', name: displayName, value: token, id: id}));
                        td.append(jQuery('<label>', {id: id}).innerHTML = displayName);
                        tr.append(td);
                        tbody.append(tr);
                    }
                    var tr = jQuery('<tr>');
                    var td = jQuery('<td>', {style: 'width:600px; text-align:center;vertical-align: middle;'});
                    td.append(jQuery('<br><input type="submit" value="Submit" onClick="processRequest();">'))
                    tr.append(td);
                    tbody.append(tr);
                }
                catch (ex) {
                    var msg = ex;
                }
            }

            function processRequest() {
                try {
                var checked = jQuery('input[alt=pmatRequestRadio]:radio');
                if (checked.length == 0) return;
                var retVal = [];
                retVal.push(currentSession);
                for (var i = 0; i < checked.length; i++) {
                    if (!checked[i].checked) continue;
                    retVal.push(checked[i].value);
                    jQuery('#requestItems').append(jQuery('<li>').append(checked[i].name));
                }
                requestType.Requests = retVal.join('|');
                var requesterMailTo = 'mailto:' + requestType.Email;
                var requesterName = requestType.FirstName + ' ' + requestType.LastName;
                jQuery('#emailLink').attr('href',requesterMailTo);
                jQuery('#emailLink').text(requesterName);
                jQuery('#requestDivYes').hide();
                jQuery('#requestDivSubmit').show();
                 var jsonData = JSON.stringify(requestType);

                var requestOptions = {url: requestUrl, type: 'POST', data: jsonData, contentType: ' application/json'};
                jQuery.ajax(requestOptions);
                }
                catch (ex) {
                    var msg = ex;
                }
            }

            function isEmpty(str) {
                return (!str || 0 === str.length);
            }

            function getQueryRequest(sessionId) {
                var queryXml = [];
                queryXml.push('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:quer="http://www.niku.com/xog/Query">');
                queryXml.push('<soapenv:Header>');
                queryXml.push('<quer:Auth>');
                queryXml.push('<quer:SessionID>?</quer:SessionID>'.replace('?', sessionId));
                queryXml.push('</quer:Auth>');
                queryXml.push('</soapenv:Header>');
                queryXml.push('<soapenv:Body>');
                queryXml.push('<quer:Query>');
                queryXml.push('<quer:Code>pmat_active_request</quer:Code>');
                queryXml.push('</quer:Query>');
                queryXml.push('</soapenv:Body>');
                queryXml.push('</soapenv:Envelope>');
                return queryXml.join("");
            }
        </script>

     

    The a script to execute against the template:

     

    <script type="text/javascript">
    var currentSession = window.clarity.session.sessionId;
            var host = window.location.host;
            var requestUrl = 'https://simple.net.net/RequestServer/api/RequestTypes';
            var ppmUrl = 'https://'+host+'/niku/xog';
            var requestType = {};
            jQuery(document).ready(pmatRequest());
    </script>

     

    Once the document is ready, I execute a function that calls the needed XOG/REST queries and if successful passes the results to a processSucess function otherwise a processError function. 

     

    I chose this example as it does multiple SOAP/REST calls and renders a user specific UI which might be solution for you need.

     

    Let me know if it makes sense or I need to go into more detail -- I found this method to work very well and eliminates any external html files.

     

    I still thinking about pushing this all into a custom object that holds everything and all html portlet contain is a very simple stub to latch the custom object element to.

     

    Another option maybe,

    Gene