Skip to content

Commit 92ad5e9

Browse files
Merge branch 'master' of ssh://github.com/coding-blocks/boss
2 parents 40c59de + 91e1fe0 commit 92ad5e9

File tree

6 files changed

+87
-8
lines changed

6 files changed

+87
-8
lines changed

public_static/images/favicon.ico

1.12 KB
Binary file not shown.

routes/root.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ route.get('/claims/view', (req, res) => {
113113
}
114114

115115
var menuH = {}
116+
var current
117+
if(req.user) {
118+
current = req.user.usergithub.username
119+
}
116120

117121
if (options.status == 'claimed') menuH[options.status] = 'active'
118122
else if (options.status == 'accepted') menuH[options.status] = 'active'
@@ -182,6 +186,7 @@ route.get('/claims/view', (req, res) => {
182186
},
183187
status: options.status,
184188
menuH,
189+
current,
185190
filter: filter,
186191
filterproj: filterproj,
187192
username: options.username,
@@ -250,4 +255,38 @@ route.post('/claims/:id/update', auth.adminOnly, (req, res) => {
250255
})
251256
})
252257

258+
route.get('/claims/:id/edit', auth.ensureLoggedInGithub, (req, res) => {
259+
260+
du.getClaimById(req.params.id)
261+
.then(claim => {
262+
if (!claim) throw new Error('No claim found')
263+
res.render('pages/claims/edit', { claim })
264+
})
265+
.catch(err => {
266+
res.send('Error fetching claim id = ' + escapeHtml(req.params.id))
267+
})
268+
})
269+
270+
route.post('/claims/:id/edit', auth.ensureLoggedInGithub,(req, res) => {
271+
272+
du.updateClaim(req.params.id, req.body)
273+
.then(result => {
274+
res.redirect('/claims/view')
275+
})
276+
.catch(error => {
277+
res.send('Error updating claim')
278+
})
279+
})
280+
281+
route.get('/claims/:id/delete', auth.ensureLoggedInGithub, (req, res) => {
282+
283+
du.delClaim(req.params.id)
284+
.then(() => {
285+
res.redirect('/claims/view')
286+
})
287+
.catch(error => {
288+
res.send('Error Deleting Claim')
289+
})
290+
})
291+
253292
module.exports = route

utils/datautils.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ function getCounts() {
121121
'bounty',
122122
'sum'
123123
);
124-
if (Number.isNaN(accepted)) {
125-
accepted = 0;
126-
}
127-
if (Number.isNaN(totalclaimed)) {
128-
totalclaimed = 0;
129-
}
130-
return Promise.all([participants, claims, accepted, totalclaimed]);
124+
125+
var filterNaN = (data) => data || 0;
126+
127+
var counts = Promise.all([participants, claims, accepted, totalclaimed])
128+
.then((values) => values.map(filterNaN));
129+
130+
return counts;
131131
}
132132

133133
module.exports = {

views/layouts/main.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
66
<title>BOSS</title>
7+
<link rel='shortcut icon' type='image/x-icon' href='/images/favicon.ico' />
78
<link href="/lib/jquery-ui/jquery-ui.min.css" rel="stylesheet">
89
<link href="/lib/semantic/semantic.min.css" rel="stylesheet">
910
<script src="/lib/jquery-3.2.1.min.js"></script>
@@ -173,7 +174,7 @@
173174
<i class="github icon"></i>
174175
Open Issues
175176
</a>
176-
<a class="item" href="https://gitter.im/coding-blocks/boss-2018-lobby" target="_blank" >
177+
<a class="item" href="https://gitter.im/coding-blocks/boss-2019-lobby" target="_blank" >
177178
<i class="gitter icon"></i> Gitter
178179
</a>
179180
</div>

views/pages/claims/edit.hbs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<form class="ui form" method="post" action="/claims/{{claim.id}}/edit">
2+
<div class="field">
3+
<label>Github Username</label>
4+
<input name="user" placeholder="Github Username, eg. 'championswimmer'" disabled type="text" value="{{claim.user}}" required>
5+
</div>
6+
<div class="field">
7+
<label>Issue URL</label>
8+
<input name="issue_url" placeholder="URL of Issue, eg. http://github.com/org/proj/issue/7" type="url" value="{{claim.issueUrl}}" required>
9+
</div>
10+
<div class="field">
11+
<label>Pull Request URL</label>
12+
<input name="pull_url" placeholder="URL of PR, eg. http://github.com/org/proj/pull/7" type="url" value="{{claim.pullUrl}}" required>
13+
</div>
14+
<div class="field">
15+
<label>Bounty</label>
16+
<input name="bounty" placeholder="Bounty Points you are claiming for this" type="number" value="{{claim.bounty}}" required>
17+
</div>
18+
<div class="ui container center aligned">
19+
<button class="ui button green" type="submit">Save</button>
20+
</div>
21+
<div class="ui container center aligned">
22+
<a href="/claims/{{claim.id}}/delete" class="ui button red">Delete
23+
</a>
24+
</div>
25+
</form>
26+
{{#if error}}
27+
<div class="ui negative message">
28+
<div class="header" align="center">
29+
{{error}}
30+
</div>
31+
</div>
32+
{{/if}}

views/pages/claims/view.hbs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@
156156
{{/if}}
157157
{{#equal claim.status "claimed"}}
158158
<div class="ui label yellow">{{claim.status}}</div>
159+
{{#equal claim.user ../current }}
160+
<a href="/claims/{{claim.id}}/edit" style="color:white">
161+
<div class="ui label blue">
162+
Edit
163+
</div>
164+
</a>
165+
{{/equal}}
159166
{{/equal}}
160167
{{#equal claim.status "accepted"}}
161168
<div class="ui label green">{{claim.status}}</div>

0 commit comments

Comments
 (0)