← Back to team overview

dhis2-devs team mailing list archive

Re: [Dhis2-users] Web Portal with DHIS2

 

Hi Guy,

The 2.20 plugin does the authentication for you (as long as you provide the
crossDomain, username and password) so you can remove the login code. This
will work (replace password):

<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" type="text/css" href="
http://dhis2-cdn.org/v220/ext/resources/css/ext-plugin-gray.css"/>
  <script src="https://dhis2-cdn.org/v220/ext/ext-all.js";></script>
  <script src="https://dhis2-cdn.org/v220/plugin/table.js";></script>
</head>

<body>
  <div id="table1"></div>

  <script>
    var url = "http://localhost:8082";,
        username = "ekani.guy",
        password = "xxxxxxxxx";

    Ext.onReady(function() {

        DHIS.getTable({
            url: url,
            el: "table1",
            id: "fqk6tunwRLp",
            crossDomain: true,
            username: username,
            password: password
        });

    });
  </script>
</body>

</html>




On Fri, Oct 2, 2015 at 3:45 PM, Guy Ekani <constyekani@xxxxxxxx> wrote:

> Thanks Jan,
>
> I migrated to DHIS-Live 2.20(19682), But I'm always getting the error :
>
> XMLHttpRequest cannot load
> http://localhost:8082/dhis-web-commons-security/login.action. The request
> was redirected to '
> http://localhost:8082/dhis-web-commons/security/login.action;jsessionid=irhqgxqywe5v1kb27d5obvhec?failed=true',
> which is disallowed for cross-origin requests that require preflight.
>
> and
>
> Blocking of a multi-query origins (Cross-Origin Request): the "Same
> Origin" policy does not refer to the remote resource on http: // localhost:
> 8082 / web-dhis-commons-security / login.action . Reason: the header CORS
> "Access-Control-Allow-Origin" is missing. Reason: Failed to CORS request.
>
> Sincerely,
>
> =========================
> EKANI Guy
>
>
>
>
>
>
>
>
> Le Vendredi 2 octobre 2015 8h56, Jan Henrik Øverland <
> janhenrik.overland@xxxxxxxxx> a écrit :
>
>
> Hi Guy,
>
> A fix is needed both in the Ext version we are (still) using and in the
> plugins to make this work. Unfortunately I have only had the time to update
> trunk and 2.20 so far.
>
> If it is OK for you to upgrade to 2.20 it will work right away if you add
> the following to your plugin configuration:
>
> DHIS.getTable({
>     ...
>     ...
>
>     crossDomain: true,
>     username: <portal user>,
>     password: <portal user password>
> });
>
> Will try to find some time to backport it to 2.19 and 2.18 as well.
>
> And by the way, you say that you run
>
> - DHIS Live *2.18*
> - https://dhis2-cdn.org/*v215*/plugin/table.js
>
> Make sure that the plugin version matches the DHIS2 version.
>
> Jan
>
>
>
> On Fri, Oct 2, 2015 at 10:37 AM, Guy Ekani <constyekani@xxxxxxxx> wrote:
>
> Thank You Lars,
>
> I tried a example, Please let me give you my configuration :
> - DHIS Live 2.18 (18179) on Windows 7
> - Database = PostGreSQL  9.3
>
> *- Remote acces - CORE White Liste *
>     - http://localhost:8082/
>     - https://localhost:8082/ <http://localhost:8082/>
>     - http://127.0.0.1/ <http://localhost:8082/>
>
> *- My script*
> <!DOCTYPE html>
> <html>
> <head>
>   <link rel="stylesheet" type="text/css" href="
> http://dhis2-cdn.org/v215/ext/resources/css/ext-plugin-gray.css"; />
>   <script src="https://dhis2-cdn.org/v215/ext/ext-all.js";></script>
>   <script src="https://dhis2-cdn.org/v215/plugin/table.js";></script>
>
>   <script>
>     var base = "http://localhost:8082";;
>
>     // Login - if OK, call the setLinks function
>
>     Ext.onReady( function() {
>       Ext.Ajax.request({
>         url: base + "dhis-web-commons-security/login.action",
>         method: "POST",
>         params: { j_username: "ekani.guy", j_password: "xxxxx" },
>         success: setLinks
>       });
>     });
>
>     function setLinks() {
>
>       // Referring to an existing table through the id parameter, render
> to "table1" div
>
>       DHIS.getTable({ url: base, el: "table1", id: "fqk6tunwRLp" });
>
>     }
>   </script>
> </head>
>
> <body>
>   <div id="table1"></div>
> </body>
> </html>
>
> *- console error on web browser*
> 1.XMLHttpRequest cannot load
> http://localhost:8082/dhis-web-commons-security/login.action. The request
> was redirected to '
> http://localhost:8082/dhis-web-commons/security/login.action;jsessionid=yvbsx7nvigeft54069fvllae?failed=true',
> which is disallowed for cross-origin requests that require preflight.
>
> 2.XMLHttpRequest cannot load
> http://localhost:8082/dhis-web-commons/security/login.action. No
> 'Access-Control-Allow-Origin' header is present on the requested resource.
> Origin 'null' is therefore not allowed access.
>
> Sincerely,
>
> =========================
> EKANI Guy
>
>
>
>
>
>
>
>
> Le Jeudi 1 octobre 2015 19h11, Lars Helge Øverland <larshelge@xxxxxxxxx>
> a écrit :
>
>
> Hi Guy,
>
> for starters I recommend that you start reading up on how to use the
> analytics plugins here:
>
> https://www.dhis2.org/doc/snapshot/en/developer/html/ch01s23.html
>
> Using these you can embed pivots, charts and maps in web portals with live
> data from DHIS 2.
>
> You can also have a look at the Web portal demo here:
>
> https://apps.dhis2.org/portal/index.html
>
> https://apps.dhis2.org/portal/chart.html
>
> regards,
>
> Lars
>
>
> On Mon, Sep 28, 2015 at 5:31 PM, Guy Ekani <constyekani@xxxxxxxx> wrote:
>
> Hello Everyone,
>
> Could someone can share tips on how to build a Web Portal with DHIS2 Data
>
> Sincerely,
>
> =========================
> EKANI Guy
>
>
>
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-users
> Post to     : dhis2-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help   : https://help.launchpad.net/ListHelp
>
>
>
>
> --
> Lars Helge Øverland
> Lead developer, DHIS 2
> University of Oslo
> Skype: larshelgeoverland
> http://www.dhis2.org <https://www.dhis2.org/>
>
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
>
>
>
>

Follow ups

References