BUG 0000 adding dashboard initial module

This commit is contained in:
Erik Amaru Ortiz
2011-10-28 13:02:22 -04:00
parent 60d79ab34d
commit 89b9dbab56
7 changed files with 427 additions and 36 deletions

View File

@@ -1,13 +1,17 @@
<?php
/**
* Controller
* Controller Class
* Implementing MVC Pattern
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
* @package gulliver.system
* @access private
*/
class Controller
class Controller
{
/**
* @var boolean debug switch for general purpose
*/
public $debug = null;
/**
* @var array - private array to store proxy data
*/
@@ -18,16 +22,15 @@ class Controller
*/
private $__request__;
protected $headPublisher;
/**
* @var object - headPublisher object to handle the output
*/
private $headPublisher = null;
public $ExtVar = Array();
public $controllerClass = '';
public function __construct()
{
$this->headPublisher = headPublisher::getSingleton();
}
/**
* @var string - response type var. possibles values: json|plain
*/
private $responseType = '';
/**
* Magic setter method
@@ -37,7 +40,6 @@ class Controller
*/
public function __set($name, $value)
{
//echo "Setting '$name' to '$value'\n";
$this->__data__[$name] = $value;
}
@@ -49,7 +51,6 @@ class Controller
*/
public function __get($name)
{
//echo "Getting '$name'\n";
if (array_key_exists($name, $this->__data__)) {
return $this->__data__[$name];
}
@@ -65,55 +66,78 @@ class Controller
/**
* Magic isset method
*
* @param string $name
*/
public function __isset($name)
{
//echo "Is '$name' set?\n";
return isset($this->__data__[$name]);
}
/**
* Magic unset method
*
* @param string $name
*/
public function __unset($name)
{
//echo "Unsetting '$name'\n";
unset($this->__data__[$name]);
}
/**
* Set Response type method
* @param string $type contains : json|plain
*/
public function setResponseType($type)
{
$this->responseType = $type;
}
/**
* call to execute a internal proxy method and handle its exceptions
*
* @param string $name
*/
public function call($name)
{
//echo __CLASS__;
try {
$this->$name($this->__request__);
$result = $this->$name($this->__request__);
if ($this->responseType == 'json') {
print G::json_encode($result);
}
} catch (Exception $e) {
$template = new TemplatePower(PATH_TEMPLATE . 'controller.exception.tpl');
$template->prepare();
$template->assign('controller', get_called_class());
$template->assign('message', $e->getMessage());
$template->assign('file', $e->getFile());
$template->assign('line', $e->getLine());
$template->assign('trace', $e->getTraceAsString());
if ($this->responseType != 'json') {
$result->exception->class = get_class($e);
$result->exception->code = $e->getCode();
echo $template->getOutputContent();
$template = new TemplatePower(PATH_TEMPLATE . 'controller.exception.tpl');
$template->prepare();
$template->assign('controller', get_called_class());
$template->assign('message', $e->getMessage());
$template->assign('file', $e->getFile());
$template->assign('line', $e->getLine());
$template->assign('trace', $e->getTraceAsString());
echo $template->getOutputContent();
} else {
$result->success = false;
$result->msg = $e->getMessage();
switch(get_class($e)) {
case 'Exception': $error = "SYSTEM ERROR"; break;
case 'PMException': $error = "PROCESSMAKER ERROR"; break;
case 'PropelException': $error = "DATABASE ERROR"; break;
case 'UserException': $error = "USER ERROR"; break;
}
$result->error = $error;
$result->exception->class = get_class($e);
$result->exception->code = $e->getCode();
print G::json_encode($result);
}
}
}
/**
* Set the http request data
*
* @param array $data
*/
public function setHttpRequestData($data)
@@ -124,20 +148,93 @@ class Controller
} else
$this->__request__ = $data;
}
/**
* Get debug var. method
* @param boolan $val boolean value for debug var.
*/
public function setDebug($val)
{
$this->debug = $val;
}
/**
* Get debug var. method
*/
public function getDebug()
{
if ($this->debug === null) {
$this->debug = defined('DEBUG') && DEBUG ? true : false;
}
return $this->debug;
}
/*** HeadPublisher Functions Binding ***/
/**
* Include a particular extjs library or extension to the main output
* @param string $srcFile path of a extjs library or extension
* @param boolean $debug debug flag to indicate if the js output will be minifield or not
* $debug: true -> the js content will be not minified (readable)
* false -> the js content will be minified
*/
public function includeExtJSLib($srcFile, $debug=false)
{
$this->getHeadPublisher()->usingExtJs($srcFile, ($debug ? $debug : $this->getDebug()));
}
/**
* Include a javascript file that is using extjs framework to the main output
* @param string $srcFile path of javascrit file to include
* @param boolean $debug debug flag to indicate if the js output will be minifield or not
* $debug: true -> the js content will be not minified (readable)
* false -> the js content will be minified
*/
public function includeExtJS($srcFile, $debug=false)
{
$this->headPublisher->addExtJsScript($srcFile,true );
$this->getHeadPublisher()->addExtJsScript($srcFile, ($debug ? $debug : $this->getDebug()));
}
/**
* Include a Html file to the main output
* @param string $file path of html file to include to the main output
*/
public function setView($file)
{
$this->headPublisher->addContent($file,true );
$this->getHeadPublisher()->addContent($file);
}
/**
* Set variables to be accesible by javascripts
* @param string $name contains var. name
* @param string $value conatins var. value
*/
public function setJSVar($name, $value)
{
$this->headPublisher->assign($name, $value);
$this->getHeadPublisher()->assign($name, $value);
}
/**
* Set variables to be accesible by the extjs layout template
* @param string $name contains var. name
* @param string $value conatins var. value
*/
public function setVar($name, $value)
{
$this->getHeadPublisher()->sssignVar($name, $value);
}
/**
* method to get the local getHeadPublisher object
*/
public function getHeadPublisher()
{
if (!is_object($this->headPublisher)) {
$this->headPublisher = headPublisher::getSingleton();
}
return $this->headPublisher;
}
}

View File

@@ -17,6 +17,8 @@ class HttpProxyController {
* @var object - private object to store the http request data
*/
private $__request__;
public $jsonResponse = true;
private $sendResponse = true;
/**
@@ -81,6 +83,11 @@ class HttpProxyController {
{
try {
$result = $this->$name($this->__request__);
if (!$this->jsonResponse) {
return null;
}
if( ! $result )
$result = $this->__data__;
@@ -119,6 +126,11 @@ class HttpProxyController {
$this->__request__ = $data;
}
public function setJsonResponse($bool)
{
$this->jsonResponse = $bool;
}
/**
* Send response to client
*

View File

@@ -0,0 +1,23 @@
<?php
/**
* Dashborad controller
* @inherits Controller
* @access public
*/
class Dashboard extends Controller
{
/**
* getting default list
* @param string $httpData->PRO_UID (opional)
*/
public function index($httpData)
{
$this->includeExtJS('dashboard/index');
$this->includeExtJSLib('ux/portal');
//$this->setView('dashboard/index');
//render content
G::RenderPage('publish', 'extJs');
}
}

View File

@@ -45,6 +45,10 @@ if ($RBAC->userCanAccess('PM_FACTORY') == 1 ) {
$G_TMP_MENU->AddIdRawOption('PROCESSES', 'processes/main', G::LoadTranslation('ID_DESIGNER'));
}
// DASHBOARD MODULE
if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
$G_TMP_MENU->AddIdRawOption('DASHBOARD', 'dashboard/main', G::LoadTranslation('ID_DASHBOARD'));
}
/*if ($RBAC->userCanAccess('PM_REPORTS') == 1 ) {
$G_TMP_MENU->AddIdRawOption('REPORTS', 'reports/reportsList');

View File

@@ -0,0 +1,33 @@
<?php
/**
* dashboard.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
$RBAC->requirePermissions('PM_DASHBOARD');
$G_MAIN_MENU = 'processmaker';
$G_ID_MENU_SELECTED = 'DASHBOARD';
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'dashboard/load');
G::RenderPage('publish');

View File

@@ -0,0 +1,183 @@
Ext.onReady(function(){
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
// create some portlet tools using built in Ext tool ids
var tools = [{
id:'gear',
handler: function(){
Ext.Msg.alert('Message', 'The Settings tool was clicked.');
}
},{
id:'close',
handler: function(e, target, panel){
panel.ownerCt.remove(panel, true);
}
}];
var tbDashboard = new Ext.Toolbar({
height: 30,
items: [
{
xtype: 'tbbutton',
text : 'three columns',
handler : function(a) {
var vp = Ext.getCmp('viewportDashboard');
var pd = Ext.getCmp('portalDashboard');
pd.items.items[0].columnWidth = 0.33;
pd.items.items[1].columnWidth = 0.33;
pd.items.items[2].columnWidth = 0.33;
pd.doLayout();
}
},
{
xtype: 'tbbutton',
text : 'two columns',
handler : function(a) {
var vp = Ext.getCmp('viewportDashboard');
var pd = Ext.getCmp('portalDashboard');
pd.items.items[0].columnWidth = 0.49;
pd.items.items[1].columnWidth = 0.49;
while ( pd.items.items[2].items.items[0] ) {
pd.items.items[0].add( pd.items.items[2].items.items[0] );
}
pd.items.items[2].columnWidth = 0.01;
pd.doLayout();
}
},
{
xtype: 'tbbutton',
text : 'blog',
handler : function(a) {
var vp = Ext.getCmp('viewportDashboard');
var pd = Ext.getCmp('portalDashboard');
pd.items.items[0].columnWidth = 0.40;
pd.items.items[1].columnWidth = 0.40;
pd.items.items[2].columnWidth = 0.20;
pd.doLayout();
//vp.doLayout();
}
},
{
xtype: 'tbbutton',
text : 'new gauge',
handler : function(a) {
var np = new Ext.ux.Portlet ( {
//title: 'Panel nuevo',
//tools: tools,
html: 'hello world',
listeners: {
'render': function(p){
p.html = 'hello ' + p.getWidth();
},
'move' : function(p){
Ext.Msg.alert('Portlet ', 'move ' + p.getWidth() );
p.html = 'show ' + p.getWidth();
},
'resize' : function(p,w,h){
var randomnumber=Math.floor(Math.random()*1000000)
var img = new Ext.XTemplate("<img src='{page}?w={width}&r={random}'>").apply({
page: 'http://javaserver.colosa.net/ext/examples/portal/gauge.php', width:w, random: randomnumber })
p.update(img );
}
}
});
var vp = Ext.getCmp('viewportDashboard');
var pd = Ext.getCmp('portalDashboard');
pd.items.items[0].add( np );
pd.doLayout();
//vp.doLayout();
}
},
{
xtype: 'tbbutton',
text : 'new trend graph',
handler : function(a) {
var np = new Ext.ux.Portlet ( {
//title: 'Panel nuevo',
tools: tools,
html: 'hello world',
listeners: {
'render': function(p){
p.html = 'hello ' + p.getWidth();
},
'move' : function(p){
Ext.Msg.alert('Portlet ', 'move ' + p.getWidth() );
p.html = 'show ' + p.getWidth();
},
'resize' : function(p,w,h){
var randomnumber=Math.floor(Math.random()*1000000)
var img = new Ext.XTemplate("<img src='{page}?w={width}&r={random}'>").apply({
page: 'http://javaserver.colosa.net/ext/examples/portal/history.php', width:w, random: randomnumber })
p.update(img );
}
}
});
var vp = Ext.getCmp('viewportDashboard');
var pd = Ext.getCmp('portalDashboard');
pd.items.items[0].add( np );
pd.doLayout();
//vp.doLayout();
}
}
]
});
var viewport = new Ext.Viewport({
layout:'fit',
name : 'viewportDashboard',
id : 'viewportDashboard',
items:[{
xtype:'portal',
region:'center',
margins:'35 5 5 0',
tbar: tbDashboard,
name : 'portalDashboard',
id : 'portalDashboard',
items:[{
columnWidth:.33,
style:'padding:10px 0 10px 10px',
items:[{
title: 'Grid in a Portlet',
layout:'fit',
tools: tools,
html: 'Learn Use the included files to view samples and our API documentation. For advanced, hands-on support, please see our premium support subscriptions. Larger organizations can use our enterprise training and services.'
//items: new SampleGrid([0, 2, 3])
}]
},{
columnWidth:.33,
style:'padding:10px 0 10px 10px',
items:[{
title: 'Panel 2',
tools: tools,
html: 'Learn Use the included files to view samples and our API documentation. For advanced, hands-on support, please see our premium support subscriptions. Larger organizations can use our enterprise training and services.'
}]
},{
columnWidth:.33,
style:'padding:10px',
items:[{
title: 'Panel 3',
tools: tools,
html: 'Learn Use the included files to view samples and our API documentation. For advanced, hands-on support, please see our premium support subscriptions. Larger organizations can use our enterprise training and services.'
}]
}]
/*
* Uncomment this block to test handling of the drop event. You could use this
* to save portlet position state for example. The event arg e is the custom
* event defined in Ext.ux.Portal.DropZone.
*/
// ,listeners: {
// 'drop': function(e){
// Ext.Msg.alert('Portlet Dropped', e.panel.title + '<br />Column: ' +
// e.columnIndex + '<br />Position: ' + e.position);
// }
// }
}]
});
});

View File

@@ -0,0 +1,39 @@
<html>
<style type="text/css">
.Footer .content {
padding :0px !important;
}
*html body {
overflow-y: hidden;
}
</style>
<body onresize="autoResizeScreen()" onload="autoResizeScreen()">
<iframe name="casesFrame" id="casesFrame" src ="../dashboard" width="99%" height="768" frameborder="0">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
<script>
if ( document.getElementById('pm_submenu') )
document.getElementById('pm_submenu').style.display = 'none';
document.documentElement.style.overflowY = 'hidden';
var oClientWinSize = getClientWindowSize();
function autoResizeScreen() {
oCasesFrame = document.getElementById('casesFrame');
height = getClientWindowSize().height-90;
oCasesFrame.style.height = height;
oCasesSubFrame = oCasesFrame.contentWindow.document.getElementById('casesSubFrame');
if(oCasesSubFrame){
oCasesSubFrame.style.height = height-5;
}
else {
setTimeout('autoResizeScreen()', 2000);
}
}
</script>
</html>