1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 function run_pipeline_button_state() {
6 var a = $('a.editable.required.editable-empty,input.form-control.required[value=""]');
7 if ((a.length > 0) || ($('.unreadable-inputs-present').length)) {
8 $(".run-pipeline-button").addClass("disabled");
11 $(".run-pipeline-button").removeClass("disabled");
15 $(document).on('editable:success', function(event, tag, response, newValue) {
17 if ($('.run-pipeline-button').length == 0)
19 if ($tag.hasClass("required")) {
20 if (newValue && newValue.trim() != "") {
21 $tag.removeClass("editable-empty");
22 $tag.parent().css("background-color", "");
23 $tag.parent().prev().css("background-color", "");
26 $tag.addClass("editable-empty");
27 $tag.parent().css("background-color", "#ffdddd");
28 $tag.parent().prev().css("background-color", "#ffdddd");
31 if ($tag.attr('data-name')) {
32 // Update other inputs representing the same piece of data
33 $('.editable[data-name="' + $tag.attr('data-name') + '"]').
34 editable('setValue', newValue);
36 run_pipeline_button_state();
39 $(document).on('ready ajax:complete', function() {
40 $('a.editable.required').each(function() {
42 if ($tag.hasClass("editable-empty")) {
43 $tag.parent().css("background-color", "#ffdddd");
44 $tag.parent().prev().css("background-color", "#ffdddd");
47 $tag.parent().css("background-color", "");
48 $tag.parent().prev().css("background-color", "");
51 $('input.required').each(function() {
53 if ($tag.hasClass("unreadable-input")) {
54 $tag.parent().parent().css("background-color", "#ffdddd");
55 $tag.parent().parent().prev().css("background-color", "#ffdddd");
58 $tag.parent().parent().css("background-color", "");
59 $tag.parent().parent().prev().css("background-color", "");
62 run_pipeline_button_state();
65 $(document).on('arv-log-event', '.arv-refresh-on-state-change', function(event, eventData) {
66 if (this != event.target) {
67 // Not interested in events sent to child nodes.
70 if (eventData.event_type == "update" &&
71 eventData.properties.old_attributes.state != eventData.properties.new_attributes.state)
73 $(event.target).trigger('arv:pane:reload');
77 $(document).on('arv-log-event', '.arv-log-event-subscribe-to-pipeline-job-uuids', function(event, eventData){
78 if (this != event.target) {
79 // Not interested in events sent to child nodes.
82 if (!((eventData.object_kind == 'arvados#pipelineInstance') &&
83 (eventData.event_type == "create" ||
84 eventData.event_type == "update") &&
85 eventData.properties &&
86 eventData.properties.new_attributes &&
87 eventData.properties.new_attributes.components)) {
91 var components = eventData.properties.new_attributes.components;
92 for (a in components) {
93 if (components[a].job && components[a].job.uuid) {
94 objs += " " + components[a].job.uuid;
97 $(event.target).attr("data-object-uuids", eventData.object_uuid + objs);
100 $(document).on('ready ajax:success', function() {
101 $('.arv-log-refresh-control').each(function() {
102 var uuids = $(this).attr('data-object-uuids');
103 var $pane = $(this).closest('[data-pane-content-url]');
104 $pane.attr('data-object-uuids', uuids);
108 // Set up all events for the pipeline instances compare button.
110 var compare_form = '#compare';
111 var compare_inputs = '#comparedInstances :checkbox[name="uuids[]"]';
112 var update_button = function(event) {
113 var $form = $(compare_form);
114 var $checked_inputs = $(compare_inputs).filter(':checked');
115 $(':submit', $form).prop('disabled', (($checked_inputs.length < 2) ||
116 ($checked_inputs.length > 3)));
117 $('input[name="uuids[]"]', $form).remove();
118 $form.append($checked_inputs.clone()
119 .removeAttr('id').attr('type', 'hidden'));
122 .on('ready ajax:success', compare_form, update_button)
123 .on('change', compare_inputs, update_button);