Ejemplo n.º 1
0
    def __init__(self, width=480, height=540, papa=None, client=None):
        super(Dashboard, self).__init__()
        self.width = width
        self.height = height

        self.papa = papa
        self.client = client

        self.create_group_button = auth.TransparentButton("Create Group")
        self.view_groups_button = auth.TransparentButton("View Groups")
        self.create_template_button = auth.TransparentButton("Create Template")
        self.view_templates_button = auth.TransparentButton("View Templates")
        self.exit_button = auth.TransparentButton("Logout")
        self.set_buttons()

        unsername_label = QLabel("User: "******"color:white; font-size:18px")

        layout = QGridLayout()
        layout.addWidget(self.create_group_button, 0, 0)
        layout.addWidget(self.create_template_button, 0, 1)
        layout.addWidget(self.view_groups_button, 1, 0)
        layout.addWidget(self.view_templates_button, 1, 1)
        layout.addWidget(self.exit_button, 2, 1, alignment=Qt.AlignRight)
        layout.addWidget(unsername_label, 2, 0)
        self.setLayout(layout)
        self.resize(width, height)
        self.setWindowTitle("Dashboard")
Ejemplo n.º 2
0
    def __init__(self, groups, client=None, parent=None):
        super(ViewGroups, self).__init__(parent)
        self.setModal(True)

        self.parent = parent
        self.client = client
        self.width = parent.width
        self.height = parent.height

        self.list_groups = QListView()
        self.list_groups.setStyleSheet(GROUP_LIST_VIEW_SS)
        self.list_groups.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.list_groups.setMaximumWidth(int(2 * parent.width / 3))

        self.list_groups.doubleClicked.connect(self.select_group)

        ok_button = auth.TransparentButton(text="View",
                                           font_size=10,
                                           parent=self)
        ok_button.setMaximumWidth(int(parent.width / 10))
        ok_button.setMinimumHeight(int(parent.height / 15))
        ok_button.clicked.connect(self.view_group)

        join_button = auth.TransparentButton(text="Join",
                                             font_size=10,
                                             parent=self)
        join_button.setMaximumWidth(int(parent.width / 10))
        join_button.setMinimumHeight(int(parent.height / 15))
        join_button.clicked.connect(self.join_group)

        cancel_button = auth.TransparentButton(text="Back",
                                               font_size=10,
                                               parent=self)
        cancel_button.setMaximumWidth(int(parent.width / 10))
        cancel_button.setMinimumHeight(int(parent.height / 15))
        cancel_button.clicked.connect(self.cancel)

        layout = QGridLayout()

        layout.addWidget(self.list_groups, 0, 0, 4, 1)
        layout.addWidget(ok_button, 0, 1)
        layout.addWidget(join_button, 1, 1)
        layout.addWidget(cancel_button, 2, 1)

        self.timer = QTimer()
        self.timer.timeout.connect(self.refresh_groups_list)
        self.timer.start(REFRESH_INTERVAL)

        self.model = QStringListModel()
        self.model.setStringList(groups)
        self.list_groups.setModel(self.model)

        self.setLayout(layout)
        self.resize(self.width, self.height)
        self.setWindowTitle("View Groups")
Ejemplo n.º 3
0
    def __init__(self, requests, client=None, parent=None, group=None):
        super(ViewRequests, self).__init__(parent)
        self.setModal(True)

        self.parent = parent
        self.client = client
        self.width = parent.width
        self.height = parent.height
        self.group = group

        self.list_requests = QListView()
        self.list_requests.setStyleSheet(GROUP_LIST_VIEW_SS)
        self.list_requests.setEditTriggers(QAbstractItemView.NoEditTriggers)

        accept_button = auth.TransparentButton(text="Acept",
                                               font_size=10,
                                               parent=self)
        accept_button.setMaximumWidth(int(parent.width / 10))
        accept_button.setMinimumHeight(int(parent.height / 15))
        accept_button.clicked.connect(self.accept_request)

        reject_button = auth.TransparentButton(text="Reject",
                                               font_size=10,
                                               parent=self)
        reject_button.setMaximumWidth(int(parent.width / 10))
        reject_button.setMinimumHeight(int(parent.height / 15))
        reject_button.clicked.connect(self.reject_request)

        cancel_button = auth.TransparentButton(text="Back",
                                               font_size=10,
                                               parent=self)
        cancel_button.setMaximumWidth(int(parent.width / 10))
        cancel_button.setMinimumHeight(int(parent.height / 15))
        cancel_button.clicked.connect(self.cancel)

        layout = QGridLayout()

        layout.addWidget(self.list_requests, 0, 0, 5, 1)
        layout.addWidget(accept_button, 0, 1)
        layout.addWidget(reject_button, 1, 1)
        layout.addWidget(cancel_button, 2, 1)

        self.timer = QTimer()
        self.timer.timeout.connect(self.refresh_list)
        self.timer.start(REFRESH_INTERVAL)

        self.model = QStringListModel()
        self.model.setStringList(requests)
        self.list_requests.setModel(self.model)
        self.setLayout(layout)
        self.resize(self.width, self.height)
        self.setWindowTitle("View Requests")
Ejemplo n.º 4
0
    def __init__(self, parent=None, client=None):
        super(CreateTemplateGUI, self).__init__(parent)
        self.setModal(True)

        self.parent = parent
        self.client = client
        self.template_max_length = MAX_TEMPLATE_LENGTH

        self.edit_template_name = QLineEdit()
        self.edit_template_name.setStyleSheet(TEMPLATE_CREATE_LINEEDIT_SS)
        self.edit_template_name.setMinimumWidth(int(parent.width / 3))

        label_template_name = QLabel()
        label_template_name.setStyleSheet(TEMPLATE_LABEL_STYLE_SHEET)
        label_template_name.setText("Template Name: ")
        label_template_name.setBuddy(self.edit_template_name)

        self.edit_text = QTextEdit()
        self.edit_text.setStyleSheet(TEMPLATE_TEXT_EDIT_SS)

        ok_button = auth.TransparentButton(text="Create",
                                           font_size=10,
                                           parent=self)
        ok_button.setMaximumWidth(int(parent.width / 10))
        ok_button.setMinimumHeight(int(parent.height / 15))
        ok_button.clicked.connect(self.create_template)

        cancel_button = auth.TransparentButton(text="Back",
                                               font_size=10,
                                               parent=self)
        cancel_button.setMaximumWidth(int(parent.width / 10))
        cancel_button.setMinimumHeight(int(parent.height / 15))
        cancel_button.clicked.connect(self.cancel)

        layout = QGridLayout()
        layout.addWidget(label_template_name, 0, 0)
        layout.addWidget(self.edit_template_name,
                         0,
                         1,
                         alignment=Qt.AlignHCenter)
        layout.addWidget(self.edit_text, 2, 0, 1, 2)
        layout.addWidget(ok_button, 3, 0)
        layout.addWidget(cancel_button, 3, 1)

        self.setLayout(layout)
        self.resize(int(3 * parent.width / 4), int(3 * parent.height / 4))
        self.width = 3 * parent.width / 4
        self.height = 3 * parent.height / 4
        self.setWindowTitle("Create Template")
Ejemplo n.º 5
0
    def __init__(self,
                 group,
                 outer_join=False,
                 santa_client=None,
                 parent=None):
        super(Joiner, self).__init__(parent)
        self.setModal(True)

        self.group = group
        self.client = santa_client
        self.parent = parent
        self.outer_join = outer_join

        self.edit_password = QLineEdit()
        self.edit_password.setStyleSheet(JOINER_LINEEDIT_SS)
        self.edit_password.setMinimumWidth(int(parent.width / 5))
        self.edit_password.setEchoMode(QLineEdit.Password)

        label_password = QLabel()
        label_password.setStyleSheet(JOINER_LABEL_STYLE_SHEET)
        label_password.setText("Password: "******"Join with password",
                                                 font_size=10,
                                                 parent=self)
        join_pwd_button.setMaximumWidth(int(parent.width / 5))
        join_pwd_button.setMinimumHeight(int(parent.height / 15))
        join_pwd_button.clicked.connect(self.join_password)

        join_button = auth.TransparentButton(text="Join Request",
                                             font_size=10,
                                             parent=self)
        join_button.setMaximumWidth(int(parent.width / 5))
        join_button.setMinimumHeight(int(parent.height / 15))
        join_button.clicked.connect(self.join)

        layout = QGridLayout()
        layout.addWidget(label_password, 0, 0)
        layout.addWidget(self.edit_password, 0, 1, alignment=Qt.AlignHCenter)
        layout.addWidget(join_pwd_button, 1, 0)
        layout.addWidget(join_button, 1, 1)

        self.setLayout(layout)
        self.width = 3 * parent.width / 8
        self.height = 3 * parent.height / 8
        self.resize(self.width, self.height)
        self.edit_password.setFocus()
        self.setWindowTitle("Join group")
Ejemplo n.º 6
0
    def __init__(self,
                 template_name,
                 template,
                 client=None,
                 parent=None,
                 group=None):
        super(EditTemplate, self).__init__(parent)
        self.setModal(True)

        self.selected_template = template
        self.selected_template_name = template_name
        self.group = group
        self.parent = parent
        self.client = client

        self.text_box = QTextEdit()
        self.text_box.setText(template)
        self.text_box.setFocus()
        self.text_box.setStyleSheet(TEMPLATE_TEXT_BROWSER_SS)

        cancel_button = auth.TransparentButton(text="Back",
                                               font_size=10,
                                               parent=self)
        cancel_button.setMaximumWidth(int(self.parent.width / 10))
        cancel_button.setMinimumHeight(int(self.parent.height / 15))
        cancel_button.clicked.connect(self.close)

        send_button = auth.TransparentButton(text="Send emails",
                                             font_size=10,
                                             parent=self)
        send_button.setMaximumWidth(int(self.parent.width / 5))
        send_button.setMinimumHeight(int(self.parent.height / 15))
        send_button.clicked.connect(self.send_emails)

        layout = QGridLayout()
        layout.addWidget(self.text_box, 0, 0, 1, 3)
        layout.addWidget(send_button, 1, 0)
        layout.addWidget(cancel_button, 1, 1)
        self.setLayout(layout)
        self.width = int(3 * self.parent.width / 4)
        self.height = int(3 * self.parent.height / 4)
        self.resize(self.width, self.height)
        self.setWindowTitle("Template " + template_name)
Ejemplo n.º 7
0
 def add_leave_button(self):
     leave_group_button = auth.TransparentButton(text="Leave group",
                                                 font_size=10,
                                                 parent=self)
     leave_group_button.setMaximumWidth(int(self.parent.width / 5))
     leave_group_button.setMinimumHeight(int(self.parent.height / 15))
     leave_group_button.clicked.connect(self.leave_group)
     if self.join_button:
         self.join_button.deleteLater()
     self.layout.addWidget(leave_group_button, 3, 1)
Ejemplo n.º 8
0
    def view_template(self):
        if not self.list_templates.selectedIndexes():
            alert(WARNING, WARNING, NO_INDEX_SELECTED, parent=self)
            return
        idx = self.list_templates.selectedIndexes()[0]
        data = self.model.itemData(idx)[0]
        ret, template = self.client.get_template(data)

        if ret == ReturnCodes.NOT_AUTH:
            alert(ERROR, ERROR, NOT_AUTH, parent=self.parent)
            self.cancel()
            self.parent.return_to_login()
            return

        if ret == ReturnCodes.RELOGIN:
            alert(ERROR, ERROR, RELOGIN_ERR, parent=self.parent)
            self.cancel()
            self.parent.return_to_login()

        if ret == ReturnCodes.UNKNOWN_ERROR:
            alert(WARNING, MI_SCUZI, UNKNOWN_ERROR_TEXT, parent=self)
            return

        qd = QDialog(parent=self)
        qd.setStyleSheet(TEMPLATE_DIALOG_SS)

        tb = QTextBrowser()
        tb.setText(template)

        cancel_button = auth.TransparentButton(text="Back",
                                               font_size=10,
                                               parent=self)
        cancel_button.setMaximumWidth(int(self.width / 10))
        cancel_button.setMinimumHeight(int(self.parent.height / 15))
        cancel_button.clicked.connect(qd.close)

        tb.setStyleSheet(TEMPLATE_TEXT_BROWSER_SS)
        layout = QVBoxLayout()
        layout.addWidget(tb)
        layout.addWidget(cancel_button)
        qd.setLayout(layout)
        qd.resize(int(3 * self.width / 4), int(3 * self.height / 4))
        qd.setWindowTitle("Template " + data)
        qd.show()
        pass
Ejemplo n.º 9
0
    def __init__(self,
                 view_type,
                 templates,
                 client=None,
                 parent=None,
                 group=None):
        super(ViewTemplates, self).__init__(parent)
        self.setModal(True)

        self.parent = parent
        self.client = client
        self.width = parent.width
        self.height = parent.height
        self.type = view_type
        self.selected_template_name = ""
        self.selected_template = ""
        self.text_box = None
        self.group = group

        self.list_templates = QListView()
        self.list_templates.setStyleSheet(TEMPLATE_LIST_VIEW_SS)
        self.list_templates.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.list_templates.setMaximumWidth(int(2 * parent.width / 3))

        ok_button = auth.TransparentButton(text="View",
                                           font_size=10,
                                           parent=self)
        if self.type == SELECT_TEMPLATE:
            ok_button.setText("Select")
        ok_button.setMaximumWidth(int(parent.width / 10))
        ok_button.setMinimumHeight(int(parent.height / 15))

        if self.type == SELECT_TEMPLATE:
            ok_button.clicked.connect(self.edit_template)
            self.list_templates.doubleClicked.connect(self.edit_template)
        else:
            ok_button.clicked.connect(self.view_template)
            self.list_templates.doubleClicked.connect(self.view_template)

        cancel_button = auth.TransparentButton(text="Back",
                                               font_size=10,
                                               parent=self)
        cancel_button.setMaximumWidth(int(parent.width / 10))
        cancel_button.setMinimumHeight(int(parent.height / 15))
        cancel_button.clicked.connect(self.cancel)

        layout = QGridLayout()

        layout.addWidget(self.list_templates, 0, 0, 4, 1)
        layout.addWidget(ok_button, 0, 1)
        layout.addWidget(cancel_button, 1, 1)

        self.timer = QTimer()
        self.timer.timeout.connect(self.refresh_list)
        self.timer.start(REFRESH_INTERVAL)

        self.model = QStringListModel()
        self.model.setStringList(templates)
        self.list_templates.setModel(self.model)
        self.setLayout(layout)
        self.resize(self.width, self.height)
        self.setWindowTitle("View Templates")
Ejemplo n.º 10
0
    def __init__(self,
                 group_name,
                 group_members,
                 santa_client=None,
                 parent=None):
        super(ViewGroup, self).__init__(parent)
        self.setModal(True)

        self.parent = parent
        self.client = santa_client
        self.width = parent.width
        self.height = parent.height
        self.group_name = group_name
        self.admin_view = self.client.if_admin()

        self.list_members = QListView()
        self.list_members.setStyleSheet(GROUP_LIST_VIEW_SS)
        self.list_members.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.list_members.setMaximumWidth(int(2 * parent.width / 3))

        self.model = QStringListModel()
        self.model.setStringList(group_members)
        self.list_members.setModel(self.model)

        group_name_label = QLabel(text=group_name)
        group_name_label.setStyleSheet(GROUP_NAME_SS)

        close_button = auth.TransparentButton(text="Back",
                                              font_size=10,
                                              parent=self)
        close_button.setMaximumWidth(int(parent.width / 10))
        close_button.setMinimumHeight(int(parent.height / 15))
        close_button.clicked.connect(self.cancel)

        self.layout = QGridLayout()
        self.layout.addWidget(group_name_label,
                              0,
                              0,
                              1,
                              2,
                              alignment=Qt.AlignCenter)
        self.layout.addWidget(self.list_members, 1, 0, 8, 1)

        self.join_button = None

        if self.admin_view:
            remove_user_button = auth.TransparentButton(text="Remove User",
                                                        font_size=10,
                                                        parent=self)
            remove_user_button.setMaximumWidth(int(parent.width / 10))
            remove_user_button.setMinimumHeight(int(parent.height / 15))
            remove_user_button.clicked.connect(self.remove_user)

            delete_group_button = auth.TransparentButton(text="Delete Group",
                                                         font_size=10,
                                                         parent=self)
            delete_group_button.setMaximumWidth(int(parent.width / 10))
            delete_group_button.setMinimumHeight(int(parent.height / 15))
            delete_group_button.clicked.connect(self.delete_group)

            send_emails_button = auth.TransparentButton(text="Send Emails",
                                                        font_size=10,
                                                        parent=self)
            send_emails_button.setMaximumWidth(int(parent.width / 10))
            send_emails_button.setMinimumHeight(int(parent.height / 15))
            send_emails_button.clicked.connect(self.send_emails)

            join_requests_button = auth.TransparentButton(text="Join Requests",
                                                          font_size=10,
                                                          parent=self)
            join_requests_button.setMaximumWidth(int(parent.width / 10))
            join_requests_button.setMinimumHeight(int(parent.height / 15))
            join_requests_button.clicked.connect(self.see_requests)

            self.layout.addWidget(join_requests_button, 2, 1)
            self.layout.addWidget(remove_user_button, 3, 1)
            self.layout.addWidget(delete_group_button, 4, 1)
            self.layout.addWidget(send_emails_button, 5, 1)
        else:
            if self.client.in_current_group():
                self.add_leave_button()
            else:
                join_group_button = auth.TransparentButton(text="Join group",
                                                           font_size=10,
                                                           parent=self)
                join_group_button.setMaximumWidth(int(parent.width / 5))
                join_group_button.setMinimumHeight(int(parent.height / 15))
                join_group_button.clicked.connect(self.join_group)
                self.join_button = join_group_button
                self.layout.addWidget(join_group_button, 3, 1)

        self.layout.addWidget(close_button, 6, 1)

        self.timer = QTimer()
        self.timer.timeout.connect(self.refresh_users_list)
        self.timer.start(REFRESH_INTERVAL)

        self.setLayout(self.layout)
        self.setWindowTitle("Group " + group_name)
        self.resize(self.width, self.height)
Ejemplo n.º 11
0
    def __init__(self, santa_client=None, parent=None):
        super(CreateGroupGUI, self).__init__(parent)
        self.setModal(True)

        self.parent = parent
        self.client = santa_client

        self.edit_groupname = QLineEdit()
        self.edit_groupname.setStyleSheet(GROUP_CREATE_LINEEDIT_SS)
        self.edit_groupname.setMinimumWidth(int(parent.width / 3))

        self.edit_password = QLineEdit()
        self.edit_password.setStyleSheet(GROUP_CREATE_LINEEDIT_SS)
        self.edit_password.setEchoMode(QLineEdit.Password)
        self.edit_password.setMinimumWidth(int(parent.width / 3))

        self.edit_password2 = QLineEdit()
        self.edit_password2.setStyleSheet(GROUP_CREATE_LINEEDIT_SS)
        self.edit_password2.setEchoMode(QLineEdit.Password)
        self.edit_password2.setMinimumWidth(int(parent.width / 3))

        label_groupname = QLabel()
        label_groupname.setStyleSheet(GROUP_LABEL_STYLE_SHEET)
        label_groupname.setText("Group Name: ")
        label_groupname.setBuddy(self.edit_groupname)
        label_password = QLabel()
        label_password.setStyleSheet(GROUP_LABEL_STYLE_SHEET)
        label_password.setText("Password: "******"Reenter password: "******"Create",
                                           font_size=10,
                                           parent=self)
        ok_button.setMaximumWidth(int(parent.width / 10))
        ok_button.setMinimumHeight(int(parent.height / 15))
        ok_button.clicked.connect(self.create_group)

        cancel_button = auth.TransparentButton(text="Back",
                                               font_size=10,
                                               parent=self)
        cancel_button.setMaximumWidth(int(parent.width / 10))
        cancel_button.setMinimumHeight(int(parent.height / 15))
        cancel_button.clicked.connect(self.cancel)

        layout = QGridLayout()
        layout.addWidget(label_groupname, 0, 0)
        layout.addWidget(self.edit_groupname, 0, 1, alignment=Qt.AlignHCenter)
        layout.addWidget(label_password, 1, 0)
        layout.addWidget(self.edit_password, 1, 1, alignment=Qt.AlignHCenter)
        layout.addWidget(label_password2, 2, 0)
        layout.addWidget(self.edit_password2, 2, 1, alignment=Qt.AlignHCenter)
        layout.addWidget(ok_button, 3, 0)
        layout.addWidget(cancel_button, 3, 1, alignment=Qt.AlignLeft)
        self.setLayout(layout)
        self.resize(int(3 * parent.width / 4), int(3 * parent.height / 4))
        self.width = 3 * parent.width / 4
        self.height = 3 * parent.height / 4
        self.setWindowTitle("Create Group")
        self.edit_groupname.setFocus()