Third progress with the dashboards (first version)

This commit is contained in:
Julio Cesar Laura
2011-10-31 14:39:52 -04:00
parent aecbcd8d64
commit 1b3e769841
6 changed files with 463 additions and 266 deletions

View File

@@ -1,9 +0,0 @@
<?php
G::LoadClass('pmDashlet');
class DashletGaugeIndicator extends PMDashlet {
//
}

View File

@@ -0,0 +1,60 @@
<?php
require_once 'interfaces/dashletInterface.php';
class DashletOpenVSCompleted implements DashletInterface {
/**
width
*/
var $w = 610;
/**
height
*/
var $h = 300;
/**
value of gauge
*/
var $value = 50;
/**
maxValue
*/
var $maxValue = 100;
/**
redFrom
*/
var $redFrom = 80;
/**
redTo
*/
var $redTo = 100;
/**
yellowFrom
*/
var $yellowFrom = 60;
/**
yellowTo
*/
var $yellowTo = 80;
function setup($config) {
//$this->w = $config['w'];
//loadData
}
function render () {
/*G::LoadClass('gauge');
$g = new Gauge();
$g->w = $w;
//others
$g->render();*/
}
}

View File

@@ -6,10 +6,79 @@ require_once 'model/DashletInstance.php';
class PMDashlet extends DashletInstance implements DashletInterface { class PMDashlet extends DashletInstance implements DashletInterface {
public function setup() { // Own properties
// Interface functions
public function setup($dasInsUid) {
try {
//
}
catch (Exception $error) {
throw $error;
}
//recupera el registro
/*$array = loadDB()
//merge
$c = new $className();
$c->setup($array);*/
} }
public function render() { public function render() {
try {
//
}
catch (Exception $error) {
throw $error;
}
//$this->c->render();
}
// Own functions
public function getDashletsInstances() {
try {
//
}
catch (Exception $error) {
throw $error;
}
}
public function getDashletsInstancesQuantity() {
try {
//
}
catch (Exception $error) {
throw $error;
}
}
public function saveDashletInstance($data) {
try {
//
}
catch (Exception $error) {
throw $error;
}
}
public function deleteDashletInstance($dasInsUid) {
try {
//
}
catch (Exception $error) {
throw $error;
}
}
public function getDashletsInstancesForUser($userUid) {
try {
//
}
catch (Exception $error) {
throw $error;
}
} }
} }

View File

@@ -7,27 +7,55 @@
class Dashboard extends Controller { class Dashboard extends Controller {
// Class properties
private pmDashlet;
// Class constructor
public function __construct() {
G::LoadClass('pmDashlet');
$this->pmDashlet = new PMDashlet();
}
// Functions for the dashboards users module - Start // Functions for the dashboards users module - Start
public function index($httpData) { public function index($httpData) {
$this->includeExtJS('dashboard/index'); try {
$this->includeExtJSLib('ux/portal'); $this->setJSVar('dashletsInstances', $this->getDashletsInstancesForCurrentUser());
G::RenderPage('publish', 'extJs'); $this->includeExtJS('dashboard/index');
$this->includeExtJSLib('ux/portal');
G::RenderPage('publish', 'extJs');
}
catch (Exception $error) {
//ToDo: Display a error message
}
} }
public function renderDashletInstance($dasInsUid) { public function renderDashletInstance($data) {
require_once ( PATH_METHODS . 'dashboard/class.gauge.php' ); try {
$gauge = new pmGauge(); if (!isset($data['DAS_INS_UID'])) {
/* $data['DAS_INS_UID'] = '';
$gauge->value = x; }
$gauge->maxValue = x; if ($data['DAS_INS_UID'] == '') {
*/ throw new Exception('Parameter "DAS_INS_UID" is empty.');
//falta el width de la imagen }
$w = isset($_REQUEST['w']) ? intval($_REQUEST['w']) : 610; $this->pmDashlet->setup($data['DAS_INS_UID']);
if ( intval($_REQUEST['w']) < 50 ) $w = 50; $this->pmDashlet->render();
$gauge->w = $w; }
catch (Exception $error) {
$gauge->render(); //ToDo: Render a image with the error message
}
}
private function getDashletsInstancesForCurrentUser() {
try {
if (!isset($_SESSION['USER_LOGGED'])) {
throw new Exception('The session has expired.');
}
return $this->pmDashlet->getDashletsInstancesForUser($_SESSION['USER_LOGGED']);
}
catch (Exception $error) {
throw $error;
}
} }
// Functions for the dashboards users module - End // Functions for the dashboards users module - End
@@ -35,36 +63,88 @@ class Dashboard extends Controller {
// Functions for the dasboards administration module - Start // Functions for the dasboards administration module - Start
public function dashletsList() { public function dashletsList() {
$headPublisher =& headPublisher::getSingleton(); try {
$headPublisher->addExtJsScript('dashboard/dashletsList', false); $this->includeExtJS('dashboard/dashletsList');
$headPublisher->addContent('dashboard/dashletsList'); $this->setView('dashboard/dashletsList');
G::RenderPage('publish', 'extJs'); G::RenderPage('publish', 'extJs');
}
catch (Exception $error) {
//ToDo: Display a error message
}
} }
public function getDashletsInstances() { public function getDashletsInstances() {
// $this->setResponseType('json');
$result = new stdclass();
$result->status = 'OK';
try {
$result->dashletsInstances = $this->pmDashlet->getDashletsInstances($start, $limit);
$result->totalDashletsInstances = $this->pmDashlet->getDashletsInstancesQuantity();
}
catch (Exception $error) {
$result->status = 'ERROR';
$result->message = $error->getMessage();
}
return $result;
} }
public function dashletInstanceForm($dasInsUid) { public function dashletInstanceForm($dasInsUid = '') {
$headPublisher =& headPublisher::getSingleton(); try {
$headPublisher->addExtJsScript('dashboard/dashletInstanceForm', false); $this->includeExtJS('dashboard/dashletInstanceForm', false);
$headPublisher->addContent('dashboard/dashletInstanceForm'); $this->setView('dashboard/dashletInstanceForm');
if ($dasInsUid != '') { if ($dasInsUid != '') {
// load data before render the form $this->setJSVar('dashletInstance', $this->pmDashlet->getDashletInstance($dasInsUid));
}
else {
$this->setJSVar('dashletInstance', new stdclass());
}
G::RenderPage('publish', 'extJs');
}
catch (Exception $error) {
//ToDo: Display a error message
} }
G::RenderPage('publish', 'extJs');
} }
public function saveDashletInstance($data) { public function saveDashletInstance($data) {
// $this->setResponseType('json');
$result = new stdclass();
$result->status = 'OK';
try {
$this->pmDashlet->saveDashletInstance($data);
}
catch (Exception $error) {
$result->status = 'ERROR';
$result->message = $error->getMessage();
}
return $result;
} }
public function deleteDashletInstance($dasInsUid) { public function deleteDashletInstance($dasInsUid) {
// $this->setResponseType('json');
$result = new stdclass();
$result->status = 'OK';
try {
$this->pmDashlet->deleteDashletInstance($dasInsUid);
}
catch (Exception $error) {
$result->status = 'ERROR';
$result->message = $error->getMessage();
}
return $result;
} }
public function getOwnersByType($type) { public function getOwnersByType($type) {
// $this->setResponseType('json');
$result = new stdclass();
$result->status = 'OK';
try {
//ToDo: For the next release
}
catch (Exception $error) {
$result->status = 'ERROR';
$result->message = $error->getMessage();
}
return $result;
} }
// Functions for the dasboards administration module - End // Functions for the dasboards administration module - End

View File

@@ -1,20 +1,21 @@
new Ext.KeyMap(document, [{ new Ext.KeyMap(document, [{
key: Ext.EventObject.F5, key: Ext.EventObject.F5,
fn: function(keycode, e) { fn: function(k, e) {
if (!e.ctrlKey) { if (!e.ctrlKey) {
if (Ext.isIE) { if (Ext.isIE) {
e.browserEvent.keyCode = 8; e.browserEvent.keyCode = 8;
} }
e.stopEvent(); e.stopEvent();
document.location = document.location; document.location = document.location;
}else{ }
else {
Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5'); Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5');
} }
} }
}, },
{ {
key: Ext.EventObject.DELETE, key: Ext.EventObject.DELETE,
fn: function(k,e) { fn: function(k, e) {
iGrid = Ext.getCmp('infoGrid'); iGrid = Ext.getCmp('infoGrid');
rowSelected = iGrid.getSelectionModel().getSelected(); rowSelected = iGrid.getSelectionModel().getSelected();
if (rowSelected) { if (rowSelected) {
@@ -24,7 +25,7 @@ new Ext.KeyMap(document, [{
}, },
{ {
key: Ext.EventObject.F2, key: Ext.EventObject.F2,
fn: function(k,e) { fn: function(k, e) {
iGrid = Ext.getCmp('infoGrid'); iGrid = Ext.getCmp('infoGrid');
rowSelected = iGrid.getSelectionModel().getSelected(); rowSelected = iGrid.getSelectionModel().getSelected();
if (rowSelected){ if (rowSelected){
@@ -42,246 +43,242 @@ var smodel;
var newButton; var newButton;
var editButton; var editButton;
var deleteButton; var deleteButton;
var permissionsButton; //var searchButton;
var searchButton; //var searchText;
var serachText; //var clearTextButton;
var newForm;
var comboStatusStore;
var editForm;
var contextMenu;
var w;
var actionButtons; var actionButtons;
var contextMenu;
Ext.onReady(function(){ Ext.onReady(function(){
Ext.QuickTips.init(); Ext.QuickTips.init();
pageSize = 20; //parseInt(CONFIG.pageSize);
newButton = new Ext.Action({ pageSize = 20; //parseInt(CONFIG.pageSize);
text: _('ID_NEW'),
iconCls: 'button_menu_ext ss_sprite ss_add',
handler: newDashletInstance
});
editButton = new Ext.Action({ newButton = new Ext.Action({
text: _('ID_EDIT'), text: _('ID_NEW'),
iconCls: 'button_menu_ext ss_sprite ss_pencil', iconCls: 'button_menu_ext ss_sprite ss_add',
handler: editDashletInstance, handler: newDashletInstance
disabled: true });
});
deleteButton = new Ext.Action({ editButton = new Ext.Action({
text: _('ID_DELETE'), text: _('ID_EDIT'),
iconCls: 'button_menu_ext ss_sprite ss_delete', iconCls: 'button_menu_ext ss_sprite ss_pencil',
handler: deleteDashletInstance, handler: editDashletInstance,
disabled: true disabled: true
}); });
searchButton = new Ext.Action({ deleteButton = new Ext.Action({
text: _('ID_SEARCH'), text: _('ID_DELETE'),
handler: doSearch iconCls: 'button_menu_ext ss_sprite ss_delete',
}); handler: deleteDashletInstance,
disabled: true
});
contextMenu = new Ext.menu.Menu({ /*searchButton = new Ext.Action({
items: [editButton, deleteButton] text: _('ID_SEARCH'),
}); handler: doSearch
});
searchText = new Ext.form.TextField ({ searchText = new Ext.form.TextField ({
id: 'searchText', id: 'searchText',
ctCls:'pm_search_text_field', ctCls:'pm_search_text_field',
allowBlank: true, allowBlank: true,
width: 150, width: 150,
emptyText: _('ID_ENTER_SEARCH_TERM'),//'enter search term', emptyText: _('ID_ENTER_SEARCH_TERM'),
listeners: { listeners: {
specialkey: function(f,e){ specialkey: function(f, e){
if (e.getKey() == e.ENTER) { if (e.getKey() == e.ENTER) {
doSearch(); doSearch();
}
},
focus: function(f,e) {
var row = infoGrid.getSelectionModel().getSelected();
infoGrid.getSelectionModel().deselectRow(infoGrid.getStore().indexOf(row));
}
} }
}); },
focus: function(f, e) {
var row = infoGrid.getSelectionModel().getSelected();
infoGrid.getSelectionModel().deselectRow(infoGrid.getStore().indexOf(row));
}
}
});
clearTextButton = new Ext.Action({ clearTextButton = new Ext.Action({
text: 'X', text: 'X',
ctCls:'pm_search_x_button', ctCls:'pm_search_x_button',
handler: gridByDefault handler: gridByDefault
}); });*/
actionButtons = [newButton, '-', editButton, deleteButton, {xtype: 'tbfill'}, searchText, clearTextButton, searchButton]; contextMenu = new Ext.menu.Menu({
items: [editButton, deleteButton]
});
smodel = new Ext.grid.RowSelectionModel({ actionButtons = [newButton, '-', editButton, deleteButton/*, {xtype: 'tbfill'}, searchText, clearTextButton, searchButton*/];
singleSelect: true,
listeners:{ smodel = new Ext.grid.RowSelectionModel({
rowselect: function(sm, index, record){ singleSelect: true,
editButton.enable(); listeners:{
deleteButton.enable(); rowselect: function(sm, index, record){
if (typeof(_rowselect) !== 'undefined') { editButton.enable();
if (Ext.isArray(_rowselect)) { deleteButton.enable();
for (var i = 0; i < _rowselect.length; i++) { if (typeof(_rowselect) !== 'undefined') {
if (Ext.isFunction(_rowselect[i])) { if (Ext.isArray(_rowselect)) {
_rowselect[i](sm, index, record); for (var i = 0; i < _rowselect.length; i++) {
} if (Ext.isFunction(_rowselect[i])) {
_rowselect[i](sm, index, record);
} }
} }
} }
}, }
rowdeselect: function(sm, index, record){ },
editButton.disable(); rowdeselect: function(sm, index, record){
deleteButton.disable(); editButton.disable();
if (typeof(_rowdeselect) !== 'undefined') { deleteButton.disable();
if (Ext.isArray(_rowdeselect)) { if (typeof(_rowdeselect) !== 'undefined') {
for (var i = 0; i < _rowdeselect.length; i++) { if (Ext.isArray(_rowdeselect)) {
if (Ext.isFunction(_rowdeselect[i])) { for (var i = 0; i < _rowdeselect.length; i++) {
_rowdeselect[i](sm, index, record); if (Ext.isFunction(_rowdeselect[i])) {
} _rowdeselect[i](sm, index, record);
} }
} }
} }
} }
} }
}); }
});
store = new Ext.data.GroupingStore( { store = new Ext.data.GroupingStore( {
proxy : new Ext.data.HttpProxy({ proxy : new Ext.data.HttpProxy({
url: 'getDashletsInstances' url: 'getDashletsInstances'
}), }),
reader : new Ext.data.JsonReader( { reader : new Ext.data.JsonReader( {
root: 'sources', root: 'dashletsInstances',
totalProperty: 'total_sources', totalProperty: 'totalDashletsInstances',
fields : [ fields : [
{name : 'AUTH_SOURCE_UID'}, {name : 'AUTH_SOURCE_UID'},
{name : 'AUTH_SOURCE_NAME'}, {name : 'AUTH_SOURCE_NAME'},
{name : 'AUTH_SOURCE_PROVIDER'}, {name : 'AUTH_SOURCE_PROVIDER'},
{name : 'AUTH_SOURCE_SERVER_NAME'}, {name : 'AUTH_SOURCE_SERVER_NAME'},
{name : 'AUTH_SOURCE_PORT'}, {name : 'AUTH_SOURCE_PORT'},
{name : 'AUTH_SOURCE_ENABLED_TLS'}, {name : 'AUTH_SOURCE_ENABLED_TLS'},
{name : 'AUTH_SOURCE_VERSION'}, {name : 'AUTH_SOURCE_VERSION'},
{name : 'AUTH_SOURCE_BASE_DN'}, {name : 'AUTH_SOURCE_BASE_DN'},
{name : 'AUTH_ANONYMOUS'}, {name : 'AUTH_ANONYMOUS'},
{name : 'AUTH_SOURCE_SEARCH_USER'}, {name : 'AUTH_SOURCE_SEARCH_USER'},
{name : 'AUTH_SOURCE_ATTRIBUTES'}, {name : 'AUTH_SOURCE_ATTRIBUTES'},
{name : 'AUTH_SOURCE_OBJECT_CLASSES'}, {name : 'AUTH_SOURCE_OBJECT_CLASSES'},
{name : 'CURRENT_USERS', type:'int'} {name : 'CURRENT_USERS', type:'int'}
]
})
});
cmodel = new Ext.grid.ColumnModel({
defaults: {
width: 50,
sortable: true
},
columns: [
{id:'AUTH_SOURCE_UID', dataIndex: 'AUTH_SOURCE_UID', hidden:true, hideable:false},
{header: _('ID_NAME'), dataIndex: 'AUTH_SOURCE_NAME', width: 200, hidden:false, align:'left'},
{header: _('ID_PROVIDER'), dataIndex: 'AUTH_SOURCE_PROVIDER', width: 120, hidden: false, align: 'center'},
{header: _('ID_SERVER_NAME'), dataIndex: 'AUTH_SOURCE_SERVER_NAME', width: 180, hidden: false, align: 'center'},
{header: _('ID_PORT'), dataIndex: 'AUTH_SOURCE_PORT', width: 60, hidden: false, align: 'center'},
{header: _('ID_ACTIVE_USERS'), dataIndex: 'CURRENT_USERS', width: 90, hidden: false, align: 'center'}
]
});
storePageSize = new Ext.data.SimpleStore({
fields: ['size'],
data: [['20'],['30'],['40'],['50'],['100']],
autoLoad: true
});
comboPageSize = new Ext.form.ComboBox({
typeAhead : false,
mode : 'local',
triggerAction : 'all',
store: storePageSize,
valueField: 'size',
displayField: 'size',
width: 50,
editable: false,
listeners:{
select: function(c,d,i){
UpdatePageConfig(d.data['size']);
bbarpaging.pageSize = parseInt(d.data['size']);
bbarpaging.moveFirst();
}
}
});
comboPageSize.setValue(pageSize);
bbarpaging = new Ext.PagingToolbar({
pageSize: pageSize,
store: store,
displayInfo: true,
displayMsg: _('ID_GRID_PAGE_DISPLAYING_DASHLET_MESSAGE') + '&nbsp; &nbsp; ',
emptyMsg: _('ID_GRID_PAGE_NO_DASHLET_MESSAGE'),
items: ['-',_('ID_PAGE_SIZE')+':',comboPageSize]
});
infoGrid = new Ext.grid.GridPanel({
region: 'center',
layout: 'fit',
id: 'infoGrid',
height:100,
autoWidth : true,
stateful : true,
stateId : 'grid',
enableColumnResize: true,
enableHdMenu: true,
frame:false,
//iconCls:'icon-grid',
columnLines: false,
viewConfig: {
forceFit:true
},
title : _('ID_DASHLET_INSTANCE'),
store: store,
cm: cmodel,
sm: smodel,
tbar: actionButtons,
bbar: bbarpaging,
listeners: {
rowdblclick: editDashletInstance,
render: function(){
this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING_GRID')});
}
},
view: new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl: '{text}',
cls:"x-grid-empty",
emptyText: _('ID_NO_RECORDS_FOUND')
})
});
infoGrid.on('rowcontextmenu',
function (grid, rowIndex, evt) {
var sm = grid.getSelectionModel();
sm.selectRow(rowIndex, sm.isSelected(rowIndex));
},
this
);
infoGrid.on('contextmenu',
function (evt) {
evt.preventDefault();
},
this
);
infoGrid.addListener('rowcontextmenu',onMessageContextMenu,this);
infoGrid.store.load();
viewport = new Ext.Viewport({
layout: 'fit',
autoScroll: false,
items: [
infoGrid
] ]
}); })
});
cmodel = new Ext.grid.ColumnModel({
defaults: {
width: 50,
sortable: true
},
columns: [
{id:'AUTH_SOURCE_UID', dataIndex: 'AUTH_SOURCE_UID', hidden:true, hideable:false},
{header: _('ID_NAME'), dataIndex: 'AUTH_SOURCE_NAME', width: 200, hidden:false, align:'left'},
{header: _('ID_PROVIDER'), dataIndex: 'AUTH_SOURCE_PROVIDER', width: 120, hidden: false, align: 'center'},
{header: _('ID_SERVER_NAME'), dataIndex: 'AUTH_SOURCE_SERVER_NAME', width: 180, hidden: false, align: 'center'},
{header: _('ID_PORT'), dataIndex: 'AUTH_SOURCE_PORT', width: 60, hidden: false, align: 'center'},
{header: _('ID_ACTIVE_USERS'), dataIndex: 'CURRENT_USERS', width: 90, hidden: false, align: 'center'}
]
});
storePageSize = new Ext.data.SimpleStore({
fields: ['size'],
data: [['20'],['30'],['40'],['50'],['100']],
autoLoad: true
});
comboPageSize = new Ext.form.ComboBox({
typeAhead : false,
mode : 'local',
triggerAction : 'all',
store: storePageSize,
valueField: 'size',
displayField: 'size',
width: 50,
editable: false,
listeners:{
select: function(c,d,i){
UpdatePageConfig(d.data['size']);
bbarpaging.pageSize = parseInt(d.data['size']);
bbarpaging.moveFirst();
}
}
});
comboPageSize.setValue(pageSize);
bbarpaging = new Ext.PagingToolbar({
pageSize: pageSize,
store: store,
displayInfo: true,
displayMsg: _('ID_GRID_PAGE_DISPLAYING_DASHLET_MESSAGE') + '&nbsp; &nbsp; ',
emptyMsg: _('ID_GRID_PAGE_NO_DASHLET_MESSAGE'),
items: ['-',_('ID_PAGE_SIZE')+':',comboPageSize]
});
infoGrid = new Ext.grid.GridPanel({
region: 'center',
layout: 'fit',
id: 'infoGrid',
height:100,
autoWidth : true,
stateful : true,
stateId : 'grid',
enableColumnResize: true,
enableHdMenu: true,
frame:false,
//iconCls:'icon-grid',
columnLines: false,
viewConfig: {
forceFit:true
},
title : _('ID_DASHLET_INSTANCE'),
store: store,
cm: cmodel,
sm: smodel,
tbar: actionButtons,
bbar: bbarpaging,
listeners: {
rowdblclick: editDashletInstance,
render: function(){
this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING_GRID')});
}
},
view: new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl: '{text}',
cls:"x-grid-empty",
emptyText: _('ID_NO_RECORDS_FOUND')
})
});
infoGrid.on('rowcontextmenu',
function (grid, rowIndex, evt) {
var sm = grid.getSelectionModel();
sm.selectRow(rowIndex, sm.isSelected(rowIndex));
},
this
);
infoGrid.on('contextmenu',
function (evt) {
evt.preventDefault();
},
this
);
infoGrid.addListener('rowcontextmenu',onMessageContextMenu,this);
infoGrid.store.load();
viewport = new Ext.Viewport({
layout: 'fit',
autoScroll: false,
items: [
infoGrid
]
});
}); });
//Funtion Handles Context Menu Opening //Funtion Handles Context Menu Opening
@@ -293,14 +290,14 @@ onMessageContextMenu = function (grid, rowIndex, e) {
//Load Grid By Default //Load Grid By Default
gridByDefault = function(){ gridByDefault = function(){
searchText.reset(); //searchText.reset();
infoGrid.store.load(); infoGrid.store.load();
}; };
//Do Search Function //Do Search Function
doSearch = function(){ /*doSearch = function(){
infoGrid.store.load({params: {textFilter: searchText.getValue()}}); infoGrid.store.load({params: {textFilter: searchText.getValue()}});
}; };*/
//New Dashlet Instance Action //New Dashlet Instance Action
newDashletInstance = function() { newDashletInstance = function() {
@@ -341,7 +338,7 @@ deleteDashletInstance = function(){
}else{ }else{
PMExt.error(_('ID_DASHLET_INSTANCE'),resp.error); PMExt.error(_('ID_DASHLET_INSTANCE'),resp.error);
} }
doSearch(); //doSearch();
editButton.disable(); editButton.disable();
deleteButton.disable(); deleteButton.disable();
}, },