Skip to content

Commit

Permalink
Save action does not work (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
amelki committed Nov 19, 2017
1 parent f282c5b commit c0ae9fe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/actions.ts
Expand Up @@ -185,7 +185,7 @@ export const save = () => {
}
}
if (state.main.dataStale) {
promises.push(axios.post('data.json', getState().main.tree.data));
promises.push(axios.post('/data.json', getState().main.tree.data));
if (!state.main.schemaStale) {
beforeMessage = 'Saving data file';
afterMessage = 'Data file saved on disk';
Expand Down
2 changes: 1 addition & 1 deletion app/cms.ts
Expand Up @@ -500,7 +500,7 @@ export const modelToSchema = (model): RootSchemaElement => {
return Object.assign({} as RootSchemaElement, { $schema: schemaVersion }, root);
};
export const _modelToSchema = (model: Model): SchemaElement => {
const element: SchemaElement = {type: Type.TObject, properties: {}, patternProperties: {} };
const element: SchemaElement = {type: Type.TObject, properties: {} };
element.title = model.name;
if (model.type === NodeType.TYPE_TREE) {
const treeModel: TreeModel = model as TreeModel;
Expand Down
8 changes: 8 additions & 0 deletions index.js
Expand Up @@ -63,6 +63,14 @@ module.exports.run = function(options) {
res.send("OK");
});
});
app.post('/schema.json', function (req, res) {
var json = req.body;
fs.writeFile(modelFile, JSON.stringify(json, undefined, 2), function (err) {
if (err) console.log(err);
console.log("File " + modelFile + " saved");
res.send("OK");
});
});
}

if (isDeveloping) {
Expand Down

0 comments on commit c0ae9fe

Please sign in to comment.