Third progress with the dashboards (first version)
This commit is contained in:
@@ -7,27 +7,55 @@
|
||||
|
||||
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
|
||||
|
||||
public function index($httpData) {
|
||||
$this->includeExtJS('dashboard/index');
|
||||
$this->includeExtJSLib('ux/portal');
|
||||
G::RenderPage('publish', 'extJs');
|
||||
try {
|
||||
$this->setJSVar('dashletsInstances', $this->getDashletsInstancesForCurrentUser());
|
||||
$this->includeExtJS('dashboard/index');
|
||||
$this->includeExtJSLib('ux/portal');
|
||||
G::RenderPage('publish', 'extJs');
|
||||
}
|
||||
catch (Exception $error) {
|
||||
//ToDo: Display a error message
|
||||
}
|
||||
}
|
||||
|
||||
public function renderDashletInstance($dasInsUid) {
|
||||
require_once ( PATH_METHODS . 'dashboard/class.gauge.php' );
|
||||
$gauge = new pmGauge();
|
||||
/*
|
||||
$gauge->value = x;
|
||||
$gauge->maxValue = x;
|
||||
*/
|
||||
//falta el width de la imagen
|
||||
$w = isset($_REQUEST['w']) ? intval($_REQUEST['w']) : 610;
|
||||
if ( intval($_REQUEST['w']) < 50 ) $w = 50;
|
||||
$gauge->w = $w;
|
||||
|
||||
$gauge->render();
|
||||
public function renderDashletInstance($data) {
|
||||
try {
|
||||
if (!isset($data['DAS_INS_UID'])) {
|
||||
$data['DAS_INS_UID'] = '';
|
||||
}
|
||||
if ($data['DAS_INS_UID'] == '') {
|
||||
throw new Exception('Parameter "DAS_INS_UID" is empty.');
|
||||
}
|
||||
$this->pmDashlet->setup($data['DAS_INS_UID']);
|
||||
$this->pmDashlet->render();
|
||||
}
|
||||
catch (Exception $error) {
|
||||
//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
|
||||
@@ -35,36 +63,88 @@ class Dashboard extends Controller {
|
||||
// Functions for the dasboards administration module - Start
|
||||
|
||||
public function dashletsList() {
|
||||
$headPublisher =& headPublisher::getSingleton();
|
||||
$headPublisher->addExtJsScript('dashboard/dashletsList', false);
|
||||
$headPublisher->addContent('dashboard/dashletsList');
|
||||
G::RenderPage('publish', 'extJs');
|
||||
try {
|
||||
$this->includeExtJS('dashboard/dashletsList');
|
||||
$this->setView('dashboard/dashletsList');
|
||||
G::RenderPage('publish', 'extJs');
|
||||
}
|
||||
catch (Exception $error) {
|
||||
//ToDo: Display a error message
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
$headPublisher =& headPublisher::getSingleton();
|
||||
$headPublisher->addExtJsScript('dashboard/dashletInstanceForm', false);
|
||||
$headPublisher->addContent('dashboard/dashletInstanceForm');
|
||||
if ($dasInsUid != '') {
|
||||
// load data before render the form
|
||||
public function dashletInstanceForm($dasInsUid = '') {
|
||||
try {
|
||||
$this->includeExtJS('dashboard/dashletInstanceForm', false);
|
||||
$this->setView('dashboard/dashletInstanceForm');
|
||||
if ($dasInsUid != '') {
|
||||
$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) {
|
||||
//
|
||||
$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) {
|
||||
//
|
||||
$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) {
|
||||
//
|
||||
$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
|
||||
|
||||
Reference in New Issue
Block a user