improve activity feed

This commit is contained in:
Alexander Machehin 2015-05-05 17:25:29 +05:00
parent 86b929328b
commit d7727fe6a5
41 changed files with 558 additions and 368 deletions

View File

@ -1,201 +0,0 @@
RosaABF.controller('ActivityCtrl', ['$scope', '$http', '$timeout', '$q', '$filter', '$location',
function($scope, $http, $timeout, $q, $filter, $location) {
$scope.activity_tab = { title: 'activity_menu.activity_feed', filter: 'all',
all: {}, code: {}, tracker: {}, build: {}, wiki: {} };
$scope.tracker_tab = { title: 'activity_menu.tracker', content: [] ,
filter: { all: true, assigned: false, created: false, name: 'all',
all_count: 0, assigned_count: 0, created_count: 0, closed_count: 0 },
sort: { sort: 'updated', direction: 'desc', updated_class: 'fa-chevron-up' },
status: 'open', pagination: { page: 1, total_count: 0 } };
$scope.pull_requests_tab = { title: 'activity_menu.pull_requests', content: [] ,
filter: { all: true, assigned: false, created: false, name: 'all',
all_count: 0, assigned_count: 0, created_count: 0, closed_count: 0 },
sort: { sort: 'updated', direction: 'desc', updated_class: 'fa-chevron-up' },
status: 'open', pagination: { page: 1, total_count: 0 } };
$scope.init = function(active_tab) {
if(active_tab === 'activity') {
$scope.activity_tab.active = true;
}
else if(active_tab === 'issues') {
$scope.tracker_tab.active = true;
}
else if(active_tab === 'pull_requests') {
$scope.pull_requests_tab.active = true;
};
};
$scope.getContent = function(tab){
var cur_tab = $scope.$eval(tab+'_tab');
var tmp = $location.path();
if (tab === 'activity') {
$scope.activity_tab.active = true;
$scope.tracker_tab.active = false;
$scope.pull_requests_tab.active = false;
$scope.getActivityContent();
if($location.path() !== '/') {
$location.path('/').replace()
};
}
else if (tab === 'tracker') {
$scope.activity_tab.active = false;
$scope.tracker_tab.active = true;
$scope.pull_requests_tab.active = false;
$scope.getIssuesContent();
if($location.path() !== '/issues') {
$location.path('/issues').replace()
};
}
else if (tab === 'pull_requests') {
$scope.activity_tab.active = false;
$scope.tracker_tab.active = false;
$scope.pull_requests_tab.active = true;
$scope.getIssuesContent();
if($location.path() !== '/pull_requests') {
$location.path('/pull_requests').replace()
};
};
};
getIssuesTab = function(kind) {
if(kind === 'tracker') {
return $scope.tracker_tab;
}
else if(kind === 'pull_requests') {
return $scope.pull_requests_tab;
};
};
$scope.getTimeLinefaClass = function(content) {
var template = 'btn-warning fa-question';
switch(content.kind) {
case 'build_list_notification':
template = 'btn-success fa-gear';
break;
case 'new_comment_notification':
case 'new_comment_commit_notification':
template = 'btn-warning fa-comment';
break;
case 'git_new_push_notification':
template = 'bg-primary fa-sign-in';
break;
case 'new_issue_notification':
template = 'btn-warning fa-check-square-o';
break;
};
return template;
}
$scope.getCurActivity = function() {
return $scope.activity_tab[$scope.activity_tab.filter];
};
$scope.needShowTimeLabel = function(index) {
var feed = $scope.getCurActivity().feed;
if (feed === undefined) {
return false;
};
var cur_date = $filter('amDateFormat')(feed[index].date, 'll');
var prev_date = index == 0 || $filter('amDateFormat')(feed[index-1].date, 'll');
return cur_date !== prev_date;
};
$scope.getTemplate = function(content) {
return content.kind + '.html';
};
$scope.load_more = function() {
var cur_tab = $scope.getCurActivity();
var path = cur_tab.next_page_link;
if(!path) {
return;
};
$http.get(path).then(function(res){
cur_tab.feed.push.apply(cur_tab.feed, res.data.feed);
cur_tab.next_page_link = res.data.next_page_link;
});
};
$scope.changeActivityFilter = function(filter) {
$scope.activity_tab.filter = filter;
$scope.getActivityContent();
};
$scope.getActivityContent = function() {
var path = Routes.root_path({ filter: $scope.activity_tab.filter, format: 'json' });
$http.get(path).then(function(res) {
$scope.getCurActivity().feed = res.data.feed;
$scope.getCurActivity().next_page_link = res.data.next_page_link;
});
};
$scope.setIssuesFilter = function(kind, issues_filter) {
var filter = getIssuesTab(kind).filter;
filter.all = false;
filter.assigned = false;
filter.created = false;
filter[issues_filter] = true;
filter.name = issues_filter;
$scope.getIssuesContent();
};
$scope.getIssuesContent = function() {
if($scope.tracker_tab.active) {
var tab = $scope.tracker_tab;
var path = Routes.issues_path({ filter: tab.filter.name,
sort: tab.sort.sort,
direction: tab.sort.direction,
status: tab.status,
page: tab.pagination.page,
format: 'json' });
}
else if($scope.pull_requests_tab.active) {
var tab = $scope.pull_requests_tab;
var path = Routes.pull_requests_path({ filter: tab.filter.name,
sort: tab.sort.sort,
direction: tab.sort.direction,
status: tab.status,
page: tab.pagination.page,
format: 'json' });
};
$http.get(path).then(function(res) {
tab.content = res.data.content;
tab.filter.all_count = res.data.all_count;
tab.filter.assigned_count = res.data.assigned_count;
tab.filter.created_count = res.data.created_count;
tab.filter.closed_count = res.data.closed_count;
tab.filter.open_count = res.data.open_count;
tab.pagination.page = res.data.page;
tab.pagination.total_items = parseInt(res.data.issues_count, 10);
});
};
$scope.setIssuesSort = function(kind, issues_sort) {
var tab = getIssuesTab(kind);
if(tab.sort.direction === 'desc') {
tab.sort = { sort: issues_sort, direction: 'asc' };
var sort_class = 'fa-chevron-down';
}
else {
tab.sort = { sort: issues_sort, direction: 'desc' };
var sort_class = 'fa-chevron-up';
};
tab.sort[issues_sort+'_class'] = sort_class;
$scope.getIssuesContent();
};
$scope.setIssuesStatus = function(kind, issues_status) {
var tab = getIssuesTab(kind);
tab.status = issues_status;
tab.pagination.page = 1;
$scope.getIssuesContent();
};
$scope.selectPage = function(kind, page) {
$scope.getIssuesContent();
};
}]);

View File

@ -0,0 +1,244 @@
ActivityController = ($scope, $http, $timeout, $q, $filter, $location, ActivityFilter) ->
getIssuesTab = (kind)->
return vm.tracker_tab if kind is 'tracker'
return vm.pull_requests_tab if kind is 'pull_requests'
vm = this
vm.activity_tab =
filter: 'all'
all: {}
code: {}
tracker: {}
build: {}
wiki: {}
owner_filter: null
project_name_filter: null
owner_uname_filter_tmp: null
project_name_filter_tmp: null
vm.own_activity_tab = $.extend({}, vm.activity_tab)
vm.current_activity_tab = vm.activity_tab
vm.tracker_tab =
content: []
filter:
all: true
assigned: false
created: false
name: 'all'
all_count: 0
assigned_count: 0
created_count: 0
closed_count: 0
sort:
sort: 'updated'
direction: 'desc'
updated_class: 'fa-chevron-up'
status: 'open'
pagination:
page: 1
total_count: 0
vm.pull_requests_tab = $.extend({}, vm.tracker_tab)
vm.init = (active_tab)->
switch active_tab
when 'activity'
vm.activity_tab.active = true
vm.current_activity_tab = vm.activity_tab
when 'own_activity'
vm.own_activity_tab.active = true
vm.current_activity_tab = vm.own_activity_tab
when 'issues'
vm.tracker_tab.active = true
when active_tab is 'pull_requests'
vm.pull_requests_tab.active = true
true
vm.getContent = (tab)->
switch tab
when 'activity'
vm.activity_tab.active = true
vm.own_activity_tab.active = false
vm.tracker_tab.active = false
vm.pull_requests_tab.active = false
vm.current_activity_tab = vm.activity_tab
vm.getActivityContent()
if $location.path() isnt '/'
$location.path('/').replace()
when 'own_activity'
vm.activity_tab.active = false
vm.own_activity_tab.active = true
vm.tracker_tab.active = false
vm.pull_requests_tab.active = false
vm.current_activity_tab = vm.own_activity_tab
vm.getActivityContent()
if $location.path() isnt '/own_activity'
$location.path('/own_activity').replace()
when 'tracker'
vm.activity_tab.active = false
vm.own_activity_tab.active = false
vm.tracker_tab.active = true
vm.pull_requests_tab.active = false
vm.getIssuesContent()
if $location.path() isnt '/issues'
$location.path('/issues').replace()
when 'pull_requests'
vm.activity_tab.active = false
vm.own_activity_tab.active = false
vm.tracker_tab.active = false
vm.pull_requests_tab.active = true
vm.getIssuesContent()
if $location.path() isnt '/pull_requests'
$location.path('/pull_requests').replace()
vm.getTimeLinefaClass = (content)->
template = switch content.kind
when 'build_list_notification' then 'btn-success fa-gear'
when 'new_comment_notification', 'new_comment_commit_notification' then 'btn-warning fa-comment'
when 'git_new_push_notification' then 'bg-primary fa-sign-in'
when 'new_issue_notification' then 'btn-warning fa-check-square-o'
else 'btn-warning fa-question'
template
vm.getCurActivity = ()->
vm.current_activity_tab[vm.current_activity_tab.filter]
vm.needShowTimeLabel = (index)->
feed = vm.getCurActivity().feed
return false unless feed
cur_date = $filter('amDateFormat')(feed[index].date, 'll')
prev_date = index is 0 or $filter('amDateFormat')(feed[index-1].date, 'll')
return cur_date isnt prev_date
vm.getTemplate = (content)->
content.kind + '.html'
vm.load_more = ()->
cur_tab = vm.getCurActivity()
path = cur_tab.next_page_link
return unless path
$http.get(path).then (res)->
cur_tab.feed.push.apply(cur_tab.feed, res.data.feed)
cur_tab.next_page_link = res.data.next_page_link
vm.changeActivityFilter = (filter)->
return if vm.current_activity_tab.filter is filter
vm.current_activity_tab.filter = filter
vm.getActivityContent()
vm.getActivityContent = ()->
options =
filter: vm.current_activity_tab.filter
owner_filter: vm.current_activity_tab.owner_filter
project_name_filter: vm.current_activity_tab.project_name_filter
format: 'json'
if vm.activity_tab.active
path = Routes.root_path(options)
else
path = Routes.own_activity_path(options)
$http.get(path).then (res)->
vm.getCurActivity().feed = res.data.feed
vm.getCurActivity().next_page_link = res.data.next_page_link
vm.setIssuesFilter = (kind, issues_filter)->
filter = getIssuesTab(kind).filter
filter.all = false
filter.assigned = false
filter.created = false
filter[issues_filter] = true
filter.name = issues_filter
vm.getIssuesContent()
vm.getIssuesContent = ()->
if vm.tracker_tab.active
tab = vm.tracker_tab
path = Routes.issues_path(
filter: tab.filter.name
sort: tab.sort.sort
direction: tab.sort.direction
status: tab.status
page: tab.pagination.page
format: 'json')
else if vm.pull_requests_tab.active
tab = vm.pull_requests_tab
path = Routes.pull_requests_path(
filter: tab.filter.name
sort: tab.sort.sort
direction: tab.sort.direction
status: tab.status
page: tab.pagination.page
format: 'json')
$http.get(path).then (res)->
tab.content = res.data.content
tab.filter.all_count = res.data.all_count
tab.filter.assigned_count = res.data.assigned_count
tab.filter.created_count = res.data.created_count
tab.filter.closed_count = res.data.closed_count
tab.filter.open_count = res.data.open_count
tab.pagination.page = res.data.page
tab.pagination.total_items = parseInt(res.data.issues_count, 10)
vm.setIssuesSort = (kind, issues_sort)->
tab = getIssuesTab(kind)
if tab.sort.direction is 'desc'
tab.sort = { sort: issues_sort, direction: 'asc' }
sort_class = 'fa-chevron-down'
else
tab.sort = { sort: issues_sort, direction: 'desc' }
sort_class = 'fa-chevron-up'
tab.sort[issues_sort+'_class'] = sort_class
vm.getIssuesContent()
vm.setIssuesStatus = (kind, issues_status)->
tab = getIssuesTab(kind)
tab.status = issues_status
tab.pagination.page = 1
vm.getIssuesContent()
vm.selectPage = (kind, page)->
vm.getIssuesContent()
vm.getOwnersList = (value)->
return [] if value.length < 1
ActivityFilter.get_owners(value)
vm.selectOwnerFilter = (item, model, label)->
return if vm.current_activity_tab.owner_filter is item.uname
vm.current_activity_tab.owner_filter = item.uname
vm.current_activity_tab.project_name_filter = null
vm.current_activity_tab.project_name_filter_tmp = null
vm.getActivityContent()
true
vm.getProjectNamesList = (value)->
return [] if value.length < 1
ActivityFilter.get_project_names(vm.current_activity_tab.owner_filter, value)
vm.selectProjectNameFilter = (item, model, label)->
return if vm.current_activity_tab.project_name_filter is item.name
vm.current_activity_tab.project_name_filter = item.name
vm.getActivityContent()
true
angular
.module("RosaABF")
.controller "ActivityController", ActivityController
ActivityController.$inject = ['$scope', '$http', '$timeout', '$q', '$filter', '$location', 'ActivityFilter']

View File

@ -19,7 +19,6 @@ var _locales = {
<%= BuildList::STATUSES.map{|s| "'build_list.status.#{s}': '#{BuildList.human_status(s)}'"}.join(',') %>, <%= BuildList::STATUSES.map{|s| "'build_list.status.#{s}': '#{BuildList.human_status(s)}'"}.join(',') %>,
// //
<%= I18n.t('activity_menu').map{ |k,v| "'activity_menu.#{k}': '#{v}'" }.join(',') %>,
'tracker.filter.all': '<%= I18n.t('layout.issues.all') %>', 'tracker.filter.all': '<%= I18n.t('layout.issues.all') %>',
'tracker.filter.assigned': '<%= I18n.t('layout.issues.assigned') %>', 'tracker.filter.assigned': '<%= I18n.t('layout.issues.assigned') %>',
'tracker.filter.created': '<%= I18n.t('layout.issues.created') %>', 'tracker.filter.created': '<%= I18n.t('layout.issues.created') %>',
@ -66,7 +65,6 @@ var _locales = {
<%= BuildList::STATUSES.map{|s| "'build_list.status.#{s}': '#{BuildList.human_status(s)}'"}.join(',') %>, <%= BuildList::STATUSES.map{|s| "'build_list.status.#{s}': '#{BuildList.human_status(s)}'"}.join(',') %>,
// //
<%= I18n.t('activity_menu').map{ |k,v| "'activity_menu.#{k}': '#{v}'" }.join(',') %>,
'tracker.filter.all': '<%= I18n.t('layout.issues.all') %>', 'tracker.filter.all': '<%= I18n.t('layout.issues.all') %>',
'tracker.filter.assigned': '<%= I18n.t('layout.issues.assigned') %>', 'tracker.filter.assigned': '<%= I18n.t('layout.issues.assigned') %>',
'tracker.filter.created': '<%= I18n.t('layout.issues.created') %>', 'tracker.filter.created': '<%= I18n.t('layout.issues.created') %>',

View File

@ -0,0 +1,27 @@
ActivityFilterService = ($http) ->
get_owners: (val) ->
path = Routes.get_owners_list_path(
{
term: val
}
)
$http.get(path).then (response) ->
response.data
get_project_names: (owner, val) ->
path = Routes.get_project_names_list_path(
{
owner_uname: owner
term: val
}
)
$http.get(path).then (response) ->
response.data
angular
.module("RosaABF")
.factory "ActivityFilter", ActivityFilterService
ActivityFilterService.$inject = ['$http']

View File

@ -38,7 +38,7 @@ $mini-avatar-height: 30px
.panel-title a, .panel-title a,
i.fa-question-circle[data-toggle='modal'], i.fa-question-circle[data-toggle='modal'],
span.fa.fa-times, span.fa.fa-times,
.navbar a .navbar a, ul.dropdown-menu a
cursor: pointer cursor: pointer
footer footer

View File

@ -1,5 +1,5 @@
class HomeController < ApplicationController class HomeController < ApplicationController
before_action :authenticate_user!, only: [:activity, :issues, :pull_requests] before_action :authenticate_user!, except: [:root]
skip_after_action :verify_authorized skip_after_action :verify_authorized
def root def root
@ -8,21 +8,34 @@ class HomeController < ApplicationController
end end
end end
def activity def activity(is_my_activity = false)
@filter = t('feed_menu').has_key?(params[:filter].try(:to_sym)) ? params[:filter].to_sym : :all @filter = t('feed_menu').has_key?(params[:filter].try(:to_sym)) ? params[:filter].to_sym : :all
@activity_feeds = current_user.activity_feeds @activity_feeds = current_user.activity_feeds
.by_project_name(params[:project_name_filter])
.by_owner_uname(params[:owner_filter])
@activity_feeds = @activity_feeds.where(kind: "ActivityFeed::#{@filter.upcase}".constantize) unless @filter == :all @activity_feeds = @activity_feeds.where(kind: "ActivityFeed::#{@filter.upcase}".constantize) unless @filter == :all
@activity_feeds = @activity_feeds.where(user_id: current_user) if @own_filter == :created @activity_feeds = @activity_feeds.where(user_id: current_user) if @own_filter == :created
@activity_feeds = @activity_feeds.where.not(user_id: current_user) if @own_filter == :not_created @activity_feeds = @activity_feeds.where.not(user_id: current_user) if @own_filter == :not_created
@activity_feeds = if is_my_activity
@activity_feeds.where(creator_id: current_user)
else
@activity_feeds.where.not(creator_id: current_user)
end
@activity_feeds = @activity_feeds.paginate page: current_page @activity_feeds = @activity_feeds.paginate page: current_page
respond_to do |format| respond_to do |format|
format.html { render 'activity' } format.html { render 'activity' }
format.json {} format.json { render 'activity' }
format.atom format.atom
end end
end end
def own_activity
activity(true)
end
def issues def issues
@created_issues = current_user.issues @created_issues = current_user.issues
@assigned_issues = Issue.where(assignee_id: current_user.id) @assigned_issues = Issue.where(assignee_id: current_user.id)
@ -69,4 +82,31 @@ class HomeController < ApplicationController
def pull_requests def pull_requests
issues issues
end end
def get_owners_list
if params[:term].present?
users = User.opened.search(params[:term]).pluck(:uname).first(5)
groups = Group.opened.search(params[:term]).pluck(:uname).first(5)
@owners = users | groups
end
respond_to do |format|
format.json {}
end
end
def get_project_names_list
if params[:term].present?
@projects = ProjectPolicy::Scope.new(current_user, Project).membered
@projects = @projects.where(owner_uname: params[:owner_uname]) if params[:owner_uname].present?
@projects = @projects.by_name("%#{params[:term]}%")
.distinct
.pluck(:name)
.first(10)
end
respond_to do |format|
format.json {}
end
end
end end

View File

@ -11,7 +11,7 @@ module ActivityFeedsHelper
end end
def get_user_from_activity_item(item) def get_user_from_activity_item(item)
email = item.data[:user_email] email = item.data[:creator_email]
User.where(email: email).first || User.new(email: email) if email.present? User.where(email: email).first || User.new(email: email) if email.present?
end end

View File

@ -6,16 +6,19 @@ class ActivityFeed < ActiveRecord::Base
WIKI = %w(wiki_new_commit_notification) WIKI = %w(wiki_new_commit_notification)
belongs_to :user belongs_to :user
belongs_to :creator, class_name: 'User'
serialize :data serialize :data
attr_accessible :user, :kind, :data attr_accessible :user, :kind, :data
default_scope { order created_at: :desc } default_scope { order created_at: :desc }
scope :outdated, -> { offset(100) } scope :outdated, -> { offset(200) }
scope :by_project_name, ->(name) { where(project_name: name) if name.present? }
scope :by_owner_uname, ->(owner) { where(project_owner: owner) if owner.present? }
self.per_page = 10 self.per_page = 20
def partial def partial
'home/partials/' + self.kind "home/partials/#{self.kind}"
end end
end end

View File

@ -199,7 +199,7 @@ class Comment < ActiveRecord::Base
if issue_comment? if issue_comment?
commentable.subscribes.create(user: user) if !commentable.subscribes.exists?(user_id: user.id) commentable.subscribes.create(user: user) if !commentable.subscribes.exists?(user_id: user.id)
elsif commit_comment? elsif commit_comment?
recipients = project.admins recipients = project.all_members
recipients << user << User.find_by(email: commentable.try(:committer).try(:email)) # commentor and committer recipients << user << User.find_by(email: commentable.try(:committer).try(:email)) # commentor and committer
recipients.compact.uniq.each do |user| recipients.compact.uniq.each do |user|
options = {project_id: project.id, subscribeable_id: commentable_id, subscribeable_type: commentable.class.name, user_id: user.id} options = {project_id: project.id, subscribeable_id: commentable_id, subscribeable_type: commentable.class.name, user_id: user.id}

View File

@ -20,20 +20,20 @@ module Feed::BuildList
) )
updater = publisher || user updater = publisher || user
(project.all_members | [publisher].compact).each do |recipient| (project.all_members | [publisher]).compact.each do |recipient|
ActivityFeed.create( ActivityFeed.create(
user: recipient, user: recipient,
kind: 'build_list_notification', kind: 'build_list_notification',
project_owner: project.owner_uname,
project_name: project.name,
creator_id: updater.id,
data: { data: {
build_list_id: id, build_list_id: id,
status: status, status: status,
updated_at: updated_at, updated_at: updated_at,
project_id: project_id, project_id: project_id,
project_name: project.name, creator_name: updater.name,
project_owner: project.owner.uname, creator_email: updater.email
user_name: updater.name,
user_email: updater.email,
user_id: updater.id
} }
) )
end end

View File

@ -20,17 +20,17 @@ module Feed::Comment
{ {
user_id: subscribe.user_id, user_id: subscribe.user_id,
kind: 'new_comment_notification', kind: 'new_comment_notification',
project_owner: project.owner_uname,
project_name: project.name,
creator_id: user_id,
data: { data: {
user_name: user.name, creator_name: user.name,
user_email: user.email, creator_email: user.email,
user_id: user_id,
comment_body: body.truncate(100, omission: '…'), comment_body: body.truncate(100, omission: '…'),
issue_title: commentable.title, issue_title: commentable.title,
issue_serial_id: commentable.serial_id, issue_serial_id: commentable.serial_id,
project_id: commentable.project.id, project_id: commentable.project.id,
comment_id: id, comment_id: id
project_name: project.name,
project_owner: project.owner.uname
} }
}, without_protection: true }, without_protection: true
) )
@ -49,17 +49,18 @@ module Feed::Comment
{ {
user_id: subscribe.user_id, user_id: subscribe.user_id,
kind: 'new_comment_commit_notification', kind: 'new_comment_commit_notification',
project_owner: project.owner_uname,
project_name: project.name,
creator_id: user_id,
data: { data: {
user_name: user.name, creator_name: user.name,
user_email: user.email, creator_email: user.email,
user_id: user_id,
comment_body: body.truncate(100, omission: '…'), comment_body: body.truncate(100, omission: '…'),
commit_message: commentable.message.truncate(70, omission: '…'), commit_message: commentable.message.truncate(70, omission: '…'),
commit_id: commentable.id, commit_id: commentable.id,
project_id: project.id, project_id: project.id,
comment_id: id, comment_id: id
project_name: project.name,
project_owner: project.owner.uname
} }
}, without_protection: true }, without_protection: true
) )

View File

@ -13,8 +13,7 @@ module Feed::Git
if change_type == 'delete' if change_type == 'delete'
kind = 'git_delete_branch_notification' kind = 'git_delete_branch_notification'
options = {project_id: record.project.id, project_name: record.project.name, branch_name: branch_name, options = {project_id: record.project.id, branch_name: branch_name, change_type: change_type}
change_type: change_type, project_owner: record.project.owner.uname}
else else
if record.message # online update if record.message # online update
last_commits, commits = [[record.newrev, record.message.truncate(70, omission: '…')]], [] last_commits, commits = [[record.newrev, record.message.truncate(70, omission: '…')]], []
@ -26,8 +25,8 @@ module Feed::Git
end end
kind = 'git_new_push_notification' kind = 'git_new_push_notification'
options = {project_id: record.project.id, project_name: record.project.name, last_commits: last_commits, options = {project_id: record.project.id, last_commits: last_commits,
branch_name: branch_name, change_type: change_type, project_owner: record.project.owner.uname} branch_name: branch_name, change_type: change_type}
if commits.count > 3 if commits.count > 3
commits = commits[0...-3] commits = commits[0...-3]
options.merge!({other_commits_count: commits.count, other_commits: "#{commits[0].sha[0..9]}...#{commits[-1].sha[0..9]}"}) options.merge!({other_commits_count: commits.count, other_commits: "#{commits[0].sha[0..9]}...#{commits[-1].sha[0..9]}"})
@ -44,12 +43,15 @@ module Feed::Git
Comment.create_link_on_issues_from_item(record, all_commits) Comment.create_link_on_issues_from_item(record, all_commits)
end end
end end
options.merge!({user_id: record.user.id, user_name: record.user.name, user_email: record.user.email}) if record.user options.merge!({creator_name: record.user.name, creator_email: record.user.email}) if record.user
record.project.admins.each do |recipient| record.project.all_members.each do |recipient|
ActivityFeed.create!( ActivityFeed.create!(
user: recipient, user: recipient,
kind: kind, kind: kind,
project_owner: record.project.owner_uname,
project_name: record.project.name,
creator_id: record.user.id,
data: options data: options
) )
next if record.user && record.user.id == recipient.id next if record.user && record.user.id == recipient.id
@ -62,12 +64,15 @@ module Feed::Git
actor = User.find_by! uname: record[:actor_name] actor = User.find_by! uname: record[:actor_name]
project = Project.find record[:project_id] project = Project.find record[:project_id]
project.admins.each do |recipient| project.all_members.each do |recipient|
ActivityFeed.create!( ActivityFeed.create!(
user: recipient, user: recipient,
kind: 'wiki_new_commit_notification', kind: 'wiki_new_commit_notification',
data: {user_id: actor.id, user_name: actor.name, user_email: actor.email, project_id: project.id, project_owner: project.owner_uname,
project_name: project.name, commit_sha: record[:commit_sha], project_owner: project.owner.uname} project_name: project.name,
creator_id: actor.id,
data: {creator_name: actor.name, creator_email: actor.email,
project_id: project.id, commit_sha: record[:commit_sha]}
) )
end end
end end

View File

@ -22,15 +22,15 @@ module Feed::Issue
ActivityFeed.create( ActivityFeed.create(
user: recipient, user: recipient,
kind: 'new_issue_notification', kind: 'new_issue_notification',
project_owner: project.owner_uname,
project_name: project.name,
creator_id: user_id,
data: { data: {
user_name: user.name, creator_name: user.name,
user_email: user.email, creator_email: user.email,
user_id: user_id,
issue_serial_id: serial_id, issue_serial_id: serial_id,
issue_title: title, issue_title: title,
project_id: project.id, project_id: project.id
project_name: project.name,
project_owner: project.owner.uname
} }
) )
end end
@ -47,14 +47,14 @@ module Feed::Issue
ActivityFeed.create( ActivityFeed.create(
user: assignee, user: assignee,
kind: 'issue_assign_notification', kind: 'issue_assign_notification',
project_owner: project.owner_uname,
project_name: project.name,
data: { data: {
user_name: assignee.name, user_name: assignee.name,
user_email: assignee.email, user_email: assignee.email,
issue_serial_id: serial_id, issue_serial_id: serial_id,
issue_title: title, issue_title: title,
project_id: project.id, project_id: project.id
project_name: project.name,
project_owner: project.owner.uname
} }
) )
end end

View File

@ -15,6 +15,7 @@ module Project::Finders
} }
scope :by_name, ->(name) { where('projects.name ILIKE ?', name) if name.present? } scope :by_name, ->(name) { where('projects.name ILIKE ?', name) if name.present? }
scope :by_owner, ->(name) { where('projects.owner_uname ILIKE ?', "%#{name}%") if name.present? } scope :by_owner, ->(name) { where('projects.owner_uname ILIKE ?', "%#{name}%") if name.present? }
scope :by_owner_and_name, ->(*params) { scope :by_owner_and_name, ->(*params) {
term = params.map(&:strip).join('/').downcase term = params.map(&:strip).join('/').downcase
where("lower(concat(owner_uname, '/', name)) ILIKE ?", "%#{term}%") if term.present? where("lower(concat(owner_uname, '/', name)) ILIKE ?", "%#{term}%") if term.present?

View File

@ -99,7 +99,7 @@ class Issue < ActiveRecord::Base
end end
def collect_recipients def collect_recipients
recipients = self.project.admins recipients = self.project.all_members
recipients = recipients | [self.assignee] if self.assignee recipients = recipients | [self.assignee] if self.assignee
recipients recipients
end end

View File

@ -1,4 +1,6 @@
tab heading = "{{activity_tab.title | i18n}}" active = "activity_tab.active" select = "getContent('activity')" tab[ heading= t('activity_menu.activity_feed')
active= "actCtrl.activity_tab.active"
select = "actCtrl.getContent('activity')" ]
.row .row
.col-md-3.offset10== render 'sidebar' .col-md-3.offset10== render 'sidebar'
.col-md-9.offset10 .col-md-9.offset10
@ -6,22 +8,4 @@ tab heading = "{{activity_tab.title | i18n}}" active = "activity_tab.active" sel
= t 'layout.activity_feed.header' = t 'layout.activity_feed.header'
= link_to image_tag('rss.ico', width: '15px', height: '15px', class: 'atom_icon'), = link_to image_tag('rss.ico', width: '15px', height: '15px', class: 'atom_icon'),
atom_activity_feeds_path(format: 'atom', token: current_user.authentication_token) atom_activity_feeds_path(format: 'atom', token: current_user.authentication_token)
tabset == render 'activity_tabsets'
- (collection = t 'feed_menu').each do |base, title|
tab heading = title active = (@filter == base) select = "changeActivityFilter('#{base}')"
/ The time line
.row.offset10
.col-md-12.col-sm-12
ul.timeline
/ timeline time label
li.time-label ng-repeat-start = 'item in getCurActivity().feed'
span ng-show = "needShowTimeLabel($index)"
| {{item.date | amDateFormat:'ll'}}
/ timeline item
li ng-include = "getTemplate(item)"
.hide ng-repeat-end = true
li
i.img-circle.bg-primary.fa.fa-clock-o
hr
btn.center-block.btn.btn-primary ng-show = 'getCurActivity().next_page_link' ng-click = "load_more()"
= t('layout.activity_feed.load_messages')

View File

@ -0,0 +1,20 @@
tabset
- (collection = t 'feed_menu').each do |base, title|
tab heading= title active= (@filter == base) select= "actCtrl.changeActivityFilter('#{base}')"
/ The time line
.row.offset10
.col-md-12.col-sm-12
ul.timeline
/ timeline time label
li.time-label ng-repeat-start= 'item in actCtrl.getCurActivity().feed'
span ng-show= "actCtrl.needShowTimeLabel($index)"
| {{item.date | amDateFormat:'ll'}}
/ timeline item
li ng-include= "actCtrl.getTemplate(item)"
.hide ng-repeat-end= true
li
i.img-circle.bg-primary.fa.fa-clock-o
hr
btn.center-block.btn.btn-primary[ ng-show= 'actCtrl.getCurActivity().next_page_link'
ng-click= "actCtrl.load_more()" ]
= t('layout.activity_feed.load_messages')

View File

@ -1,15 +1,17 @@
hr.offset10 hr
h3=t('layout.relations.filters') h4=t('layout.relations.filters')
.form-group
input.form-control[ name = 'search' = text_field_tag :owner_uname, nil,
size = 30 class: 'form-control',
type = 'text' placeholder: t('search.placeholders.owner_filter'),
ng-model = 'search' 'ng-model' => 'actCtrl.current_activity_tab.owner_uname_filter_tmp',
placeholder = t('layout.find_project') 'typeahead' => 'owner.uname for owner in actCtrl.getOwnersList($viewValue)',
ng-change = 'filterProjects()' ] 'typeahead-on-select' => 'actCtrl.selectOwnerFilter($item, $model, $label)'
.form-group
ul.nav.nav-pills.nav-stacked = text_field_tag :project_name, nil,
- options_for_filters(@projects, @groups, @owners).each do |options| class: 'form-control',
li{ 'ng-class' => "{active: #{options[:class_name]}_filter_#{options[:id]}_class}" } placeholder: t('search.placeholders.name_filter'),
a{ href: '#', 'ng-click' => "change_#{options[:class_name]}_filter(#{options[:id]})" } 'ng-model' => 'actCtrl.current_activity_tab.project_name_filter_tmp',
= options[:uname] 'ng-value' => 'actCtrl.current_activity_tab.project_name_filter_tmp',
'typeahead' => 'project.name for project in actCtrl.getProjectNamesList($viewValue)',
'typeahead-on-select' => 'actCtrl.selectProjectNameFilter($item, $model, $label)'

View File

@ -0,0 +1,9 @@
tab[ heading= t('activity_menu.own_activity')
active= "actCtrl.own_activity_tab.active"
select = "actCtrl.getContent('own_activity')" ]
.row
.col-md-3.offset10== render 'sidebar'
.col-md-9.offset10
h3
= t 'layout.activity_feed.own_header'
== render 'activity_tabsets'

View File

@ -1,6 +1,7 @@
p p
= link_to t('layout.activity_feed.new_project'), new_project_path, = link_to t('layout.activity_feed.new_project'), new_project_path,
class: 'btn btn-primary btn-small', role: 'button' class: 'btn btn-primary btn-small', role: 'button'
== render 'filters'
hr hr
h5= t('layout.activity_feed.my_last_projects') h5= t('layout.activity_feed.my_last_projects')

View File

@ -1,70 +1,70 @@
- %w(tracker pull_requests).each do |kind| - %w(tracker pull_requests).each do |kind|
tab[ heading = "{{#{kind}_tab.title | i18n}}" tab[ heading= t("activity_menu.#{kind}")
active = "#{kind}_tab.active" active= "actCtrl.#{kind}_tab.active"
select = "getContent('#{kind}')" ] select= "actCtrl.getContent('#{kind}')" ]
.row .row
.col-md-3.offset10 .col-md-3.offset10
ul.nav.nav-pills.nav-stacked ul.nav.nav-pills.nav-stacked
- %w(all assigned created).each do |kind_filter| - %w(all assigned created).each do |kind_filter|
li ng-class = "{ active: #{kind}_tab.filter.#{kind_filter} }" li ng-class= "{ active: actCtrl.#{kind}_tab.filter.#{kind_filter} }"
a ng-click = "setIssuesFilter('#{kind}', '#{kind_filter}')" a ng-click= "actCtrl.setIssuesFilter('#{kind}', '#{kind_filter}')"
span.badge.pull-right= "{{ #{kind}_tab.filter.#{kind_filter}_count }}" span.badge.pull-right= "{{ actCtrl.#{kind}_tab.filter.#{kind_filter}_count }}"
= "{{'#{kind}.filter.#{kind_filter}' | i18n}}" = "{{'#{kind}.filter.#{kind_filter}' | i18n}}"
.col-md-9.offset10 .col-md-9.offset10
tabset.boffset10 tabset.boffset10
- %w(open closed).each do |status| - %w(open closed).each do |status|
- count_issues = "({{#{kind}_tab.filter.#{status}_count}})" - count_issues = "({{actCtrl.#{kind}_tab.filter.#{status}_count}})"
tab[ heading = "#{t "layout.issues.statuses.#{status}"} #{count_issues}" tab[ heading= "#{t "layout.issues.statuses.#{status}"} #{count_issues}"
active = "#{kind}_tab.status_#{status}" active= "actCtrl.#{kind}_tab.status_#{status}"
ng-click = "setIssuesStatus('#{kind}', '#{status}')" ] ng-click= "actCtrl.setIssuesStatus('#{kind}', '#{status}')" ]
.pull-right.boffset10 .pull-right.boffset10
button.btn.btn-default.roffset5[ type = 'button' button.btn.btn-default.roffset5[ type= 'button'
ng-click = "setIssuesSort('#{kind}', 'updated')" ] ng-click= "actCtrl.setIssuesSort('#{kind}', 'updated')" ]
span.fa ng-class = "#{kind}_tab.sort.updated_class" span.fa ng-class= "actCtrl.#{kind}_tab.sort.updated_class"
=> t('layout.issues.sort.updated') => t('layout.issues.sort.updated')
button.btn.btn-default[ type = 'button' button.btn.btn-default[ type= 'button'
ng-click = "setIssuesSort('#{kind}', 'submitted')" ] ng-click= "actCtrl.setIssuesSort('#{kind}', 'submitted')" ]
span.fa ng-class = "#{kind}_tab.sort.submitted_class" span.fa ng-class= "actCtrl.#{kind}_tab.sort.submitted_class"
=> t('layout.issues.sort.submitted') => t('layout.issues.sort.submitted')
table.table table.table
tr ng-repeat = "issue in #{kind}_tab.content" tr ng-repeat= "issue in actCtrl.#{kind}_tab.content"
td td
a ng-href = "{{issue.issue_url}}" a ng-href= "{{issue.issue_url}}"
span.text-info span.text-info
= '{{issue.project_name}} ' = '{{issue.project_name}} '
| {{issue.title}} | {{issue.title}}
span.label.small.loffset5[ ng-repeat = "label in issue.labels" span.label.small.loffset5[ ng-repeat= "label in issue.labels"
ng-style = "{background: label.color}" ] ng-style= "{background: label.color}" ]
| {{label.name}} | {{label.name}}
.small .small
= t 'layout.issues.created_by' = t 'layout.issues.created_by'
a>[ ng-href = "{{issue.user.path}}" ] {{issue.user.uname}} a>[ ng-href= "{{issue.user.path}}" ] {{issue.user.uname}}
span.text-muted[ ng-show = '#{kind}_tab.sort.sort == "submitted"' span.text-muted[ ng-show= 'actCtrl.#{kind}_tab.sort.sort == "submitted"'
title = "{{issue.created_at_utc}}" ] title= "{{issue.created_at_utc}}" ]
| {{issue.created_at | amDateFormat:'YYYY-MM-DD HH:mm'}} ( | {{issue.created_at | amDateFormat:'YYYY-MM-DD HH:mm'}} (
span am-time-ago = 'issue.created_at' span am-time-ago= 'issue.created_at'
| ) | )
span> class = 'text-muted' ng-show = '#{kind}_tab.sort.sort == "updated"' span> class= 'text-muted' ng-show= 'actCtrl.#{kind}_tab.sort.sort == "updated"'
= t 'layout.issues.updated_at' = t 'layout.issues.updated_at'
span.text-muted[ ng-show = '#{kind}_tab.sort.sort == "updated"' span.text-muted[ ng-show= 'actCtrl.#{kind}_tab.sort.sort == "updated"'
title = "{{issue.updated_at_utc}}" ] title= "{{issue.updated_at_utc}}" ]
| {{issue.updated_at | amDateFormat:'YYYY-MM-DD HH:mm'}} ( | {{issue.updated_at | amDateFormat:'YYYY-MM-DD HH:mm'}} (
span am-time-ago = 'issue.updated_at' span am-time-ago= 'issue.updated_at'
| ) | )
td td
a ng-href = "{{issue.issue_url + '#comments'}}" a ng-href= "{{issue.issue_url + '#comments'}}"
span.fa.fa-comments.text-primary span.fa.fa-comments.text-primary
= " {{issue.comments_count}}" = " {{issue.comments_count}}"
td td
a>[ ng-href = '{{issue.assignee.link}}' a>[ ng-href= '{{issue.assignee.link}}'
title = "#{t('layout.issues.assigned_to')} {{issue.assignee.fullname}}" ] title= "#{t('layout.issues.assigned_to')} {{issue.assignee.fullname}}" ]
img ng-src = '{{issue.assignee.image}}' img ng-src= '{{issue.assignee.image}}'
span.text-muted.roffset5 span.text-muted.roffset5
| {{'#' + issue.serial_id}} | {{'#' + issue.serial_id}}
= angularjs_paginate( total_items: "#{kind}_tab.pagination.total_items", = angularjs_paginate( total_items: "actCtrl.#{kind}_tab.pagination.total_items",
page: "#{kind}_tab.pagination.page", page: "actCtrl.#{kind}_tab.pagination.page",
per_page: Issue.per_page, per_page: Issue.per_page,
select_page: "selectPage('#{kind}', page)" ) select_page: "actCtrl.selectPage('#{kind}', page)" )

View File

@ -4,14 +4,17 @@ atom_feed do |feed|
@activity_feeds.each do |activity_feed| @activity_feeds.each do |activity_feed|
feed.entry(activity_feed, url: root_url(anchor: "feed#{activity_feed.id}")) do |entry| feed.entry(activity_feed, url: root_url(anchor: "feed#{activity_feed.id}")) do |entry|
feed_content = raw(render(inline: true, partial: activity_feed.partial, locals: activity_feed.data.merge(activity_feed: activity_feed))) feed_content = raw(render(inline: true, partial: activity_feed.partial,
locals: activity_feed.data.merge(activity_feed: activity_feed,
project_owner: activity_feed.project_owner,
project_name: activity_feed.project_name)))
entry.title(truncate(get_feed_title_from_content(feed_content), length: 50)) entry.title(truncate(get_feed_title_from_content(feed_content), length: 50))
entry.content(feed_content, type: 'html') entry.content(feed_content, type: 'html')
entry.author do |author| entry.author do |author|
author.name(activity_feed.data[:user_name]) author.name(activity_feed.data[:creator_name])
author.email(activity_feed.data[:user_email]) author.email(activity_feed.data[:creator_email])
end if activity_feed.kind != 'git_delete_branch_notification' end if activity_feed.kind != 'git_delete_branch_notification'
end end
end end

View File

@ -1,6 +1,8 @@
-set_meta_tags title: nil -set_meta_tags title: nil
.row .row
.col-xs-12.col-md-10.col-md-offset-1 ng-controller = 'ActivityCtrl' ng-init = "init('#{action_name}')" .col-xs-12.col-md-10.col-md-offset-1[ ng-controller= 'ActivityController as actCtrl'
tabset.offset10 ng-cloak = true ng-init= "actCtrl.init('#{action_name}')" ]
tabset.offset10 ng-cloak= true
== render 'activity_tab' == render 'activity_tab'
== render 'tracker_and_pulls_tabs' == render 'tracker_and_pulls_tabs'
== render 'own_activity_tab'

View File

@ -1,5 +1,9 @@
if @activity_feeds.next_page if @activity_feeds.next_page
json.next_page_link root_path(filter: @filter, page: @activity_feeds.next_page, format: :json) json.next_page_link root_path(filter: @filter,
page: @activity_feeds.next_page,
owner_filter: @owner_filter,
project_name_filter: @project_name_filter,
format: :json)
end end
json.feed do json.feed do
@ -14,7 +18,7 @@ json.feed do
json.uname (user.fullname || user.email) json.uname (user.fullname || user.email)
end if user end if user
project_name_with_owner = "#{item.data[:project_owner]}/#{item.data[:project_name]}" project_name_with_owner = "#{item.project_owner}/#{item.project_name}"
@project = Project.find_by_owner_and_name(item.data[:project_owner], item.data[:project_name]) @project = Project.find_by_owner_and_name(item.data[:project_owner], item.data[:project_name])
json.project_name_with_owner project_name_with_owner json.project_name_with_owner project_name_with_owner

View File

@ -0,0 +1,3 @@
json.array!(@owners) do |uname|
json.uname uname
end

View File

@ -0,0 +1,3 @@
json.array!(@projects) do |name|
json.name name
end

View File

@ -1,4 +1,4 @@
-user= User.where(email: user_email).first || User.new(email: user_email) if defined?(user_email) -user= User.where(email: creator_email).first || User.new(email: creator_email) if defined?(creator_email)
.top .top
.image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.persisted? .image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.persisted?
.text .text

View File

@ -1,9 +1,9 @@
-user= User.where(email: user_email).first || User.new(email: user_email) if defined?(user_email) -user= User.where(email: creator_email).first || User.new(email: creator_email) if defined?(creator_email)
.top .top
.image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.try(:persisted?) .image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.try(:persisted?)
.text .text
%span %span
-_user_link = defined?(user_email) ? user_link(user, defined?(user_name) ? user_name : user_email) : nil -_user_link = defined?(creator_email) ? user_link(user, defined?(creator_name) ? creator_name : creator_email) : nil
= t('notifications.bodies.delete_branch', branch_name: branch_name, user_link: _user_link).html_safe = t('notifications.bodies.delete_branch', branch_name: branch_name, user_link: _user_link).html_safe
- name_with_owner = "#{project_owner}/#{project_name}" - name_with_owner = "#{project_owner}/#{project_name}"
= raw t("notifications.bodies.project", project_link: link_to(name_with_owner, project_path(name_with_owner)) ) = raw t("notifications.bodies.project", project_link: link_to(name_with_owner, project_path(name_with_owner)) )

View File

@ -1,10 +1,10 @@
-user= User.where(email: user_email).first || User.new(email: user_email) if defined?(user_email) -user= User.where(email: creator_email).first || User.new(email: creator_email) if defined?(creator_email)
- name_with_owner = "#{project_owner}/#{project_name}" - name_with_owner = "#{project_owner}/#{project_name}"
.top .top
.image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.try(:persisted?) .image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.try(:persisted?)
.text .text
%span %span
-_user_link = defined?(user_email) ? user_link(user, defined?(user_name) ? user_name : user_email) : nil -_user_link = defined?(creator_email) ? user_link(user, defined?(creator_name) ? creator_name : creator_email) : nil
= raw t("notifications.bodies.#{change_type}_branch", {branch_name: branch_name, user_link: _user_link}) = raw t("notifications.bodies.#{change_type}_branch", {branch_name: branch_name, user_link: _user_link})
= raw t("notifications.bodies.project", project_link: link_to(name_with_owner, project_path(name_with_owner)) ) = raw t("notifications.bodies.project", project_link: link_to(name_with_owner, project_path(name_with_owner)) )
.both .both

View File

@ -1,10 +1,10 @@
-user= User.where(email: user_email).first || User.new(email: user_email) if defined?(user_email) -user= User.where(email: creator_email).first || User.new(email: creator_email) if defined?(creator_email)
- name_with_owner = "#{project_owner}/#{project_name}" - name_with_owner = "#{project_owner}/#{project_name}"
.top .top
.image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.persisted? .image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.persisted?
.text .text
%span %span
= raw t("notifications.bodies.new_comment_notification.title", user_link: user_link(user, user_name)) = raw t("notifications.bodies.new_comment_notification.title", user_link: user_link(user, creator_name))
= raw t("notifications.bodies.new_comment_notification.commit_content", {commit_link: link_to(commit_message, commit_path(name_with_owner, commit_id) + "#comment#{comment_id}")}) = raw t("notifications.bodies.new_comment_notification.commit_content", {commit_link: link_to(commit_message, commit_path(name_with_owner, commit_id) + "#comment#{comment_id}")})
= raw t("notifications.bodies.project", project_link: link_to(name_with_owner, project_path(name_with_owner)) ) = raw t("notifications.bodies.project", project_link: link_to(name_with_owner, project_path(name_with_owner)) )
.both .both

View File

@ -1,10 +1,10 @@
-user= User.where(email: user_email).first || User.new(email: user_email) if defined?(user_email) -user= User.where(email: creator_email).first || User.new(email: creator_email) if defined?(creator_email)
- name_with_owner = "#{project_owner}/#{project_name}" - name_with_owner = "#{project_owner}/#{project_name}"
.top .top
.image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.persisted? .image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.persisted?
.text .text
%span %span
= raw t("notifications.bodies.new_comment_notification.title", {user_link: user_link(user, user_name)}) = raw t("notifications.bodies.new_comment_notification.title", {user_link: user_link(user, creator_name)})
= raw t("notifications.bodies.new_comment_notification.content", {issue_link: link_to(issue_title, project_issue_path(name_with_owner, issue_serial_id) + "#comment#{comment_id}")}) = raw t("notifications.bodies.new_comment_notification.content", {issue_link: link_to(issue_title, project_issue_path(name_with_owner, issue_serial_id) + "#comment#{comment_id}")})
= raw t("notifications.bodies.project", project_link: link_to(name_with_owner, project_path(name_with_owner)) ) = raw t("notifications.bodies.project", project_link: link_to(name_with_owner, project_path(name_with_owner)) )
.both .both

View File

@ -1,11 +1,11 @@
-user= User.where(email: user_email).first || User.new(email: user_email) if defined?(user_email) -user= User.where(email: creator_email).first || User.new(email: creator_email) if defined?(creator_email)
- name_with_owner = "#{project_owner}/#{project_name}" - name_with_owner = "#{project_owner}/#{project_name}"
- issue_path = issue_serial_id.present? ? project_issue_path(name_with_owner, issue_serial_id) : '#' - issue_path = issue_serial_id.present? ? project_issue_path(name_with_owner, issue_serial_id) : '#'
.top .top
.image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.persisted? .image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.persisted?
.text .text
%span %span
= raw t("notifications.bodies.new_issue_notification", { user_link: user_link(user, user_name), issue_link: issue_path }) = raw t("notifications.bodies.new_issue_notification", { user_link: user_link(user, creator_name), issue_link: issue_path })
= raw t("notifications.bodies.project", project_link: link_to(name_with_owner, project_path(name_with_owner)) ) = raw t("notifications.bodies.project", project_link: link_to(name_with_owner, project_path(name_with_owner)) )
.both .both
= datetime_moment activity_feed.created_at, tag: :span, class: 'date' = datetime_moment activity_feed.created_at, tag: :span, class: 'date'

View File

@ -1,10 +1,10 @@
-user= User.where(email: user_email).first || User.new(email: user_email) if defined?(user_email) -user= User.where(email: creator_email).first || User.new(email: creator_email) if defined?(creator_email)
- name_with_owner = "#{project_owner}/#{project_name}" - name_with_owner = "#{project_owner}/#{project_name}"
.top .top
.image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.persisted? .image= link_to(image_tag(avatar_url(user, :small), alt: 'avatar'), user_path(user)) if user.persisted?
.text .text
%span %span
= raw t("notifications.bodies.wiki_new_commit_notification", {user_link: user_link(user, user_name), history_link: link_to("wiki", history_project_wiki_index_path(name_with_owner))}) = raw t("notifications.bodies.wiki_new_commit_notification", {user_link: user_link(user, creator_name), history_link: link_to("wiki", history_project_wiki_index_path(name_with_owner))})
= raw t("notifications.bodies.project", project_link: link_to(name_with_owner, project_path(name_with_owner)) ) = raw t("notifications.bodies.project", project_link: link_to(name_with_owner, project_path(name_with_owner)) )
.both .both
= datetime_moment activity_feed.created_at, tag: :span, class: 'date' = datetime_moment activity_feed.created_at, tag: :span, class: 'date'

View File

@ -16,6 +16,10 @@ ru:
project: project:
updated: "Обновлен:" updated: "Обновлен:"
placeholders:
owner_filter: Владелец проекта
name_filter: Имя проекта
simple_form: simple_form:
placeholders: placeholders:
search: search:

View File

@ -40,6 +40,7 @@ en:
activity_feed: Activity Feed activity_feed: Activity Feed
tracker: Tracker tracker: Tracker
pull_requests: Pull Requests pull_requests: Pull Requests
own_activity: Own activity
feed_menu: feed_menu:
all: All all: All
code: Code code: Code

View File

@ -40,6 +40,7 @@ ru:
activity_feed: Лента активности activity_feed: Лента активности
tracker: Трекер tracker: Трекер
pull_requests: Пул реквесты pull_requests: Пул реквесты
own_activity: Мои действия
feed_menu: feed_menu:
all: Все all: Все
code: Код code: Код

View File

@ -2,6 +2,7 @@ en:
layout: layout:
activity_feed: activity_feed:
header: Activity Feed header: Activity Feed
own_header: Own Activity Feed
my_last_projects: My last projects my_last_projects: My last projects
all_my_projects: All my projects all_my_projects: All my projects
all_my_builds: All my builds all_my_builds: All my builds
@ -9,10 +10,6 @@ en:
new_project: Create project new_project: Create project
load_messages: show previous messages load_messages: show previous messages
atom_title: Activity Feed atom_title: Activity Feed
filters:
all: All
my: Mine
others: Others
notifications: notifications:
subjects: subjects:

View File

@ -2,6 +2,7 @@ ru:
layout: layout:
activity_feed: activity_feed:
header: Лента активности header: Лента активности
own_header: Мои действия
my_last_projects: Мои последние проекты my_last_projects: Мои последние проекты
all_my_projects: Все мои проекты all_my_projects: Все мои проекты
all_my_builds: Все мои сборки all_my_builds: Все мои сборки
@ -9,10 +10,6 @@ ru:
new_project: Создать проект new_project: Создать проект
load_messages: показать предыдущие сообщения load_messages: показать предыдущие сообщения
atom_title: Лента активности atom_title: Лента активности
filters:
all: Вся
my: Моя
others: Чужая
notifications: notifications:
subjects: subjects:

View File

@ -145,8 +145,11 @@ Rosa::Application.routes.draw do
#match '/invite.html' => redirect('/register_requests/new') #match '/invite.html' => redirect('/register_requests/new')
get '/activity_feeds.:format' => 'home#activity', as: 'atom_activity_feeds', format: /atom/ get '/activity_feeds.:format' => 'home#activity', as: 'atom_activity_feeds', format: /atom/
get '/own_activity' => 'home#own_activity', as: 'own_activity'
get '/issues' => 'home#issues' get '/issues' => 'home#issues'
get '/pull_requests' => 'home#pull_requests' get '/pull_requests' => 'home#pull_requests'
get '/get_owners_list' => 'home#get_owners_list'
get '/get_project_names_list' => 'home#get_project_names_list'
if APP_CONFIG['anonymous_access'] if APP_CONFIG['anonymous_access']
authenticated do authenticated do

View File

@ -0,0 +1,32 @@
class AddOwnerNameAndCreatorToActivityFeeds < ActiveRecord::Migration
def up
add_column :activity_feeds, :project_owner, :string
add_column :activity_feeds, :project_name, :string
add_column :activity_feeds, :creator_id, :integer
add_index :activity_feeds, :project_owner
add_index :activity_feeds, :project_name
add_index :activity_feeds, :creator_id
ActivityFeed.reset_column_information
ActivityFeed.find_each do |feed|
feed.project_owner = feed.data[:project_owner]
feed.project_name = feed.data[:project_name]
feed.creator_id = feed.data[:user_id]
feed.data[:creator_name] = feed.data[:user_name]
feed.data[:creator_email] = feed.data[:user_email]
feed.data[:project_owner] = nil
feed.data[:project_name] = nil
feed.data[:user_id] = nil
feed.data[:user_name] = nil
feed.data[:user_email] = nil
feed.save
end
end
def down
remove_column :activity_feeds, :project_owner
remove_column :activity_feeds, :project_name
remove_column :activity_feeds, :creator_id
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150218231015) do ActiveRecord::Schema.define(version: 20150502145718) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -23,6 +23,12 @@ ActiveRecord::Schema.define(version: 20150218231015) do
t.text "data" t.text "data"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "project_owner"
t.string "project_name"
t.integer "creator_id"
t.index ["creator_id"], :name => "index_activity_feeds_on_creator_id"
t.index ["project_name"], :name => "index_activity_feeds_on_project_name"
t.index ["project_owner"], :name => "index_activity_feeds_on_project_owner"
t.index ["user_id", "kind"], :name => "index_activity_feeds_on_user_id_and_kind" t.index ["user_id", "kind"], :name => "index_activity_feeds_on_user_id_and_kind"
end end