Skip to content

Commit

Permalink
Gitlab plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed Jan 20, 2019
1 parent 1d89d93 commit 1af915f
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<base href="/">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Online planning poker</title>
<meta name="description" content="Scrumpoker online is an open source web implementation of planning poker for scrum teams to determine the complexity of stories. It aims to integrate ticketing systems like Redmine or Github.">
<meta name="description" content="Scrumpoker online is an open source web implementation of planning poker for scrum teams to determine the complexity of stories. It aims to integrate ticketing systems like JIRA, Github or Gitlab.">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="apple-touch-icon" href="apple-touch-icon.png">
Expand Down
53 changes: 53 additions & 0 deletions src/js/gitlab-plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*globals scrum */

// Add a plugin for github integration
scrum.sources.push({
// Fixed properties and methods
name: "Gitlab",
position: 4,
view: "templates/gitlab_source.html",
feedback: false,
// Feedback call for completed poll
completed: function(result) {
},

// Custom properties and methods
loaded: false,
server: 'https://gitlab.com/',
repo: '',
issues: [],
issue: {},

// Private repo
isPrivate: false,
token: '',

// Load issues from github
load: function() {
var self = this;

var headers = {};
if(self.isPrivate) {
headers['Private-Token'] = this.token;
}

// Build access URL. Gitlab is very picky about that!
var encodedRepo = encodeURIComponent(this.repo);
var uri = this.server;
if(uri.substr(-1) !== '/')
uri += '/';
uri += 'api/v4/projects/' + encodedRepo + '/issues';
this.parent.$http
.get(uri, { headers: headers })
.then(function (response) {
// Convert markdown to HTML
var converter = new showdown.Converter();
response.data.forEach(function(issue) {
issue.description = converter.makeHtml(issue.description);
});
self.issues = response.data;
self.issue = self.issues[0];
self.loaded = true;
});
}
});
4 changes: 3 additions & 1 deletion src/sample-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
// Plugin to load issues from github
'GitHub',
// Plugin to load issues from JIRA
'JIRA'
'JIRA',
// Plugin to load issues from Gitlab
'Gitlab'
];

// Configuration for the server side JIRA controller
Expand Down
68 changes: 68 additions & 0 deletions src/templates/gitlab_source.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!-- Initial screen till static information was put in -->
<div ng-if="!master.current.loaded">
<form role="form">
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="form-group">
<label>Server:</label>
<input type="text" class="form-control" placeholder="{{master.current.server}}" ng-model="master.current.server">
</div>
</div>
<div class="col-xs-12 col-md-6">
<div class="form-group">
<label>Repo:</label>
<input type="text" class="form-control" placeholder="user/repo" ng-model="master.current.repo">
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="form-group">
<label><input type="checkbox" ng-model="master.current.isPrivate"> is private</label>
</div>
</div>
<div class="col-xs-12 col-md-6" ng-if="master.current.isPrivate">
<div class="form-group">
<label>Token: <a target="_blank" href="https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html">?</a></label>
<input type="text" class="form-control" ng-model="master.current.token">
</div>
</div>
</div>
<button class="btn btn-default" ng-click="master.current.load()">Load issues</button>
</form>
</div>

<!-- Screen after static process was completed -->
<div ng-if="master.current.loaded">
<div class="row">
<div class="col-xs-4">
<div class="list-group issue-list">
<a ng-repeat="issue in master.current.issues track by issue.id" class="selectable list-group-item" ng-class="{active: master.current.issue == issue}" ng-click="master.current.issue = issue">
#{{ issue.iid }}: {{ issue.title }}
</a>
</div>
</div>
<div class="col-xs-8">
<div class="row">
<div class="col-xs-1">
<img src="{{ master.current.issue.author.avatar_url }}" alt="{{ master.current.issue.author.name }}" style="width: 100%" />
</div>
<div class="col-xs-11">
<h2><a href="{{ master.current.issue.web_url }}" target="_blank">#{{ master.current.issue.iid }}</a>: {{ master.current.issue.title }}</h2>
</div>
</div>
<div ng-if="master.current.issue.labels.length > 0">
<p><span ng-repeat="label in master.current.issue.labels" class="label label-default">{{ label.name }}</span></p>
</div>

<div class="panel panel-default">
<div class="panel-heading">
{{ master.current.issue.author.name }} created issue on {{ master.current.issue.created_at | date : "medium" }}
</div>
<div class="panel-body" style="white-space: pre-line" ng-bind-html="master.current.issue.description"></div>
</div>

<button class="btn btn-default" ng-click="master.startPoll(master.current.issue.title, master.current.issue.description, master.current.issue.web_url)">Start</button>
</div>
</div>
</div>

0 comments on commit 1af915f

Please sign in to comment.