auditLogEntry.py (5725B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\structure\accessGroups\auditLogEntry.py 2 from carbon.common.script.util.format import FmtDate 3 from carbon.common.script.util.linkUtil import GetShowInfoLink 4 from carbonui.primitives.sprite import Sprite 5 from menu import MenuLabel 6 from eve.client.script.ui.control.eveLabel import EveLabelMedium 7 from localization import GetByLabel 8 from ownergroups.ownergroupConst import GROUP_NAME_CHANGED, GROUP_DESCRIPTION_CHANGED, GROUP_CREATED, GROUP_DELETED, PUBLIC_MEMBER_ID 9 from ownergroups.ownergroupsUIUtil import TEXTS_AND_ICONS_FOR_MEMBERC_CHANGES 10 from sovDashboard.sovStatusEntries import MouseInsideScrollEntry 11 import carbonui.const as uiconst 12 import blue 13 14 class AuditLogEntryBase(MouseInsideScrollEntry): 15 default_name = 'AuditLogEntry' 16 changeIconSize = 32 17 ENTRYHEIGHT = 36 18 19 def ApplyAttributes(self, attributes): 20 MouseInsideScrollEntry.ApplyAttributes(self, attributes) 21 self.node = attributes.node 22 self.ConstructUI() 23 24 def ConstructUI(self): 25 self.changeSprite = Sprite(name='changeSprite', parent=self, align=uiconst.CENTERLEFT, pos=(4, 0, 20, 20)) 26 labelLeft = self.changeSprite.left + self.changeSprite.width + 10 27 self.logLabel = EveLabelMedium(name='logLabel', parent=self, left=labelLeft, align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL) 28 29 def Load(self, node): 30 if node.selected: 31 self.Select() 32 else: 33 self.Deselect() 34 timeStamp = FmtDate(node.eventInfo.logDate) 35 text, texturePath = self.GetTextAndTextureForEvent(node.eventInfo) 36 self.logLabel.text = ' '.join([timeStamp, text]) 37 self.changeSprite.SetTexturePath(texturePath) 38 39 def OnClick(self, *args): 40 self.sr.node.scroll.SelectNode(self.sr.node) 41 42 def GetMenu(self): 43 return [] 44 45 @classmethod 46 def GetTextAndTextureForEvent(cls, eventInfo): 47 return ('', '') 48 49 @classmethod 50 def GetCopyData(cls, node): 51 timeStamp = FmtDate(node.eventInfo.logDate) 52 text, texturePath = cls.GetTextAndTextureForEvent(node.eventInfo) 53 eventText = node.eventInfo.newText or '' 54 return '<t>'.join([timeStamp, text, eventText]) 55 56 57 class AuditLogGroupChanges(AuditLogEntryBase): 58 59 def ApplyAttributes(self, attributes): 60 AuditLogEntryBase.ApplyAttributes(self, attributes) 61 62 @classmethod 63 def GetTextAndTextureForEvent(cls, eventInfo): 64 charText = GetLinkForCharacter(eventInfo.characterID) 65 if eventInfo.actionID == GROUP_CREATED: 66 return (GetByLabel('UI/Structures/LoggedChanges/GroupCreated', actorName=charText), 'res:/UI/Texture/classes/AccessGroups/groupCreated.png') 67 if eventInfo.actionID == GROUP_DELETED: 68 return (GetByLabel('UI/Structures/LoggedChanges/GroupDeleted', actorName=charText), '') 69 return ('', '') 70 71 72 class AuditLogChangedText(AuditLogEntryBase): 73 74 def ApplyAttributes(self, attributes): 75 AuditLogEntryBase.ApplyAttributes(self, attributes) 76 77 def Load(self, node): 78 AuditLogEntryBase.Load(self, node) 79 eventInfo = node.eventInfo 80 if eventInfo.actionID == GROUP_NAME_CHANGED: 81 labelPath = 'UI/Structures/LoggedChanges/DescriptionChangedHint' 82 elif eventInfo.actionID == GROUP_DESCRIPTION_CHANGED: 83 labelPath = 'UI/Structures/LoggedChanges/NameChangedHint' 84 else: 85 return 86 self.hint = GetByLabel(labelPath, oldText=eventInfo.oldText, newText=eventInfo.newText) 87 88 def GetMenu(self): 89 eventInfo = self.node.eventInfo 90 if eventInfo.actionID == GROUP_NAME_CHANGED: 91 labelPath = 'UI/Structures/LoggedChanges/CopyOldName' 92 elif eventInfo.actionID == GROUP_DESCRIPTION_CHANGED: 93 labelPath = 'UI/Structures/LoggedChanges/CopyOldDescription' 94 else: 95 return [] 96 m = [(MenuLabel(labelPath), self.CopyOldText, ())] 97 return m 98 99 def CopyOldText(self): 100 oldText = self.node.eventInfo.oldText 101 blue.pyos.SetClipboardData(oldText) 102 103 @classmethod 104 def GetTextAndTextureForEvent(cls, eventInfo): 105 charText = GetLinkForCharacter(eventInfo.characterID) 106 if eventInfo.actionID == GROUP_NAME_CHANGED: 107 labelText = GetByLabel('UI/Structures/LoggedChanges/GroupNameChanged', actorName=charText) 108 elif eventInfo.actionID == GROUP_DESCRIPTION_CHANGED: 109 labelText = GetByLabel('UI/Structures/LoggedChanges/GroupDescriptionChanged', actorName=charText) 110 else: 111 return ('', '') 112 texturePath = 'res:/UI/Texture/classes/AccessGroups/nameDescChanged.png' 113 return (labelText, texturePath) 114 115 116 class AuditLogMemberChanges(AuditLogEntryBase): 117 118 @classmethod 119 def GetTextAndTextureForEvent(cls, eventInfo): 120 keyTuple = (eventInfo.oldMembershipType, eventInfo.newMembershipType) 121 labelPath, iconPath = TEXTS_AND_ICONS_FOR_MEMBERC_CHANGES.get(keyTuple, (None, None)) 122 if labelPath is None: 123 return ('', '') 124 charText = GetLinkForCharacter(eventInfo.characterID) 125 if eventInfo.ownerID: 126 changedText = GetLinkForCharacter(eventInfo.ownerID) 127 elif eventInfo.ownerID == PUBLIC_MEMBER_ID: 128 changedText = "'%s'" % GetByLabel('UI/Structures/AccessGroups/PublicUser') 129 else: 130 changedText = '' 131 labelText = GetByLabel(labelPath, actorName=charText, changedName=changedText) 132 return (labelText, iconPath) 133 134 135 def GetLinkForCharacter(charID): 136 charInfo = cfg.eveowners.Get(charID) 137 charText = GetShowInfoLink(charInfo.typeID, charInfo.name, itemID=charID) 138 return charText