Yii Framework Forum: [EXTENSION] Dashboard controller - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] Dashboard controller To discuss about bugs, new implementations and features of this ext Rate Topic: -----

#1 User is offline   FlyBot 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 63
  • Joined: 20-January 09
  • Location:Ukraine

Posted 03 March 2011 - 03:11 PM

jQueryUI based Dashboard controller here
1

#2 User is offline   sbasuki 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 14-January 10

Posted 04 March 2011 - 03:14 AM

View PostFlyBot, on 03 March 2011 - 03:11 PM, said:

jQueryUI based Dashboard controller here


How to use it, can you give some example code?
0

#3 User is offline   FlyBot 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 63
  • Joined: 20-January 09
  • Location:Ukraine

Posted 04 March 2011 - 07:26 AM

View Postsbasuki, on 04 March 2011 - 03:14 AM, said:

How to use it, can you give some example code?

Sample controller DashController is present under controller folder.

Override init() function, set up array of portlets & DB-related params.
0

#4 User is offline   Tobias B. 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 03-August 10

Posted 04 March 2011 - 11:58 AM

Nice extension. A few notes:

Autosaving doesn't seem to work here. It doesn't send http requests in the background.

Also at the moment it's not good to save dasboard prefs in the user table, because the prefs are not just updated but the whole row deleted and inserted. Which kills all other columns of the user. (UIDashController:162-171). Maybe that could be improved.

But thanks for this base.
1

#5 User is offline   FlyBot 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 63
  • Joined: 20-January 09
  • Location:Ukraine

Posted 04 March 2011 - 02:59 PM

View PostTobias B., on 04 March 2011 - 11:58 AM, said:

Nice extension. A few notes:

Autosaving doesn't seem to work here. It doesn't send http requests in the background.

Also at the moment it's not good to save dasboard prefs in the user table, because the prefs are not just updated but the whole row deleted and inserted. Which kills all other columns of the user. (UIDashController:162-171). Maybe that could be improved.

But thanks for this base.

Tobias, thanks for the help. Now fixed :rolleyes:
Please, download ver 1.1
0

#6 User is offline   Jgsaw 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 01-March 11

Posted 08 March 2011 - 06:55 PM

View PostFlyBot, on 04 March 2011 - 02:59 PM, said:

Tobias, thanks for the help. Now fixed :rolleyes:
Please, download ver 1.1


Ok so ive been using YII for about 3 days now so these are no expert tips but just a few points to be aware of that i came across while playing around with this which took me a while to figure out! (they are by no means definitive or the best way to do it!)

I couldnt figure out why once i got the saving working it was always loading my saved data even if i wasnt logged in. In UIController.php it has
// for testing purpose
if (empty($this->uid))
   $this->uid = 1;

This meant it always had a uid of 1 and as my testing userid was 1 it kept loading it! Just something to be aware of!

Anyway how i set it up:

Extracted the files to the protected folder (components, controllers and messages) maybe be nice if this was a self contained extension? Can that be done?)

I created a db table as so:
CREATE TABLE IF NOT EXISTS tbl_dashboard (
  `userId` INT UNSIGNED NOT NULL ,
  `configData` VARCHAR(255) ,
  PRIMARY KEY (`userId`) )
ENGINE = InnoDB;


Then created the Dashboard Model using GII

Then updated a couple of the methods in UIDashboardController to use the models:

private function getPreference()
    {
    	$dashboard = Dashboard::model()->find(
    		$this->_userIdFieldName." = :id", 
        	array(":id" => $this->uid)
        );
        
	    return ($dashboard === null) ? '' : unserialize($dashboard->configData);
    }


private function setPreference($preference)
    {
        $dashboard = Dashboard::model()->find(
    		$this->_userIdFieldName." = :id", 
        	array(":id" => $this->uid)
        );
        if( $dashboard === null ) {
    		$dashboard = new Dashboard();
    		$dashboard->userId = $this->uid;
        }
        
        $dashboard->configData = $preference;
        return $dashboard->save();


My main reason for changing setPreference was that when it was called for the first time the record didnt exist and as the command invoked update it and there was nothing to update it didnt work. I first played about with invoking insert first but then figured the model was an easier approach in my case.

All suggestions/error pointing outs welcome :rolleyes:

Anyhow i like the extension so far and look forward to more improvements.

Thanks
Ross
0

#7 User is offline   Command 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 06-September 10
  • Location:Berlin

Posted 18 March 2011 - 08:25 AM

I have changed the functions a little bit to use the variables and ActiveRecords.
     /**
     * Store dashboard state to DB
     * If $preference is null - reset to default
     * @param <string> $preference
     * @return <bool>
     */
    private function setPreference($preference)
    {
        $dashboard = CActiveRecord::model($this->_tableName)->find(
                $this->_userIdFieldName." = :id",
                array(":id" => $this->uid)
        );
        if( $dashboard === null ) {
                $dashboard = new $this->_tableName();
                $dashboard->{$this->_userIdFieldName} = $this->uid;
        }

        $dashboard->{$this->_userPrefFieldName} = $preference;

        return  $dashboard->save();
    }

    /**
     * Read dashboard state from DB
     * @return <array>
     */
    private function getPreference()
    {
        $pref = CActiveRecord::model($this->_tableName)->find($this->_userIdFieldName . ' = :id',array(":id" => $this->uid));
        return (count($pref) === 0) ? '' : unserialize($pref->{$this->_userPrefFieldName});
    }

0

#8 User is offline   navonisalio 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 22-March 11

Posted 01 April 2011 - 01:21 PM

Thanks for the extension.
I tried calling a view that uses CGridView as the 'content' of one of the portlet. I used renderPartial.
But this results in whole page getting overwritten and all the page source code shows is
<div id="product-grid" class="grid-view"> 
<table class="items"> 
<thead> 
<tr> 
<th id="product-grid_c0">


what am i doing wrong. How do i used CGridView inside one of the portlet?
0

#9 User is offline   julias 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 08-April 11
  • Location:Cape Town, South Africa

Posted 09 April 2011 - 09:50 PM

View PostFlyBot, on 03 March 2011 - 03:11 PM, said:

jQueryUI based Dashboard controller here


Ok, I am a total nood to yii and to php. I have been teaching my self php and i thought yii made it quit simple. i have been trying to get this dashboard to work and am failing. could you give a step by step guide for dummies (Dashboard controller for Dummies v. 1.0)
0

#10 User is offline   FlyBot 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 63
  • Joined: 20-January 09
  • Location:Ukraine

Posted 10 April 2011 - 10:42 AM

View Postjulias, on 09 April 2011 - 09:50 PM, said:

Dashboard controller for Dummies v. 1.0


Simple unzip this archive under protected folder and look http://localhost/dash in your browser.
0

#11 User is offline   navonisalio 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 22-March 11

Posted 11 April 2011 - 08:07 PM

View Postnavonisalio, on 01 April 2011 - 01:21 PM, said:

Thanks for the extension.
I tried calling a view that uses CGridView as the 'content' of one of the portlet. I used renderPartial.
But this results in whole page getting overwritten and all the page source code shows is
<div id="product-grid" class="grid-view"> 
<table class="items"> 
<thead> 
<tr> 
<th id="product-grid_c0">


what am i doing wrong. How do i used CGridView inside one of the portlet?



I still see this problem, any ideas?

here is code from my controller for the dashboard.
// set array of portlets
        $this->setPortlets(
                array(                    
                    array('id' => 1, 'title' => 'Overview', 'content' => $this->renderPartial('application.views.dashboard._overview', array('dashData'=>intval($nMyVal),),true)),
                    array('id' => 2, 'title' => 'Products', 'content' => $this->renderPartial('application.views.product.index', array('dataProvider'=>$dataProvider,),true,false)),
                   
                )
        );


problem is with that second portlet, it is pointing to the view that uses CGridView.
here is complete code of the that view.

<h2>My Products</h2>
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'dataProvider'=>$dataProvider,
	'columns'=>array( 
        'productName',
        'productType',		
        'productVersion', 
	),
)); ?>

0

#12 User is offline   Balu 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 152
  • Joined: 09-August 11
  • Location:Kerala, India

Posted 01 December 2011 - 06:34 AM

I have to make two dashboard in my site, can you help me. What all changes to be done.
0

#13 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 323
  • Joined: 10-November 10

Posted 03 January 2012 - 01:20 PM

View Postnavonisalio, on 01 April 2011 - 01:21 PM, said:

I tried calling a view that uses CGridView as the 'content' of one of the portlet. I used renderPartial.
How do i used CGridView inside one of the portlet?


Did you solve this? Is it possible to render CGridView inside the portlet?
Fipick - Find and pick recommendations
0

#14 User is offline   tburandt 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 04-December 11

Posted 11 February 2012 - 02:08 PM

View PostFlyBot, on 10 April 2011 - 10:42 AM, said:

Simple unzip this archive under protected folder and look http://localhost/dash in your browser.

Not really....

CDbCommand failed to execute the SQL statement: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "dashboard_page" does not exist. The SQL statement executed was: SELECT "title"
FROM "dashboard_page"
WHERE user_id = :id. Bound with :id=1

0

#15 User is offline   ruderbytes 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 05-November 12
  • Location:Indonesia

Posted 20 May 2013 - 12:47 AM

i have problem

how to make it work?

array('id' => 6, 'title' => 'Reference', 'content' => $this->renderPartial('viewName', null, true)),


thanks before

~Happy :)) Coding~
0

#16 User is offline   333ashok333 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 16-April 14

Posted 23 April 2014 - 06:10 AM

Can any one please give me the sample tutorial of how to use the dashboard extensions with sample code ?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users