You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
import { NamedPage } from 'vj/misc/PageLoader';
|
|
import Notification from 'vj/components/notification';
|
|
import { ActionDialog } from 'vj/components/dialog';
|
|
|
|
import request from 'vj/utils/request';
|
|
|
|
const page = new NamedPage('manage_script', () => {
|
|
const runScriptDialog = new ActionDialog({
|
|
$body: $('.dialog__body--run-script > div'),
|
|
onDispatch(action) {
|
|
const $args = runScriptDialog.$dom.find('[name="args"]');
|
|
if (action === 'ok' && $args.val() === '') {
|
|
$args.focus();
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
});
|
|
runScriptDialog.clear = function () {
|
|
this.$dom.find('[name="args"]').val('');
|
|
return this;
|
|
};
|
|
|
|
window.runScript = async function (id) {
|
|
const action = await runScriptDialog.clear().open();
|
|
if (action !== 'ok') return;
|
|
const args = runScriptDialog.$dom.find('[name="args"]').val();
|
|
try {
|
|
const res = await request.post('', {
|
|
args,
|
|
id,
|
|
});
|
|
window.location.href = res.url;
|
|
} catch (error) {
|
|
Notification.error(error.message);
|
|
}
|
|
};
|
|
});
|
|
|
|
export default page;
|