1 function run_pipeline_button_state() {
2 var a = $('a.editable.required.editable-empty,input.form-control.required[value=""]');
4 $(".run-pipeline-button").addClass("disabled");
7 $(".run-pipeline-button").removeClass("disabled");
11 $(document).on('editable:success', function(event, tag, response, newValue) {
13 if ($('.run-pipeline-button').length == 0)
15 if ($tag.hasClass("required")) {
16 if (newValue && newValue.trim() != "") {
17 $tag.removeClass("editable-empty");
18 $tag.parent().css("background-color", "");
19 $tag.parent().prev().css("background-color", "");
22 $tag.addClass("editable-empty");
23 $tag.parent().css("background-color", "#ffdddd");
24 $tag.parent().prev().css("background-color", "#ffdddd");
27 if ($tag.attr('data-name')) {
28 // Update other inputs representing the same piece of data
29 $('.editable[data-name="' + $tag.attr('data-name') + '"]').
30 editable('setValue', newValue);
32 run_pipeline_button_state();
35 $(document).on('ready ajax:complete', function() {
36 $('a.editable.required').each(function() {
38 if ($tag.hasClass("editable-empty")) {
39 $tag.parent().css("background-color", "#ffdddd");
40 $tag.parent().prev().css("background-color", "#ffdddd");
43 $tag.parent().css("background-color", "");
44 $tag.parent().prev().css("background-color", "");
47 run_pipeline_button_state();
50 $(document).on('arv-log-event', '.arv-refresh-on-state-change', function(event, eventData) {
51 if (this != event.target) {
52 // Not interested in events sent to child nodes.
55 if (eventData.event_type == "update" &&
56 eventData.properties.old_attributes.state != eventData.properties.new_attributes.state)
58 $(event.target).trigger('arv:pane:reload');
62 $(document).on('arv-log-event', '.arv-log-event-subscribe-to-pipeline-job-uuids', function(event, eventData){
63 if (this != event.target) {
64 // Not interested in events sent to child nodes.
67 if (!((eventData.object_kind == 'arvados#pipelineInstance') &&
68 (eventData.event_type == "create" ||
69 eventData.event_type == "update") &&
70 eventData.properties &&
71 eventData.properties.new_attributes &&
72 eventData.properties.new_attributes.components)) {
76 var components = eventData.properties.new_attributes.components;
77 for (a in components) {
78 if (components[a].job && components[a].job.uuid) {
79 objs += " " + components[a].job.uuid;
82 $(event.target).attr("data-object-uuids", eventData.object_uuid + objs);
85 $(document).on('ready ajax:success', function() {
86 $('.arv-log-refresh-control').each(function() {
87 var uuids = $(this).attr('data-object-uuids');
88 var $pane = $(this).closest('[data-pane-content-url]');
89 $pane.attr('data-object-uuids', uuids);
93 $(document).on('arv-log-event', '.arv-log-event-handler-append-logs', function(event, eventData){
94 if (this != event.target) {
95 // Not interested in events sent to child nodes.
98 var wasatbottom = ($(this).scrollTop() + $(this).height() >= this.scrollHeight);
100 if (eventData.event_type == "stderr" || eventData.event_type == "stdout") {
101 if( eventData.prepend ) {
102 $(this).prepend(eventData.properties.text);
104 $(this).append(eventData.properties.text);
109 this.scrollTop = this.scrollHeight;
113 // Set up all events for the pipeline instances compare button.
115 var compare_form = '#compare';
116 var compare_inputs = '#comparedInstances :checkbox[name="uuids[]"]';
117 var update_button = function(event) {
118 var $form = $(compare_form);
119 var $checked_inputs = $(compare_inputs).filter(':checked');
120 $(':submit', $form).prop('disabled', (($checked_inputs.length < 2) ||
121 ($checked_inputs.length > 3)));
122 $('input[name="uuids[]"]', $form).remove();
123 $form.append($checked_inputs.clone()
124 .removeAttr('id').attr('type', 'hidden'));
127 .on('ready ajax:success', compare_form, update_button)
128 .on('change', compare_inputs, update_button);