2756: trigger event for any elements that contain this log event's object_uuid in...
[arvados.git] / apps / workbench / app / assets / javascripts / pipeline_instances.js
1 (function() {
2     var run_pipeline_button_state = function() {
3         var a = $('a.editable.required.editable-empty');
4         if (a.length > 0) {
5             $("#run-pipeline-button").addClass("disabled");
6         }
7         else {
8             $("#run-pipeline-button").removeClass("disabled");
9         }
10     }
11
12     $.fn.editable.defaults.success = function (response, newValue) {
13         var tag = $(this);
14         if (tag.hasClass("required")) {
15             if (newValue && newValue.trim() != "") {
16                 tag.removeClass("editable-empty");
17                 tag.parent().css("background-color", "");
18                 tag.parent().prev().css("background-color", "");
19             }
20             else {
21                 tag.addClass("editable-empty");
22                 tag.parent().css("background-color", "#ffdddd");
23                 tag.parent().prev().css("background-color", "#ffdddd");
24             }
25         }
26         run_pipeline_button_state();
27     }
28
29     $(window).on('load', function() {
30         var a = $('a.editable.required');
31         for (var i = 0; i < a.length; i++) {
32             var tag = $(a[i]);
33             if (tag.hasClass("editable-empty")) {
34                 tag.parent().css("background-color", "#ffdddd");
35                 tag.parent().prev().css("background-color", "#ffdddd");
36             }
37             else {
38                 tag.parent().css("background-color", "");
39                 tag.parent().prev().css("background-color", "");
40             }
41         }
42         run_pipeline_button_state();
43     } );
44
45     $(document).on('ajax:complete ready', function() {
46       var a = $('.arv-log-event-listener');
47       if (a.length > 0) {
48         $('.arv-log-event-listener').each(function() {
49           subscribeToEventLog(this.id);
50         });
51       }
52     });
53
54     $(document).on('arv-log-event', '.arv-log-event-handler-append-logs', function(event, eventData){
55       parsedData = JSON.parse(eventData);
56       summary = parsedData.summary;
57       properties = parsedData.properties;
58       updatedProperties = null;
59       if (properties !== null) {
60         new_attributes = properties.new_attributes;
61         if (new_attributes !== null) {
62           updatedProperties = JSON.stringify(properties.new_attributes);
63         }
64       }
65
66       if (updatedProperties !== null) {
67         $(this).append(updatedProperties + "<br/><br/>");
68       } else {
69         $(this).append(summary + "<br/><br/>");
70       }
71     });
72
73 })();