Skip to content

Commit

Permalink
Merge pull request #110 from flashingcursor/develop
Browse files Browse the repository at this point in the history
Started implementing Datatables ... User table partially implemented.
  • Loading branch information
snipe committed Dec 2, 2013
2 parents dddba11 + a0267db commit cfd6c43
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 2 deletions.
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,39 @@ composer.phar
/app/config/*/app.php

/app/config/testing/database.php
public/packages/barryvdh/laravel-debugbar/debugbar.css
public/packages/barryvdh/laravel-debugbar/debugbar.js
public/packages/barryvdh/laravel-debugbar/icons.png
public/packages/barryvdh/laravel-debugbar/openhandler.css
public/packages/barryvdh/laravel-debugbar/openhandler.js
public/packages/barryvdh/laravel-debugbar/php-icon.png
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/css/font-awesome-ie7.css
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/css/font-awesome-ie7.min.css
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/css/font-awesome.css
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/css/font-awesome.min.css
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/font/FontAwesome.otf
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/font/fontawesome-webfont.eot
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/font/fontawesome-webfont.svg
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/font/fontawesome-webfont.ttf
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/font/fontawesome-webfont.woff
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/bootstrap.less
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/core.less
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/extras.less
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/font-awesome-ie7.less
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/font-awesome.less
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/icons.less
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/mixins.less
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/path.less
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/less/variables.less
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_bootstrap.scss
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_core.scss
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_extras.scss
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_icons.scss
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_mixins.scss
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_path.scss
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/_variables.scss
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/font-awesome-ie7.scss
public/packages/barryvdh/laravel-debugbar/vendor/font-awesome/scss/font-awesome.scss
public/packages/barryvdh/laravel-debugbar/vendor/jquery-1.8.3.min.js
public/packages/barryvdh/laravel-debugbar/widgets.css
public/packages/barryvdh/laravel-debugbar/widgets.js
35 changes: 35 additions & 0 deletions app/controllers/admin/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Cartalyst\Sentry\Users\PasswordRequiredException;
use Cartalyst\Sentry\Users\UserExistsException;
use Cartalyst\Sentry\Users\UserNotFoundException;
use HTML;
use URL;
use Config;
use DB;
use Input;
Expand All @@ -18,6 +20,7 @@
use Sentry;
use Validator;
use View;
use Chumper\Datatable\Facades\Datatable;

class UsersController extends AdminController {

Expand Down Expand Up @@ -448,4 +451,36 @@ public function getView($userId = null)

}

public function getDatatable()
{
return Datatable::collection(User::all())
->addColumn('name',function($model)
{
$name = HTML::image($model->gravatar(), $model->first_name, array('class'=>'img-circle avatar hidden-phone', 'style'=>'max-width: 45px'));
$name .= HTML::link(URL::action('Controllers\Admin\UsersController@getView', $model->id), $model->first_name . ' ' . $model->last_name, array('class' => 'name'));
return $name;
}
)
->showColumns('email')
->addColumn('assets', function($model)
{
$assets = $model->assets->count();
return $assets;
}
)
->addColumn('licenses', function($model)
{
$licenses = $model->licenses->count();
return $licenses;
}
)
->addColumn('activated', function($model)
{
$activated = $model->isActivated() ? '<i class="icon-ok"></i>' : '';
return $activated;
}
)
->make();
}

}
2 changes: 1 addition & 1 deletion app/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function fullName()
public function gravatar()
{
// Generate the Gravatar hash
$gravatar = md5(strtolower(trim($this->gravatar)));
$gravatar = md5(strtolower(trim($this->email)));

// Return the Gravatar url
return "//gravatar.com/avatar/{$gravatar}";
Expand Down
2 changes: 2 additions & 0 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@
Route::get('{userId}/delete', array('as' => 'delete/user', 'uses' => 'Controllers\Admin\UsersController@getDelete'));
Route::get('{userId}/restore', array('as' => 'restore/user', 'uses' => 'Controllers\Admin\UsersController@getRestore'));
Route::get('{userId}/view', array('as' => 'view/user', 'uses' => 'Controllers\Admin\UsersController@getView'));

Route::get('datatable', array('as'=>'api.users', 'uses'=>'Controllers\Admin\UsersController@getDatatable'));
});

# Group Management
Expand Down
16 changes: 15 additions & 1 deletion app/views/backend/users/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div class="row form-wrapper">

@if ($users->getTotal() > 0)
<div class="row-fluid table users-list">
<!-- <div class="row-fluid table users-list">
<table id="example">
<thead>
<tr role="row">
Expand Down Expand Up @@ -78,7 +78,21 @@
</tbody>
</table>
</div>
-->
{{
Datatable::table()
->addColumn(Lang::get('name'))
->addColumn(Lang::get('email'))
->addColumn('Assets')
->addColumn('Licenses')
->addColumn(Lang::get('activated'))
->setUrl(route('api.users'))
->render()
}}

@else


<div class="col-md-6">
<div class="alert alert-warning alert-block">
<i class="icon-warning-sign"></i>
Expand Down

0 comments on commit cfd6c43

Please sign in to comment.