@mongoosejs/studio
Advanced tools
Comparing version 0.0.22 to 0.0.23
'use strict'; | ||
exports.getDashboards = require('./getDashboards'); | ||
exports.getDashboard = require('./getDashboard'); | ||
exports.getDashboards = require('./getDashboards'); | ||
exports.updateDashboard = require('./updateDashboard'); |
@@ -12,6 +12,10 @@ 'use strict'; | ||
db.model('__Studio_Dashboard', dashboardSchema, '__studio_dashboards'); | ||
const Dashboard = db.model('__Studio_Dashboard', dashboardSchema, '__studio_dashboards'); | ||
const doc = new Dashboard({ | ||
name: 'Test', | ||
code: 'Test Code' | ||
}); | ||
doc.save().then(res => console.log(res)) | ||
const actions = applySpec(Actions, { db }); | ||
return actions; | ||
}; |
@@ -23,4 +23,10 @@ 'use strict'; | ||
exports.Dashboard = { | ||
getDashboard(params) { | ||
return client.post('', { action: 'Dashboard.getDashboard', ...params }).then(res => res.data); | ||
}, | ||
getDashboards(params) { | ||
return client.post('', { action: 'Dashboard.getDashboards', ...params }).then(res => res.data); | ||
}, | ||
updateDashboard(params) { | ||
return client.post('', { action: 'Dashboard.updateDashboard', ...params}).then(res => res.data); | ||
} | ||
@@ -56,5 +62,11 @@ } | ||
exports.Dashboard = { | ||
getDashboard: function getDashboard(params) { | ||
return client.get('/Dashboard/getDashboard', params).then(res => res.data); | ||
}, | ||
getDashboards: function getDashboards(params) { | ||
return client.get('/Dashboard/getDashboards', params).then(res => res.data); | ||
}, | ||
updateDashboard: function updateDashboard(params) { | ||
return client.post('/Dashboard/updateDashboard', params).then(res => res.data); | ||
} | ||
} | ||
@@ -61,0 +73,0 @@ exports.Model = { |
'use strict'; | ||
const api = require('../api'); | ||
const { EditorState } = require('@codemirror/state'); | ||
const { lineNumbers } = require('@codemirror/view') | ||
const { EditorView, basicSetup } = require('codemirror'); | ||
const { javascript } = require('@codemirror/lang-javascript'); | ||
@@ -29,3 +25,4 @@ const { BSON, EJSON } = require('bson'); | ||
documentData: '', | ||
editor: null | ||
editor: null, | ||
errors: [] | ||
} | ||
@@ -35,5 +32,10 @@ }, | ||
async createDocument() { | ||
const data = EJSON.serialize(eval(`(${this.documentData})`)); | ||
const data = EJSON.serialize(eval(`(${this.editor.getValue()})`)); | ||
const { doc } = await api.Model.createDocument({ model: this.currentModel, data }).catch(err => { | ||
if (err.response?.data?.message) { | ||
console.log(err.response.data); | ||
const message = err.response.data.message.split(": ").slice(1).join(": "); | ||
this.errors = message.split(',').map(error => { | ||
return error.split(': ').slice(1).join(': ').trim(); | ||
}) | ||
throw new Error(err.response?.data?.message); | ||
@@ -43,2 +45,3 @@ } | ||
}); | ||
this.errors.length = 0; | ||
this.$emit('close', doc); | ||
@@ -48,3 +51,2 @@ }, | ||
mounted: function() { | ||
console.log(this.currentModel, this.paths); | ||
const requiredPaths = this.paths.filter(x => x.required); | ||
@@ -57,24 +59,8 @@ this.documentData = `{\n`; | ||
this.documentData += '}'; | ||
this.editor = new EditorView({ | ||
state: EditorState.create({ | ||
doc: this.documentData, | ||
extensions: [ | ||
basicSetup, | ||
javascript(), | ||
// history(), | ||
EditorView.updateListener.of((v) => { | ||
// Your update logic here | ||
}), | ||
// keymap.of(historyKeymap) | ||
] | ||
}), | ||
parent: this.$refs.codeEditor | ||
this.$refs.codeEditor.value = this.documentData; | ||
this.editor = CodeMirror.fromTextArea(this.$refs.codeEditor, { | ||
mode: 'javascript', | ||
lineNumbers: true | ||
}); | ||
}, | ||
beforeDestroy() { | ||
if (this.editor) { | ||
this.editor.toTextArea(); | ||
} | ||
} | ||
}) |
@@ -6,18 +6,32 @@ 'use strict'; | ||
module.exports = app => app.component('dashboard', { | ||
template: template, | ||
data: () => ({ | ||
dashboards: [], | ||
dashboard: null | ||
}), | ||
async mounted() { | ||
const { dashboards } = await api.Dashboard.getDashboards(); | ||
this.dashboards = dashboards; | ||
if (!this.$route.query.dashboardId) { | ||
data: function() { | ||
return { | ||
status: 'loading', | ||
code: '', | ||
name: '', | ||
showEditor: false, | ||
dashboard: null | ||
} | ||
}, | ||
methods: { | ||
toggleEditor() { | ||
this.showEditor = !this.showEditor; | ||
}, | ||
async updateCode(update) { | ||
this.code = update; | ||
} | ||
}, | ||
mounted: async function() { | ||
const dashboardId = this.$route.query.dashboardId; | ||
const { dashboard } = await api.Dashboard.getDashboard({ params: { dashboardId: dashboardId } }); | ||
if (!dashboard) { | ||
return; | ||
} | ||
this.dashboard = dashboards.find(x => x._id.toString() == this.$route.query.dashboardId); | ||
this.dashboard = dashboard; | ||
this.name = this.dashboard.name; | ||
this.code = this.dashboard.code; | ||
this.status = 'loaded'; | ||
}, | ||
} | ||
}); |
@@ -20,2 +20,3 @@ 'use strict'; | ||
changes: {}, | ||
invalid: {}, | ||
editting: false, | ||
@@ -80,2 +81,5 @@ virtuals: [], | ||
async save() { | ||
if (Object.keys(this.invalid).length > 0) { | ||
throw new Error('Invalid paths: ' + Object.keys(this.invalid).join(', ')); | ||
} | ||
const { doc } = await api.Model.updateDocument({ | ||
@@ -82,0 +86,0 @@ model: this.model, |
@@ -5,2 +5,10 @@ 'use strict'; | ||
const { BSON, EJSON } = require('bson'); | ||
const ObjectId = new Proxy(BSON.ObjectId, { | ||
apply (target, thisArg, argumentsList) { | ||
return new target(...argumentsList); | ||
} | ||
}); | ||
const appendCSS = require('../appendCSS'); | ||
@@ -14,14 +22,24 @@ appendCSS(require('./edit-array.css')); | ||
mounted() { | ||
this.currentValue = this.value; | ||
this.currentValue = JSON.stringify(this.value, null, ' ').trim(); | ||
this.$refs.arrayEditor.value = this.currentValue; | ||
this.editor = CodeMirror.fromTextArea(this.$refs.arrayEditor, { | ||
mode: 'javascript', | ||
lineNumbers: true | ||
}); | ||
}, | ||
methods: { | ||
onUpdate() { | ||
this.$emit('input', this.currentValue); | ||
}, | ||
removeValue(i) { | ||
this.currentValue.splice(i, 1); | ||
this.$emit('input', this.currentValue); | ||
watch: { | ||
currentValue() { | ||
try { | ||
this.$emit('input', eval(this.currentValue)); | ||
} catch (err) { | ||
this.$emit('error', err); | ||
} | ||
} | ||
}, | ||
emits: ['input'] | ||
beforeDestroy() { | ||
if (this.editor) { | ||
this.editor.toTextArea(); | ||
} | ||
}, | ||
emits: ['input', 'error'] | ||
}); |
@@ -12,4 +12,5 @@ 'use strict'; | ||
require('./create-document/create-document')(app); | ||
require('./dashboards/dashboards')(app); | ||
require('./dashboard/dashboard')(app); | ||
require('./dashboard-details/dashboard-details')(app); | ||
require('./dashboard/edit-dashboard/edit-dashboard')(app) | ||
require('./detail-array/detail-array')(app); | ||
@@ -16,0 +17,0 @@ require('./detail-default/detail-default')(app); |
@@ -8,6 +8,2 @@ 'use strict'; | ||
const { EditorState } = require('@codemirror/state'); | ||
const { lineNumbers } = require('@codemirror/view') | ||
const { EditorView, basicSetup } = require('codemirror'); | ||
const { javascript } = require('@codemirror/lang-javascript'); | ||
@@ -14,0 +10,0 @@ |
@@ -27,4 +27,9 @@ 'use strict'; | ||
name: 'dashboards', | ||
component: 'dashboards' | ||
}, | ||
{ | ||
path: '/dashboard', | ||
name: 'dashboard', | ||
component: 'dashboard' | ||
} | ||
]; |
{ | ||
"name": "@mongoosejs/studio", | ||
"version": "0.0.22", | ||
"version": "0.0.23", | ||
"dependencies": { | ||
"@codemirror/commands": "^6.5.0", | ||
"@codemirror/lang-javascript": "^6.2.2", | ||
"@codemirror/state": "^6.4.1", | ||
"@codemirror/view": "^6.26.3", | ||
"archetype": "0.13.0", | ||
"codemirror": "^6.0.1", | ||
"csv-stringify": "6.3.0", | ||
@@ -12,0 +7,0 @@ "ejson": "^2.2.3", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9
710472
107
12422
8
- Removed@codemirror/commands@^6.5.0
- Removed@codemirror/lang-javascript@^6.2.2
- Removed@codemirror/state@^6.4.1
- Removed@codemirror/view@^6.26.3
- Removedcodemirror@^6.0.1
- Removed@codemirror/autocomplete@6.18.1(transitive)
- Removed@codemirror/commands@6.6.2(transitive)
- Removed@codemirror/lang-javascript@6.2.2(transitive)
- Removed@codemirror/language@6.10.3(transitive)
- Removed@codemirror/lint@6.8.2(transitive)
- Removed@codemirror/state@6.4.1(transitive)
- Removed@codemirror/view@6.34.1(transitive)
- Removed@lezer/common@1.2.1(transitive)
- Removed@lezer/highlight@1.2.1(transitive)
- Removed@lezer/javascript@1.4.18(transitive)
- Removed@lezer/lr@1.4.2(transitive)
- Removedcodemirror@6.65.7(transitive)
- Removedcrelt@1.0.6(transitive)
- Removedstyle-mod@4.1.2(transitive)
- Removedw3c-keyname@2.2.8(transitive)