-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathworkflow.js
More file actions
181 lines (163 loc) · 7.9 KB
/
Copy pathworkflow.js
File metadata and controls
181 lines (163 loc) · 7.9 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// Initialize when the DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
// DOM elements
const workflowBtn = document.getElementById('workflow-btn');
const workflowSection = document.getElementById('workflow-section');
const closeWorkflowBtn = document.getElementById('close-workflow-btn');
const backToGalleryBtn = document.getElementById('back-to-gallery-btn');
const backToComparisonBtn = document.getElementById('back-to-comparison-btn');
const backToWorkflowInfoBtn = document.getElementById('back-to-workflow-info-btn');
const backToToolsTableBtn = document.getElementById('back-to-tools-table-btn');
const pipelineSelect = document.getElementById('pipeline-select');
const workflowDisplay = document.getElementById('workflow-display');
if (!workflowBtn || !workflowSection || !closeWorkflowBtn || !backToGalleryBtn ||
!backToComparisonBtn || !backToWorkflowInfoBtn || !backToToolsTableBtn || !pipelineSelect || !workflowDisplay) {
console.error('Required workflow elements not found');
return;
}
// Initialize the workflow section
function initWorkflowSection() {
// Populate the pipeline select dropdown (alphabetically by name)
const sortedOptions = [...preLoadedObjects].sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: 'base' }));
sortedOptions.forEach(pipeline => {
const option = document.createElement('option');
option.value = pipeline.id;
option.textContent = pipeline.name;
pipelineSelect.appendChild(option);
});
// Add event listeners
workflowBtn.addEventListener('click', showWorkflowSection);
closeWorkflowBtn.addEventListener('click', hideWorkflowSection);
pipelineSelect.addEventListener('change', handlePipelineSelection);
// Back to Gallery button
backToGalleryBtn.addEventListener('click', function(e) {
e.preventDefault();
hideWorkflowSection();
if (typeof window.showGallery === 'function') {
window.showGallery();
} else {
console.error('showGallery function not found');
}
});
// Back to Comparison button
backToComparisonBtn.addEventListener('click', function(e) {
e.preventDefault();
hideWorkflowSection();
// Ensure other sections are hidden
document.getElementById('selector-page-section').style.display = 'none';
document.getElementById('tools-table-section').style.display = 'none';
if (typeof window.showTable === 'function') {
window.showTable();
} else {
console.error('showTable function not found');
}
});
// Back to Tools Selector page button
backToWorkflowInfoBtn.addEventListener('click', function(e) {
e.preventDefault();
hideWorkflowSection();
const selectorSection = document.getElementById('selector-page-section');
const selectorBtn = document.getElementById('selector-page-btn');
if (selectorSection) {
const mount = document.getElementById('selector-page-mount');
if (mount && mount.innerHTML.trim() === '' && selectorBtn) {
// Trigger the existing loader to render the selector
selectorBtn.click();
} else {
selectorSection.style.display = 'block';
document.body.style.overflow = 'hidden';
}
}
});
// Back to Tools Table button
backToToolsTableBtn.addEventListener('click', function(e) {
e.preventDefault();
hideWorkflowSection();
// Ensure other sections are hidden
document.getElementById('selector-page-section').style.display = 'none';
document.getElementById('table-section').style.display = 'none';
if (typeof window.showToolsTable === 'function') {
window.showToolsTable();
} else {
console.error('showToolsTable function not found');
}
});
// Prevent event propagation to avoid triggering other sections
workflowSection.addEventListener('click', (e) => {
e.stopPropagation();
});
}
// Show workflow section
function showWorkflowSection(e) {
e.preventDefault();
e.stopPropagation();
workflowSection.style.display = 'block';
document.body.style.overflow = 'hidden';
// Hide other sections if they're visible
document.getElementById('gallery-section').style.display = 'none';
document.getElementById('table-section').style.display = 'none';
document.getElementById('workflow-info-section').style.display = 'none';
}
// Hide workflow section
function hideWorkflowSection(e) {
if (e) {
e.preventDefault();
e.stopPropagation();
}
workflowSection.style.display = 'none';
document.body.style.overflow = 'auto';
// Clear the workflow display
workflowDisplay.innerHTML = '';
// Reset the select dropdown
pipelineSelect.value = '';
// Ensure other sections are also hidden to prevent interference
document.getElementById('gallery-section').style.display = 'none';
document.getElementById('table-section').style.display = 'none';
document.getElementById('workflow-info-section').style.display = 'none';
document.getElementById('selector-page-section').style.display = 'none';
document.getElementById('tools-table-section').style.display = 'none';
}
// Handle pipeline selection
function handlePipelineSelection(event) {
const selectedPipelineId = event.target.value;
if (!selectedPipelineId) {
workflowDisplay.innerHTML = '';
return;
}
// Find the selected pipeline object using ID
const pipeline = preLoadedObjects.find(p => p.id === selectedPipelineId);
if (!pipeline) return;
// Display the workflow
displayWorkflow(pipeline);
}
// Display the workflow for a pipeline
function displayWorkflow(pipeline) {
// Create the workflow content
const workflowContent = document.createElement('div');
workflowContent.className = 'workflow-content';
// Construct the workflow image path using pipeline ID
const workflowImagePath = `assets/${pipeline.id}.png`;
// Add pipeline name and description
workflowContent.innerHTML = `
<div class="workflow-header-content">
<h3>${pipeline.name}</h3>
<a href="${pipeline.url}" target="_blank" class="workflow-link">
<i class="fas fa-external-link-alt"></i>
Match me with ${pipeline.name}
</a>
</div>
<p class="pipeline-description">${pipeline.details}</p>
<div class="workflow-diagram">
<img src="${workflowImagePath}"
alt="${pipeline.name} workflow diagram"
class="workflow-image"
onerror="this.onerror=null; this.parentElement.innerHTML='<div class=\'no-workflow-message\'><p>No workflow diagram available for this pipeline.</p><p>Please check the pipeline\'s documentation for workflow information.</p></div>';">
</div>
`;
// Clear and update the workflow display
workflowDisplay.innerHTML = '';
workflowDisplay.appendChild(workflowContent);
}
// Initialize the workflow section
initWorkflowSection();
});