-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenericpluginsettingslist.html
More file actions
137 lines (124 loc) · 3.94 KB
/
Copy pathgenericpluginsettingslist.html
File metadata and controls
137 lines (124 loc) · 3.94 KB
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
<div class="genericpluginsettingslist">
<h3></h3>
<div class="buttonBar">
<button class="btn btn-primary btnAdd">Add </button>
</div>
<div class="well ih noPlugins">
No plugins of this type have been installed for the current user
</div>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>State</th>
<th>Actions</th>
<th>Plugin State</th>
<th class="defaultHeader">Default</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<script>
function GenericPluginSettingsList(main, usersettings, configuration) {
var othis = this;
$(".genericpluginsettingslist h3").html(configuration.listTitle);
if (configuration.setDefaultMethodName == null) {
$(".genericpluginsettingslist .defaultHeader").hide();
}
this.show = function(){
};
this.pluginClick = function(event) {
if (!$(event.target).is("a, button, span.caret, input")) {
event.preventDefault();
var plugin = $(this).parents("tr").andSelf().data("plugin");
configuration.showDetailsFunction(plugin, null, true);
}
};
this.enableDisableClick = function(event){
var tr = $(this).parents("tr");
var plugin = tr.data("plugin");
var link = $(this);
var state = $(this).parents("tr").find(".state");
plugin.enabled = !plugin.enabled;
Global.bimServerApi.callWithFullIndication("PluginInterface", configuration.updateMethodName, configuration.createUpdateObject(plugin), function(){
tr.data("plugin", plugin);
if (plugin.enabled) {
link.html("disable");
state.html("Enabled");
} else {
link.html("enable");
state.html("Disabled");
}
});
};
this.setDefaultClick = function(){
var oid = $(this).parents("tr").data("plugin").oid;
Global.bimServerApi.callWithFullIndication("PluginInterface", configuration.setDefaultMethodName, {
oid: oid
}, function(){});
};
this.addPlugin = function(plugin) {
var tr = $("<tr>");
tr.data("plugin", plugin);
tr.click(othis.pluginClick);
tr.append("<td>" + plugin.name + "</td>");
tr.append("<td>" + plugin.description + "</td>");
tr.append("<td class=\"state\">" + (plugin.enabled ? "Enabled" : "Disabled") + "</td>");
var link = $("<a>");
if (plugin.enabled) {
link.html("disable");
} else {
link.html("enable");
}
link.click(othis.enableDisableClick);
var deleteLink = $("<a>delete</a>");
deleteLink.click(function(){
Global.bimServerApi.call("PluginInterface", "deletePluginConfiguration", {oid: plugin.oid}, function(){
tr.remove();
});
});
var td = $("<td>");
td.append(link);
td.append(" ");
td.append(deleteLink);
tr.append(td);
tr.append("<td class=\"pluginstate\"></td>");
Global.bimServerApi.call("PluginInterface", "getPluginDescriptor", {oid: plugin.pluginDescriptorId}, function(pluginDescriptor){
tr.find(".pluginstate").html((pluginDescriptor.enabled ? "Enabled" : "Disabled"));
});
if (configuration.setDefaultMethodName != null) {
tr.append("<td><input name=\"default\" type=\"radio\"></td>");
tr.find("input").change(othis.setDefaultClick);
if (othis.userSettings[configuration.defaultFieldName] == plugin.oid) {
tr.find("input").attr("checked", "checked");
}
}
$(".genericpluginsettingslist table tbody").append(tr);
};
this.loadPluginConfigurations = function(){
Global.bimServerApi.call("ServiceInterface", "getUserSettings", {}, function(userSettings){
othis.userSettings = userSettings;
Global.bimServerApi.call("PluginInterface", configuration.getAllMethodName, {onlyEnabled: false}, function(data){
if (data.length == 0) {
$(".noPlugins").show();
$(".genericpluginsettingslist table").hide();
} else {
$(".genericpluginsettingslist table tbody").empty();
data.forEach(function(plugin){
othis.addPlugin(plugin);
});
}
});
});
};
this.close = function(){
};
$(".btnAdd").click(function(){
configuration.showAddFunction(configuration);
});
othis.loadPluginConfigurations();
}
</script>