added copy password to clipboard for IT User Account

added role IT User Account Manager
This commit is contained in:
root 2021-03-24 13:32:26 +01:00
parent 4f7b75dbe5
commit 5111280392
4 changed files with 48 additions and 8 deletions

View File

@ -98,7 +98,7 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Status",
"options": "in Production\nImplementation\nin Maintenance\nDecommissioned"
"options": "in Production\nImplementation\nin Maintenance\nfailed\nDecommissioned"
},
{
"fieldname": "link",
@ -120,7 +120,7 @@
}
],
"image_field": "image",
"modified": "2021-03-23 21:28:29.467402",
"modified": "2021-03-24 13:25:22.542341",
"modified_by": "Administrator",
"module": "MSP",
"name": "IT Object",

View File

@ -2,7 +2,32 @@
// For license information, please see license.txt
frappe.ui.form.on('IT User Account', {
// refresh: function(frm) {
refresh: function(frm) {
frm.add_custom_button('Copy PW', () => frm.trigger('get_pw'));
// }
},
get_pw: function(frm) {
frm.call('copy_pw', {
'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);
},
});

View File

@ -54,7 +54,7 @@
"label": "UPN"
}
],
"modified": "2021-03-24 00:27:17.507476",
"modified": "2021-03-24 13:31:10.543697",
"modified_by": "Administrator",
"module": "MSP",
"name": "IT User Account",
@ -68,7 +68,7 @@
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"role": "IT User Account Manager",
"share": 1,
"write": 1
}

View File

@ -3,8 +3,23 @@
# For license information, please see license.txt
from __future__ import unicode_literals
# import frappe
import frappe
from frappe.model.document import Document
class ITUserAccount(Document):
pass
@frappe.whitelist()
def copy_pw(self, user_agent, platform):
"""
pw_access_doc = frappe.get_doc({
"doctype": "User Account Password Access",
"access_datetime": frappe.utils.datetime.datetime.now(),
"user": frappe.session.user,
"ip": frappe.local.request_ip,
"method": "copy_pw",
"platform": platform,
"user_agent": user_agent})
self.append("access_history", pw_access_doc)
self.save()
"""
return(self.get_password("password"))