Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added all further events that are visible in timeline and will still … #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/events.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

angular
.module('adf.widget.github')
.directive('events', function() {
return {
templateUrl: 'src/events.html'
};
});
31 changes: 31 additions & 0 deletions src/events.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<ul class="media-list">
<li class="media" ng-repeat="event in vm.events">
<div class="media-left">
<a href="{{event.userUrl}}" target="_blank">
<img class="media-object img-thumbnail"
ng-src="{{event.userImage}}"
style="width: 64px; height: 64px;"
alt="">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">
<a href="{{event.userUrl}}" target="_blank">{{event.actor.login}}</a>
<span> {{event.messageAction | limitTo: 128}}
<a href="{{event.linkElementOne}}">{{event.messageElementOne}}</a>
</span>
<span ng-if="event.messageElementTwo"> at
<a href="{{event.linkElementTwo}}">{{event.messageElementTwo}}</a>
</span>
</h4>
<p ng-if="event.comments" ng-repeat="comment in event.comments | limitTo:2">
<a ng-if="comment.link" href="{{comment.link}}">{{comment.id | limitTo: 7}}&nbsp;</a>
<span>{{comment.message | limitTo: 128}}</span>
</p>
<small>
<a href="{{event.userUrl}}" target="_blank">{{event.actor.login}}</a>,
{{event.created_at | date: 'yyyy-MM-dd HH:mm'}}
</small>
</div>
</li>
</ul>
32 changes: 1 addition & 31 deletions src/events.org.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,6 @@
Please configure the widget
</div>
<div ng-if="config.org">
<ul class="media-list">
<li class="media" ng-repeat="event in vm.events">
<div class="media-left">
<a href="{{event.userUrl}}" target="_blank">
<img class="media-object img-thumbnail"
ng-src="{{event.userImage}}"
style="width: 64px; height: 64px;"
alt="">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">
<a href="{{event.userUrl}}" target="_blank">{{event.actor.login}}</a>
<span> {{event.messageAction | limitTo: 128}}
<a href="{{event.linkElementOne}}">{{event.messageElementOne}}</a>
</span>
<span ng-if="event.messageElementTwo"> at
<a href="{{event.linkElementTwo}}">{{event.messageElementTwo}}</a>
</span>
</h4>
<p ng-if="event.comments" ng-repeat="comment in event.comments | limitTo:2">
<a ng-if="comment.link" href="{{comment.link}}">{{comment.id | limitTo: 7}}&nbsp;</a>
<span>{{comment.message | limitTo: 128}}</span>
</p>
<small>
<a href="{{event.userUrl}}" target="_blank">{{event.actor.login}}</a>,
{{event.created_at | date: 'yyyy-MM-dd HH:mm'}}
</small>
</div>
</li>
</ul>
<events></events>
</div>
</div>
28 changes: 1 addition & 27 deletions src/events.repo.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,6 @@
Please configure the widget
</div>
<div ng-if="config.path">
<ul class="media-list">
<li class="media" ng-repeat="event in vm.events">
<div class="media-left">
<a href="{{event.userUrl}}" target="_blank">
<img class="media-object img-thumbnail"
ng-src="{{event.userImage}}"
style="width: 64px; height: 64px;"
alt="">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">
<a href="{{event.userUrl}}" target="_blank">{{event.actor.login}}</a>
<span> {{event.messageAction | limitTo: 128}}<a href="{{event.linkElementOne}}">{{event.messageElementOne}}</a></span>
<span ng-if="event.messageElementTwo"> at <a href="{{event.linkElementTwo}}">{{event.messageElementTwo}}</a></span>
</h4>
<p ng-if="event.comments" ng-repeat="comment in event.comments | limitTo:2">
<a ng-if="comment.link" href="{{comment.link}}">{{comment.id | limitTo: 7}}</a>
<span>{{comment.message | limitTo: 128}}</span>
</p>
<small>
<a href="{{event.userUrl}}" target="_blank">{{event.actor.login}}</a>,
{{event.created_at | date: 'yyyy-MM-dd HH:mm'}}
</small>
</div>
</li>
</ul>
<events></events>
</div>
</div>
27 changes: 1 addition & 26 deletions src/events.user.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,6 @@
Please configure the widget
</div>
<div ng-if="config.user">
<ul class="media-list">
<li class="media" ng-repeat="event in vm.events">
<div class="media-left">
<a href="{{event.userUrl}}" target="_blank">
<img class="media-object img-thumbnail"
ng-src="{{event.userImage}}"
style="width: 64px; height: 64px;"
alt="">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">
<a href="{{event.userUrl}}" target="_blank">{{event.actor.login}}</a>
<span> {{event.messageAction | limitTo: 128}}<a href="{{event.linkElementOne}}">{{event.messageElementOne}}</a></span>
<span ng-if="event.messageElementTwo"> at <a href="{{event.linkElementTwo}}">{{event.messageElementTwo}}</a></span>
</h4>
<p ng-if="event.comments" ng-repeat="comment in event.comments | limitTo:2">
<a ng-if="comment.link" href="{{comment.link}}">{{comment.id | limitTo: 7}}</a> {{comment.message | limitTo: 128}}
</p>
<small>
<a href="{{event.userUrl}}" target="_blank">{{event.actor.login}}</a>,
{{event.created_at | date: 'yyyy-MM-dd HH:mm'}}
</small>
</div>
</li>
</ul>
<events></events>
</div>
</div>
107 changes: 89 additions & 18 deletions src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ function GithubService($q, $http, githubApiUrl) {
.then(transformData);
}

// transform data from promise to fit in view of repo, org and user events

function transformData(data){
for(var i = 0; i<data.length; i++){

Expand All @@ -79,19 +81,13 @@ function GithubService($q, $http, githubApiUrl) {

if(eventType === "PullRequestEvent"){

var issueNumer = data[i].payload.number;
var issueNumber = data[i].payload.number;
var actionStatus = data[i].payload.action;

if (actionStatus === "closed") {
data[i].messageAction = "closed pull request ";
data[i].messageElementOne = repoName + "#" + issueNumer;
data[i].linkElementOne = repoUrl + "/issues/" + issueNumer;
}
else if (actionStatus === "opened"){
data[i].messageAction = "opened pull request ";
data[i].messageElementOne = repoName + "#" + issueNumer;
data[i].linkElementOne = repoUrl + "/issues/" + issueNumer;
}
data[i].messageAction = actionStatus + " pull request ";
data[i].messageElementOne = repoName + "#" + issueNumber;
data[i].linkElementOne = repoUrl + "/issues/" + issueNumber;

if(data[i].payload.pull_request){
data[i].comments = bindSingleComment(data[i].payload.pull_request.title);
}
Expand Down Expand Up @@ -139,12 +135,8 @@ function GithubService($q, $http, githubApiUrl) {
else if (eventType === "IssuesEvent") {
var actionStatus = data[i].payload.action;

if (actionStatus === "closed") {
data[i].messageAction = "closed issue ";
}
else if (actionStatus === "opened"){
data[i].messageAction = "opened issue ";
}
data[i].messageAction = actionStatus + " issue ";

var issueNumber = data[i].payload.issue.number;

data[i].messageElementOne = repoName + "#" + issueNumber;
Expand All @@ -158,10 +150,15 @@ function GithubService($q, $http, githubApiUrl) {
data[i].messageElementOne = repoName;
data[i].linkElementOne = repoUrl;
}
else if (eventType === "CreateEvent") {
data[i].messageAction = "created " + data[i].payload.ref_type + " " + data[i].payload.ref + " at ";
data[i].messageElementOne = repoName;
data[i].linkElementOne = repoUrl;
}
else if (eventType === "ReleaseEvent") {
var releaseName = data[i].payload.release.name;

data[i].messageAction = "released "
data[i].messageAction = "released ";
data[i].messageElementOne = releaseName;
data[i].linkElementOne = repoUrl + "/releases/tag/" + releaseName;
data[i].messageElementTwo = repoName;
Expand All @@ -179,6 +176,80 @@ function GithubService($q, $http, githubApiUrl) {
data[i].comments = comments;
}
}
else if (eventType === "ForkEvent") {
data[i].messageAction = "forked ";
data[i].messageElementOne = repoName;
data[i].linkElementOne = repoUrl;
}
else if (eventType === "CommitCommentEvent") {
var commitId = data[i].payload.comment.commit_id;
var commentId = data[i].payload.comment.id;

data[i].messageAction = "commented on commit ";
data[i].messageElementOne = "#" + commitId.substring(0,7);
data[i].linkElementOne = repoUrl + "/commit/" + commitId + "#commitcomment-" + commentId;

if(data[i].payload.comment){
data[i].comments = bindSingleComment(data[i].payload.comment.body);
}
}
else if (eventType === "GollumEvent") {
data[i].messageAction = "changed Wiki in ";

data[i].messageElementOne = repoName;
data[i].linkElementOne = repoUrl;

if (data[i].payload.pages){

var itLength = data[i].payload.pages.length;
var comments = [];

for (var j = 0; j < itLength; j++){
var page = data[i].payload.pages[j];
var sha = page.sha;
var object = {
"id": sha,
"link": repoUrl + "/wiki/Home",
"message": page.action + " page " + page.page_name
};
comments.push(object);
}
data[i].comments = comments;
}
}
else if (eventType === "MemberEvent") {
var memberName = data[i].payload.member.login;
data[i].messageAction = "added user ";
data[i].messageElementOne = memberName;
data[i].linkElementOne = "https://github.com/" + memberName;
data[i].messageElementTwo = repoName;
data[i].linkElementTwo = repoUrl;
}
else if (eventType === "PublicEvent") {
data[i].messageAction = "published ";
data[i].messageElementOne = repoName;
data[i].linkElementOne = repoUrl;
}
else if (eventType === "PullRequestReviewCommentEvent") {
var commentId = data[i].payload.comment.id;
var commentUrl = data[i].payload.comment.html_url;
var requestId = data[i].payload.pull_request.id;
var requestUrl = data[i].payload.pull_request.html_url;
data[i].messageAction = data[i].payload.action + " comment ";
data[i].messageElementOne = "#"+ commentId;
data[i].linkElementOne = commentUrl;
data[i].messageElementTwo = "PullRequest#" + requestId;
data[i].linkElementTwo = requestUrl;

if(data[i].payload.comment){
data[i].comments = bindSingleComment(data[i].payload.comment.body);
}
}
else if (eventType === "WatchEvent") {
data[i].messageAction = "starred ";
data[i].messageElementOne = repoName;
data[i].linkElementOne = repoUrl;
}
}
return data;
}
Expand Down