Commit 8290d112 authored by John Tourtellott's avatar John Tourtellott
Browse files

Update to work with latest cumulus authentication (MFA)

parent 79a74540
......@@ -7,12 +7,13 @@
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/cumulus/jobspanel/pqCumulusJobsPanel.h"
#include "pqCumulusJobsPanel.h"
#include "smtk/cumulus/jobspanel/cumuluswidget.h"
#include "smtk/cumulus/jobspanel/job.h"
#include <QAction>
#include <QDebug>
#include <QFormLayout>
#include <QLineEdit>
#include <QMessageBox>
......@@ -20,6 +21,7 @@
#include <QSslSocket>
#include <QString>
#include <QVBoxLayout>
#include <QWidget>
#include <QtGlobal>
class pqCumulusJobsPanel::pqCumulusJobsPanelInternal
......@@ -32,6 +34,8 @@ public:
QWidget* FirstWidget;
QLineEdit* CumulusUrlEdit;
QLineEdit* SessionIdEdit;
QPushButton* AuthenticateButton;
cumulus::CumulusWidget* CumulusWidget;
};
......@@ -48,8 +52,8 @@ pqCumulusJobsPanel::pqCumulusJobsPanelInternal::pqCumulusJobsPanelInternal()
pqCumulusJobsPanel::pqCumulusJobsPanel(QWidget* parent)
: QDockWidget(parent)
{
this->setObjectName("CumulusJobs");
this->setWindowTitle("Cumulus Job Tracker");
this->setObjectName("Jobs Panel");
this->setWindowTitle("Cumulus Jobs");
this->Internal = new pqCumulusJobsPanelInternal;
// Initialize main widget
......@@ -59,11 +63,21 @@ pqCumulusJobsPanel::pqCumulusJobsPanel(QWidget* parent)
// Instantiate first page (displayed at startup)
this->Internal->FirstWidget = new QWidget(this->Internal->MainWidget);
QFormLayout* firstLayout = new QFormLayout;
// Cumulus URL
this->Internal->CumulusUrlEdit = new QLineEdit(this->Internal->FirstWidget);
this->Internal->CumulusUrlEdit->setText("http://localhost:8080/api/v1");
// this->Internal->CumulusUrlEdit->setText("http://localhost:8080/api/v1");
QString spinUrl("http://app-girder.ace3p.dev-cattle.stable.spin.nersc.org:60002/api/v1");
this->Internal->CumulusUrlEdit->setText(spinUrl);
firstLayout->addRow("Cumulus URL", this->Internal->CumulusUrlEdit);
QPushButton* authenticateButton = new QPushButton("Authenticate", this->Internal->FirstWidget);
firstLayout->addRow("NERSC Logon", authenticateButton);
// Login button and NEWT session id
this->Internal->AuthenticateButton = new QPushButton("NERSC Login", this->Internal->FirstWidget);
this->Internal->SessionIdEdit = new QLineEdit(this->Internal->FirstWidget);
this->Internal->SessionIdEdit->setPlaceholderText("NERSC/NEWT Session Id");
this->Internal->SessionIdEdit->setReadOnly(true);
firstLayout->addRow(this->Internal->AuthenticateButton, this->Internal->SessionIdEdit);
this->Internal->FirstWidget->setLayout(firstLayout);
this->Internal->MainLayout->addWidget(this->Internal->FirstWidget);
......@@ -72,6 +86,8 @@ pqCumulusJobsPanel::pqCumulusJobsPanel(QWidget* parent)
this->Internal->MainLayout->addWidget(this->Internal->CumulusWidget);
connect(this->Internal->CumulusWidget, &cumulus::CumulusWidget::info, this,
&pqCumulusJobsPanel::infoSlot);
connect(this->Internal->CumulusWidget, &cumulus::CumulusWidget::newtSessionId, this,
&pqCumulusJobsPanel::receivedNewtSessionId);
// Add context menu item to load results
QAction* action = new QAction("Load Simulation Results", this);
......@@ -79,15 +95,14 @@ pqCumulusJobsPanel::pqCumulusJobsPanel(QWidget* parent)
QObject::connect(
action, &QAction::triggered, this, &pqCumulusJobsPanel::requestSimulationResults);
QObject::connect(authenticateButton, SIGNAL(clicked()), this, SLOT(authenticateHPC()));
QObject::connect(this->Internal->AuthenticateButton, &QPushButton::clicked, this,
&pqCumulusJobsPanel::authenticateHPC);
connect(this->Internal->CumulusWidget, SIGNAL(resultDownloaded(const QString&)), this,
SIGNAL(resultDownloaded(const QString&)));
// Finish main widget
this->Internal->MainWidget->setLayout(this->Internal->MainLayout);
this->setWidget(this->Internal->MainWidget);
this->setObjectName("Jobs Panel");
}
pqCumulusJobsPanel::~pqCumulusJobsPanel()
......@@ -147,3 +162,10 @@ void pqCumulusJobsPanel::requestSimulationResults()
emit this->loadSimulationResults(job.downloadFolder());
}
void pqCumulusJobsPanel::receivedNewtSessionId(const QString& sessionId, int lifetime)
{
this->Internal->SessionIdEdit->setText(sessionId);
bool enable = sessionId.isEmpty();
this->Internal->AuthenticateButton->setEnabled(enable);
}
......@@ -35,6 +35,7 @@ protected slots:
void infoSlot(const QString& msg);
void authenticateHPC();
void requestSimulationResults();
void receivedNewtSessionId(const QString& sessionId, int lifetime);
private:
class pqCumulusJobsPanelInternal;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment