Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_save = () => {
const { code, selectedProgramNumber } = this.state;
xhr.put(
getApiUrl(this.props.spaceName, `/programs/${selectedProgramNumber}`),
{
json: { code },
},
error => {
if (error) console.error(error); // eslint-disable-line no-console
}
);
};
function onSave (data) {
assert.equal(typeof data, 'object', 'enoki: data must be type object')
assert.equal(typeof data.file, 'string', 'enoki: data.file must be type string')
assert.equal(typeof data.pathPage, 'string', 'enoki: data.pathPage must be type string')
assert.equal(typeof data.page, 'object', 'enoki: data.file must be type object')
emitter.emit(state.events.PANEL_LOADING, { loading: true })
emitter.emit(state.events.RENDER)
xhr.put({
uri: '/api/v1/update',
body: data,
json: true
}, function (err, resp, body) {
emitter.emit(state.events.PANEL_LOADING, { loading: false })
emitter.emit(state.events.RENDER)
if (err) alert(err.message)
})
}
function onPageAdd (data) {
assert.equal(typeof data, 'object', 'enoki: data must be type object')
assert.equal(typeof data.pathPage, 'string', 'enoki: data.pathPage must be type string')
assert.equal(typeof data.title, 'string', 'enoki: data.title must be type string')
assert.equal(typeof data.view, 'string', 'enoki: data.view must be type string')
emitter.emit(state.events.PANEL_LOADING, { loading: true })
emitter.emit(state.events.RENDER)
xhr.put({
uri: '/api/v1/add',
body: data,
json: true
}, function (err, resp, body) {
emitter.emit(state.events.PANEL_LOADING, { loading: false })
emitter.emit(state.events.RENDER)
if (err) return alert(err.message)
emitter.emit(state.events.REPLACESTATE, data.pathPage + '?panel=active')
})
}
function onRemove (data) {
assert.equal(typeof data, 'object', 'enoki: data must be type object')
assert.equal(typeof data.pathPage, 'string', 'enoki: data.pathPage must be type string')
if (data.confirm) {
if (!window.confirm(`Are you sure you want to delete ${data.title || data.pathPage}?`)) {
return
}
}
emitter.emit(state.events.PANEL_LOADING, { loading: true })
emitter.emit(state.events.RENDER)
xhr.put({
uri: '/api/v1/remove',
body: data,
json: true
}, function (err, resp, body) {
emitter.emit(state.events.PANEL_LOADING, { loading: false })
emitter.emit(state.events.RENDER)
if (err) return alert(err.message)
if (data.redirect !== false) {
emitter.emit(state.events.REPLACESTATE, path.join(data.pathPage, '../') + '?panel=active')
}
})
}
_updateDebugData = throttle(() => {
xhr.put(this._program().debugUrl, { json: this.state.debugData }, () => {});
}, 300);
function UsersChangePassword(name, password, callback) {
let bodyStr = JSON.stringify({ password: password })
xhr.put("user/" + encodeURIComponent(name) + "/password", withAuth({ body: bodyStr }), handler(callback))
}
function KVPut(path, value, callback) {
let bodyStr = JSON.stringify({ value: value })
xhr.put("kv" + path, withAuth({ body: bodyStr }), handler(callback))
}
function UsersGrantRole(name, role, callback) {
xhr.put("user/" + encodeURIComponent(name) + "/role/" + encodeURIComponent(role), withAuth(), handler(callback))
}