dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23851
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11619: Dashboard, impl support for embedded pivot tables in dashboard
------------------------------------------------------------
revno: 11619
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-08-08 19:05:40 +0200
message:
Dashboard, impl support for embedded pivot tables in dashboard
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/dashboard/hibernate/DashboardItem.hbm.xml
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java 2013-07-24 15:55:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java 2013-08-08 17:05:40 +0000
@@ -58,6 +58,7 @@
public static final String TYPE_CHART = "chart";
public static final String TYPE_MAP = "map";
+ public static final String TYPE_REPORT_TABLE = "reportTable";
public static final String TYPE_USERS = "users";
public static final String TYPE_REPORT_TABLES = "reportTables";
public static final String TYPE_REPORTS = "reports";
@@ -67,6 +68,8 @@
private Map map;
+ private ReportTable reportTable;
+
private List<User> users = new ArrayList<User>();
private List<ReportTable> reportTables = new ArrayList<ReportTable>();
@@ -105,6 +108,10 @@
{
return TYPE_MAP;
}
+ else if ( reportTable != null )
+ {
+ return TYPE_REPORT_TABLE;
+ }
else if ( !users.isEmpty() )
{
return TYPE_USERS;
@@ -208,6 +215,18 @@
this.map = map;
}
+ @JsonProperty
+ @JsonSerialize( as = BaseIdentifiableObject.class )
+ public ReportTable getReportTable()
+ {
+ return reportTable;
+ }
+
+ public void setReportTable( ReportTable reportTable )
+ {
+ this.reportTable = reportTable;
+ }
+
@JsonProperty( value = "users" )
@JsonSerialize( contentAs = BaseIdentifiableObject.class )
@JacksonXmlElementWrapper( localName = "users", namespace = DxfNamespaces.DXF_2_0)
@@ -279,6 +298,7 @@
chart = item.getChart() == null ? chart : item.getChart();
map = item.getMap() == null ? map : item.getMap();
+ reportTable = item.getReportTable() == null ? reportTable : item.getReportTable();
users = item.getUsers() == null ? users : item.getUsers();
reportTables = item.getReportTables() == null ? reportTables : item.getReportTables();
reports = item.getReports() == null ? reports : item.getReports();
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java 2013-07-23 17:21:14 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java 2013-08-08 17:05:40 +0000
@@ -30,6 +30,7 @@
import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
import static org.hisp.dhis.dashboard.DashboardItem.TYPE_CHART;
import static org.hisp.dhis.dashboard.DashboardItem.TYPE_MAP;
+import static org.hisp.dhis.dashboard.DashboardItem.TYPE_REPORT_TABLE;
import static org.hisp.dhis.dashboard.DashboardItem.TYPE_REPORTS;
import static org.hisp.dhis.dashboard.DashboardItem.TYPE_REPORT_TABLES;
import static org.hisp.dhis.dashboard.DashboardItem.TYPE_RESOURCES;
@@ -113,6 +114,12 @@
item.setMap( objectManager.get( Map.class, contentUid ) );
dashboard.getItems().add( 0, item );
}
+ else if ( TYPE_REPORT_TABLE.equals( type ) )
+ {
+ DashboardItem item = new DashboardItem();
+ item.setReportTable( objectManager.get( ReportTable.class, contentUid ) );
+ dashboard.getItems().add( 0, item );
+ }
else // Link item
{
DashboardItem availableItem = dashboard.getAvailableItemByType( type );
@@ -168,6 +175,11 @@
item.setMap( objectManager.get( Map.class, item.getMap().getUid() ) );
}
+ if ( item.getReportTable() != null )
+ {
+ item.setReportTable( objectManager.get( ReportTable.class, item.getReportTable().getUid() ) );
+ }
+
if ( item.getUsers() != null )
{
item.setUsers( objectManager.getByUid( User.class, getUids( item.getUsers() ) ) );
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/dashboard/hibernate/DashboardItem.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/dashboard/hibernate/DashboardItem.hbm.xml 2013-07-22 21:08:05 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/dashboard/hibernate/DashboardItem.hbm.xml 2013-08-08 17:05:40 +0000
@@ -19,6 +19,8 @@
<many-to-one name="map" class="org.hisp.dhis.mapping.Map" column="mapid" foreign-key="fk_dashboarditem_mapid" />
+ <many-to-one name="reportTable" class="org.hisp.dhis.reporttable.ReportTable" foreign-key="fk_dashboarditem_reporttableid" />
+
<list name="users" table="dashboarditem_users">
<key column="dashboarditemid" foreign-key="fk_dashboarditem_users_dashboardid" />
<list-index column="sort_order" base="0" />
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js 2013-08-08 10:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js 2013-08-08 17:05:40 +0000
@@ -7,6 +7,8 @@
dhis2.db.currentShareType;
dhis2.db.currentShareId;
+// TODO remove position from template
+// TODO support table as link and embedded
// TODO double horizontal size
// TODO dashboard list horizontal scroll
// TODO report type in link
@@ -57,13 +59,20 @@
"<li id='li-${itemId}' class='liItem'><div class='item' id='${itemId}'><div class='itemHeader'><a href='javascript:dhis2.db.removeItem( \"${itemId}\" )'>${i18n_remove}</a>" +
"<a href='javascript:dhis2.db.viewImage( \"../api/charts/${id}/data?width=820&height=550\", \"${name}\" )'>${i18n_view}</a>" +
"<a href='javascript:dhis2.db.viewShareForm( \"${id}\", \"chart\", \"${name}\" )'>${i18n_share}</a></div>" +
- "<img src='../api/charts/${id}/data?width=405&height=295' onclick='dhis2.db.exploreChart( \"${id}\" )' title='${i18n_click}'></div></li>",
+ "<img src='../api/charts/${id}/data?width=405&height=294' onclick='dhis2.db.exploreChart( \"${id}\" )' title='${i18n_click}'></div></li>",
mapItem: "<li id='liDrop-${itemId}' class='liDropItem'><div class='dropItem' id='drop-${itemId}' data-item='${itemId}'></div></li>" +
"<li id='li-${itemId}' class='liItem'><div class='item' id='${itemId}'><div class='itemHeader'><a href='javascript:dhis2.db.removeItem( \"${itemId}\" )'>${i18n_remove}</a>" +
"<a href='javascript:dhis2.db.viewImage( \"../api/maps/${id}/data?width=820&height=550\", \"${name}\" )'>${i18n_view}</a>" +
"<a href='javascript:dhis2.db.viewShareForm( \"${id}\", \"map\", \"${name}\" )'>${i18n_share}</a></div>" +
- "<img src='../api/maps/${id}/data?width=405&height=295' onclick='dhis2.db.exploreMap( \"${id}\" )' title='${i18n_click}'></div></li>"
+ "<img src='../api/maps/${id}/data?width=405&height=294' onclick='dhis2.db.exploreMap( \"${id}\" )' title='${i18n_click}'></div></li>",
+
+ reportTableItem: "<li id='liDrop-${itemId}' class='liDropItem'><div class='dropItem' id='drop-${itemId}' data-item='${itemId}'></div></li>" +
+ "<li id='li-${itemId}' class='liItem'><div class='item' id='${itemId}'><div class='itemHeader'><a href='javascript:dhis2.db.removeItem( \"${itemId}\" )'>${i18n_remove}</a>" +
+ "<a href='javascript:dhis2.db.viewImage( \"../api/reportTables/${id}/data.html\", \"${name}\" )'>${i18n_view}</a>" +
+ "<a href='javascript:dhis2.db.viewShareForm( \"${id}\", \"table\", \"${name}\" )'>${i18n_share}</a></div>" +
+ "<div id='pivot-${itemId}' onclick='dhis2.db.exploreReportTable( \"${id}\" )' title='${i18n_click}'></div>" +
+ "<script type='text/javascript'>dhis2.db.renderReportTable( '${id}', '${itemId}' );</script></div></li>"
};
dhis2.db.dashboardReady = function( id )
@@ -303,6 +312,11 @@
$d.append( $.tmpl( dhis2.db.tmpl.mapItem, { "itemId": item.id, "id": item.map.id, "name": item.map.name, "position": position,
"i18n_remove": i18n_remove, "i18n_view": i18n_view_full_size, "i18n_share": i18n_share, "i18n_click": i18n_click_to_explore_drag_to_new_position } ) )
}
+ else if ( "reportTable" == item.type )
+ {
+ $d.append( $.tmpl( dhis2.db.tmpl.reportTableItem, { "itemId": item.id, "id": item.reportTable.id, "name": item.reportTable.name, "position": position,
+ "i18n_remove": i18n_remove, "i18n_view": i18n_view_full_size, "i18n_share": i18n_share, "i18n_click": i18n_click_to_explore_drag_to_new_position } ) )
+ }
else if ( "users" == item.type )
{
dhis2.db.renderLinkItem( $d, item.id, item.users, "Users", position, "../dhis-web-dashboard-integration/profile.action?id=", "" );
@@ -419,6 +433,28 @@
return parseInt( $( ".liDropItem" ).index( $( "#liDrop-" + itemId ) ) );
}
+dhis2.db.exploreChart = function( uid )
+{
+ window.location.href = "../dhis-web-visualizer/app/index.html?id=" + uid;
+}
+
+dhis2.db.exploreMap = function( uid )
+{
+ window.location.href = "../dhis-web-mapping/app/index.html?id=" + uid;
+}
+
+dhis2.db.exploreReportTable = function( uid )
+{
+ window.location.href = "../dhis-web-pivot/app/index.html?id=" + uid;
+}
+
+dhis2.db.renderReportTable = function( tableId, itemId )
+{
+ $.get( "../api/reportTables/" + tableId + "/data.html", function( data ) {
+ $( "#pivot-" + itemId ).html( data );
+ } );
+}
+
//------------------------------------------------------------------------------
// Search
//------------------------------------------------------------------------------
@@ -486,7 +522,7 @@
for ( var i in data.reportTables )
{
var o = data.reportTables[i];
- $h.append( $.tmpl( dhis2.db.tmpl.hitItem, { "link": "../dhis-web-pivot/app/index.html?id=" + o.id, "img": "table_small", "name": o.name, "type": "reportTables", "id": o.id } ) );
+ $h.append( $.tmpl( dhis2.db.tmpl.hitItem, { "link": "../dhis-web-pivot/app/index.html?id=" + o.id, "img": "table_small", "name": o.name, "type": "reportTable", "id": o.id } ) );
}
}
@@ -598,14 +634,3 @@
title : title
} );
}
-
-dhis2.db.exploreChart = function( uid )
-{
- window.location.href = "../dhis-web-visualizer/app/index.html?id=" + uid;
-}
-
-dhis2.db.exploreMap = function( uid )
-{
- window.location.href = "../dhis-web-mapping/app/index.html?id=" + uid;
-}
-
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css 2013-08-07 14:32:02 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css 2013-08-08 17:05:40 +0000
@@ -86,6 +86,20 @@
cursor: pointer;
box-shadow: #ddd 0px 1px 3px 0px;
background-color: #fff;
+ overflow: auto;
+}
+
+.item h3
+{
+ font-size: 12px;
+ font-family: LiberationSansBold, sans-serif;
+ color: #39547d;
+ margin: 2px 5px;
+}
+
+.item h4
+{
+ margin: 0;
}
.item:hover