-
Notifications
You must be signed in to change notification settings - Fork 87
/
addrepomodelchecker.html
119 lines (109 loc) · 3.44 KB
/
addrepomodelchecker.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
107
108
109
110
111
112
113
114
115
116
117
118
119
<div class="addrepomodelchecker">
<div class="well well-sm noschemas initialhide">
No (unused) model checkers available
</div>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Plugin</th>
<th>Add</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="well well-sm">
<button class="btn btn-default cancelButton">Cancel</button>
<button class="btn btn-default addAllButton">Add all</button>
</div>
</div>
<script>
function AddRepoModelChecker(main, serversettings) {
var othis = this;
this.close = function() {
};
this.addButtonClick = function() {
serversettings.showAddNewModelChecker($(this).parents("tr").data("modelchecker"));
};
this.addModelChecker = function(modelChecker) {
var tr = $("<tr>");
var td = $("<td>");
tr.data("modelchecker", modelChecker);
tr.append("<td>" + modelChecker.name + "</td>");
tr.append("<td>" + modelChecker.description + "</td>");
tr.append("<td>" + modelChecker.modelCheckerPluginClassName + "</td>");
var td = $("<td>");
var addButton = $("<button class=\"btn btn-default\">Add</button>");
addButton.click(othis.addButtonClick);
td.append(addButton);
tr.append(td);
$(".addrepomodelchecker table tbody").append(tr);
};
this.loadModelCheckers = function() {
var checkers = {};
Global.bimServerApi.call("ServiceInterface", "getAllModelCheckers", {}, function(modelCheckers){
modelCheckers.forEach(function(modelChecker){
checkers[modelChecker.name] = modelChecker;
});
});
Global.bimServerApi.call("ServiceInterface", "getAllRepositoryModelCheckers", {}, function(data){
$("addrepomodelchecker table tbody tr").remove();
data.forEach(function(modelChecker){
if (checkers[modelChecker.name] == null) {
othis.addModelChecker(modelChecker);
}
});
if ($(".addrepomodelchecker .table tbody tr").length == 0) {
$(".addrepomodelchecker .noschemas").show();
$(".addrepomodelchecker .table").hide();
} else {
$(".addrepomodelchecker .noschemas").hide();
$(".addrepomodelchecker .table").show();
}
});
};
this.cancelClick = function(event) {
event.preventDefault();
main.showServerSettings(null, function(){
main.current.showExtendedDataSchemas();
});
};
this.addAllClick = function(){
var schemas = {};
Global.bimServerApi.call("ServiceInterface", "getAllModelCheckers", {}, function(modelCheckers){
modelCheckers.forEach(function(modelChecker){
schemas[modelChecker.name] = modelChecker;
});
});
Global.bimServerApi.call("ServiceInterface", "getAllRepositoryModelCheckers", {}, function(data){
var requests = [];
$("addrepoextendeddata table tbody tr").remove();
data.forEach(function(modelChecker){
if (schemas[modelChecker.name] == null) {
var request = [
"ServiceInterface", "addModelChecker", {modelCheckerInstance: modelChecker}
];
requests.push(request);
}
});
Global.bimServerApi.multiCall(requests, function(responses){
var requests = [];
responses.forEach(function(response){
var request = [
"ServiceInterface", "validateModelChecker", {oid: response.result}
];
requests.push(request);
});
Global.bimServerApi.multiCall(requests, function(responses){
serversettings.showModelCheckers();
});
});
});
};
$(".addrepomodelchecker .cancelButton").click(othis.cancelClick);
$(".addrepomodelchecker .addAllButton").click(othis.addAllClick);
this.loadModelCheckers();
}
</script>