← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17982: Dashboard, resize

 

------------------------------------------------------------
revno: 17982
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-01-14 12:45:05 +0100
message:
  Dashboard, resize
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardItemController.java
  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-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardItemController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardItemController.java	2015-01-13 18:53:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardItemController.java	2015-01-14 11:45:05 +0000
@@ -28,9 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.dashboard.DashboardItem.SHAPE_FULL_WIDTH;
-import static org.hisp.dhis.dashboard.DashboardItem.SHAPE_NORMAL;
-
 import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
@@ -84,8 +81,8 @@
         return entityList;
     }
     
-    @RequestMapping( value = "/{uid}/shape", method = RequestMethod.PUT )
-    public void putDashboardItemShape( @PathVariable String uid,
+    @RequestMapping( value = "/{uid}/shape/{shape}", method = RequestMethod.PUT )
+    public void putDashboardItemShape( @PathVariable String uid, @PathVariable String shape,
         HttpServletRequest request, HttpServletResponse response ) throws Exception
     {
         DashboardItem item = dashboardService.getDashboardItem( uid );
@@ -96,8 +93,6 @@
             return;
         }
         
-        String shape = item.getShape() == null || SHAPE_NORMAL.equals( item.getShape() ) ? SHAPE_FULL_WIDTH : SHAPE_NORMAL;
-        
         item.setShape( shape );
         
         dashboardService.updateDashboardItem( item );

=== 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	2015-01-14 11:08:32 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js	2015-01-14 11:45:05 +0000
@@ -26,7 +26,9 @@
 dhis2.db.currentShareId;
 dhis2.db.currentMaxType = [];
 dhis2.db.maxItems = 40;
+dhis2.db.shapeNormal = "normal";
 dhis2.db.shapeFullWidth = "full_width";
+dhis2.db.widthNormal = 408;
 
 // TODO support table as link and embedded
 // TODO double horizontal size
@@ -408,10 +410,34 @@
 	return fullWidth;
 }
 
+dhis2.db.resizeItem = function( id )
+{
+	$.getJSON( "../api/dashboardItems/" + id, function( item ) {
+		
+		var newShape = dhis2.db.shapeFullWidth;			
+		
+		if ( dhis2.db.shapeFullWidth == item.shape ) {
+			newShape = dhis2.db.shapeNormal;
+			$( "#" + id ).css( "width", dhis2.db.widthNormal + "px" );
+			Ext.get( "plugin-" + id ).viewport.setWidth( dhis2.db.widthNormal );
+		}
+		else {
+			newShape = dhis2.db.shapeFullWidth,
+			fullWidth = dhis2.db.getFullWidth();
+			$( "#" + id ).css( "width", fullWidth + "px" );
+			Ext.get( "plugin-" + id ).viewport.setWidth( fullWidth );
+		}
+		
+		$.ajax( {
+			url: "../api/dashboardItems/" + id + "/shape/" + newShape,
+			type: "put"
+		} );
+	} );
+}
+
 dhis2.db.renderDashboard = function( id )
 {
-    var contentWidth = 408,
-        contentHeight = 304,
+    var contentHeight = 304,
         isChrome = /\bchrome\b/.test(navigator.userAgent.toLowerCase()),
         scrollbarWidth = isChrome ? 8 : 17;
 
@@ -443,9 +469,9 @@
 				    return true;
 				}
 
-				var width = ( dhis2.db.shapeFullWidth == dashboardItem.shape ) ? fullWidth : contentWidth;
-				var style = ( dhis2.db.shapeFullWidth == dashboardItem.shape ) ? "width:" + fullWidth + "px" : "";
-
+				var width = ( dhis2.db.shapeFullWidth == dashboardItem.shape ) ? fullWidth : dhis2.db.widthNormal;
+				var style = "width:" + width + "px";
+				
 				if ( "chart" == dashboardItem.type )
 				{
 				    $d.append( $.tmpl( dhis2.db.tmpl.chartItem, { "itemId": dashboardItem.id, "id": dashboardItem.chart.id, "name": dashboardItem.chart.name, "style": style,
@@ -764,14 +790,6 @@
 	window.location.href = "../dhis-web-event-reports/index.html?id=" + uid;
 }
 
-dhis2.db.resizeItem = function( uid )
-{
-	$.ajax( {
-		url: "../api/dashboardItems/" + uid + "/shape",
-		type: "put"
-	} );
-}
-
 dhis2.db.renderReportTable = function( tableId, itemId )
 {
 	$.get( "../api/reportTables/" + tableId + "/data.html", function( data ) {

=== 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	2015-01-14 10:27:59 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css	2015-01-14 11:45:05 +0000
@@ -96,7 +96,6 @@
 {
   background-color: #fff;
   border: 1px solid #ccc;
-  width: 408px;
   height: 329px;
   padding: 6px;
   margin: 0 19px 19px 0;