password protected reset button
This commit is contained in:
@@ -111,5 +111,6 @@
|
||||
},
|
||||
"IOC": {
|
||||
"resultsTabTitle" : "IOC"
|
||||
}
|
||||
},
|
||||
"Reset": "HUSH!"
|
||||
}
|
||||
|
||||
2
hush.sh
2
hush.sh
@@ -58,7 +58,7 @@ echo "PYTHON_VERSION $PYTHON_VERSION"
|
||||
|
||||
#C_EXT version for Py 3.5, 3.7. 3.8, 3.10:
|
||||
|
||||
export PYTHONPATH=.:/opt/gfa/cafe/python/pycafe/cafe-1.21.0/lib/${_EPICS_HOST_ARCH}:/hipa/bd/applications/deps/apps4ops/v1.12.0
|
||||
export PYTHONPATH=.:/opt/gfa/cafe/python/pycafe/cafe-1.21.0/lib/${_EPICS_HOST_ARCH}:/hipa/bd/applications/deps/apps4ops/v1.13.0
|
||||
|
||||
echo $PYTHONPATH
|
||||
|
||||
|
||||
65
src/gui.py
65
src/gui.py
@@ -15,16 +15,15 @@ from qtpy.QtGui import QColor, QPixmap
|
||||
from qtpy.QtCore import __version__ as QT_VERSION_STR
|
||||
from qtpy.QtCore import QEventLoop, Qt, QTimer, Slot
|
||||
from qtpy.QtWidgets import (
|
||||
QApplication, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QMessageBox,
|
||||
QPushButton, QTabBar, QTabWidget, QTableWidgetItem, QTextEdit, QVBoxLayout,
|
||||
QWidget)
|
||||
QApplication, QGridLayout, QGroupBox, QHBoxLayout, QInputDialog, QLabel,
|
||||
QLineEdit, QMessageBox, QPushButton, QTabBar, QTabWidget, QTableWidgetItem,
|
||||
QTextEdit, QVBoxLayout, QWidget)
|
||||
|
||||
try:
|
||||
import elog
|
||||
except:
|
||||
from common.packages import elog
|
||||
|
||||
|
||||
from apps4ops.bdbase.utils import _line
|
||||
|
||||
from apps4ops.bdbase.enumkind import MsgSeverity
|
||||
@@ -32,6 +31,8 @@ from caqtwidgets.pvwidgets import (
|
||||
CAQLabel, CAQLineEdit, CAQMessageButton, CAQTableWidget, CAQTextEntry,
|
||||
QHLine)
|
||||
|
||||
from src.passwordedit import PasswordEdit
|
||||
|
||||
_pymodule = os.path.basename(__file__)
|
||||
|
||||
|
||||
@@ -155,7 +156,7 @@ class AppGui(QWidget):
|
||||
label.setFixedHeight(180)
|
||||
label.setPixmap(pixmap)
|
||||
label.setScaledContents(True)
|
||||
|
||||
|
||||
self.gui_frame.results_layout.addWidget(
|
||||
label, 0, 2, 1, 1, Qt.AlignLeft)
|
||||
self.gui_frame.results_layout.setContentsMargins(10, 40, 10, 10)
|
||||
@@ -1067,18 +1068,52 @@ class AppGui(QWidget):
|
||||
def clear_saving(self, sector_prefix_list: list = None):
|
||||
if not sector_prefix_list:
|
||||
return
|
||||
qm = QMessageBox()
|
||||
mess = ("This action will reset the energy saving account to zero. \n" +
|
||||
"This is typically undertaken at the end of the calendar " +
|
||||
"year. \n\n" +
|
||||
"Present accounting figures will be entered in the elogbook\n" +
|
||||
"Are you sure you wish to continue with the reset?")
|
||||
reply = qm.warning(self, "Reset Accounting", mess,
|
||||
QMessageBox.Yes | QMessageBox.No)
|
||||
|
||||
#qm = QMessageBox()
|
||||
#mess = ("This action will reset the energy saving account to zero. \n" +
|
||||
# "This is typically undertaken at the end of the calendar " +
|
||||
# "year. \n\n" +
|
||||
# "Present accounting figures will be entered in the elogbook\n" +
|
||||
# "Are you sure you wish to continue with the reset?")
|
||||
#reply = qm.warning(self, "Reset Accounting", mess,
|
||||
# QMessageBox.Yes | QMessageBox.No)
|
||||
|
||||
if reply == QMessageBox.No:
|
||||
#if reply == QMessageBox.No:
|
||||
# return
|
||||
|
||||
|
||||
#Now prompt for password
|
||||
mess = (#"This action will reset the energy\nsaving account to zero.\n" +
|
||||
#"This is typically undertaken at\nthe end of the calendar " +
|
||||
#"year.\n" +
|
||||
#"The current accounting figures\nwill be entered into elog\n " +
|
||||
"To execute the reset,\nplease enter the password:"
|
||||
)
|
||||
pwedit = QLineEdit()
|
||||
pwedit.setObjectName("Write")
|
||||
pwedit.setFixedWidth(40)
|
||||
pwedit.setFixedHeight(25)
|
||||
|
||||
|
||||
qd = QInputDialog()
|
||||
#qd.resize(500,100)
|
||||
#qd.setObjectName('Password')
|
||||
#qd.setWindowFlag(Qt.WindowType.WindowMinimizeButtonHint, False)
|
||||
|
||||
text, ok = qd.getText(pwedit, "Reset Account", mess,
|
||||
pwedit.Password)
|
||||
if ok and text:
|
||||
print(f'ok={ok}, password={text}', flush=True)
|
||||
if text.upper()!= self.settings.data["Reset"]:
|
||||
qmb = QMessageBox()
|
||||
mess = "Incorrect password!\nTry Reset Account once again."
|
||||
qmb.information(self, "Reset Account", mess)
|
||||
return
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
self.parent.prepare_elog_message()
|
||||
print("message", self.parent.message, flush=True)
|
||||
print("logbook", self.parent.logbook, flush=True)
|
||||
|
||||
5
src/invisible-eye.svg
Normal file
5
src/invisible-eye.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon">
|
||||
<defs><clipPath><path fill="none" d="M124-288l388-672 388 672H124z" clip-rule="evenodd"/></clipPath></defs><path d="M508 624a112 112 0 0 0 112-112c0-3.28-.15-6.53-.43-9.74L498.26 623.57c3.21.28 6.45.43 9.74.43zm370.72-458.44L836 122.88a8 8 0 0 0-11.31 0L715.37 232.23Q624.91 186 512 186q-288.3 0-430.2 300.3a60.3 60.3 0 0 0 0 51.5q56.7 119.43 136.55 191.45L112.56 835a8 8 0 0 0 0 11.31L155.25 889a8 8 0 0 0 11.31 0l712.16-712.12a8 8 0 0 0 0-11.32zM332 512a176 176 0 0 1 258.88-155.28l-48.62 48.62a112.08 112.08 0 0 0-140.92 140.92l-48.62 48.62A175.09 175.09 0 0 1 332 512z"/><path d="M942.2 486.2Q889.4 375 816.51 304.85L672.37 449A176.08 176.08 0 0 1 445 676.37L322.74 798.63Q407.82 838 512 838q288.3 0 430.2-300.3a60.29 60.29 0 0 0 0-51.5z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 979 B |
65
src/passwordedit.py
Normal file
65
src/passwordedit.py
Normal file
@@ -0,0 +1,65 @@
|
||||
import os
|
||||
|
||||
from qtpy import QtGui
|
||||
from qtpy.QtWidgets import QLineEdit
|
||||
|
||||
class PasswordEdit(QLineEdit):
|
||||
"""
|
||||
A LineEdit with icons to show/hide password entries
|
||||
"""
|
||||
CSS = '''QLineEdit {
|
||||
border-radius: 0px;
|
||||
height: 30px;
|
||||
margin: 0px 0px 0px 0px;
|
||||
}
|
||||
'''
|
||||
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
super().__init__(self.parent)
|
||||
|
||||
# Set styles
|
||||
self.setStyleSheet(self.CSS)
|
||||
|
||||
self.visibleIcon = QtGui.QIcon(':/eye-visible.svg') #QtGui.QIcon(':/eye-visible.svg') #self.load_icon("visible-eye.svg")
|
||||
self.hiddenIcon = QtGui.QIcon(':/eye-invisible.svg') # QtGui.QIcon(':/eye-invisible.svg') #self.load_icon("invisible-eye.svg")
|
||||
|
||||
self.setEchoMode(QLineEdit.Password)
|
||||
self.togglepasswordAction = self.addAction(
|
||||
self.visibleIcon, QLineEdit.TrailingPosition)
|
||||
self.togglepasswordAction.triggered.connect(
|
||||
self.on_toggle_password_Action)
|
||||
self.password_shown = False
|
||||
print('PasswordEdit init complete')
|
||||
print(f'on_init {self.visibleIcon} {self.hiddenIcon} {self.password_shown} ', flush=True)
|
||||
|
||||
def load_icon(self, fname_icon):
|
||||
#path_this_file = os.path.abspath(__file__)
|
||||
#path_this_dir = os.path.dirname(path_this_file)
|
||||
#path_icons = os.path.join(path_this_dir, '..', 'media', 'icons')
|
||||
#path_icon = os.path.join(path_icons, fname_icon)
|
||||
|
||||
#pixmap = QtGui.QPixmap(path_icon)
|
||||
|
||||
pixmap = QtGui.QPixmap(fname_icon)
|
||||
|
||||
pixmap.fill(QtGui.QColor('red'))
|
||||
#pixmap.setMask(pixmap.createMaskFromColor(QtGui.QColor('black'), QtGui.Qt.MaskOutColor))
|
||||
|
||||
icon = QtGui.QIcon()
|
||||
icon.addPixmap(pixmap, QtGui.QIcon.Normal)
|
||||
icon.addPixmap(pixmap, QtGui.QIcon.Disabled)
|
||||
|
||||
return icon
|
||||
|
||||
def on_toggle_password_Action(self):
|
||||
if not self.password_shown:
|
||||
self.setEchoMode(QLineEdit.Normal)
|
||||
self.password_shown = True
|
||||
self.togglepasswordAction.setIcon(self.hiddenIcon)
|
||||
else:
|
||||
self.setEchoMode(QLineEdit.Password)
|
||||
self.password_shown = False
|
||||
self.togglepasswordAction.setIcon(self.visibleIcon)
|
||||
|
||||
print(f'on_toggle {self.visibleIcon} {self.hiddenIcon} {self.password_shown} {QLineEdit.Password}', flush=True)
|
||||
13
src/visible-eye.svg
Normal file
13
src/visible-eye.svg
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg fill="#000000" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
width="800px" height="800px" viewBox="0 0 121.025 121.025"
|
||||
xml:space="preserve">
|
||||
<g>
|
||||
<path d="M1.35,64.212c7.9,9.9,31.4,36.3,59.2,36.3c27.8,0,51.3-26.399,59.2-36.3c1.699-2.2,1.699-5.3,0-7.399
|
||||
c-7.9-9.9-31.4-36.3-59.2-36.3c-27.8-0.1-51.3,26.3-59.2,36.2C-0.45,58.913-0.45,62.012,1.35,64.212z M60.55,36.413
|
||||
c13.3,0,24,10.7,24,24s-10.7,24-24,24c-13.3,0-24-10.7-24-24S47.25,36.413,60.55,36.413z"/>
|
||||
<circle cx="60.55" cy="60.413" r="12"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 815 B |
@@ -1,11 +0,0 @@
|
||||
Summary for 2024
|
||||
|
||||
Power saved for the current year stands at 1516.412 MWh:
|
||||
IP2: 314.258 MWh
|
||||
IW2: 91.529 MWh
|
||||
PK1: 86.399 MWh
|
||||
PK2: 393.997 MWh
|
||||
SNQ: 178.202 MWh
|
||||
UCN: 452.027 MWh
|
||||
------------------
|
||||
Tot: 1516.412 MWh
|
||||
Reference in New Issue
Block a user