-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from rhpds/acasanov-stage-scripts
feat: Execute stage scripts
- Loading branch information
Showing
4 changed files
with
218 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* Absolute Center Spinner */ | ||
.loading-wrapper { | ||
position: fixed; | ||
z-index: 999; | ||
height: 2em; | ||
width: 2em; | ||
overflow: show; | ||
margin: auto; | ||
top: 0; | ||
left: 0; | ||
bottom: 0; | ||
right: 0; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
background: radial-gradient(rgba(20, 20, 20,.9), rgba(0, 0, 0, .9)); | ||
background: -webkit-radial-gradient(rgba(20, 20, 20,.9), rgba(0, 0, 0,.9)); | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.loading-text { | ||
margin-top: 25px; | ||
color: #fff; | ||
} | ||
|
||
/* Transparent Overlay */ | ||
.loading:before { | ||
content: ''; | ||
display: block; | ||
} | ||
|
||
/* :not(:required) hides these rules from IE9 and below */ | ||
.loading:not(:required) { | ||
/* hide "loading..." text */ | ||
font: 0/0 a; | ||
color: transparent; | ||
text-shadow: none; | ||
background-color: transparent; | ||
border: 0; | ||
} | ||
|
||
.loading:not(:required):after { | ||
content: ''; | ||
display: block; | ||
font-size: 10px; | ||
width: 1em; | ||
height: 1em; | ||
margin-top: -0.5em; | ||
-webkit-animation: spinner 150ms infinite linear; | ||
-moz-animation: spinner 150ms infinite linear; | ||
-ms-animation: spinner 150ms infinite linear; | ||
-o-animation: spinner 150ms infinite linear; | ||
animation: spinner 150ms infinite linear; | ||
border-radius: 0.5em; | ||
-webkit-box-shadow: rgba(255,255,255, 0.75) 1.5em 0 0 0, rgba(255,255,255, 0.75) 1.1em 1.1em 0 0, rgba(255,255,255, 0.75) 0 1.5em 0 0, rgba(255,255,255, 0.75) -1.1em 1.1em 0 0, rgba(255,255,255, 0.75) -1.5em 0 0 0, rgba(255,255,255, 0.75) -1.1em -1.1em 0 0, rgba(255,255,255, 0.75) 0 -1.5em 0 0, rgba(255,255,255, 0.75) 1.1em -1.1em 0 0; | ||
box-shadow: rgba(255,255,255, 0.75) 1.5em 0 0 0, rgba(255,255,255, 0.75) 1.1em 1.1em 0 0, rgba(255,255,255, 0.75) 0 1.5em 0 0, rgba(255,255,255, 0.75) -1.1em 1.1em 0 0, rgba(255,255,255, 0.75) -1.5em 0 0 0, rgba(255,255,255, 0.75) -1.1em -1.1em 0 0, rgba(255,255,255, 0.75) 0 -1.5em 0 0, rgba(255,255,255, 0.75) 1.1em -1.1em 0 0; | ||
} | ||
|
||
/* Animation */ | ||
|
||
@-webkit-keyframes spinner { | ||
0% { | ||
-webkit-transform: rotate(0deg); | ||
-moz-transform: rotate(0deg); | ||
-ms-transform: rotate(0deg); | ||
-o-transform: rotate(0deg); | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
-webkit-transform: rotate(360deg); | ||
-moz-transform: rotate(360deg); | ||
-ms-transform: rotate(360deg); | ||
-o-transform: rotate(360deg); | ||
transform: rotate(360deg); | ||
} | ||
} | ||
@-moz-keyframes spinner { | ||
0% { | ||
-webkit-transform: rotate(0deg); | ||
-moz-transform: rotate(0deg); | ||
-ms-transform: rotate(0deg); | ||
-o-transform: rotate(0deg); | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
-webkit-transform: rotate(360deg); | ||
-moz-transform: rotate(360deg); | ||
-ms-transform: rotate(360deg); | ||
-o-transform: rotate(360deg); | ||
transform: rotate(360deg); | ||
} | ||
} | ||
@-o-keyframes spinner { | ||
0% { | ||
-webkit-transform: rotate(0deg); | ||
-moz-transform: rotate(0deg); | ||
-ms-transform: rotate(0deg); | ||
-o-transform: rotate(0deg); | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
-webkit-transform: rotate(360deg); | ||
-moz-transform: rotate(360deg); | ||
-ms-transform: rotate(360deg); | ||
-o-transform: rotate(360deg); | ||
transform: rotate(360deg); | ||
} | ||
} | ||
@keyframes spinner { | ||
0% { | ||
-webkit-transform: rotate(0deg); | ||
-moz-transform: rotate(0deg); | ||
-ms-transform: rotate(0deg); | ||
-o-transform: rotate(0deg); | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
-webkit-transform: rotate(360deg); | ||
-moz-transform: rotate(360deg); | ||
-ms-transform: rotate(360deg); | ||
-o-transform: rotate(360deg); | ||
transform: rotate(360deg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from "react"; | ||
|
||
import './loading.css'; | ||
|
||
export default function({text, isVisible}:{text: string, isVisible: boolean}) { | ||
if (!isVisible) { | ||
return null; | ||
} | ||
|
||
return <div className="loading-wrapper"> | ||
<div className="loading" /> | ||
<div className="loading-text"> | ||
{text} | ||
</div> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
export async function getJobStatus(jobId: string): Promise<({'Status': 'successful' | 'error', 'Output'?: string})> { | ||
async function jobStatusFn() { | ||
await new Promise(resolve => setTimeout(resolve, 1000)); | ||
return getJobStatus(jobId); | ||
} | ||
const response = await fetch(`/runner/api/job/${jobId}`); | ||
const data = await response.json(); | ||
const status = data['Status']; | ||
|
||
if (status) { | ||
if (status === 'scheduled' || status === 'running') { | ||
return await jobStatusFn(); | ||
} else { | ||
return data; | ||
} | ||
} | ||
return { | ||
'Status': 'error' | ||
} | ||
} | ||
|
||
export async function executeStage(moduleName: string, stage: 'setup' | 'validation' | 'solve') { | ||
const response = await fetch(`/runner/api/${moduleName}/${stage}`, {method: 'POST'}); | ||
const data = await response.json(); | ||
return data['Job_id'] ?? null; | ||
} | ||
|
||
export async function executeStageAndGetStatus(moduleName: string, stage: 'setup' | 'validation' | 'solve') { | ||
const jobId = await executeStage(moduleName, stage); | ||
if (jobId) { | ||
return await getJobStatus(jobId); | ||
} | ||
return Promise.resolve({Status: 'successful', Output: 'Script not found'}); | ||
} |