webdetails / cdf

Community Dashboard Framework
Other
56 stars 145 forks source link

Dashboards.context is not complete. #29

Closed belerweb closed 12 years ago

belerweb commented 12 years ago

The generated dashboard HTML contain a javascrit variable named Dashboards.context. I think it is not complete. The file value is blank. And I suggest add a fullPath value.

The generated sample Dashboards.context as folow:

  Dashboards.context = {
  "file": "",
  "locale": "en_US",
  "params": {},
  "path": "",
  "queryData": {},
  "roles": [
    "Admin",
    "Authenticated",
    "ceo"
  ],
  "serverLocalDate": 1345879506232,
  "serverUTCDate": 1345908306232,
  "sessionAttributes": {},
  "solution": "00-Dashboard",
  "user": "joe"
}

What I expect as folow:

  Dashboards.context = {
  "file": "xxx.xcdf",
  "fullPath":"/00-Dashboard/xxx.xcdf",
  "locale": "en_US",
  "params": {},
  "path": "",
  "queryData": {},
  "roles": [
    "Admin",
    "Authenticated",
    "ceo"
  ],
  "serverLocalDate": 1345879506232,
  "serverUTCDate": 1345908306232,
  "sessionAttributes": {},
  "solution": "00-Dashboard",
  "user": "joe"
}
belerweb commented 12 years ago

"file value is blank" can be fixed by modify org.pentaho.cdf.DashboardContext. Issue code:

            String solution = requestParams.getStringParameter("solution", ""),
                    path = requestParams.getStringParameter("path", ""),
                    file = requestParams.getStringParameter("file", ""),
                    fullPath = ("/" + solution + "/" + path + "/" + file).replaceAll("/+", "/");

Correct code:

            String solution = requestParams.getStringParameter("solution", ""),
                    path = requestParams.getStringParameter("path", ""),
                    file = requestParams.getStringParameter("action", ""), // Because there is no file parameter, but action parameter
                    fullPath = ("/" + solution + "/" + path + "/" + file).replaceAll("/+", "/");
belerweb commented 12 years ago

"I suggest add a fullPath value" can be fixed by add a sample line. Issue code

            context.put("path", path);
            context.put("file", file);

Correct code:

            context.put("path", path);
            context.put("file", file);
            context.put("fullPath", fullPath);