[#369] activity filters
This commit is contained in:
parent
1aceaff1b8
commit
836139c54b
|
@ -1,25 +1,17 @@
|
|||
RosaABF.controller('ActivityCtrl', ['$scope', '$http', '$timeout', '$q', '$filter',
|
||||
function($scope, $http, $timeout, $q, $filter) {
|
||||
$scope.activity_tab = { title: 'activity_menu.activity_feed', content: [] , isLoaded: false , active: true };
|
||||
$scope.tracker_tab = { title: 'activity_menu.tracker', content: [] , isLoaded: false , active: false };
|
||||
$scope.pull_requests_tab = { title: 'activity_menu.pull_requests', content: [] , isLoaded: false , active: false };
|
||||
|
||||
var today = moment().startOf('day');
|
||||
// $scope.activity_tab.content = [{date: today, kind:'new_comment_notification'},
|
||||
// {date: today, kind:'git_new_push_notification'},
|
||||
// {date: moment().add('days', 1), kind:'build_list_notification'}];
|
||||
$scope.activity_tab = { title: 'activity_menu.activity_feed', active: true, filter: 'all',
|
||||
all: {}, code: {}, tracker: {}, build: {}, wiki: {} };
|
||||
$scope.tracker_tab = { title: 'activity_menu.tracker', content: [] , active: false };
|
||||
$scope.pull_requests_tab = { title: 'activity_menu.pull_requests', content: [] , active: false };
|
||||
|
||||
$scope.getContent=function(tab){
|
||||
var cur_tab = $scope.$eval(tab+'_tab');
|
||||
/* see if we have data already */
|
||||
if(cur_tab.isLoaded){
|
||||
return;
|
||||
}
|
||||
/* or make request for data */
|
||||
/* make request for data */
|
||||
var path = Routes.root_path({ filter: cur_tab.filter, format: 'json' });
|
||||
$http.get(path).then(function(res){
|
||||
cur_tab.content=res.data;
|
||||
cur_tab.isLoaded=true;
|
||||
cur_tab[cur_tab.filter].feed = res.data.feed;
|
||||
cur_tab[cur_tab.filter].next_page_link = res.data.next_page_link;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -45,9 +37,13 @@ RosaABF.controller('ActivityCtrl', ['$scope', '$http', '$timeout', '$q', '$filte
|
|||
return template;
|
||||
}
|
||||
|
||||
$scope.getCurActivity = function() {
|
||||
return $scope.activity_tab[$scope.activity_tab.filter];
|
||||
};
|
||||
|
||||
$scope.needShowTimeLabel = function(index) {
|
||||
var cur_date = $filter('amDateFormat')($scope.activity_tab.content[index].date, 'll');
|
||||
var prev_date = index == 0 || $filter('amDateFormat')($scope.activity_tab.content[index-1].date, 'll');
|
||||
var cur_date = $filter('amDateFormat')($scope.getCurActivity().feed[index].date, 'll');
|
||||
var prev_date = index == 0 || $filter('amDateFormat')($scope.getCurActivity().feed[index-1].date, 'll');
|
||||
return cur_date !== prev_date;
|
||||
};
|
||||
|
||||
|
@ -60,4 +56,15 @@ RosaABF.controller('ActivityCtrl', ['$scope', '$http', '$timeout', '$q', '$filte
|
|||
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;
|
||||
});
|
||||
};
|
||||
}]);
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
.row
|
||||
- item.data[:last_commits].each do |commit|
|
||||
.col-sm-3.col-md-2= link_to shortest_hash_id(commit[0]), commit_path(project_name_with_owner, commit[0])
|
||||
.col-sm-8.col-md-9= truncate(commit[1], length: 70, omission: '…')
|
||||
.clearfix
|
||||
-#%br
|
||||
- if item.data[:other_commits].present?
|
||||
%br
|
||||
=link_to t('notifications.bodies.more_commits', count: item.data[:other_commits_count],
|
||||
commits: commits_pluralize(item.data[:other_commits_count])),
|
||||
diff_path(project_name_with_owner, diff: item.data[:other_commits])
|
|
@ -39,7 +39,7 @@
|
|||
.col-md-12.col-sm-12
|
||||
%ul.timeline
|
||||
/ timeline time label
|
||||
%li.time-label{ 'ng-repeat-start' => 'item in activity_tab.content' }
|
||||
%li.time-label{ 'ng-repeat-start' => 'item in getCurActivity().feed' }
|
||||
%span{ 'ng-show' => "needShowTimeLabel($index)", 'ng-cloak' => true }
|
||||
{{item.date | amDateFormat:'ll'}}
|
||||
/ timeline item
|
||||
|
@ -47,3 +47,8 @@
|
|||
.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()", 'ng-cloak' => true }
|
||||
= t('layout.activity_feed.load_messages')
|
||||
{{activity_tab.content.next_page_link}}
|
||||
|
|
|
@ -1,63 +1,70 @@
|
|||
json.array!(@activity_feeds) do |item|
|
||||
#json.cache! item, expires_in: 10.minutes do
|
||||
json.date item.created_at
|
||||
json.kind item.kind
|
||||
user = get_user_from_activity_item(item)
|
||||
json.user do
|
||||
json.link user_path(user) if user.persisted?
|
||||
json.image avatar_url(user, :small) if user.persisted?
|
||||
json.uname (user.fullname || user.email)
|
||||
end if user
|
||||
if @activity_feeds.next_page
|
||||
json.next_page_link root_path(filter: @filter, page: @activity_feeds.next_page, format: :json)
|
||||
end
|
||||
|
||||
project_name_with_owner = "#{item.data[:project_owner]}/#{item.data[:project_name]}"
|
||||
@project = Project.find_by_owner_and_name(item.data[:project_owner], item.data[:project_name])
|
||||
json.feed do
|
||||
json.array!(@activity_feeds) do |item|
|
||||
#json.cache! item, expires_in: 10.minutes do
|
||||
json.date item.created_at
|
||||
json.kind item.kind
|
||||
user = get_user_from_activity_item(item)
|
||||
json.user do
|
||||
json.link user_path(user) if user.persisted?
|
||||
json.image avatar_url(user, :small) if user.persisted?
|
||||
json.uname (user.fullname || user.email)
|
||||
end if user
|
||||
|
||||
json.project_name_with_owner project_name_with_owner
|
||||
project_name_with_owner = "#{item.data[:project_owner]}/#{item.data[:project_name]}"
|
||||
@project = Project.find_by_owner_and_name(item.data[:project_owner], item.data[:project_name])
|
||||
|
||||
case item.kind
|
||||
when 'new_comment_notification'
|
||||
json.issue do
|
||||
json.link project_issue_path(project_name_with_owner, item.data[:issue_serial_id]) if item.data[:issue_serial_id].present?
|
||||
json.title short_message(item.data[:issue_title], 50)
|
||||
json.read_more item.data[:comment_id]
|
||||
end
|
||||
json.body markdown(short_message(item.data[:comment_body], 100))
|
||||
json.project_name_with_owner project_name_with_owner
|
||||
|
||||
when 'git_new_push_notification'
|
||||
json.change_type item.data[:change_type]
|
||||
json.project_link project_path(project_name_with_owner)
|
||||
json.branch_name item.data[:branch_name]
|
||||
|
||||
json.last_commits do
|
||||
json.array! item.data[:last_commits] do |commit|
|
||||
json.hash shortest_hash_id(commit[0])
|
||||
json.message markdown(short_message(commit[1], 70))
|
||||
json.commit_path commit_path(project_name_with_owner, commit[0])
|
||||
case item.kind
|
||||
when 'new_comment_notification'
|
||||
json.issue do
|
||||
json.link project_issue_path(project_name_with_owner, item.data[:issue_serial_id]) if item.data[:issue_serial_id].present?
|
||||
json.title short_message(item.data[:issue_title], 50)
|
||||
json.read_more item.data[:comment_id]
|
||||
end
|
||||
end
|
||||
if item.data[:other_commits].present?
|
||||
json.other_commits t('notifications.bodies.more_commits', count: item.data[:other_commits_count], commits: commits_pluralize(item.data[:other_commits_count]))
|
||||
json.other_commits_path diff_path(project_name_with_owner, diff: item.data[:other_commits])
|
||||
json.body markdown(short_message(item.data[:comment_body], 100))
|
||||
|
||||
when 'git_new_push_notification'
|
||||
json.change_type item.data[:change_type]
|
||||
json.project_link project_path(project_name_with_owner)
|
||||
json.branch_name item.data[:branch_name]
|
||||
|
||||
json.last_commits do
|
||||
json.array! item.data[:last_commits] do |commit|
|
||||
json.hash shortest_hash_id(commit[0])
|
||||
json.message markdown(short_message(commit[1], 70))
|
||||
json.commit_path commit_path(project_name_with_owner, commit[0])
|
||||
end
|
||||
end
|
||||
if item.data[:other_commits].present?
|
||||
json.other_commits t('notifications.bodies.more_commits', count: item.data[:other_commits_count], commits: commits_pluralize(item.data[:other_commits_count]))
|
||||
json.other_commits_path diff_path(project_name_with_owner, diff: item.data[:other_commits])
|
||||
end
|
||||
|
||||
when 'git_delete_branch_notification'
|
||||
json.branch_name item.data[:branch_name]
|
||||
json.project_link project_path(project_name_with_owner)
|
||||
|
||||
when 'new_issue_notification'
|
||||
json.project_link project_path(project_name_with_owner)
|
||||
json.issue do
|
||||
json.title item.data[:issue_title]
|
||||
json.link project_issue_path(project_name_with_owner, item.data[:issue_serial_id]) if item.data[:issue_serial_id].present?
|
||||
end
|
||||
|
||||
when 'new_user_notification'
|
||||
json.user_name item.data[:user_name]
|
||||
|
||||
when 'wiki_new_commit_notification'
|
||||
json.wiki_link history_project_wiki_index_path(project_name_with_owner)
|
||||
json.project_link project_path(project_name_with_owner)
|
||||
end
|
||||
|
||||
when 'git_delete_branch_notification'
|
||||
json.branch_name item.data[:branch_name]
|
||||
json.project_link project_path(project_name_with_owner)
|
||||
|
||||
when 'new_issue_notification'
|
||||
json.project_link project_path(project_name_with_owner)
|
||||
json.issue do
|
||||
json.title item.data[:issue_title]
|
||||
json.link project_issue_path(project_name_with_owner, item.data[:issue_serial_id]) if item.data[:issue_serial_id].present?
|
||||
end
|
||||
|
||||
when 'new_user_notification'
|
||||
json.user_name item.data[:user_name]
|
||||
|
||||
when 'wiki_new_commit_notification'
|
||||
json.wiki_link history_project_wiki_index_path(project_name_with_owner)
|
||||
json.project_link project_path(project_name_with_owner)
|
||||
end
|
||||
json.id item.id
|
||||
#end
|
||||
end
|
||||
json.id item.id
|
||||
#end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue