-
Notifications
You must be signed in to change notification settings - Fork 87
/
regenerategeometry.html
84 lines (80 loc) · 3.45 KB
/
regenerategeometry.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
<div class="regenerategeometry">
<div class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">Regenerate geometry</h4>
</div>
<div class="modal-body">
<p class="startMessage">The geometry currently stored for this revision will be overwritten</p>
<div class="uploadStatus"></div>
<div class="progressBarHolder"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary btnStart">Start</button>
</div>
</div>
</div>
</div>
</div>
<script>
function RegenerateGeometry(cd, roids, engine) {
var o = this;
cd.find(".modal-title").html("Regenerate geometry with " + engine.name);
this.progressHandler = function(topicId, state) {
var oldStage = o.stage;
o.stage = state.stage;
if (state.state == "AS_ERROR") {
cd.find(".uploadStatus").empty();
state.errors.forEach(function(error){
cd.find(".uploadStatus").append("<div class=\"alert alert-block alert-danger\">" + error + "</div>");
});
o.showUpload();
Global.bimServerApi.unregisterProgressHandler(topicId, o.progressHandler);
} else {
cd.find(".uploadStatus").html(state.title);
if (oldStage != state.stage) {
cd.find(".progressBarHolder .uploadProgressBar").remove();
cd.find(".progressBarHolder").append("<div class=\"uploadProgressBar progress initialhide\"><div class=\"progress-bar\"></div></div>");
}
if (state.progress == -1) {
cd.find(".uploadProgressBar").addClass("progress-striped").addClass("active");
cd.find(".uploadProgressBar .progress-bar").css("width", "100%");
} else {
cd.find(".uploadProgressBar").removeClass("progress-striped").removeClass("active");
cd.find(".uploadProgressBar .progress-bar").css("width", parseInt(state.progress) + "%");
}
cd.find(".progressBarHolder .uploadProgressBar").show();
if (state.state == "FINISHED") {
if (!o.progressDoneHandled) {
o.progressDoneHandled = true;
cd.find(".regenerategeometry").parent().modal("hide");
Global.bimServerApi.callWithNoIndication("ServiceInterface", "cleanupLongAction", {topicId: topicId}, function(){
}).done(function(){
cd.find(".progressBarHolder").hide();
cd.find(".uploadStatus").addClass("alert").addClass("alert-success");
// This also automatically unregisters the progress handler, so we only have to tell bimserverapi that it's unregistered
Global.bimServerApi.unregister(o.progressHandler);
});
}
} else if (state.state == "STARTED" || state.state == "NONE") {
}
}
};
cd.find(".btnStart").click(function(){
cd.find(".btnStart").hide();
cd.find(".uploadStatus").html("Generating geometry...");
Global.bimServerApi.call("ServiceInterface", "regenerateGeometry", {roid: roids[0], eoid: engine.oid}, function(topicId){
cd.find(".startMessage").hide();
cd.find(".progressBarHolder .uploadProgressBar").remove();
cd.find(".progressBarHolder").append("<div class=\"uploadProgressBar progress\"><div class=\"progress-bar\"></div></div>");
Global.bimServerApi.registerProgressHandler(topicId, o.progressHandler);
});
});
}
</script>