refs #751, info if user can directly update models

* modified login component, give hints
* user object has flag for direct write
This commit is contained in:
Klaus Basan
2016-08-31 17:14:32 +02:00
committed by Roland Winklmeier
parent 03c642d88a
commit ced9f5294e
5 changed files with 372 additions and 271 deletions

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>401</height>
<height>407</height>
</rect>
</property>
<property name="minimumSize">
@@ -150,33 +150,7 @@
<string>swift DB</string>
</property>
<layout class="QGridLayout" name="gl_SwiftDB">
<item row="0" column="0">
<widget class="BlackGui::Components::CDbLoginComponent" name="comp_LoginComponent">
<property name="minimumSize">
<size>
<width>0</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="BlackGui::Components::CDbDebugDatabaseSetup" name="comp_DebugDb">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -189,6 +163,16 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="BlackGui::Components::CDbLoginComponent" name="comp_LoginComponent">
<property name="minimumSize">
<size>
<width>0</width>
<height>150</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -201,12 +185,6 @@
<header>blackgui/components/dblogincomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CDbDebugDatabaseSetup</class>
<extends>QFrame</extends>
<header>blackgui/components/dbdebugdatabasesetup.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CDistributorPreferencesComponent</class>
<extends>QFrame</extends>

View File

@@ -45,10 +45,11 @@ namespace BlackGui
ui->setupUi(this);
this->setModeLogin(true);
CUrl url(sGui->getGlobalSetup().getDbHomePageUrl());
ui->lbl_SwiftDB->setText("<a href=\"" + url.getFullUrl() + "\">swift DB@" + url.getHost() + "</a>");
ui->lbl_SwiftDB->setTextFormat(Qt::RichText);
ui->lbl_SwiftDB->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->lbl_SwiftDB->setOpenExternalLinks(true);
QString html = ui->tbr_InfoAndHints->toHtml();
html = html.replace("##swiftDB##", url.getFullUrl(), Qt::CaseInsensitive);
html = html.replace("##swiftEnableSSO##", url.getFullUrl(), Qt::CaseInsensitive);
ui->tbr_InfoAndHints->setHtml(html);
ui->tbr_InfoAndHints->setOpenExternalLinks(true);
connect(ui->pb_Login, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLoginClicked);
connect(ui->pb_Logoff, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLogoffClicked);
@@ -98,21 +99,29 @@ namespace BlackGui
{
CLogMessage(this).info("User authenticated: %1") << user.toQString();
this->setModeLogin(false);
this->ui->le_Name->setText(user.getRealNameAndId());
this->ui->te_Roles->setPlainText(user.getRolesAsString());
ui->le_Name->setText(user.getRealNameAndId());
ui->te_Roles->setPlainText(user.getRolesAsString());
if (user.canDirectlyWriteModels())
{
ui->le_Info->setText("You can directly update models");
}
else
{
ui->le_Info->setText("You can create model change requests");
}
}
else
{
this->setModeLogin(true);
this->displayOverlayMessages(status);
CLogMessage::preformatted(status);
ui->le_Info->setText("Authentication failed, see hints");
}
}
void CDbLoginComponent::setModeLogin(bool modeLogin)
{
this->ui->fr_Login->setVisible(modeLogin);
this->ui->fr_Logoff->setVisible(!modeLogin);
ui->sw_LoginLogoff->setCurrentIndex(modeLogin ? 0 : 1);
}
} // ns
} // ns

View File

@@ -6,32 +6,336 @@
<rect>
<x>0</x>
<y>0</y>
<width>345</width>
<height>279</height>
<width>457</width>
<height>318</height>
</rect>
</property>
<property name="windowTitle">
<string>DB login</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QVBoxLayout" name="vl_LoginComponent">
<property name="leftMargin">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>4</number>
<number>2</number>
</property>
<property name="rightMargin">
<number>4</number>
<number>2</number>
</property>
<property name="bottomMargin">
<number>4</number>
<number>2</number>
</property>
<item>
<widget class="QTabWidget" name="tb_LoginToDbAndHints">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tb_LoginToDb">
<attribute name="title">
<string>Login to DB</string>
</attribute>
<layout class="QVBoxLayout" name="vl_LoginToDb">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QStackedWidget" name="sw_LoginLogoff">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pg_Login">
<layout class="QVBoxLayout" name="vl_PageLogin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="fr_Login">
<layout class="QGridLayout" name="gl_Login">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="1">
<widget class="QLineEdit" name="le_Username">
<property name="maxLength">
<number>40</number>
</property>
<property name="placeholderText">
<string>user name or id</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_User">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Password">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pb_Login">
<property name="text">
<string>login</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="hs_Login">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>75</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_Password">
<property name="echoMode">
<enum>QLineEdit::PasswordEchoOnEdit</enum>
</property>
<property name="placeholderText">
<string>password</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="BlackGui::Components::CDbDebugDatabaseSetup" name="comp_DebugSetup">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pg_Logoff">
<layout class="QVBoxLayout" name="vl_PageLogoff">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="fr_Logoff">
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gl_Logoff">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="3" column="1">
<widget class="QPushButton" name="pb_Logoff">
<property name="text">
<string>logoff</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPlainTextEdit" name="te_Roles">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="documentTitle">
<string>User roles</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="hs_Logoff">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>75</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Roles">
<property name="text">
<string>Roles:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Name">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="le_Name">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>user name</string>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_Info">
<property name="text">
<string>Info:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="le_Info">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>info text will go here</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_LoginToDbHints">
<attribute name="title">
<string>Login hints, trouble shooting</string>
</attribute>
<layout class="QVBoxLayout" name="vl_LoginHints">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QTextBrowser" name="tbr_InfoAndHints">
<property name="documentTitle">
<string>Login hints</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;title&gt;Login hints&lt;/title&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:7.875pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Arial';&quot;&gt; &lt;/span&gt;&lt;/p&gt;
&lt;ol style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; font-family:'Arial';&quot; style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;You can go directly to the swift DB: &lt;a href=&quot;##swiftDb##&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;##swiftDb##&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot; font-family:'Arial';&quot; style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;If you want to use VATSIM SSO, you need to enable it once &lt;a href=&quot;##swiftEnableSSO##&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;##swiftEnableSSO##&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_Header">
<property name="maximumSize">
@@ -62,228 +366,30 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lbl_SwiftDBIcon">
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../blackmisc/blackmisc.qrc">:/own/icons/own/swift/swift32Database.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_SwiftDB">
<property name="text">
<string>DB replaced by URL</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_Login">
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gl_Login">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>4</number>
</property>
<item row="0" column="1">
<widget class="QLineEdit" name="le_Username">
<property name="maxLength">
<number>40</number>
</property>
<property name="placeholderText">
<string>user name or id</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_User">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Password">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_Password">
<property name="echoMode">
<enum>QLineEdit::PasswordEchoOnEdit</enum>
</property>
<property name="placeholderText">
<string>password</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pb_Login">
<property name="text">
<string>login</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="hs_Login">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>75</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_Logoff">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>125</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gl_Logoff">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>4</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Name">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="le_Name">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Roles">
<property name="text">
<string>Roles:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pb_Logoff">
<property name="text">
<string>logoff</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPlainTextEdit" name="te_Roles">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="documentTitle">
<string>User roles</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="hs_Logoff">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>75</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>
</resources>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CDbDebugDatabaseSetup</class>
<extends>QFrame</extends>
<header>blackgui/components/dbdebugdatabasesetup.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>le_Username</tabstop>
<tabstop>le_Password</tabstop>
<tabstop>pb_Login</tabstop>
<tabstop>le_Name</tabstop>
<tabstop>te_Roles</tabstop>
<tabstop>le_Info</tabstop>
<tabstop>pb_Logoff</tabstop>
<tabstop>tb_LoginToDbAndHints</tabstop>
<tabstop>tbr_InfoAndHints</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -101,6 +101,11 @@ namespace BlackMisc
return this->hasRole("MAPPINGADMIN") || this->isAdmin();
}
bool CAuthenticatedUser::canDirectlyWriteModels() const
{
return this->isAdmin() || this->isMappingAdmin();
}
CIcon CAuthenticatedUser::toIcon() const
{
return CIconList::iconByIndex(CIcons::StandardIconUser16);

View File

@@ -139,6 +139,9 @@ namespace BlackMisc
//! Enabled
bool isEnabled() const { return this->m_enabled; }
//! Entitled to directly update models
bool canDirectlyWriteModels() const;
//! \copydoc BlackMisc::Mixin::Icon::toIcon()
BlackMisc::CIcon toIcon() const;