-
Notifications
You must be signed in to change notification settings - Fork 87
/
extendeddatalist.html
158 lines (141 loc) · 5.25 KB
/
extendeddatalist.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
151
152
153
154
155
156
157
158
<div class="extendeddatalist">
<a class="ih backButton">back</a>
<div class="details"></div>
<div class="list">
<div class="well well-sm noextendeddata">
No extended data
</div>
<table class="table initialhide table-striped table-hover">
<thead>
<tr>
<th>Title</th>
<th>Added</th>
<th>Time to generate</th>
<th>User</th>
<th>Schema</th>
<th>Size</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<script>
function ExtendedDataList(main, revision, parent, extendedData) {
var othis = this;
othis.revision = revision;
this.userClick = function(event){
if (!$(event.target).is("a, button, span.caret")) {
main.showUser($(this).data("user"), event);
othis.close();
}
};
this.loadExtendedDataSingle = function(extendedData){
$(".extendeddatalist .backButton").show();
$(".extendeddatalist .list").hide();
$(".extendeddatalist .details").show();
$(".extendeddatalist .details").load(Global.baseDir + "extendeddata.html", function(){
new ExtendedData($(this), main, extendedData, parent);
pushHistory({page: "Project", poid: othis.revision.projectId, tab: "extendeddata", edid: extendedData.oid}, "Project");
});
};
this.extendedDataClick = function(event) {
if (!$(event.target).is("a, button, span.caret")) {
event.preventDefault();
var extendedData = $(this).parents("tr").andSelf().data("extendeddata");
othis.loadExtendedDataSingle(extendedData);
}
};
this.newLogAction = function(uuid, logAction, serviceIdentifier, profileIdentifier, token, apiUrl){
if (logAction.__type == "SExtendedDataAddedToRevision") {
Global.bimServerApi.call("ServiceInterface", "getExtendedData", {oid: logAction.extendedDataId}, function(data){
othis.addExtendedData(data);
});
}
};
this.addExtendedData = function(extendedData) {
$(".extendeddatalist table").show();
$(".extendeddatalist .noextendeddata").hide();
var tr = $("<tr>");
tr.click(othis.extendedDataClick);
tr.data("extendeddata", extendedData);
tr.append("<td>" + extendedData.title + "</td>");
tr.append("<td><span title=\"" + formatDateTime(new Date(extendedData.added)) + "\" class=\"timespan\" datetime=\"" + extendedData.added + "\">" + formatTimeSpan(new Date().getTime() - extendedData.added, false) + "</span></td>");
tr.append("<td><span>" + formatDuration(extendedData.timeToGenerate, true) + "</span></td>");
var userTd = $("<td></td>");
var userA = $("<a>loading...</a>");
userA.attr("uoid", extendedData.userId);
userA.click(othis.userClick);
userTd.append(userA);
loadUser(userA);
tr.append(userTd);
var schemaTd = $("<td>");
schemaTd.append(main.makeSchemaLink(extendedData.schemaId));
tr.append(schemaTd);
tr.append("<td>" + getHumanSize(extendedData.size) + "</td>");
var actions = newSplitDropDownTd("Download", othis.download);
actions.find("button.dropdown-toggle").click(function(){
Global.bimServerApi.call("ServiceInterface", "getAllServicesOfProject", {poid: othis.revision.projectId}, function(data){
actions.find("ul li").remove();
var added = 0;
data.forEach(function(service){
if (service.trigger == "NEW_EXTENDED_DATA") {
var li = $("<li><a>Run \"" + service.name + "\"</a></li>");
added++;
li.find("a").click(function(event){
Global.bimServerApi.call("ServiceInterface", "triggerNewExtendedData", {edid: extendedData.oid, soid: service.oid}, function(data){
});
});
actions.find("ul").append(li);
}
});
if (added == 0) {
var li = $("<li><a>No services configured</a></li>");
actions.find("ul").append(li);
}
});
});
tr.append(actions);
$(".extendeddatalist table tbody").prepend(tr);
};
this.download = function(event) {
var extendedData = $(this).parents("tr").data("extendeddata");
document.location = Global.bimServerApi.generateExtendedDataDownloadUrl(extendedData.oid);
};
this.loadExtendedData = function() {
$(".extendeddatalist .details div").remove();
$(".extendeddatalist .backButton").hide();
$(".extendeddatalist .list").show();
Global.bimServerApi.call("ServiceInterface", "getAllExtendedDataOfRevision", {roid: revision.oid}, function(data){
$(".extendeddatalist table tbody").empty();
data.forEach(function(extendedData){
othis.addExtendedData(extendedData);
});
});
};
this.close = function(){
Global.bimServerApi.unregister(othis.newLogAction);
};
this.newExtendedDataOnRevisionHandler = function(poid, edid){
Global.bimServerApi.call("ServiceInterface", "getExtendedData", {oid: edid}, function(extendedData){
othis.addExtendedData(extendedData);
});
};
$(".extendeddatalist .backButton").click(function(){
$(".extendeddatalist .list").show();
$(".extendeddatalist .details").hide();
$(".extendeddatalist .backButton").hide();
othis.loadExtendedData();
pushHistory({page: "Project", poid: othis.revision.projectId, tab: "extendeddata"}, "Project");
});
Global.bimServerApi.register("NotificationInterface", "newLogAction", othis.newLogAction);
Global.bimServerApi.registerNewExtendedDataOnRevisionHandler(othis.revision.oid, othis.newExtendedDataOnRevisionHandler);
if (extendedData != null) {
othis.loadExtendedDataSingle(extendedData);
} else {
othis.loadExtendedData();
}
}
</script>