1 function run_pipeline_button_state() {
2 var a = $('a.editable.required.editable-empty,input.form-control.required[value=""]');
3 if ((a.length > 0) || ($('.unreadable-inputs-present').length)) {
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 $('input.required').each(function() {
49 if ($tag.hasClass("unreadable-input")) {
50 $tag.parent().parent().css("background-color", "#ffdddd");
51 $tag.parent().parent().prev().css("background-color", "#ffdddd");
54 $tag.parent().parent().css("background-color", "");
55 $tag.parent().parent().prev().css("background-color", "");
58 run_pipeline_button_state();
61 $(document).on('arv-log-event', '.arv-refresh-on-state-change', function(event, eventData) {
62 if (this != event.target) {
63 // Not interested in events sent to child nodes.
66 if (eventData.event_type == "update" &&
67 eventData.properties.old_attributes.state != eventData.properties.new_attributes.state)
69 $(event.target).trigger('arv:pane:reload');
73 $(document).on('arv-log-event', '.arv-log-event-subscribe-to-pipeline-job-uuids', function(event, eventData){
74 if (this != event.target) {
75 // Not interested in events sent to child nodes.
78 if (!((eventData.object_kind == 'arvados#pipelineInstance') &&
79 (eventData.event_type == "create" ||
80 eventData.event_type == "update") &&
81 eventData.properties &&
82 eventData.properties.new_attributes &&
83 eventData.properties.new_attributes.components)) {
87 var components = eventData.properties.new_attributes.components;
88 for (a in components) {
89 if (components[a].job && components[a].job.uuid) {
90 objs += " " + components[a].job.uuid;
93 $(event.target).attr("data-object-uuids", eventData.object_uuid + objs);
96 $(document).on('ready ajax:success', function() {
97 $('.arv-log-refresh-control').each(function() {
98 var uuids = $(this).attr('data-object-uuids');
99 var $pane = $(this).closest('[data-pane-content-url]');
100 $pane.attr('data-object-uuids', uuids);
104 $(document).on('arv-log-event', '.arv-log-event-handler-append-logs', function(event, eventData){
105 if (this != event.target) {
106 // Not interested in events sent to child nodes.
109 var wasatbottom = ($(this).scrollTop() + $(this).height() >= this.scrollHeight);
111 if (eventData.event_type == "stderr" || eventData.event_type == "stdout") {
112 if( eventData.prepend ) {
113 $(this).prepend(eventData.properties.text);
115 $(this).append(eventData.properties.text);
120 this.scrollTop = this.scrollHeight;
124 // Set up all events for the pipeline instances compare button.
126 var compare_form = '#compare';
127 var compare_inputs = '#comparedInstances :checkbox[name="uuids[]"]';
128 var update_button = function(event) {
129 var $form = $(compare_form);
130 var $checked_inputs = $(compare_inputs).filter(':checked');
131 $(':submit', $form).prop('disabled', (($checked_inputs.length < 2) ||
132 ($checked_inputs.length > 3)));
133 $('input[name="uuids[]"]', $form).remove();
134 $form.append($checked_inputs.clone()
135 .removeAttr('id').attr('type', 'hidden'));
138 .on('ready ajax:success', compare_form, update_button)
139 .on('change', compare_inputs, update_button);