mirror of
https://github.com/itsdave-de/msp_remoteadmin.git
synced 2025-05-06 20:35:12 +02:00
add modal before connection
This commit is contained in:
parent
bc56f76743
commit
508c47547e
@ -1,30 +1,97 @@
|
|||||||
frappe.ui.form.on('IT Object', {
|
frappe.ui.form.on('IT Object', {
|
||||||
refresh: function (frm) {
|
refresh: function (frm) {
|
||||||
if (frm.doc.link) {
|
if (frm.doc.link) {
|
||||||
frm.add_custom_button(__('RDP'), function () {
|
frm.add_custom_button(__('Connect'), function () {
|
||||||
connect_remote(frm, 'RDP');
|
open_modal(frm);
|
||||||
}, __("Connect"));
|
});
|
||||||
|
|
||||||
frm.add_custom_button(__('SSH'), function () {
|
|
||||||
connect_remote(frm, 'SSH');
|
|
||||||
}, __("Connect"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function connect_remote(frm, type) {
|
function open_modal(frm) {
|
||||||
frappe.call({
|
// Protocol options
|
||||||
method: "msp_remoteadmin.tools.create_session",
|
const protocol_options = [
|
||||||
args: {
|
{ label: __('RDP'), value: 'RDP' },
|
||||||
name: frm.doc.name,
|
{ label: __('SSH'), value: 'SSH' }
|
||||||
protocol: type
|
];
|
||||||
},
|
// Resolutions options
|
||||||
callback: function (r) {
|
const resolution_options = [
|
||||||
if (r.message) {
|
{ label: __('800x600'), value: '800x600' },
|
||||||
var url = r.message;
|
{ label: __('1024x768'), value: '1024x768' },
|
||||||
window.open(url, 'GuacamoleConsole', 'width=1024,height=768');
|
{ label: __('1280x1024'), value: '1280x1024' },
|
||||||
|
{ label: __('1440x900'), value: '1440x900' },
|
||||||
|
{ label: __('1920x1080'), value: '1920x1080' }
|
||||||
|
];
|
||||||
|
// Keyboard options
|
||||||
|
const keyboard_options = [
|
||||||
|
{ label: __('Brazilian (Portuguese)'), value: 'pt-br-qwerty' },
|
||||||
|
{ label: __('English (UK)'), value: 'en-gb-qwerty' },
|
||||||
|
{ label: __('English (US)'), value: 'en-us-qwerty' },
|
||||||
|
{ label: __('French'), value: 'fr-fr-azerty' },
|
||||||
|
{ label: __('French (Belgian)'), value: 'fr-be-azerty' },
|
||||||
|
{ label: __('French (Swiss)'), value: 'fr-ch-qwertz' },
|
||||||
|
{ label: __('German'), value: 'de-de-qwertz' },
|
||||||
|
{ label: __('German (Swiss)'), value: 'de-ch-qwertz' },
|
||||||
|
{ label: __('Hungarian'), value: 'hu-hu-qwertz' },
|
||||||
|
{ label: __('Italian'), value: 'it-it-qwerty' },
|
||||||
|
{ label: __('Japanese'), value: 'ja-jp-qwerty' },
|
||||||
|
{ label: __('Norwegian'), value: 'no-no-qwerty' },
|
||||||
|
{ label: __('Spanish'), value: 'es-es-qwerty' },
|
||||||
|
{ label: __('Spanish (Latin American)'), value: 'es-latam-qwerty' },
|
||||||
|
{ label: __('Swedish'), value: 'sv-se-qwerty' },
|
||||||
|
{ label: __('Turkish-Q'), value: 'tr-tr-qwerty' }
|
||||||
|
];
|
||||||
|
|
||||||
|
const dialog = new frappe.ui.Dialog({
|
||||||
|
title: __('Connect to Remote'),
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
label: __('Protocol'),
|
||||||
|
fieldtype: 'Select',
|
||||||
|
fieldname: 'protocol',
|
||||||
|
options: protocol_options.map(option => option.label)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __('Port'),
|
||||||
|
fieldtype: 'Int',
|
||||||
|
fieldname: 'port'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __('Resolution'),
|
||||||
|
fieldtype: 'Select',
|
||||||
|
fieldname: 'resolution',
|
||||||
|
options: resolution_options.map(option => option.label)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __('Keyboard Layout'),
|
||||||
|
fieldtype: 'Select',
|
||||||
|
fieldname: 'keyboard',
|
||||||
|
options: keyboard_options.map(option => option.label)
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
primary_action_label: __('Connect'),
|
||||||
|
primary_action: () => {
|
||||||
|
const values = dialog.get_values();
|
||||||
|
if (!values) return;
|
||||||
|
frappe.call({
|
||||||
|
method: 'msp_remoteadmin.tools.create_session',
|
||||||
|
args: {
|
||||||
|
name: frm.doc.name,
|
||||||
|
protocol: values.protocol,
|
||||||
|
port: values.port,
|
||||||
|
resolution: values.resolution,
|
||||||
|
keyboard: values.keyboard
|
||||||
|
},
|
||||||
|
callback: r => {
|
||||||
|
if (r.message) {
|
||||||
|
const url = r.message;
|
||||||
|
var resolution = values.resolution.split('x');
|
||||||
|
window.open(url, 'GuacamoleConsole', 'width=' + resolution[0] + ',height=' + resolution[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.hide();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user