-
Notifications
You must be signed in to change notification settings - Fork 87
/
newservice.html
106 lines (98 loc) · 3.69 KB
/
newservice.html
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
<div class="newservice">
<div class="button-bar">
<div class="btn-group triggerBtnGroup">
<button type="button" class="btn btn-primary triggerBtn">Trigger on last revision</button>
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span> <span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu revisionsUl">
</ul>
</div>
</div>
<table class="table">
<thead></thead>
<tbody></tbody>
</table>
</div>
<script>
function NewService(cd, main, service, serverId) {
var o = this;
var code = QueryString.code;
this.trigger = function(){
var roid = $(this).data("roid");
Global.bimServerApi.callWithFullIndication("ServiceInterface", "triggerRevisionService", {
roid: roid,
soid: service.oid
}, function(){
});
};
if (service.status != "AUTHENTICATED" && code != null) {
Global.bimServerApi.call("OAuthInterface", "getRemoteToken", {
soid : service.oid,
code : code,
serverId : serverId
}, function(result) {
Global.bimServerApi.call("ServiceInterface", "getNewService", {
soid : service.oid
}, function(service) {
cd.find(".table .statusrow").remove();
cd.find(".table").append("<tr class=\"statusrow\"><td>Status</td><td>" + formatNewServiceStatus(service.status) + "</td></tr>");
});
});
}
function formatAction(action) {
if (action.__type == "SCheckinRevision") {
console.log(action);
var span = $("<span>Checkin new revision</span>");
Global.bimServerApi.call("ServiceInterface", "getProjectByPoid", {
poid: action.projectId
}, function(project){
span.append(" (" + project.name + ")");
});
return span;
} else if (action.__type == "SStoreExtendedData") {
return action.__type.substring(1) + " (the returned data will be stored as extended data on the revision)";
} else {
return action.__type;
}
}
Global.bimServerApi.call("ServiceInterface", "getAllRevisionsOfProject", {
poid: service.projectId
}, function(data){
if (data.length == 0) {
cd.find(".triggerBtnGroup").hide();
}
data.forEach(function(revision, index){
if (index == data.length - 1) {
cd.find(".triggerBtn").data("roid", revision.oid);
}
var li = $("<li>");
var a = $("<a>Trigger on " + revision.id + " (" + revision.comment + ")</a>");
a.data("roid", revision.oid);
a.click(o.trigger);
li.append(a);
cd.find(".revisionsUl").prepend(li);
});
});
cd.find(".table").append("<tr><td>Name</td><td>" + service.name + "</td></tr>");
cd.find(".table").append("<tr><td>Description</td><td>" + service.description + "</td></tr>");
cd.find(".table").append("<tr><td>Provider</td><td>" + service.provider + "</td></tr>");
cd.find(".table").append("<tr><td>Input</td><td class=\"ed\" name=\"" + service.input + "\">" + service.input + "</td></tr>");
cd.find(".table").append("<tr><td>Output</td><td class=\"ed\" name=\"" + service.output + "\">" + service.output + "</td></tr>");
Global.bimServerApi.call("ServiceInterface", "getExtendedDataSchemaByName", {name: service.input}, function(ed){
var link = $("<a target=\"_blank\" href=\"" + ed.url + "\">" + ed.name + "</a>");
cd.find(".ed[name=\"" + ed.name + "\"]").html(link);
});
var td = $("<td>");
td.append(formatAction(service.action));
var tr = $("<tr><td>Action</td></tr>");
tr.append(td);
cd.find(".table").append(tr);
cd.find(".triggerBtn").click(o.trigger);
var tr = $("<tr class=\"statusrow\"><td>Status</td></tr>");
var td = $("<td>");
tr.append(td);
td.append(formatNewServiceStatus(service.status));
cd.find(".table").append(tr);
}
</script>