OSDN Git Service

Admin dashboard
authorrandx <dmitriy.zaporozhets@gmail.com>
Fri, 20 Apr 2012 16:41:49 +0000 (19:41 +0300)
committerrandx <dmitriy.zaporozhets@gmail.com>
Fri, 20 Apr 2012 16:41:49 +0000 (19:41 +0300)
app/assets/stylesheets/common.scss
app/controllers/admin/dashboard_controller.rb [new file with mode: 0644]
app/views/admin/dashboard/index.html.haml [new file with mode: 0644]
app/views/layouts/admin.html.haml
config/routes.rb

index a0b3abb..4752dfd 100644 (file)
@@ -903,3 +903,20 @@ li.note {
 .milestone { 
   @extend .wll;
 }
+
+/**
+ * Admin area
+ *
+ */
+.admin_dash { 
+  .data { 
+    a { 
+      h1 { 
+        line-height:48px;
+        font-size:48px;
+        padding:20px;
+        text-align:center;
+      }
+    }
+  }
+}
diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb
new file mode 100644 (file)
index 0000000..ad80f4d
--- /dev/null
@@ -0,0 +1,12 @@
+class Admin::DashboardController < ApplicationController
+  layout "admin"
+  before_filter :authenticate_user!
+  before_filter :authenticate_admin!
+
+  def index
+    @workers = Resque.workers
+    @pending_jobs = Resque.size(:post_receive)
+    @projects = Project.order("created_at DESC").limit(10)
+    @users = User.order("created_at DESC").limit(10)
+  end
+end
diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml
new file mode 100644 (file)
index 0000000..b5b453d
--- /dev/null
@@ -0,0 +1,45 @@
+.admin_dash.row
+  .span4
+    .ui-box
+      %h5
+        Resque Workers
+      .data.padded
+        = link_to "/info/resque" do 
+          %h1{:class => @workers.present? ? "cgreen" : "cred"}
+            = @workers.count
+        %hr
+        %p
+          %strong{:class => @pending_jobs > 0 ? "cred" : "cgreen"}
+            #{@pending_jobs} post receive jobs waiting
+
+  .span4
+    .ui-box
+      %h5 Projects
+      .data.padded
+        = link_to admin_projects_path do 
+          %h1= Project.count
+        %hr
+        = link_to 'New Project', new_admin_project_path, :class => "btn small"
+  .span4
+    .ui-box
+      %h5 Users
+      .data.padded
+        = link_to admin_users_path do 
+          %h1= User.count
+        %hr
+        = link_to 'New User', new_admin_user_path, :class => "btn small"
+
+
+.row
+  .span6
+    %h3 Latest projects
+    %hr
+    - @projects.each do |project|
+      %h5
+        = link_to project.name, [:admin, project]
+  .span6
+    %h3 Latest users
+    %hr
+    - @users.each do |user|
+      %h5
+        = link_to user.name, [:admin, user]
index a71dd57..2d5387c 100644 (file)
@@ -7,6 +7,7 @@
     .container
       %nav.main_menu
         = render "layouts/const_menu_links"
+        = link_to "Stats", admin_root_path, :class => controller.controller_name == "dashboard" ? "current" : nil
         = link_to "Projects", admin_projects_path, :class => controller.controller_name == "projects" ? "current" : nil
         = link_to "Users", admin_users_path, :class => controller.controller_name == "users" ? "current" : nil
         = link_to "Emails", admin_emails_path, :class => controller.controller_name == "mailer" ? "current" : nil
index 6e29ec7..a6e32bc 100644 (file)
@@ -29,7 +29,7 @@ Gitlab::Application.routes.draw do
     get 'mailer/preview_note'
     get 'mailer/preview_user_new'
     get 'mailer/preview_issue_new'
-    root :to => "users#index"
+    root :to => "dashboard#index"
   end
 
   get "errors/githost"