From 3ba8ef6e8846e0d1f6bbd77b52224fc439f0e220 Mon Sep 17 00:00:00 2001 From: kiran kumar Date: Tue, 23 Dec 2014 09:44:37 +0530 Subject: [PATCH 1/5] added all followups in ui layer --- codebrag-ui/app/index.html | 9 ++++++ codebrag-ui/app/scripts/app.js | 19 ++++++++++++ .../app/scripts/followups/allfollowupsCtrl.js | 22 ++++++++++++++ .../notifications/notificationsCtrl.js | 5 ++++ .../secured/followups/allfollowupDetails.html | 23 +++++++++++++++ .../views/secured/followups/allfollowups.html | 29 +++++++++++++++++++ 6 files changed, 107 insertions(+) create mode 100644 codebrag-ui/app/scripts/followups/allfollowupsCtrl.js create mode 100644 codebrag-ui/app/views/secured/followups/allfollowupDetails.html create mode 100644 codebrag-ui/app/views/secured/followups/allfollowups.html diff --git a/codebrag-ui/app/index.html b/codebrag-ui/app/index.html index c95dc6b9..499a5907 100644 --- a/codebrag-ui/app/index.html +++ b/codebrag-ui/app/index.html @@ -124,6 +124,7 @@ + @@ -225,6 +226,14 @@ +
  • + + + all followups ({{ followupsNotification.count }}) + + + +
  • diff --git a/codebrag-ui/app/scripts/app.js b/codebrag-ui/app/scripts/app.js index d10432c4..4c45e4f4 100644 --- a/codebrag-ui/app/scripts/app.js +++ b/codebrag-ui/app/scripts/app.js @@ -159,3 +159,22 @@ angular.module('codebrag.common') angular.module('codebrag.userMgmt').run(function(userMgmtService) { userMgmtService.initialize(); }); + +angular.module('codebrag.followups') +.config(function ($stateProvider, authenticatedUser) { + $stateProvider + .state('allfollowups', { + url: '/allfollowups', + abstract: true, + templateUrl: 'views/secured/followups/allfollowups.html', + resolve: authenticatedUser + }) + .state('allfollowups.list', { + url: '', + templateUrl: 'views/secured/followups/emptyFollowups.html' + }) + .state('allfollowups.details', { + url: '/{followupId}/comments/{commentId}', + templateUrl: 'views/secured/followups/allfollowupDetails.html' + }); +}); \ No newline at end of file diff --git a/codebrag-ui/app/scripts/followups/allfollowupsCtrl.js b/codebrag-ui/app/scripts/followups/allfollowupsCtrl.js new file mode 100644 index 00000000..637a5897 --- /dev/null +++ b/codebrag-ui/app/scripts/followups/allfollowupsCtrl.js @@ -0,0 +1,22 @@ +angular.module('codebrag.followups') + + .controller('AllFollowupsCtrl', function ($scope, $http, followupsService, pageTourService, events) { + + $scope.$on(events.allfollowupsTabOpened, initCtrl); + + + $scope.pageTourForFollowupsVisible = function() { + return pageTourService.stepActive('followups') || pageTourService.stepActive('invites'); + }; + + function initCtrl() { + followupsService.allFollowups().then(function(followups) { + $scope.followupCommits = followups; + }); + $scope.hasFollowupsAvailable = followupsService.hasFollowups; + $scope.mightHaveFollowups = followupsService.mightHaveFollowups; + } + + initCtrl(); + + }); \ No newline at end of file diff --git a/codebrag-ui/app/scripts/notifications/notificationsCtrl.js b/codebrag-ui/app/scripts/notifications/notificationsCtrl.js index 06939590..7ea41f1b 100644 --- a/codebrag-ui/app/scripts/notifications/notificationsCtrl.js +++ b/codebrag-ui/app/scripts/notifications/notificationsCtrl.js @@ -43,5 +43,10 @@ angular.module('codebrag.notifications') $rootScope.$on('followupsNotificationRead', function() { $scope.followupsNotificationAvailable = false; }); + + $scope.openAllFollowups = function() { + $rootScope.$broadcast(events.allfollowupsTabOpened); + $state.transitionTo('allfollowups.list'); + }; }); \ No newline at end of file diff --git a/codebrag-ui/app/views/secured/followups/allfollowupDetails.html b/codebrag-ui/app/views/secured/followups/allfollowupDetails.html new file mode 100644 index 00000000..0dbffcf6 --- /dev/null +++ b/codebrag-ui/app/views/secured/followups/allfollowupDetails.html @@ -0,0 +1,23 @@ +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    {{currentCommit.info.authorName}}{{currentCommit.info.date | relativeDate}} +
    +
    +
    + +
    + OK THX +
    +
    +
    +
    \ No newline at end of file diff --git a/codebrag-ui/app/views/secured/followups/allfollowups.html b/codebrag-ui/app/views/secured/followups/allfollowups.html new file mode 100644 index 00000000..c742945b --- /dev/null +++ b/codebrag-ui/app/views/secured/followups/allfollowups.html @@ -0,0 +1,29 @@ +
    +
    +
    + +
    +
    +
    +
    {{commit.commit.authorName}}{{commit.commit.date | relativeDate}} in {{ commit.commit.repoName }}
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    + Yay!
    No follow-ups! +
    + +
    +
    +
    +
    +
    \ No newline at end of file From 569ac6f67100d2364fd0a0be142fad3d396c44ab Mon Sep 17 00:00:00 2001 From: kiran kumar Date: Tue, 23 Dec 2014 19:13:24 +0530 Subject: [PATCH 2/5] added all followup service , dao changes, ui changes --- .../dao/finders/followup/FollowupFinder.scala | 4 + .../finders/followup/SQLFollowupFinder.scala | 35 ++++++ .../src/main/scala/ScalatraBootstrap.scala | 1 + .../codebrag/rest/AllFollowupsServlet.scala | 38 ++++++ codebrag-ui/app/index.html | 7 +- codebrag-ui/app/scripts/app.js | 7 +- .../followups/allfollowupDetailsCtrl.js | 32 +++++ .../followups/allfollowupListItemCtrl.js | 28 +++++ .../app/scripts/followups/allfollowupsCtrl.js | 14 +-- .../scripts/followups/allfollowupsService.js | 118 ++++++++++++++++++ .../app/scripts/followups/followupsCtrl.js | 4 +- .../app/scripts/followups/followupsService.js | 4 +- .../secured/followups/allfollowupDetails.html | 4 +- .../views/secured/followups/allfollowups.html | 4 +- .../secured/followups/followupDetails.html | 2 +- .../secured/followups/statsFollowups.html | 3 + 16 files changed, 285 insertions(+), 20 deletions(-) create mode 100644 codebrag-rest/src/main/scala/com/softwaremill/codebrag/rest/AllFollowupsServlet.scala create mode 100644 codebrag-ui/app/scripts/followups/allfollowupDetailsCtrl.js create mode 100644 codebrag-ui/app/scripts/followups/allfollowupListItemCtrl.js create mode 100644 codebrag-ui/app/scripts/followups/allfollowupsService.js create mode 100644 codebrag-ui/app/views/secured/followups/statsFollowups.html diff --git a/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/FollowupFinder.scala b/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/FollowupFinder.scala index 616c4916..b8139658 100644 --- a/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/FollowupFinder.scala +++ b/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/FollowupFinder.scala @@ -9,9 +9,13 @@ trait FollowupFinder { def findAllFollowupsByCommitForUser(userId: ObjectId): FollowupsByCommitListView def findFollowupForUser(userId: ObjectId, followupId: ObjectId): Either[String, SingleFollowupView] + + def findFollowupforAdmin(followupId: ObjectId): Either[String, SingleFollowupView] def countFollowupsForUser(userId: ObjectId): Long def countFollowupsForUserSince(date: DateTime, userId: ObjectId): Long + + def findAllFollowupsByCommitForAdmin(): FollowupsByCommitListView } diff --git a/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/SQLFollowupFinder.scala b/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/SQLFollowupFinder.scala index 81bd26a2..f21a3d85 100644 --- a/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/SQLFollowupFinder.scala +++ b/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/SQLFollowupFinder.scala @@ -129,4 +129,39 @@ class SQLFollowupFinder(val database: SQLDatabase, userDAO: UserDAO) extends Fol case like: Like => FollowupLastLikeView(like.id.toString, author.name, like.postingTime, author.avatarUrl) } } + def findAllFollowupsByCommitForAdmin(): FollowupsByCommitListView = db.withTransaction { implicit session => + val followups = findAllFollowups() + val followupReactions = findFollowupReactions(followups) + val lastReactions = findLastReactionsForFollowups(followups) + val reactionAuthors = findReactionAuthors(lastReactions) + val commits = findCommitsForFollowups(followups) + + val followupsGroupedByCommit = followups.groupBy(_.threadCommitId) + + val sortFollowupsForCommitByDate = (f1: FollowupReactionsView, f2: FollowupReactionsView) => f1.lastReaction.date.isAfter(f2.lastReaction.date) + + val followupsForCommits = followupsGroupedByCommit.map { + case (commitId, commitFollowups) => + val followupsForCommitViews = commitFollowups + .map(f => followupToReactionsView(f, followupReactions.getOrElse(f.id, Nil), lastReactions, reactionAuthors)) + .sortWith(sortFollowupsForCommitByDate) + val commit = commits(commitId) + val commitView = FollowupCommitView(commit.id.toString, commit.sha, commit.repoName, commit.authorName, commit.message, commit.authorDate) + FollowupsByCommitView(commitView, followupsForCommitViews) + } + FollowupsByCommitListView(sortFollowupGroupsByNewest(followupsForCommits)) + } + private def findAllFollowups()(implicit session: Session): List[SQLFollowup] = { + followups.list() + } + def findFollowupforAdmin(followupId: ObjectId) = db.withTransaction { implicit session => + val r = for { + followup <- followups.filter(f => f.id === followupId).firstOption + reaction <- findLastReaction(followup.lastReactionId) + author <- userDAO.findPartialUserDetails(List(reaction.authorId)).headOption + commit <- commitInfos.filter(_.id === followup.threadCommitId).firstOption() + } yield recordsToFollowupView(commit, reaction, author, followup) + + r.fold[Either[String, SingleFollowupView]](Left("No such followup"))(Right(_)) + } } diff --git a/codebrag-rest/src/main/scala/ScalatraBootstrap.scala b/codebrag-rest/src/main/scala/ScalatraBootstrap.scala index 61e21022..57a35d64 100644 --- a/codebrag-rest/src/main/scala/ScalatraBootstrap.scala +++ b/codebrag-rest/src/main/scala/ScalatraBootstrap.scala @@ -75,6 +75,7 @@ class ScalatraBootstrap extends LifeCycle with Logging { context.mount(new CommitsServlet(authenticator, toReviewCommitsFinder, allCommitsFinder, reactionFinder, addCommentUseCase, reviewCommitUseCase, userReactionService, userDao, diffWithCommentsService, unlikeUseCaseFactory, likeUseCase), Prefix + CommitsServlet.MAPPING_PATH) context.mount(new FollowupsServlet(authenticator, followupFinder, followupDoneUseCase), Prefix + FollowupsServlet.MappingPath) +context.mount(new AllFollowupsServlet(authenticator, followupFinder, followupDoneUseCase), Prefix + AllFollowupsServlet.MappingPath) context.mount(new VersionServlet, Prefix + "version") context.mount(new ConfigServlet(config, authenticator), Prefix + "config") context.mount(new InvitationServlet(authenticator, generateInvitationCodeUseCase, sendInvitationEmailUseCase), Prefix + "invitation") diff --git a/codebrag-rest/src/main/scala/com/softwaremill/codebrag/rest/AllFollowupsServlet.scala b/codebrag-rest/src/main/scala/com/softwaremill/codebrag/rest/AllFollowupsServlet.scala new file mode 100644 index 00000000..b30c32a0 --- /dev/null +++ b/codebrag-rest/src/main/scala/com/softwaremill/codebrag/rest/AllFollowupsServlet.scala @@ -0,0 +1,38 @@ +package com.softwaremill.codebrag.rest + +import com.softwaremill.codebrag.service.user.Authenticator +import org.scalatra.json.JacksonJsonSupport +import org.bson.types.ObjectId +import org.scalatra.NotFound +import com.softwaremill.codebrag.dao.finders.followup.FollowupFinder +import com.softwaremill.codebrag.dao.finders.views.SingleFollowupView +import com.softwaremill.codebrag.usecases.reactions.FollowupDoneUseCase + +class AllFollowupsServlet(val authenticator: Authenticator, + followupFinder: FollowupFinder, + followupDoneUseCase: FollowupDoneUseCase) + extends JsonServletWithAuthentication with JacksonJsonSupport { + + get("/") { + haltIfNotAuthenticated() + followupFinder.findAllFollowupsByCommitForAdmin() + } + + get("/:id") { + haltIfNotAuthenticated() + val followupId = params("id") + followupFinder.findFollowupforAdmin(new ObjectId(followupId)) match { + case Right(followup) => followup + case Left(msg) => NotFound(msg) + } + } + + delete("/:id") { + haltIfNotAuthenticated() + followupDoneUseCase.execute(user.id, new ObjectId(params("id"))) + } +} + +object AllFollowupsServlet { + val MappingPath = "allfollowups" +} diff --git a/codebrag-ui/app/index.html b/codebrag-ui/app/index.html index 499a5907..0c539ad2 100644 --- a/codebrag-ui/app/index.html +++ b/codebrag-ui/app/index.html @@ -126,8 +126,11 @@ + + + @@ -229,7 +232,7 @@
  • - all followups ({{ followupsNotification.count }}) + all followups @@ -257,4 +260,4 @@
    - \ No newline at end of file + diff --git a/codebrag-ui/app/scripts/app.js b/codebrag-ui/app/scripts/app.js index 4c45e4f4..42c4b1cb 100644 --- a/codebrag-ui/app/scripts/app.js +++ b/codebrag-ui/app/scripts/app.js @@ -23,6 +23,8 @@ angular.module('codebrag.commits', [ angular.module('codebrag.followups', ['ngResource', 'ui.compat', 'codebrag.auth', 'codebrag.events', 'codebrag.tour']); +angular.module('codebrag.allfollowups', ['ngResource', 'ui.compat', 'codebrag.auth', 'codebrag.events', 'codebrag.tour','codebrag.followups']); + angular.module('codebrag.invitations', ['ui.validate', 'ui.keypress']); angular.module('codebrag.profile', ['codebrag.session']); @@ -47,6 +49,7 @@ angular.module('codebrag', [ 'codebrag.commits', 'codebrag.branches', 'codebrag.followups', + 'codebrag.allfollowups', 'codebrag.repostatus', 'codebrag.favicon', 'codebrag.tour', @@ -160,7 +163,7 @@ angular.module('codebrag.userMgmt').run(function(userMgmtService) { userMgmtService.initialize(); }); -angular.module('codebrag.followups') +angular.module('codebrag.allfollowups') .config(function ($stateProvider, authenticatedUser) { $stateProvider .state('allfollowups', { @@ -177,4 +180,4 @@ angular.module('codebrag.followups') url: '/{followupId}/comments/{commentId}', templateUrl: 'views/secured/followups/allfollowupDetails.html' }); -}); \ No newline at end of file +}); diff --git a/codebrag-ui/app/scripts/followups/allfollowupDetailsCtrl.js b/codebrag-ui/app/scripts/followups/allfollowupDetailsCtrl.js new file mode 100644 index 00000000..d00b1b41 --- /dev/null +++ b/codebrag-ui/app/scripts/followups/allfollowupDetailsCtrl.js @@ -0,0 +1,32 @@ +angular.module('codebrag.allfollowups') + + .controller('AllFollowupDetailsCtrl', function ($stateParams, $state, $scope, allfollowupsService, commitsService) { + + var followupId = $stateParams.followupId; + + $scope.scrollTo = $stateParams.commentId; + + allfollowupsService.loadFollowupDetails(followupId).then(function(followup) { + $scope.currentFollowup = followup; + commitsService.commitDetails(followup.commit.sha, followup.commit.repoName).then(function(commit) { + $scope.currentCommit = new codebrag.CurrentCommit(commit); + + }); + }); + + $scope.markCurrentFollowupAsDone = function() { + allfollowupsService.removeAndGetNext(followupId).then(function(nextFollowup) { + goTo(nextFollowup); + }); + }; + + function goTo(nextFollowup) { + if (_.isNull(nextFollowup)) { + $state.transitionTo('allfollowups.list'); + } else { + $state.transitionTo('allfollowups.details', {followupId: nextFollowup.followupId, commentId: nextFollowup.lastReaction.reactionId}); + } + } + + + }); diff --git a/codebrag-ui/app/scripts/followups/allfollowupListItemCtrl.js b/codebrag-ui/app/scripts/followups/allfollowupListItemCtrl.js new file mode 100644 index 00000000..6981f52d --- /dev/null +++ b/codebrag-ui/app/scripts/followups/allfollowupListItemCtrl.js @@ -0,0 +1,28 @@ +angular.module('codebrag.allfollowups') + + .controller('AllFollowupListItemCtrl', function ($scope, $state, $stateParams, allfollowupsService, $rootScope, events) { + + $scope.openFollowupDetails = function (followup) { + if(_thisFollowupOpened(followup)) { + $rootScope.$broadcast(events.scrollOnly); + } else { + $state.transitionTo('allfollowups.details', {followupId: followup.followupId, commentId: followup.lastReaction.reactionId}); + } + }; + + $scope.dismiss = function (followup) { + allfollowupsService.removeAndGetNext(followup.followupId).then(function(nextFollowup) { + if(nextFollowup) { + $state.transitionTo('allfollowups.details', {followupId: nextFollowup.followupId, commentId: nextFollowup.lastReaction.reactionId}); + } else { + $state.transitionTo('allfollowups.list'); + } + }); + }; + + function _thisFollowupOpened(followup) { + return $state.current.name === 'allfollowups.details' && $state.params.followupId === followup.followupId; + } + + + }); diff --git a/codebrag-ui/app/scripts/followups/allfollowupsCtrl.js b/codebrag-ui/app/scripts/followups/allfollowupsCtrl.js index 637a5897..76f0cdbe 100644 --- a/codebrag-ui/app/scripts/followups/allfollowupsCtrl.js +++ b/codebrag-ui/app/scripts/followups/allfollowupsCtrl.js @@ -1,22 +1,22 @@ -angular.module('codebrag.followups') +angular.module('codebrag.allfollowups') - .controller('AllFollowupsCtrl', function ($scope, $http, followupsService, pageTourService, events) { + .controller('AllFollowupsCtrl', function ($scope, $http, allfollowupsService, pageTourService, events) { $scope.$on(events.allfollowupsTabOpened, initCtrl); $scope.pageTourForFollowupsVisible = function() { - return pageTourService.stepActive('followups') || pageTourService.stepActive('invites'); + return pageTourService.stepActive('allfollowups') || pageTourService.stepActive('invites'); }; function initCtrl() { - followupsService.allFollowups().then(function(followups) { + allfollowupsService.allFollowups().then(function(followups) { $scope.followupCommits = followups; }); - $scope.hasFollowupsAvailable = followupsService.hasFollowups; - $scope.mightHaveFollowups = followupsService.mightHaveFollowups; + $scope.hasFollowupsAvailable = allfollowupsService.hasFollowups; + $scope.mightHaveFollowups = allfollowupsService.mightHaveFollowups; } initCtrl(); - }); \ No newline at end of file + }); diff --git a/codebrag-ui/app/scripts/followups/allfollowupsService.js b/codebrag-ui/app/scripts/followups/allfollowupsService.js new file mode 100644 index 00000000..359fca99 --- /dev/null +++ b/codebrag-ui/app/scripts/followups/allfollowupsService.js @@ -0,0 +1,118 @@ +angular.module('codebrag.allfollowups') + + .factory('allfollowupsService', function($http, $rootScope, events) { + + var followupsListLocal = new codebrag.followups.LocalFollowupsList(); + var listFetched = false; + + function allFollowups() { + return _httpRequest('GET').then(function(response) { + followupsListLocal.addAll(response.data.followupsByCommit); + listFetched = true; + return followupsListLocal.collection; + }); + } + + function removeAndGetNext(followupId, commitId) { + return _httpRequest('DELETE', followupId, {unique: true, requestId: 'removeFollowup_' + followupId}).then(function() { + triggerCounterDecrease(); + var nextFollowup = followupsListLocal.removeOneAndGetNext(followupId, commitId); + return nextFollowup; + }); + + } + + function loadFollowupDetails(followupId) { + return _httpRequest('GET', followupId).then(function(response) { + return response.data; + }); + } + + function hasFollowups() { + return followupsListLocal.hasFollowups(); + } + + function mightHaveFollowups() { + return !listFetched || followupsListLocal.hasFollowups() + } + + function _httpRequest(method, id, config) { + var followupsUrl = 'rest/allfollowups/' + (id || ''); + var reqConfig = angular.extend(config || {}, {method: method, url: followupsUrl}); + return $http(reqConfig); + } + + function triggerCounterDecrease() { + $rootScope.$broadcast(events.followupDone); + } + + return { + allFollowups: allFollowups, + removeAndGetNext: removeAndGetNext, + loadFollowupDetails: loadFollowupDetails, + hasFollowups: hasFollowups, + mightHaveFollowups: mightHaveFollowups + }; + + }); + +var codebrag = codebrag || {}; +codebrag.followups = codebrag.followups || {}; + +codebrag.followups.LocalFollowupsList = function(collection) { + + var self = this; + + this.collection = collection || []; + + this.addAll = function(newCollection) { + this.collection.length = 0; + Array.prototype.push.apply(this.collection, newCollection); + }; + + function nextFollowup(commit, removeAtIndex) { + var followupToReturn = null; + var currentCommitIndex = self.collection.indexOf(commit); + + if (commit.followups[removeAtIndex]) { + followupToReturn = commit.followups[removeAtIndex]; + } else if (self.collection[currentCommitIndex + 1]) { + followupToReturn = self.collection[currentCommitIndex + 1].followups[0]; + } else if (removeAtIndex > 0) { + followupToReturn = commit.followups[removeAtIndex - 1]; + } else if (removeAtIndex === 0 && currentCommitIndex > 0) { + var previousCommitFollowupsLength = self.collection[currentCommitIndex - 1].followups.length; + followupToReturn = self.collection[currentCommitIndex - 1].followups[previousCommitFollowupsLength - 1]; + } + if (!commit.followups.length) { + self.collection.splice(currentCommitIndex, 1); + } + return followupToReturn; + } + + this.removeOneAndGetNext = function(followupId) { + var currentCommit = _.find(this.collection, function(group) { + return _.some(group.followups, function(followup) { + return followup.followupId === followupId; + }); + }); + var followupToRemove = _.find(currentCommit.followups, function(followup) { + return followup.followupId === followupId; + }); + var indexToRemove = currentCommit.followups.indexOf(followupToRemove); + currentCommit.followups.splice(indexToRemove, 1); + return nextFollowup(currentCommit, indexToRemove); + }; + + this.hasFollowups = function() { + return this.collection.length > 0; + }; + + this.followupsCount = function() { + return _.reduce(this.collection, function(sum, followupsGroup) { + return sum + followupsGroup.followups.length; + }, 0); + }; + +}; + diff --git a/codebrag-ui/app/scripts/followups/followupsCtrl.js b/codebrag-ui/app/scripts/followups/followupsCtrl.js index 59dc8ad2..96bb4e7d 100644 --- a/codebrag-ui/app/scripts/followups/followupsCtrl.js +++ b/codebrag-ui/app/scripts/followups/followupsCtrl.js @@ -10,7 +10,7 @@ angular.module('codebrag.followups') }; function initCtrl() { - followupsService.allFollowups().then(function(followups) { + followupsService.followups().then(function(followups) { $scope.followupCommits = followups; }); $scope.hasFollowupsAvailable = followupsService.hasFollowups; @@ -19,4 +19,4 @@ angular.module('codebrag.followups') initCtrl(); - }); \ No newline at end of file + }); diff --git a/codebrag-ui/app/scripts/followups/followupsService.js b/codebrag-ui/app/scripts/followups/followupsService.js index 822b465a..d3c07233 100644 --- a/codebrag-ui/app/scripts/followups/followupsService.js +++ b/codebrag-ui/app/scripts/followups/followupsService.js @@ -5,7 +5,7 @@ angular.module('codebrag.followups') var followupsListLocal = new codebrag.followups.LocalFollowupsList(); var listFetched = false; - function allFollowups() { + function followups() { return _httpRequest('GET').then(function(response) { followupsListLocal.addAll(response.data.followupsByCommit); listFetched = true; @@ -47,7 +47,7 @@ angular.module('codebrag.followups') } return { - allFollowups: allFollowups, + followups: followups, removeAndGetNext: removeAndGetNext, loadFollowupDetails: loadFollowupDetails, hasFollowups: hasFollowups, diff --git a/codebrag-ui/app/views/secured/followups/allfollowupDetails.html b/codebrag-ui/app/views/secured/followups/allfollowupDetails.html index 0dbffcf6..0b87a724 100644 --- a/codebrag-ui/app/views/secured/followups/allfollowupDetails.html +++ b/codebrag-ui/app/views/secured/followups/allfollowupDetails.html @@ -1,4 +1,4 @@ -
    +
    @@ -20,4 +20,4 @@
    -
    \ No newline at end of file +
    diff --git a/codebrag-ui/app/views/secured/followups/allfollowups.html b/codebrag-ui/app/views/secured/followups/allfollowups.html index c742945b..968b6900 100644 --- a/codebrag-ui/app/views/secured/followups/allfollowups.html +++ b/codebrag-ui/app/views/secured/followups/allfollowups.html @@ -7,7 +7,7 @@
    {{commit.commit.authorName}}{{commit.commit.date | relativeDate}} in {{ commit.commit.repoName }}
  • -
    @@ -26,4 +26,4 @@
    -
    \ No newline at end of file + diff --git a/codebrag-ui/app/views/secured/followups/followupDetails.html b/codebrag-ui/app/views/secured/followups/followupDetails.html index 0dbffcf6..864729b7 100644 --- a/codebrag-ui/app/views/secured/followups/followupDetails.html +++ b/codebrag-ui/app/views/secured/followups/followupDetails.html @@ -20,4 +20,4 @@
    - \ No newline at end of file + diff --git a/codebrag-ui/app/views/secured/followups/statsFollowups.html b/codebrag-ui/app/views/secured/followups/statsFollowups.html new file mode 100644 index 00000000..3e1563e7 --- /dev/null +++ b/codebrag-ui/app/views/secured/followups/statsFollowups.html @@ -0,0 +1,3 @@ + +
    +
    \ No newline at end of file From 458979c806f8cac7a5701e52a50b54ce4cfa0790 Mon Sep 17 00:00:00 2001 From: kiran kumar Date: Mon, 5 Jan 2015 11:54:56 +0530 Subject: [PATCH 3/5] renames all followps to dashboard --- codebrag-ui/app/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codebrag-ui/app/index.html b/codebrag-ui/app/index.html index 0c539ad2..7308e578 100644 --- a/codebrag-ui/app/index.html +++ b/codebrag-ui/app/index.html @@ -229,10 +229,10 @@ -
  • +
  • - all followups + Dashboard From c2884305a0120b1998c572d7749bac9959de96b7 Mon Sep 17 00:00:00 2001 From: kiran kumar Date: Tue, 6 Jan 2015 15:00:08 +0530 Subject: [PATCH 4/5] Dashboard added to ui layer ; renamed allfollowups to dashboard except allFollowupsService --- .../dao/finders/followup/FollowupFinder.scala | 4 +-- .../finders/followup/SQLFollowupFinder.scala | 4 +-- .../codebrag/rest/AllFollowupsServlet.scala | 4 +-- codebrag-ui/app/index.html | 10 +++---- codebrag-ui/app/scripts/app.js | 18 ++++++------ .../allFollowupsService.js} | 4 +-- .../app/scripts/dashboard/dashboardCtrl.js | 22 +++++++++++++++ .../dashboardDetailsCtrl.js} | 12 ++++---- .../dashboard/dashboardListItemCtrl.js | 28 +++++++++++++++++++ .../followups/allfollowupListItemCtrl.js | 28 ------------------- .../app/scripts/followups/allfollowupsCtrl.js | 22 --------------- .../notifications/notificationsCtrl.js | 6 ++-- .../dashboard.html} | 4 +-- .../dashboardDetails.html} | 2 +- .../secured/followups/followupDetails.html | 2 +- .../secured/followups/statsFollowups.html | 3 -- 16 files changed, 85 insertions(+), 88 deletions(-) rename codebrag-ui/app/scripts/{followups/allfollowupsService.js => dashboard/allFollowupsService.js} (97%) create mode 100644 codebrag-ui/app/scripts/dashboard/dashboardCtrl.js rename codebrag-ui/app/scripts/{followups/allfollowupDetailsCtrl.js => dashboard/dashboardDetailsCtrl.js} (57%) create mode 100644 codebrag-ui/app/scripts/dashboard/dashboardListItemCtrl.js delete mode 100644 codebrag-ui/app/scripts/followups/allfollowupListItemCtrl.js delete mode 100644 codebrag-ui/app/scripts/followups/allfollowupsCtrl.js rename codebrag-ui/app/views/secured/{followups/allfollowups.html => dashboard/dashboard.html} (87%) rename codebrag-ui/app/views/secured/{followups/allfollowupDetails.html => dashboard/dashboardDetails.html} (95%) delete mode 100644 codebrag-ui/app/views/secured/followups/statsFollowups.html diff --git a/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/FollowupFinder.scala b/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/FollowupFinder.scala index b8139658..fc0f40d4 100644 --- a/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/FollowupFinder.scala +++ b/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/FollowupFinder.scala @@ -10,12 +10,12 @@ trait FollowupFinder { def findFollowupForUser(userId: ObjectId, followupId: ObjectId): Either[String, SingleFollowupView] - def findFollowupforAdmin(followupId: ObjectId): Either[String, SingleFollowupView] + def findFollowupforDashboard(followupId: ObjectId): Either[String, SingleFollowupView] def countFollowupsForUser(userId: ObjectId): Long def countFollowupsForUserSince(date: DateTime, userId: ObjectId): Long - def findAllFollowupsByCommitForAdmin(): FollowupsByCommitListView + def findAllFollowupsByCommitForDashboard(): FollowupsByCommitListView } diff --git a/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/SQLFollowupFinder.scala b/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/SQLFollowupFinder.scala index f21a3d85..e1973a6c 100644 --- a/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/SQLFollowupFinder.scala +++ b/codebrag-dao/src/main/scala/com/softwaremill/codebrag/dao/finders/followup/SQLFollowupFinder.scala @@ -129,7 +129,7 @@ class SQLFollowupFinder(val database: SQLDatabase, userDAO: UserDAO) extends Fol case like: Like => FollowupLastLikeView(like.id.toString, author.name, like.postingTime, author.avatarUrl) } } - def findAllFollowupsByCommitForAdmin(): FollowupsByCommitListView = db.withTransaction { implicit session => + def findAllFollowupsByCommitForDashboard(): FollowupsByCommitListView = db.withTransaction { implicit session => val followups = findAllFollowups() val followupReactions = findFollowupReactions(followups) val lastReactions = findLastReactionsForFollowups(followups) @@ -154,7 +154,7 @@ class SQLFollowupFinder(val database: SQLDatabase, userDAO: UserDAO) extends Fol private def findAllFollowups()(implicit session: Session): List[SQLFollowup] = { followups.list() } - def findFollowupforAdmin(followupId: ObjectId) = db.withTransaction { implicit session => + def findFollowupforDashboard(followupId: ObjectId) = db.withTransaction { implicit session => val r = for { followup <- followups.filter(f => f.id === followupId).firstOption reaction <- findLastReaction(followup.lastReactionId) diff --git a/codebrag-rest/src/main/scala/com/softwaremill/codebrag/rest/AllFollowupsServlet.scala b/codebrag-rest/src/main/scala/com/softwaremill/codebrag/rest/AllFollowupsServlet.scala index b30c32a0..73f5c477 100644 --- a/codebrag-rest/src/main/scala/com/softwaremill/codebrag/rest/AllFollowupsServlet.scala +++ b/codebrag-rest/src/main/scala/com/softwaremill/codebrag/rest/AllFollowupsServlet.scala @@ -15,13 +15,13 @@ class AllFollowupsServlet(val authenticator: Authenticator, get("/") { haltIfNotAuthenticated() - followupFinder.findAllFollowupsByCommitForAdmin() + followupFinder.findAllFollowupsByCommitForDashboard() } get("/:id") { haltIfNotAuthenticated() val followupId = params("id") - followupFinder.findFollowupforAdmin(new ObjectId(followupId)) match { + followupFinder.findFollowupforDashboard(new ObjectId(followupId)) match { case Right(followup) => followup case Left(msg) => NotFound(msg) } diff --git a/codebrag-ui/app/index.html b/codebrag-ui/app/index.html index 7308e578..683e66e9 100644 --- a/codebrag-ui/app/index.html +++ b/codebrag-ui/app/index.html @@ -124,13 +124,13 @@ - - - - + + + + @@ -230,7 +230,7 @@
  • - + Dashboard diff --git a/codebrag-ui/app/scripts/app.js b/codebrag-ui/app/scripts/app.js index 42c4b1cb..4c151ea4 100644 --- a/codebrag-ui/app/scripts/app.js +++ b/codebrag-ui/app/scripts/app.js @@ -23,7 +23,7 @@ angular.module('codebrag.commits', [ angular.module('codebrag.followups', ['ngResource', 'ui.compat', 'codebrag.auth', 'codebrag.events', 'codebrag.tour']); -angular.module('codebrag.allfollowups', ['ngResource', 'ui.compat', 'codebrag.auth', 'codebrag.events', 'codebrag.tour','codebrag.followups']); +angular.module('codebrag.dashboard', ['ngResource', 'ui.compat', 'codebrag.auth', 'codebrag.events', 'codebrag.tour','codebrag.followups']); angular.module('codebrag.invitations', ['ui.validate', 'ui.keypress']); @@ -49,7 +49,7 @@ angular.module('codebrag', [ 'codebrag.commits', 'codebrag.branches', 'codebrag.followups', - 'codebrag.allfollowups', + 'codebrag.dashboard', 'codebrag.repostatus', 'codebrag.favicon', 'codebrag.tour', @@ -163,21 +163,21 @@ angular.module('codebrag.userMgmt').run(function(userMgmtService) { userMgmtService.initialize(); }); -angular.module('codebrag.allfollowups') +angular.module('codebrag.dashboard') .config(function ($stateProvider, authenticatedUser) { $stateProvider - .state('allfollowups', { - url: '/allfollowups', + .state('dashboard', { + url: '/dashboard', abstract: true, - templateUrl: 'views/secured/followups/allfollowups.html', + templateUrl: 'views/secured/dashboard/dashboard.html', resolve: authenticatedUser }) - .state('allfollowups.list', { + .state('dashboard.list', { url: '', templateUrl: 'views/secured/followups/emptyFollowups.html' }) - .state('allfollowups.details', { + .state('dashboard.details', { url: '/{followupId}/comments/{commentId}', - templateUrl: 'views/secured/followups/allfollowupDetails.html' + templateUrl: 'views/secured/dashboard/dashboardDetails.html' }); }); diff --git a/codebrag-ui/app/scripts/followups/allfollowupsService.js b/codebrag-ui/app/scripts/dashboard/allFollowupsService.js similarity index 97% rename from codebrag-ui/app/scripts/followups/allfollowupsService.js rename to codebrag-ui/app/scripts/dashboard/allFollowupsService.js index 359fca99..573bf72f 100644 --- a/codebrag-ui/app/scripts/followups/allfollowupsService.js +++ b/codebrag-ui/app/scripts/dashboard/allFollowupsService.js @@ -1,6 +1,6 @@ -angular.module('codebrag.allfollowups') +angular.module('codebrag.dashboard') - .factory('allfollowupsService', function($http, $rootScope, events) { + .factory('allFollowupsService', function($http, $rootScope, events) { var followupsListLocal = new codebrag.followups.LocalFollowupsList(); var listFetched = false; diff --git a/codebrag-ui/app/scripts/dashboard/dashboardCtrl.js b/codebrag-ui/app/scripts/dashboard/dashboardCtrl.js new file mode 100644 index 00000000..a8146ca1 --- /dev/null +++ b/codebrag-ui/app/scripts/dashboard/dashboardCtrl.js @@ -0,0 +1,22 @@ +angular.module('codebrag.dashboard') + + .controller('DashboardCtrl', function ($scope, $http, allFollowupsService, pageTourService, events) { + + $scope.$on(events.allfollowupsTabOpened, initCtrl); + + + $scope.pageTourForFollowupsVisible = function() { + return pageTourService.stepActive('dashboard') || pageTourService.stepActive('invites'); + }; + + function initCtrl() { + allFollowupsService.allFollowups().then(function(followups) { + $scope.followupCommits = followups; + }); + $scope.hasFollowupsAvailable = allFollowupsService.hasFollowups; + $scope.mightHaveFollowups = allFollowupsService.mightHaveFollowups; + } + + initCtrl(); + + }); diff --git a/codebrag-ui/app/scripts/followups/allfollowupDetailsCtrl.js b/codebrag-ui/app/scripts/dashboard/dashboardDetailsCtrl.js similarity index 57% rename from codebrag-ui/app/scripts/followups/allfollowupDetailsCtrl.js rename to codebrag-ui/app/scripts/dashboard/dashboardDetailsCtrl.js index d00b1b41..bc806598 100644 --- a/codebrag-ui/app/scripts/followups/allfollowupDetailsCtrl.js +++ b/codebrag-ui/app/scripts/dashboard/dashboardDetailsCtrl.js @@ -1,12 +1,12 @@ -angular.module('codebrag.allfollowups') +angular.module('codebrag.dashboard') - .controller('AllFollowupDetailsCtrl', function ($stateParams, $state, $scope, allfollowupsService, commitsService) { + .controller('DashboardDetailsCtrl', function ($stateParams, $state, $scope, allFollowupsService, commitsService) { var followupId = $stateParams.followupId; $scope.scrollTo = $stateParams.commentId; - allfollowupsService.loadFollowupDetails(followupId).then(function(followup) { + allFollowupsService.loadFollowupDetails(followupId).then(function(followup) { $scope.currentFollowup = followup; commitsService.commitDetails(followup.commit.sha, followup.commit.repoName).then(function(commit) { $scope.currentCommit = new codebrag.CurrentCommit(commit); @@ -15,16 +15,16 @@ angular.module('codebrag.allfollowups') }); $scope.markCurrentFollowupAsDone = function() { - allfollowupsService.removeAndGetNext(followupId).then(function(nextFollowup) { + allFollowupsService.removeAndGetNext(followupId).then(function(nextFollowup) { goTo(nextFollowup); }); }; function goTo(nextFollowup) { if (_.isNull(nextFollowup)) { - $state.transitionTo('allfollowups.list'); + $state.transitionTo('dashboard.list'); } else { - $state.transitionTo('allfollowups.details', {followupId: nextFollowup.followupId, commentId: nextFollowup.lastReaction.reactionId}); + $state.transitionTo('dashboard.details', {followupId: nextFollowup.followupId, commentId: nextFollowup.lastReaction.reactionId}); } } diff --git a/codebrag-ui/app/scripts/dashboard/dashboardListItemCtrl.js b/codebrag-ui/app/scripts/dashboard/dashboardListItemCtrl.js new file mode 100644 index 00000000..ec05d473 --- /dev/null +++ b/codebrag-ui/app/scripts/dashboard/dashboardListItemCtrl.js @@ -0,0 +1,28 @@ +angular.module('codebrag.dashboard') + + .controller('DashboardListItemCtrl', function ($scope, $state, $stateParams, allFollowupsService, $rootScope, events) { + + $scope.openFollowupDetails = function (followup) { + if(_thisFollowupOpened(followup)) { + $rootScope.$broadcast(events.scrollOnly); + } else { + $state.transitionTo('dashboard.details', {followupId: followup.followupId, commentId: followup.lastReaction.reactionId}); + } + }; + + $scope.dismiss = function (followup) { + allfollowupsService.removeAndGetNext(followup.followupId).then(function(nextFollowup) { + if(nextFollowup) { + $state.transitionTo('dashboard.details', {followupId: nextFollowup.followupId, commentId: nextFollowup.lastReaction.reactionId}); + } else { + $state.transitionTo('dashboard.list'); + } + }); + }; + + function _thisFollowupOpened(followup) { + return $state.current.name === 'dashboard.details' && $state.params.followupId === followup.followupId; + } + + + }); diff --git a/codebrag-ui/app/scripts/followups/allfollowupListItemCtrl.js b/codebrag-ui/app/scripts/followups/allfollowupListItemCtrl.js deleted file mode 100644 index 6981f52d..00000000 --- a/codebrag-ui/app/scripts/followups/allfollowupListItemCtrl.js +++ /dev/null @@ -1,28 +0,0 @@ -angular.module('codebrag.allfollowups') - - .controller('AllFollowupListItemCtrl', function ($scope, $state, $stateParams, allfollowupsService, $rootScope, events) { - - $scope.openFollowupDetails = function (followup) { - if(_thisFollowupOpened(followup)) { - $rootScope.$broadcast(events.scrollOnly); - } else { - $state.transitionTo('allfollowups.details', {followupId: followup.followupId, commentId: followup.lastReaction.reactionId}); - } - }; - - $scope.dismiss = function (followup) { - allfollowupsService.removeAndGetNext(followup.followupId).then(function(nextFollowup) { - if(nextFollowup) { - $state.transitionTo('allfollowups.details', {followupId: nextFollowup.followupId, commentId: nextFollowup.lastReaction.reactionId}); - } else { - $state.transitionTo('allfollowups.list'); - } - }); - }; - - function _thisFollowupOpened(followup) { - return $state.current.name === 'allfollowups.details' && $state.params.followupId === followup.followupId; - } - - - }); diff --git a/codebrag-ui/app/scripts/followups/allfollowupsCtrl.js b/codebrag-ui/app/scripts/followups/allfollowupsCtrl.js deleted file mode 100644 index 76f0cdbe..00000000 --- a/codebrag-ui/app/scripts/followups/allfollowupsCtrl.js +++ /dev/null @@ -1,22 +0,0 @@ -angular.module('codebrag.allfollowups') - - .controller('AllFollowupsCtrl', function ($scope, $http, allfollowupsService, pageTourService, events) { - - $scope.$on(events.allfollowupsTabOpened, initCtrl); - - - $scope.pageTourForFollowupsVisible = function() { - return pageTourService.stepActive('allfollowups') || pageTourService.stepActive('invites'); - }; - - function initCtrl() { - allfollowupsService.allFollowups().then(function(followups) { - $scope.followupCommits = followups; - }); - $scope.hasFollowupsAvailable = allfollowupsService.hasFollowups; - $scope.mightHaveFollowups = allfollowupsService.mightHaveFollowups; - } - - initCtrl(); - - }); diff --git a/codebrag-ui/app/scripts/notifications/notificationsCtrl.js b/codebrag-ui/app/scripts/notifications/notificationsCtrl.js index 7ea41f1b..17678c6b 100644 --- a/codebrag-ui/app/scripts/notifications/notificationsCtrl.js +++ b/codebrag-ui/app/scripts/notifications/notificationsCtrl.js @@ -44,9 +44,9 @@ angular.module('codebrag.notifications') $scope.followupsNotificationAvailable = false; }); - $scope.openAllFollowups = function() { + $scope.openDashboard = function() { $rootScope.$broadcast(events.allfollowupsTabOpened); - $state.transitionTo('allfollowups.list'); + $state.transitionTo('dashboard.list'); }; - }); \ No newline at end of file + }); diff --git a/codebrag-ui/app/views/secured/followups/allfollowups.html b/codebrag-ui/app/views/secured/dashboard/dashboard.html similarity index 87% rename from codebrag-ui/app/views/secured/followups/allfollowups.html rename to codebrag-ui/app/views/secured/dashboard/dashboard.html index 968b6900..dd078a56 100644 --- a/codebrag-ui/app/views/secured/followups/allfollowups.html +++ b/codebrag-ui/app/views/secured/dashboard/dashboard.html @@ -1,4 +1,4 @@ -
    +
    @@ -7,7 +7,7 @@
    {{commit.commit.authorName}}{{commit.commit.date | relativeDate}} in {{ commit.commit.repoName }}
    -
    diff --git a/codebrag-ui/app/views/secured/followups/allfollowupDetails.html b/codebrag-ui/app/views/secured/dashboard/dashboardDetails.html similarity index 95% rename from codebrag-ui/app/views/secured/followups/allfollowupDetails.html rename to codebrag-ui/app/views/secured/dashboard/dashboardDetails.html index 0b87a724..b6f948ff 100644 --- a/codebrag-ui/app/views/secured/followups/allfollowupDetails.html +++ b/codebrag-ui/app/views/secured/dashboard/dashboardDetails.html @@ -1,4 +1,4 @@ -
    +
    diff --git a/codebrag-ui/app/views/secured/followups/followupDetails.html b/codebrag-ui/app/views/secured/followups/followupDetails.html index 864729b7..0dbffcf6 100644 --- a/codebrag-ui/app/views/secured/followups/followupDetails.html +++ b/codebrag-ui/app/views/secured/followups/followupDetails.html @@ -20,4 +20,4 @@
    -
    +
    \ No newline at end of file diff --git a/codebrag-ui/app/views/secured/followups/statsFollowups.html b/codebrag-ui/app/views/secured/followups/statsFollowups.html deleted file mode 100644 index 3e1563e7..00000000 --- a/codebrag-ui/app/views/secured/followups/statsFollowups.html +++ /dev/null @@ -1,3 +0,0 @@ - -
    -
    \ No newline at end of file From 7e6c5c771748b40ca630e1eea92ed6652cc6f850 Mon Sep 17 00:00:00 2001 From: kiran kumar Date: Tue, 6 Jan 2015 15:38:29 +0530 Subject: [PATCH 5/5] reverted unwanted changes --- codebrag-ui/app/scripts/followups/followupsCtrl.js | 4 ++-- codebrag-ui/app/scripts/followups/followupsService.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/codebrag-ui/app/scripts/followups/followupsCtrl.js b/codebrag-ui/app/scripts/followups/followupsCtrl.js index 96bb4e7d..59dc8ad2 100644 --- a/codebrag-ui/app/scripts/followups/followupsCtrl.js +++ b/codebrag-ui/app/scripts/followups/followupsCtrl.js @@ -10,7 +10,7 @@ angular.module('codebrag.followups') }; function initCtrl() { - followupsService.followups().then(function(followups) { + followupsService.allFollowups().then(function(followups) { $scope.followupCommits = followups; }); $scope.hasFollowupsAvailable = followupsService.hasFollowups; @@ -19,4 +19,4 @@ angular.module('codebrag.followups') initCtrl(); - }); + }); \ No newline at end of file diff --git a/codebrag-ui/app/scripts/followups/followupsService.js b/codebrag-ui/app/scripts/followups/followupsService.js index d3c07233..822b465a 100644 --- a/codebrag-ui/app/scripts/followups/followupsService.js +++ b/codebrag-ui/app/scripts/followups/followupsService.js @@ -5,7 +5,7 @@ angular.module('codebrag.followups') var followupsListLocal = new codebrag.followups.LocalFollowupsList(); var listFetched = false; - function followups() { + function allFollowups() { return _httpRequest('GET').then(function(response) { followupsListLocal.addAll(response.data.followupsByCommit); listFetched = true; @@ -47,7 +47,7 @@ angular.module('codebrag.followups') } return { - followups: followups, + allFollowups: allFollowups, removeAndGetNext: removeAndGetNext, loadFollowupDetails: loadFollowupDetails, hasFollowups: hasFollowups,