From ced9f5294e787c44df95ffa6ff9c11317fbe1359 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 31 Aug 2016 17:14:32 +0200 Subject: [PATCH] refs #751, info if user can directly update models * modified login component, give hints * user object has flag for direct write --- .../components/datasettingscomponent.ui | 44 +- src/blackgui/components/dblogincomponent.cpp | 25 +- src/blackgui/components/dblogincomponent.ui | 566 +++++++++++------- src/blackmisc/network/authenticateduser.cpp | 5 + src/blackmisc/network/authenticateduser.h | 3 + 5 files changed, 372 insertions(+), 271 deletions(-) diff --git a/src/blackgui/components/datasettingscomponent.ui b/src/blackgui/components/datasettingscomponent.ui index 78fe41b26..fc90faa9e 100644 --- a/src/blackgui/components/datasettingscomponent.ui +++ b/src/blackgui/components/datasettingscomponent.ui @@ -7,7 +7,7 @@ 0 0 400 - 401 + 407 @@ -150,33 +150,7 @@ swift DB - - - - - 0 - 150 - - - - - - - - 0 - 40 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - Qt::Vertical @@ -189,6 +163,16 @@ + + + + + 0 + 150 + + + + @@ -201,12 +185,6 @@
blackgui/components/dblogincomponent.h
1 - - BlackGui::Components::CDbDebugDatabaseSetup - QFrame -
blackgui/components/dbdebugdatabasesetup.h
- 1 -
BlackGui::Components::CDistributorPreferencesComponent QFrame diff --git a/src/blackgui/components/dblogincomponent.cpp b/src/blackgui/components/dblogincomponent.cpp index 9d05e5c0c..72c785993 100644 --- a/src/blackgui/components/dblogincomponent.cpp +++ b/src/blackgui/components/dblogincomponent.cpp @@ -45,10 +45,11 @@ namespace BlackGui ui->setupUi(this); this->setModeLogin(true); CUrl url(sGui->getGlobalSetup().getDbHomePageUrl()); - ui->lbl_SwiftDB->setText("swift DB@" + url.getHost() + ""); - 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 diff --git a/src/blackgui/components/dblogincomponent.ui b/src/blackgui/components/dblogincomponent.ui index bd9e5ef5c..49756d957 100644 --- a/src/blackgui/components/dblogincomponent.ui +++ b/src/blackgui/components/dblogincomponent.ui @@ -6,32 +6,336 @@ 0 0 - 345 - 279 + 457 + 318 DB login - - QFrame::NoFrame - - - QFrame::Plain - - + 4 + + 2 + - 4 + 2 - 4 + 2 - 4 + 2 + + + + 0 + + + + Login to DB + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 4 + + + 4 + + + 4 + + + 4 + + + 6 + + + + + 40 + + + user name or id + + + true + + + + + + + Name: + + + + + + + Password: + + + + + + + login + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 75 + 10 + + + + + + + + QLineEdit::PasswordEchoOnEdit + + + password + + + true + + + + + + + + 0 + 25 + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::Raised + + + + 4 + + + 4 + + + 4 + + + 4 + + + 6 + + + + + logoff + + + + + + + + 0 + 40 + + + + User roles + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 75 + 10 + + + + + + + + Roles: + + + + + + + Name: + + + + + + + true + + + user name + + + false + + + + + + + Info: + + + + + + + true + + + info text will go here + + + + + + + + + + + + + + + Login hints, trouble shooting + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + Login hints + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><title>Login hints</title><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.875pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial';"> </span></p> +<ol style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" font-family:'Arial';" style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You can go directly to the swift DB: <a href="##swiftDb##"><span style=" text-decoration: underline; color:#0000ff;">##swiftDb##</span></a></li> +<li style=" font-family:'Arial';" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If you want to use VATSIM SSO, you need to enable it once <a href="##swiftEnableSSO##"><span style=" text-decoration: underline; color:#0000ff;">##swiftEnableSSO##</span></a></li></ol></body></html> + + + Qt::TextBrowserInteraction + + + + + + + @@ -62,228 +366,30 @@ 0 - - - - - 40 - 16777215 - - - - - - - :/own/icons/own/swift/swift32Database.png - - - - - - - DB replaced by URL - - - - - - - - - - - 0 - 100 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 4 - - - - - 40 - - - user name or id - - - true - - - - - - - Name: - - - - - - - Password: - - - - - - - QLineEdit::PasswordEchoOnEdit - - - password - - - true - - - - - - - login - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 75 - 10 - - - - - - - - - - - - 16777215 - 125 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 4 - - - - - Name: - - - - - - - true - - - false - - - - - - - Roles: - - - - - - - logoff - - - - - - - - 0 - 40 - - - - User roles - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 75 - 10 - - - - - - - + + + BlackGui::Components::CDbDebugDatabaseSetup + QFrame +
blackgui/components/dbdebugdatabasesetup.h
+ 1 +
+
+ + le_Username + le_Password + pb_Login + le_Name + te_Roles + le_Info + pb_Logoff + tb_LoginToDbAndHints + tbr_InfoAndHints + + diff --git a/src/blackmisc/network/authenticateduser.cpp b/src/blackmisc/network/authenticateduser.cpp index f2c502fa9..ab6859f5e 100644 --- a/src/blackmisc/network/authenticateduser.cpp +++ b/src/blackmisc/network/authenticateduser.cpp @@ -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); diff --git a/src/blackmisc/network/authenticateduser.h b/src/blackmisc/network/authenticateduser.h index daf465bfc..c33c89425 100644 --- a/src/blackmisc/network/authenticateduser.h +++ b/src/blackmisc/network/authenticateduser.h @@ -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;