This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The init version of job submission. This version contains: most widgets for Job submission The features not finished: css styles Data widgets Call job submission api to finish to submit job
- Loading branch information
1 parent
de73f65
commit 9b2f3de
Showing
32 changed files
with
1,916 additions
and
355 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
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
94 changes: 94 additions & 0 deletions
94
src/webportal/src/plugins/job-submission/components/App.jsx
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,94 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation | ||
* All rights reserved. | ||
* | ||
* MIT License | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
import React from 'react'; | ||
import {Fabric, Stack, DefaultButton, PrimaryButton} from 'office-ui-fabric-react'; | ||
import {TabForm} from './TabForm'; | ||
import {initializeIcons} from '@uifabric/icons'; | ||
import {TabFormContent} from './TabFormContent'; | ||
import {JobTaskRole} from '../models/jobTaskRole'; | ||
import {JobInformation} from './JobInformation'; | ||
import {Parameter} from './Parameter'; | ||
import {getFormClassNames} from './formStyle'; | ||
import {initTheme} from '../../../app/components/theme'; | ||
|
||
initTheme(); | ||
initializeIcons(); | ||
|
||
export class App extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
const items = [{headerText: 'Task role 1', content: new JobTaskRole({})}]; | ||
this.state = { | ||
items: items, | ||
}; | ||
} | ||
|
||
_onRenderTabContent(keyName, content, defaultOnContentChange) { | ||
return ( | ||
<TabFormContent key={keyName} defaultValue={content} onContentChange={defaultOnContentChange}/> | ||
); | ||
} | ||
|
||
render() { | ||
const {items} = this.state; | ||
const formLayout = getFormClassNames().formLayout; | ||
const topForm = getFormClassNames().topForm; | ||
|
||
return ( | ||
<Fabric> | ||
<Stack className={formLayout}> | ||
<Stack horizontal gap='l2'> | ||
<Stack styles={{root: {width: '70%'}}} gap='l2'> | ||
<Stack className={topForm}> | ||
<JobInformation /> | ||
</Stack> | ||
<Stack className={topForm} gap='l1'> | ||
<Stack> | ||
<TabForm defaultItems={items} | ||
headerTextPrefix='Task Role' | ||
createContentFunc={() => new JobTaskRole({})} | ||
onRenderTabContent={this._onRenderTabContent.bind(this)} | ||
onItemsChange={(items)=>this.setState({items: items})}/> | ||
</Stack> | ||
<Stack horizontal gap='s1' horizontalAlign='center'> | ||
<PrimaryButton>Submit</PrimaryButton> | ||
<DefaultButton>Edit YAML</DefaultButton> | ||
<DefaultButton>Export</DefaultButton> | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
<Stack styles={{root: {width: '30%'}}}> | ||
<Stack className={topForm}> | ||
<Parameter/> | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
</Fabric> | ||
); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/webportal/src/plugins/job-submission/components/BasicSection.jsx
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,72 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation | ||
* All rights reserved. | ||
* | ||
* MIT License | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
import React, {useState} from 'react'; | ||
import {getId, Label, Stack, Text, Icon} from 'office-ui-fabric-react'; | ||
import {FormSection} from './FormPage'; | ||
import {getFormPageSytle, getFormBasicSectionStyle} from './formStyle'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const formPageStyle = getFormPageSytle(); | ||
|
||
export const BasicSection = (props) => { | ||
const {sectionLabel, sectionOptional, children} = props; | ||
const textFieldId = getId('textField'); | ||
const basicSectionStyle = getFormBasicSectionStyle(sectionOptional); | ||
|
||
const [isSectionOn, setSectionOn] = useState(false); | ||
const [iconName, setIconName] = useState('CaretSolidRight'); | ||
const onOpenItem = () => { | ||
if (isSectionOn) { | ||
setIconName('CaretSolidRight'); | ||
} else { | ||
setIconName('CaretDown8'); | ||
} | ||
setSectionOn(!isSectionOn); | ||
}; | ||
|
||
return ( | ||
<FormSection> | ||
<Stack styles={formPageStyle.formFirstColumn}> | ||
<Stack horizontal gap='s2'> | ||
<Icon iconName={iconName} styles={basicSectionStyle.icon} onClick={onOpenItem}/> | ||
<Label htmlFor={textFieldId} styles={basicSectionStyle.label}>{sectionLabel}</Label> | ||
{ sectionOptional && <Text styles={basicSectionStyle.optionalText}>Optional</Text>} | ||
</Stack> | ||
</Stack> | ||
<Stack styles={formPageStyle.formSecondColunm}> | ||
<Stack gap='m'> | ||
{(!sectionOptional || isSectionOn) && children} | ||
</Stack> | ||
</Stack> | ||
</FormSection> | ||
); | ||
}; | ||
|
||
BasicSection.propTypes = { | ||
sectionLabel: PropTypes.string.isRequired, | ||
children: PropTypes.node, | ||
sectionOptional: PropTypes.bool, | ||
}; |
66 changes: 66 additions & 0 deletions
66
src/webportal/src/plugins/job-submission/components/CompletionSection.jsx
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,66 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation | ||
* All rights reserved. | ||
* | ||
* MIT License | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
import React, {useState} from 'react'; | ||
import {Stack} from 'office-ui-fabric-react'; | ||
import PropTypes from 'prop-types'; | ||
import {BasicSection} from './BasicSection'; | ||
import {Completion} from '../models/completion'; | ||
import {CSpinButton} from './CustomizedComponents'; | ||
|
||
export const CompletionSection= (props) => { | ||
const {onChange, defaultValue} = props; | ||
const [value, setValue] = useState(defaultValue); | ||
const {minFailedInstances, minSuceedInstances} = value; | ||
|
||
const _onChange = (keyName, newValue) => { | ||
const completion = new Completion(value); | ||
completion[keyName] = newValue; | ||
if (onChange !== undefined) { | ||
onChange(completion); | ||
} | ||
setValue(completion); | ||
}; | ||
|
||
return ( | ||
<BasicSection sectionLabel={'Completion'} sectionOptional> | ||
<Stack horizontal gap='s1'> | ||
<CSpinButton label={'Min Failed Instances'} | ||
value={minFailedInstances} | ||
onChange={(v) => _onChange('minFailedInstances', v)}/> | ||
</Stack> | ||
<Stack horizontal gap='s1'> | ||
<CSpinButton label={'Min Succeed Instances'} | ||
value={minSuceedInstances} | ||
onChange={(v) => _onChange('minSuceedInstances', v)}/> | ||
</Stack> | ||
</BasicSection> | ||
); | ||
}; | ||
|
||
CompletionSection.propTypes = { | ||
defaultValue: PropTypes.instanceOf(Completion).isRequired, | ||
onChange: PropTypes.func, | ||
}; |
89 changes: 89 additions & 0 deletions
89
src/webportal/src/plugins/job-submission/components/ContainerSizeSection.jsx
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,89 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation | ||
* All rights reserved. | ||
* | ||
* MIT License | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
import React, {useState} from 'react'; | ||
import {getTheme, Toggle, Stack} from 'office-ui-fabric-react'; | ||
import PropTypes from 'prop-types'; | ||
import {BasicSection} from './BasicSection'; | ||
import {ContainerSize} from '../models/containerSize'; | ||
import {CSpinButton} from './CustomizedComponents'; | ||
|
||
const {spacing} = getTheme(); | ||
|
||
export const ContainerSizeSection = (props) => { | ||
const {defaultValue, onChange, isContainerSizeEnabled, onEnable} = props; | ||
const [value, setValue] = useState(defaultValue); | ||
const {cpu, memoryMB, gpu, shmMB} = value; | ||
|
||
const _onChange = (keyName, newValue) => { | ||
const containerSize = new ContainerSize(value); | ||
containerSize[keyName] = newValue; | ||
if (onChange !== undefined) { | ||
onChange(containerSize); | ||
} | ||
setValue(containerSize); | ||
}; | ||
|
||
const _onEnable = (_, checked) => { | ||
if (onEnable === undefined) { | ||
return; | ||
} | ||
onEnable(checked); | ||
}; | ||
|
||
return ( | ||
<BasicSection sectionLabel={'ContainerSize'}> | ||
<Stack horizontal> | ||
<CSpinButton label={'GPU count'} | ||
value={gpu} | ||
onChange={(value)=>_onChange('gpu', value)}/> | ||
<Toggle checked={isContainerSizeEnabled} | ||
label='Custom' | ||
inlineLabel={true} | ||
styles={{label: {order: -1, marginRight: spacing.s2}}} | ||
onChange={_onEnable}/> | ||
</Stack> | ||
<CSpinButton label={'CPU count'} | ||
disabled={!isContainerSizeEnabled} | ||
value={cpu} | ||
onChange={(value)=>_onChange('cpu', value)}/> | ||
<CSpinButton label={'Memory (MB)'} | ||
disabled={!isContainerSizeEnabled} | ||
value={memoryMB} | ||
onChange={(value)=>_onChange('memoryMB', value)}/> | ||
<CSpinButton label={'Shared memory (MB)'} | ||
value={shmMB} | ||
disabled={!isContainerSizeEnabled} | ||
onChange={(value)=>_onChange('shmMB', value)}/> | ||
</BasicSection> | ||
); | ||
}; | ||
|
||
ContainerSizeSection.propTypes = { | ||
defaultValue: PropTypes.instanceOf(ContainerSize).isRequired, | ||
onChange: PropTypes.func, | ||
isContainerSizeEnabled: PropTypes.bool, | ||
onEnable: PropTypes.func, | ||
}; |
Oops, something went wrong.