-
Notifications
You must be signed in to change notification settings - Fork 87
/
installpluginbundle.html
150 lines (135 loc) · 5.5 KB
/
installpluginbundle.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
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
<div class="installplugin" bundle>
<h3>Install Plugin Bundle <a class="helpBtn" title="Help"><span class="glyphicon glyphicon-question-sign"></span></a></h3>
<div class="alert alert-success ih">
Plugin successfully installed, <a class="btnBack">Back to available plugins</a>
</div>
<div class="panel panel-default helpDiv ih">
<div class="panel-body">
<p><b>Plugins</b>
<p>A plugin bundle consists of 1 or more plugins. Each plugin you can initially enable or disable. There are also convenience method to automatically enable this plugin for all (active) users of this BIMserver, and to select whether to automatically enable this plugin for new users.</p>
</div>
</div>
<h4>Plugin Bundle Information</h4>
<table class="table infoTable">
<thead></thead>
<tbody></tbody>
</table>
<h4>Plugins</h4>
<table class="table pluginsTable">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Enable</th>
<th>Enable for all users</th>
<th>Enable for new users</th>
</tr>
</thead>
<tbody></tbody>
</table>
<button class="btn btn-primary btnInstall">Install</button>
</div>
<script>
function InstallPluginBundle(cd, serverSettings, pluginBundle, pluginBundleVersion) {
var o = this;
this.show = function(){};
this.hide = function(){};
cd.find(".infoTable tbody").append("<tr title=\"Maven GroupID: " + pluginBundleVersion.groupId + "\"><td>Organization</td><td>" + pluginBundle.organization + "</td></tr>");
cd.find(".infoTable tbody").append("<tr title=\"Maven ArtifactID: " + pluginBundleVersion.artifactId + "\"><td>Name</td><td>" + pluginBundle.name + "</td></tr>");
cd.find(".infoTable tbody").append("<tr><td>Description</td><td>" + pluginBundleVersion.description + "</td></tr>");
cd.find(".infoTable tbody").append("<tr><td>Version</td><td>" + pluginBundleVersion.version + "</td></tr>");
cd.find(".infoTable tbody").append("<tr><td>Date/Time</td><td>" + (pluginBundleVersion.date == null ? "Unknown" : formatDateTime(new Date(pluginBundleVersion.date))) + "</td></tr>");
Global.bimServerApi.callWithFullIndication("PluginInterface", "getPluginInformation", {
repository: pluginBundleVersion.repository,
groupId: pluginBundleVersion.groupId,
artifactId: pluginBundleVersion.artifactId,
version: pluginBundleVersion.version
}, function(data){
data.forEach(function(plugin){
var tr = $("<tr>");
tr.append("<td class=\"pluginName\">" + plugin.name + "</td>");
tr.append("<td>" + o.formatPluginType(plugin.type) + "</td>");
tr.append("<td>" + plugin.description + "</td>");
tr.data("identifier", plugin.identifier);
var enableCheckbox = $("<input type=\"checkbox\" class=\"enableCheckbox\" checked=\"checked\">");
var allUsersCheckbox = $("<input type=\"checkbox\" class=\"allUsersCheckbox\" checked=\"checked\">");
var newUsersCheckbox = $("<input type=\"checkbox\" class=\"newUsersCheckbox\" checked=\"checked\">");
enableCheckbox.change(function(){
var enabled = $(this).is(":checked");
$(this).parents("tr").find(".allUsersCheckbox").prop("disabled", !enabled);
$(this).parents("tr").find(".newUsersCheckbox").prop("disabled", !enabled);
if (!enabled) {
$(this).parents("tr").find(".allUsersCheckbox").prop("checked", false);
$(this).parents("tr").find(".newUsersCheckbox").prop("checked", false);
}
});
var enableTd = $("<td>");
var enableAllUsersTd = $("<td>");
var enableNewUsersTd = $("<td>");
enableTd.append(enableCheckbox);
enableAllUsersTd.append(allUsersCheckbox);
enableNewUsersTd.append(newUsersCheckbox);
tr.append(enableTd);
tr.append(enableAllUsersTd);
tr.append(enableNewUsersTd);
cd.find(".pluginsTable tbody").append(tr);
});
});
this.formatPluginType = function(type){
if (type == "SERIALIZER") {
return "Serializer";
} else if (type == "DESERIALIZER") {
return "Deserializer";
} else if (type == "OBJECT_IDM") {
return "Object IDM";
} else if (type == "RENDER_ENGINE") {
return "Render Engine";
} else if (type == "QUERY_ENGINE") {
return "Query Engine";
} else if (type == "MODEL_CHECKER") {
return "Model Checker";
} else if (type == "MODEL_MERGER") {
return "Model Merger";
} else if (type == "SERVICE") {
return "Service";
} else if (type == "WEB_MODULE") {
return "Web Module";
} else {
return type;
}
};
this.install = function(){
var plugins = [];
cd.find(".pluginsTable tbody tr").each(function(index, item){
var tr = $(item);
plugins.push({
__type: "SPluginInformation",
identifier: tr.data("identifier"),
name: tr.find(".pluginName").text(),
enabled: tr.find(".enableCheckbox").is(":checked"),
installForAllUsers: tr.find(".allUsersCheckbox").is(":checked"),
installForNewUsers: tr.find(".newUsersCheckbox").is(":checked")
});
});
Global.bimServerApi.callWithFullIndication("PluginInterface", "installPluginBundle", {
repository: pluginBundleVersion.repository,
groupId: pluginBundleVersion.groupId,
artifactId: pluginBundleVersion.artifactId,
version: pluginBundleVersion.version,
plugins: plugins
}, function(){
cd.find(".alert-success").show();
cd.find(".btnInstall").hide();
window.scrollTo(0, 0);
});
};
cd.find(".btnInstall").click(o.install);
cd.find(".helpBtn").click(function(){
cd.find(".helpDiv").toggle();
});
cd.find(".btnBack").click(function(){
serverSettings.showAvailablePluginBundles();
});
}
</script>