-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
common.constant.coffee
51 lines (46 loc) · 1.44 KB
/
common.constant.coffee
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
invert_constant = (constant_name, inverted_constant_name) ->
angular.module('common').service inverted_constant_name, [constant_name, (original) ->
return _.invert(original)
]
class Baseurlapi extends Constant('common')
constructor: ->
return 'api/v2/'
class Baseurlws extends Constant('common')
constructor: ->
href = location.href.toString()
if location.hash != ""
href = href.replace(location.hash, "")
if href[href.length - 1] != "/"
href = href + "/"
return href.replace(/^http/, "ws") + "ws"
class Plurals extends Constant('common')
constructor: ->
return {
build: "builds"
builder: "builders"
buildset: "buildsets"
buildrequest: "buildrequests"
buildslave: "buildslaves"
master: "masters"
change: "changes"
step: "steps"
log: "logs"
logchunk: "logchunks"
forcescheduler: "forceschedulers"
scheduler: "schedulers"
spec: "specs"
property: "properties"
}
invert_constant('PLURALS', 'SINGULARS')
class Results extends Constant('common')
constructor: ->
return {
SUCCESS: 0
WARNINGS: 1
FAILURE: 2
SKIPPED: 3
EXCEPTION: 4
RETRY: 5
CANCELLED: 6
}
invert_constant('RESULTS', 'RESULTS_TEXT')