-
Notifications
You must be signed in to change notification settings - Fork 87
/
addservice.html
99 lines (89 loc) · 3.11 KB
/
addservice.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
<div class="addservice">
<h1>Add internal service</h1>
<div class="well well-sm nolocalservices">
No internal services
</div>
<table class="table localServicesTable initialhide">
<tr>
<th>Provider</th>
<th>Name</th>
<th>Description</th>
<th>Trigger</th>
<th>Actions</th>
</tr>
</table>
</div>
<script>
function AddService(main, project, projectPage, longCallBack) {
var othis = this;
this.show = function(){
pushHistory({page: "AddService", poid: project.oid}, "Add Service");
$(".addservice h1").html("Add Service to " + project.name);
};
this.proceedWithServiceDescriptor = function(serviceDescriptor, isLocal) {
if (isLocal) {
$(".addservice").load("addservice3.html", function(){
return new AddService3(main, project, projectPage, serviceDescriptor, isLocal, longCallBack);
});
} else {
$(".addservice").load("addservice2.html", function(){
return new AddService2($(this), main, project, serviceDescriptor, isLocal, longCallBack);
});
}
};
this.addButtonClick = function(event) {
var tr = $(this).parents("tr.servicedescriptor");
var serviceDescriptor = tr.data("servicedescriptor");
othis.proceedWithServiceDescriptor(serviceDescriptor, tr.data("isLocal"));
};
this.close = function() {
};
this.addServiceDescriptor = function(table, serviceDescriptor, isLocal) {
if (isLocal) {
$(".nolocalservices").hide();
table.show();
} else {
$(".noremoteservices").hide();
table.show();
}
var tr = $("<tr class=\"servicedescriptor\"></tr>");
tr.data("servicedescriptor", serviceDescriptor);
tr.data("isLocal", isLocal);
tr.append("<td>" + serviceDescriptor.providerName + "</td>");
tr.append("<td>" + serviceDescriptor.name + "</td>");
tr.append("<td>" + serviceDescriptor.description + "</td>");
tr.append("<td>" + formatTrigger(serviceDescriptor.trigger) + "</td>");
var addButton = $("<button class=\"btn btn-primary\">Add</button>");
addButton.click(othis.addButtonClick);
tr.append($("<td></td>").append(addButton));
table.append(tr);
};
this.loadServices = function() {
Global.bimServerApi.call("ServiceInterface", "getAllLocalServiceDescriptors", {}, function(data){
$(".addservice .localServicesTable tr.serviceDescriptor").remove();
data.forEach(function(serviceDescriptor){
othis.addServiceDescriptor($(".addservice .localServicesTable"), serviceDescriptor, true);
});
});
};
this.addUrlButtonClick = function(event) {
Global.bimServerApi.call("ServiceInterface", "getServiceDescriptor", {
baseUrl: $(".addservice .inputUrl").val(),
serviceIdentifier: $(".addservice .inputServiceIdentifier").val()
}, function(data){
othis.proceedWithServiceDescriptor(data, null);
});
};
Global.bimServerApi.call("SettingsInterface", "getServiceRepositoryUrl", {}, function(data){
$(".addservice .loadedFrom").html(" (loaded from: <a href=\"" + data + "\">" + data + "</a>)");
});
$(".addservice .addUrlButton").click(othis.addUrlButtonClick);
$(".addservice .inputUrl").keypress(function(event){
if (event.keyCode == 13) {
event.preventDefault();
othis.addUrlButtonClick();
}
});
othis.loadServices();
}
</script>