-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.coffee
More file actions
executable file
·192 lines (181 loc) · 4.77 KB
/
client.coffee
File metadata and controls
executable file
·192 lines (181 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
exports.render = !->
filterO = Obs.create {}
Dom.style
background: '#eee'
minHeight: '100%'
Obs.observe !->
text = 'Latest commits'
if (repo = filterO.get('repository'))
text += ' on '+repo
if (user = filterO.get('user'))
text += ' by '+user
Dom.h1 text
Dom.div !->
reset = Obs.create 0
Dom.style
padding: '0 0 50px 0'
# Loglist setup
lastV = Obs.create()
Obs.observe !->
lastV.set -(Db.shared.get('commitMaxId')||0)
firstV = Obs.create()
initFirst = !->
firstV.set -Math.max(1, (Db.shared.peek('commitMaxId')||0)-50)
reset.incr()
initFirst()
count = Obs.create 0
Obs.observe !->
reset.get()
Loglist.render lastV, firstV, (num) !->
num = -num
commit = Db.shared.ref 'commits', num
return if !commit.peek()?
count.incr()
Obs.onClean !->
count.incr -1
# Repository filter
return if (repo = filterO.get('repository'))? and commit.get('repositoryName') isnt repo
# User filter
return if (user = filterO.get('user'))? and commit.get('byUsername') isnt user
Dom.div !->
Dom.style
Box: 'horizontal'
background: '#fff'
boxShadow: '0 2px 4px rgba(0,0,0,0.1)'
margin: '0 0 10px 0'
padding: '0 10px 0 0'
Dom.div !->
avatarSize = 120
avatar = commit.get 'avatar'
if avatar
if avatar.indexOf('?') isnt -1
avatar += "&s="+avatarSize
else
avatar += "?s="+avatarSize
Dom.style
background: 'url("'+avatar+'")'
backgroundSize: 'contain'
backgroundRepeat: 'no-repeat'
backgroundPosition: 'center center'
width: '60px'
height: '60px'
Dom.div !->
Dom.style
Flex: 1
margin: '0 0 0 10px'
Dom.div !->
Dom.style
Box: 'horizontal center center'
borderBottom: '2px solid'
paddingBottom: '2px'
marginTop: '5px'
Dom.div !->
Dom.style
Flex: true
fontSize: '115%'
#color: '#00AA00'
fontWeight: 'bold'
Dom.div !->
Dom.style
display: 'inline-block'
margin: '-5px'
padding: '5px'
Dom.text commit.get('repositoryName')
Dom.onTap !->
filterO.set 'repository', commit.get('repositoryName')
Dom.div !->
Dom.style
fontSize: '12px'
margin: '-5px'
padding: '9px 5px'
parsedDate = Date.parse(commit.get('date'))
Time.deltaText parsedDate/1000
Dom.onTap !->
Modal.show !->
Dom.div !->
Dom.userText '**Committed:** '
Dom.br()
Dom.text new Date(parsedDate).toUTCString()
Dom.br()
Dom.userText '**Hash:** '
Dom.br()
Dom.text commit.get('hash')
Dom.div !->
Dom.style
Box: 'horizontal'
margin: '5px 0 0 0'
fontSize: '15px'
Dom.div !->
Dom.div !->
Dom.style
margin: '-5px -5px 0 -5px'
padding: '5px'
Dom.userText '**'+commit.get('byUsername')+':**'
Dom.onTap !->
filterO.set 'user', commit.get('byUsername')
Dom.div !->
Dom.style
marginLeft: '5px'
paddingBottom: '7px'
Flex: true
Dom.userText commit.get('message')
Obs.observe !->
return if firstV.get() is -1
Dom.div !->
Dom.style
Box: 'center'
padding: '20px 0 10px 0'
Ui.spinner 25
singleLoadMore = ->
if Page.near('bottom') < 600 and firstV.peek() isnt -1
firstV.set Math.min(-1, firstV.peek()+5)
true
completeLoadMore = !->
result = true
while result
result = singleLoadMore()
Page.onScroll singleLoadMore
Obs.observe !->
completeLoadMore()
filterO.get()
Obs.observe !->
if count.get() is 0
Ui.emptyText 'No commits yet, program something!'
Obs.observe !->
footer = []
if (repo = filterO.get('repository'))?
footer.push
label: !->
Dom.text 'Clear repository filter:'
Dom.div !->
Dom.style textTransform: 'none'
Dom.text repo
action: !->
initFirst()
filterO.remove 'repository'
Page.scroll 0
if (user = filterO.get('user'))?
footer.push
label: !->
Dom.text 'Clear user filter:'
Dom.div !->
Dom.style textTransform: 'none'
Dom.text user
action: !->
initFirst()
filterO.remove 'user'
Page.scroll 0
if footer.length > 0
Page.setFooter footer
exports.renderSettings = !->
if !Db.shared
Dom.text 'After installing the plugin you can see the webhook url on the settings page.'
return
Dom.div !->
Dom.style _userSelect: 'text'
Dom.userText '**Webhook url**: '+App.inboundUrl()
Dom.div !->
Dom.style
fontSize: '14px'
marginTop: '2px'
Dom.text 'Add this url as webhook in BitBucket or GitHub'