-
Notifications
You must be signed in to change notification settings - Fork 112
/
work_unit_log.js
72 lines (67 loc) · 2.58 KB
/
work_unit_log.js
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
// Copyright (C) The Arvados Authors. All rights reserved.
//
// SPDX-License-Identifier: AGPL-3.0
$(document).on('arv-log-event', '.arv-log-event-handler-append-logs', function(event, eventData){
var wasatbottom, txt;
if (this != event.target) {
// Not interested in events sent to child nodes.
return;
}
if (!('properties' in eventData)) {
return;
}
txt = '';
if ('text' in eventData.properties &&
eventData.properties.text.length > 0) {
txt += eventData.properties.text;
if (txt.slice(txt.length-1) != "\n") {
txt += "\n";
}
}
if (eventData.event_type == 'update' &&
eventData.object_uuid.indexOf("-dz642-") == 5 &&
'old_attributes' in eventData.properties &&
'new_attributes' in eventData.properties) {
// Container update
if (eventData.properties.old_attributes.state != eventData.properties.new_attributes.state) {
var stamp = eventData.event_at + " ";
switch(eventData.properties.new_attributes.state) {
case "Queued":
txt += stamp + "Container "+eventData.object_uuid+" was returned to the queue\n";
break;
case "Locked":
txt += stamp + "Container "+eventData.object_uuid+" was taken from the queue by a dispatch process\n";
break;
case "Running":
txt += stamp + "Container "+eventData.object_uuid+" started\n";
break;
case "Complete":
var outcome = eventData.properties.new_attributes.exit_code === 0 ? "success" : "failure";
txt += stamp + "Container "+eventData.object_uuid+" finished with exit code " +
eventData.properties.new_attributes.exit_code +
" ("+outcome+")\n";
break;
case "Cancelled":
txt += stamp + "Container "+eventData.object_uuid+" was cancelled\n";
break;
default:
// Unknown state -- unexpected, might as well log it.
txt += stamp + "Container "+eventData.object_uuid+" changed state to " +
eventData.properties.new_attributes.state + "\n";
break;
}
}
}
if (txt == '') {
return;
}
wasatbottom = ($(this).scrollTop() + $(this).height() >= this.scrollHeight);
if (eventData.prepend) {
$(this).prepend(txt);
} else {
$(this).append(txt);
}
if (wasatbottom) {
this.scrollTop = this.scrollHeight;
}
});