mirror of
https://github.com/itsdave-de/msp.git
synced 2025-05-06 15:35:12 +02:00
copy credentials from it object
This commit is contained in:
parent
a685801e1c
commit
7c2ac84e22
@ -146,6 +146,12 @@ frappe.ui.form.on('IT Object', {
|
|||||||
if (frm.doc.monitoring_link) {
|
if (frm.doc.monitoring_link) {
|
||||||
frm.add_custom_button('Open Monitoring', () => frm.trigger('open_monitoring'), 'Actions');
|
frm.add_custom_button('Open Monitoring', () => frm.trigger('open_monitoring'), 'Actions');
|
||||||
};
|
};
|
||||||
|
if (frm.doc.link) {
|
||||||
|
frm.add_custom_button('Copy Main Admin Account User', () => frm.trigger('get_user'), 'Actions');
|
||||||
|
};
|
||||||
|
if (frm.doc.link) {
|
||||||
|
frm.add_custom_button('Copy Main Admin Account PW', () => frm.trigger('get_pw'), 'Actions');
|
||||||
|
};
|
||||||
},
|
},
|
||||||
open_admin_interface: function (frm) {
|
open_admin_interface: function (frm) {
|
||||||
window.open(frm.doc.admin_interface_link, '_blank').focus();
|
window.open(frm.doc.admin_interface_link, '_blank').focus();
|
||||||
@ -153,5 +159,33 @@ frappe.ui.form.on('IT Object', {
|
|||||||
open_monitoring: function (frm) {
|
open_monitoring: function (frm) {
|
||||||
window.open(frm.doc.monitoring_link, '_blank').focus();
|
window.open(frm.doc.monitoring_link, '_blank').focus();
|
||||||
},
|
},
|
||||||
|
get_pw: function(frm) {
|
||||||
|
frm.call('copy_pw', {
|
||||||
|
'user_agent': navigator.userAgent,
|
||||||
|
'platform': navigator.platform,
|
||||||
|
},
|
||||||
|
(r) => {
|
||||||
|
frm.events.CopyToClipboard(r.message)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
get_user: function(frm) {
|
||||||
|
frm.call('copy_user', {
|
||||||
|
'user_agent': navigator.userAgent,
|
||||||
|
'platform': navigator.platform,
|
||||||
|
},
|
||||||
|
(r) => {
|
||||||
|
frm.events.CopyToClipboard(r.message)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
CopyToClipboard: function(value) {
|
||||||
|
var tempInput = document.createElement("input");
|
||||||
|
tempInput.value = value;
|
||||||
|
document.body.appendChild(tempInput);
|
||||||
|
tempInput.select();
|
||||||
|
document.execCommand("copy");
|
||||||
|
document.body.removeChild(tempInput);
|
||||||
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -11,6 +11,18 @@ class ITObject(Document):
|
|||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
self.set_it_object_data_in_ip_address_doctype()
|
self.set_it_object_data_in_ip_address_doctype()
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def copy_pw(self, user_agent, platform):
|
||||||
|
if self.link:
|
||||||
|
account_doc = frappe.get_doc("IT User Account", self.link)
|
||||||
|
return(account_doc.get_password("password"))
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def copy_user(self, user_agent, platform):
|
||||||
|
if self.link:
|
||||||
|
account_doc = frappe.get_doc("IT User Account", self.link)
|
||||||
|
return(account_doc.username)
|
||||||
|
|
||||||
def set_it_object_data_in_ip_address_doctype(self):
|
def set_it_object_data_in_ip_address_doctype(self):
|
||||||
if not self.main_ip:
|
if not self.main_ip:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user