Skip to content

Commit a3cee9c

Browse files
committed
Merge branch 'master' into nwchem-neb
2 parents e8c898c + c24db28 commit a3cee9c

32 files changed

Lines changed: 433 additions & 263 deletions

File tree

dist/simput-pyfr.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"babel-polyfill": "6.9.1",
5656
"paraviewweb": "2.0.5",
5757
"pvw-visualizer": "2.0.6",
58-
"simput": "1.2.8",
58+
"simput": "1.3.4",
5959
"candela": "0.6.2",
6060

6161
"kw-web-suite": "2.0.0"

src/network/helpers/simulations.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,32 @@ function createItemForSimulation(simulation, name, file) {
2424
});
2525
}
2626

27+
export function addFileForSimulationWithContents(simulation, name, contents) {
28+
let fileId;
29+
return girder.createItem(simulation.metadata.inputFolder._id, name)
30+
.then(resp => {
31+
const parentId = resp.data._id;
32+
return girder.newFile({
33+
parentType: 'item',
34+
parentId,
35+
name,
36+
size: 0,
37+
});
38+
})
39+
.then(resp => {
40+
fileId = resp.data._id;
41+
const blob = new Blob([contents], { type: 'text/plain' });
42+
return girder.updateFileContent(resp.data._id, contents.length)
43+
.then(upload => {
44+
girder.uploadChunk(fileId, 0, blob);
45+
});
46+
})
47+
.then(resp => ({ _id: fileId }))
48+
.catch(err => {
49+
console.log('Error adding ini content', err);
50+
});
51+
}
52+
2753
export function addEmptyFileForSimulation(simulation, name) {
2854
return girder.createItem(simulation.metadata.inputFolder._id, name)
2955
.then(resp => {

src/network/remote/file.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ export default function ({ client, filterQuery, mustContain, busy, encodeQueryAs
103103

104104
uploadFileToItem,
105105

106+
getFile(id) {
107+
return busy(client._.get(`/file/${id}`));
108+
},
109+
106110
getUploadOffset(id) {
107111
return busy(client._.get('/file/offset', { params: { uploadId: id } }));
108112
},
@@ -133,6 +137,10 @@ export default function ({ client, filterQuery, mustContain, busy, encodeQueryAs
133137
return missingKeys ? promise : busy(client._.put(`/file/${file._id}${encodeQueryAsString(params)}`));
134138
},
135139

140+
copyFile(fileId, itemId) {
141+
return busy(client._.post(`/file/${fileId}/copy?itemId=${itemId}`));
142+
},
143+
136144
newFile(file) {
137145
const expected = ['parentType', 'parentId', 'name', 'size', 'mimeType', 'linkUrl'],
138146
params = filterQuery(file, ...expected),

src/pages/Project/Edit/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ const ProjectEdit = React.createClass({
5151
}
5252

5353
const childComponent = project.type ? Workflows[project.type].components.EditProject : null;
54-
const workflowAddOn = childComponent ? React.createElement(childComponent, { owner: () => this.refs.container }) : null;
54+
const workflowAddOn = childComponent ? React.createElement(childComponent, { owner: () => this.refs.container,
55+
parentProps: this.props }) : null;
5556

5657
return (
5758
<ItemEditor
@@ -65,7 +66,9 @@ const ProjectEdit = React.createClass({
6566
{ name: 'delete', label: 'Delete project' },
6667
{ name: 'editProject', label: 'Save project' }]}
6768
onAction={ this.onAction }
68-
>{ workflowAddOn }</ItemEditor>);
69+
>
70+
{ workflowAddOn }
71+
</ItemEditor>);
6972
},
7073
});
7174

src/pages/Project/New/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ const ProjectNew = React.createClass({
9090

9191
render() {
9292
const childComponent = this.state.type ? Workflows[this.state.type].components.NewProject : null;
93-
const workflowAddOn = childComponent ? React.createElement(childComponent, { owner: () => this.refs.container }) : null;
93+
const workflowAddOn = childComponent ? React.createElement(childComponent, { owner: () => this.refs.container,
94+
parentProps: this.props }) : null;
95+
9496
return (
9597
<ItemEditor
9698
error={ this.state._error || this.props.error }

src/pages/Simulation/Edit/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ const SimulationEdit = React.createClass({
5353
const { simulation, project, error } = this.props;
5454
const projectId = simulation.projectId;
5555
const childComponent = project.type ? Workflows[project.type].components.EditSimulation : null;
56-
const workflowAddOn = childComponent ? React.createElement(childComponent, { owner: () => this.refs.container }) : null;
56+
const workflowAddOn = childComponent ? React.createElement(childComponent, { owner: () => this.refs.container,
57+
parentProps: this.props }) : null;
5758

5859
return (
5960
<ItemEditor

src/pages/Simulation/New/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ const SimulationNew = React.createClass({
8383

8484
const type = this.props.project.type;
8585
const childComponent = type ? Workflows[type].components.NewSimulation : null;
86-
const workflowAddOn = childComponent ? React.createElement(childComponent, { owner: () => this.refs.container }) : null;
86+
const workflowAddOn = childComponent ? React.createElement(childComponent, { owner: () => this.refs.container,
87+
parentProps: this.props }) : null;
88+
8789
return (
8890
<ItemEditor
8991
breadcrumb={{

src/panels/ItemEditor/index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ const FileUploadEntry = React.createClass({
5858
Object.keys(metadata).forEach(key => {
5959
this.props.owner().addMetadata(key, metadata[key]);
6060
});
61+
})
62+
.catch(err => {
63+
this.refs.input.value = '';
6164
});
6265
}
6366
},
@@ -67,6 +70,7 @@ const FileUploadEntry = React.createClass({
6770
<div className={style.group}>
6871
<label className={style.label}>{this.props.label}</label>
6972
<input
73+
ref="input"
7074
className={style.input}
7175
data-name={this.props.name}
7276
accept={this.props.accept}
@@ -155,6 +159,10 @@ export default React.createClass({
155159
};
156160
},
157161

162+
componentDidMount() {
163+
this.attachment = {};
164+
},
165+
158166
onAction(action) {
159167
if (this.props.onAction) {
160168
this.props.onAction(action, this.state, this.attachment);
@@ -177,7 +185,17 @@ export default React.createClass({
177185
this.attachment = {};
178186
},
179187

180-
removeMetadata() {
188+
removeMetadata(key = null) {
189+
if (key) {
190+
const metadata = Object.assign({}, this.state.metadata || {});
191+
delete metadata[key];
192+
if (this.attachment[key]) {
193+
delete this.attachment[key];
194+
}
195+
this.setState({ metadata });
196+
return;
197+
}
198+
181199
const metadata = Object.assign({}, this.state.metadata || {});
182200
if (this.attachment) {
183201
Object.keys(this.attachment).forEach((el) => {

src/tools/visualizer/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const visualizer = React.createClass({
110110
this.props.setTimeStep(timeStep);
111111
},
112112

113+
/* eslint-disable react/jsx-no-bind */
113114
render() {
114115
if (!this.session) {
115116
return <LoadingPanel large center />;

0 commit comments

Comments
 (0)