gitlabhq/doc/code/classes/DashboardController.html
2012-12-30 14:43:00 +02:00

411 lines
No EOL
17 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DashboardController</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/github.css" type="text/css" media="screen" />
<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div class="banner">
<h1>
<span class="type">Class</span>
DashboardController
<span class="parent">&lt;
<a href="ApplicationController.html">ApplicationController</a>
</span>
</h1>
<ul class="files">
<li><a href="../files/app/controllers/dashboard_controller_rb.html">app/controllers/dashboard_controller.rb</a></li>
</ul>
</div>
<div id="bodyContent">
<div id="content">
<!-- Method ref -->
<div class="sectiontitle">Methods</div>
<dl class="methods">
<dt>D</dt>
<dd>
<ul>
<li>
<a href="#method-i-dashboard_filter">dashboard_filter</a>
</li>
</ul>
</dd>
<dt>E</dt>
<dd>
<ul>
<li>
<a href="#method-i-event_filter">event_filter</a>
</li>
</ul>
</dd>
<dt>I</dt>
<dd>
<ul>
<li>
<a href="#method-i-index">index</a>,
</li>
<li>
<a href="#method-i-issues">issues</a>
</li>
</ul>
</dd>
<dt>M</dt>
<dd>
<ul>
<li>
<a href="#method-i-merge_requests">merge_requests</a>
</li>
</ul>
</dd>
<dt>P</dt>
<dd>
<ul>
<li>
<a href="#method-i-projects">projects</a>
</li>
</ul>
</dd>
</dl>
<!-- Methods -->
<div class="sectiontitle">Instance Public methods</div>
<div class="method">
<div class="title method-title" id="method-i-index">
<b>index</b>()
<a href="../classes/DashboardController.html#method-i-index" name="method-i-index" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-index_source')" id="l_method-i-index_source">show</a>
</p>
<div id="method-i-index_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/controllers/dashboard_controller.rb, line 7</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">index</span>
<span class="ruby-ivar">@groups</span> = <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">authorized_groups</span>
<span class="ruby-ivar">@has_authorized_projects</span> = <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">&gt;</span> <span class="ruby-number">0</span>
<span class="ruby-ivar">@projects</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:scope</span>]
<span class="ruby-keyword">when</span> <span class="ruby-string">'personal'</span> <span class="ruby-keyword">then</span>
<span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">personal</span>(<span class="ruby-identifier">current_user</span>)
<span class="ruby-keyword">when</span> <span class="ruby-string">'joined'</span> <span class="ruby-keyword">then</span>
<span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">joined</span>(<span class="ruby-identifier">current_user</span>)
<span class="ruby-keyword">else</span>
<span class="ruby-ivar">@projects</span>
<span class="ruby-keyword">end</span>
<span class="ruby-ivar">@projects</span> = <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">page</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:page</span>]).<span class="ruby-identifier">per</span>(<span class="ruby-number">30</span>)
<span class="ruby-ivar">@events</span> = <span class="ruby-constant">Event</span>.<span class="ruby-identifier">in_projects</span>(<span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">project_ids</span>)
<span class="ruby-ivar">@events</span> = <span class="ruby-ivar">@event_filter</span>.<span class="ruby-identifier">apply_filter</span>(<span class="ruby-ivar">@events</span>)
<span class="ruby-ivar">@events</span> = <span class="ruby-ivar">@events</span>.<span class="ruby-identifier">limit</span>(<span class="ruby-number">20</span>).<span class="ruby-identifier">offset</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:offset</span>] <span class="ruby-operator">||</span> <span class="ruby-number">0</span>)
<span class="ruby-ivar">@last_push</span> = <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">recent_push</span>
<span class="ruby-identifier">respond_to</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span>
<span class="ruby-identifier">format</span>.<span class="ruby-identifier">js</span>
<span class="ruby-identifier">format</span>.<span class="ruby-identifier">atom</span> { <span class="ruby-identifier">render</span> <span class="ruby-identifier">layout</span><span class="ruby-operator">:</span> <span class="ruby-keyword">false</span> }
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title method-title" id="method-i-issues">
<b>issues</b>()
<a href="../classes/DashboardController.html#method-i-issues" name="method-i-issues" class="permalink">Link</a>
</div>
<div class="description">
<p>Get only assigned issues</p>
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-issues_source')" id="l_method-i-issues_source">show</a>
</p>
<div id="method-i-issues_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/controllers/dashboard_controller.rb, line 44</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">issues</span>
<span class="ruby-ivar">@issues</span> = <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">assigned_issues</span>
<span class="ruby-ivar">@issues</span> = <span class="ruby-identifier">dashboard_filter</span>(<span class="ruby-ivar">@issues</span>)
<span class="ruby-ivar">@issues</span> = <span class="ruby-ivar">@issues</span>.<span class="ruby-identifier">recent</span>.<span class="ruby-identifier">page</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:page</span>]).<span class="ruby-identifier">per</span>(<span class="ruby-number">20</span>)
<span class="ruby-ivar">@issues</span> = <span class="ruby-ivar">@issues</span>.<span class="ruby-identifier">includes</span>(<span class="ruby-value">:author</span>, <span class="ruby-value">:project</span>)
<span class="ruby-identifier">respond_to</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span>
<span class="ruby-identifier">format</span>.<span class="ruby-identifier">atom</span> { <span class="ruby-identifier">render</span> <span class="ruby-identifier">layout</span><span class="ruby-operator">:</span> <span class="ruby-keyword">false</span> }
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title method-title" id="method-i-merge_requests">
<b>merge_requests</b>()
<a href="../classes/DashboardController.html#method-i-merge_requests" name="method-i-merge_requests" class="permalink">Link</a>
</div>
<div class="description">
<p>Get authored or assigned open merge requests</p>
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-merge_requests_source')" id="l_method-i-merge_requests_source">show</a>
</p>
<div id="method-i-merge_requests_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/controllers/dashboard_controller.rb, line 37</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">merge_requests</span>
<span class="ruby-ivar">@merge_requests</span> = <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">cared_merge_requests</span>
<span class="ruby-ivar">@merge_requests</span> = <span class="ruby-identifier">dashboard_filter</span>(<span class="ruby-ivar">@merge_requests</span>)
<span class="ruby-ivar">@merge_requests</span> = <span class="ruby-ivar">@merge_requests</span>.<span class="ruby-identifier">recent</span>.<span class="ruby-identifier">page</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:page</span>]).<span class="ruby-identifier">per</span>(<span class="ruby-number">20</span>)
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div class="sectiontitle">Instance Protected methods</div>
<div class="method">
<div class="title method-title" id="method-i-dashboard_filter">
<b>dashboard_filter</b>(items)
<a href="../classes/DashboardController.html#method-i-dashboard_filter" name="method-i-dashboard_filter" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-dashboard_filter_source')" id="l_method-i-dashboard_filter_source">show</a>
</p>
<div id="method-i-dashboard_filter_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/controllers/dashboard_controller.rb, line 66</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">dashboard_filter</span> <span class="ruby-identifier">items</span>
<span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:project_id</span>]
<span class="ruby-identifier">items</span> = <span class="ruby-identifier">items</span>.<span class="ruby-identifier">where</span>(<span class="ruby-identifier">project_id</span><span class="ruby-operator">:</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:project_id</span>])
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:search</span>].<span class="ruby-identifier">present?</span>
<span class="ruby-identifier">items</span> = <span class="ruby-identifier">items</span>.<span class="ruby-identifier">search</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:search</span>])
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">case</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:status</span>]
<span class="ruby-keyword">when</span> <span class="ruby-string">'closed'</span>
<span class="ruby-identifier">items</span>.<span class="ruby-identifier">closed</span>
<span class="ruby-keyword">when</span> <span class="ruby-string">'all'</span>
<span class="ruby-identifier">items</span>
<span class="ruby-keyword">else</span>
<span class="ruby-identifier">items</span>.<span class="ruby-identifier">opened</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title method-title" id="method-i-event_filter">
<b>event_filter</b>()
<a href="../classes/DashboardController.html#method-i-event_filter" name="method-i-event_filter" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-event_filter_source')" id="l_method-i-event_filter_source">show</a>
</p>
<div id="method-i-event_filter_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/controllers/dashboard_controller.rb, line 62</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">event_filter</span>
<span class="ruby-ivar">@event_filter</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">EventFilter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value">:event_filter</span>])
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title method-title" id="method-i-projects">
<b>projects</b>()
<a href="../classes/DashboardController.html#method-i-projects" name="method-i-projects" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-projects_source')" id="l_method-i-projects_source">show</a>
</p>
<div id="method-i-projects_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/controllers/dashboard_controller.rb, line 58</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">projects</span>
<span class="ruby-ivar">@projects</span> = <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">authorized_projects</span>.<span class="ruby-identifier">sorted_by_activity</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
</div>
</div>
</body>
</html>