deleted settings tab and added cmd ui to sessions tab

remotes/origin/HEAD
Tobias Weiss 7 years ago
parent 0bcbdab939
commit 4bbf149fe6

@ -383,3 +383,7 @@ void lc::Settings::SetLocalzLeafSize( QString arg) {
localzLeafSize = arg;
}
void lc::Settings::SetChosenZTreePort( const int argPort ){
chosenzTreePort = argPort;
}

@ -32,8 +32,6 @@ class Settings : public QObject {
Q_OBJECT
public:
void SetLocalzLeafSize( QString arg);
Settings() = delete;
explicit Settings( const QSettings &argSettings, QObject *argParent = nullptr );
Settings( const Settings &argSettings ) = delete;
@ -58,6 +56,8 @@ public:
const QString lcDataDir;
const QString localUserName;
QString localzLeafSize;
void SetLocalzLeafSize( QString arg);
QString GetLocalzLeafSize() const { return localzLeafSize; }
const QString lprCmd;
const QString netstatCmd;
const QString netwBrdAddr;
@ -120,11 +120,6 @@ inline QString lc::Settings::GetLocalzLeafName() const {
return localzLeafName;
}
inline void lc::Settings::SetChosenZTreePort( const int argPort ) {
chosenzTreePort = argPort;
qDebug() << "'chosenZTreePort' set to:" << chosenzTreePort;
}
inline void lc::Settings::SetLocalzLeafName( const QString &argLocalzLeafName ) {
localzLeafName = argLocalzLeafName;
}

@ -33,10 +33,15 @@ lc::LocalzLeafStarter::LocalzLeafStarter( QWidget *argParent ) :
{
ui->setupUi( this );
//Choose initial port from settings
if ( settings->GetChosenZTreePort() ) {
ui->SBzLeafPort->setValue( settings->GetChosenZTreePort() );
}
//Choose initial z-Leave size from settings
ui->LELocalzLeafSize->setText( settings->GetLocalzLeafSize() );
ui->CBzLeafVersion->addItem( tr( "Please choose a version" ) );
if ( !settings->installedZTreeVersions.isEmpty() ) {
ui->CBzLeafVersion->addItems( settings->installedZTreeVersions );
@ -55,6 +60,10 @@ void lc::LocalzLeafStarter::on_PBStartLocalzLeaf_clicked() {
return;
}
//Set chosen z-Leaf size
settings->SetLocalzLeafSize( ui->LELocalzLeafSize->text() );
//Emit start local z-Leaf request to main window
emit LocalzLeafRequested( ui->LEzLeafName->text(), ui->CBzLeafVersion->currentText(),
ui->SBzLeafPort->value() );
}

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>352</width>
<width>371</width>
<height>352</height>
</rect>
</property>
@ -20,7 +20,7 @@
<string>This sets the name with which this local z-Leaf will connect to z-Tree.</string>
</property>
<property name="text">
<string>Set the name of the to be started z-Leaf:</string>
<string>Set the name of the to be started z-Leaf</string>
</property>
</widget>
</item>
@ -43,7 +43,7 @@
<string>Choose of which version the started z-Leaf shall be.</string>
</property>
<property name="text">
<string>Choose the version of the to be started z-Leaf:</string>
<string>Choose the version of the to be started z-Leaf</string>
</property>
</widget>
</item>
@ -66,12 +66,15 @@
<string>Set the port on which the z-Tree which shall be connected to listens.</string>
</property>
<property name="text">
<string>Choose the port the to be started z-Leaf shall listen on:</string>
<string>Choose the port the to be started z-Leaf shall listen on</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="SBzLeafPort">
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="toolTip">
<string>Set the port on which the z-Tree which shall be connected to listens.</string>
</property>
@ -89,6 +92,23 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="LLocalzLeafSize">
<property name="text">
<string>Choose the size the local z-Leaf shall have</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="LELocalzLeafSize"/>
</item>
<item>
<widget class="Line" name="line_Start">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="PBStartLocalzLeaf">
<property name="toolTip">

@ -280,105 +280,6 @@ void lc::MainWindow::LoadIconPixmaps() {
}
}
void lc::MainWindow::on_PBBoot_clicked() {
QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->Boot();
}
}
}
void lc::MainWindow::on_PBChooseFile_clicked() {
QFileDialog *file_dialog = new QFileDialog{ this, tr( "Choose a file to beam" ), QDir::homePath() };
file_dialog->setFileMode( QFileDialog::Directory );
file_dialog->setOption( QFileDialog::DontUseNativeDialog, true );
file_dialog->setOption( QFileDialog::ReadOnly, true );
file_dialog->setOption( QFileDialog::ShowDirsOnly, true );
if(file_dialog->exec()) {
ui->LEFilePath->setText(file_dialog->selectedFiles().at(0));
qDebug() << "Chose file" << ui->LEFilePath->text() << "for beaming.";
}
else {
ui->LEFilePath->setText( tr( "File choosing cancelled" ) );
qDebug() << "File choosing cancelled";
}
delete file_dialog;
}
void lc::MainWindow::on_PBBeamFile_clicked() {
QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes();
const QString fileToBeam{ ui->LEFilePath->text() };
if(fileToBeam == ""){
QMessageBox::information(this, "Upload failed", "You didn't choose any folder to upload.");
} else {
//Iterate over the selected clients to upload the file
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->BeamFile( fileToBeam, &settings->pkeyPathUser, &settings->userNameOnClients );
}
}
// Inform the user about the path
QMessageBox::information(this, "Upload completed", "The folder was copied to all selected clients.\nThe path on every client is /home/ewfuser" + fileToBeam.mid(fileToBeam.lastIndexOf('/')) +".\nDon't forget to adjust the media path within zTree!");
}
}
void lc::MainWindow::on_PBExecute_clicked() {
// This will be set to false, if the command shall be executed only on the chosen clients (that's if not all clients are up)
bool executeOnEveryClient = true;
// Cancel, if not all clients are up and running
for ( auto s: settings->GetClients() ) {
if ( !( s->name.contains( "backup", Qt::CaseInsensitive ) ) ) {
if ( s->GetClientState() < state_t::RESPONDING ) {
QMessageBox messageBox{ QMessageBox::Warning, tr( "Not all clients are running" ),
tr( "Not all clients are running. The command could not be executed on every client and should therefore be canceled to keep the clients consistent.\n\nAre you sure you want to continue only with the currently chosen clients?" ), QMessageBox::No | QMessageBox::Yes, this };
messageBox.setDefaultButton( QMessageBox::No );
messageBox.exec();
executeOnEveryClient = false;
if ( messageBox.clickedButton() == messageBox.button( QMessageBox::No ) ) {
return;
} else {
break;
}
}
}
}
// Get the command to be executed ...
QString command = ui->CBCommandToExecute->currentText();
// Set the correct public key
QString pkeyPathUser;
if ( ui->RBUseUserRoot->isChecked() ) {
pkeyPathUser = settings->pkeyPathRoot;
} else {
pkeyPathUser = settings->pkeyPathUser;
}
// and execute it
if ( executeOnEveryClient ) {
qDebug() << "Executing command" << command << "on every client.";
for ( auto s: settings->GetClients() ) {
if ( !( s->name.contains( "backup", Qt::CaseInsensitive ) ) ) {
s->OpenTerminal( command, ui->RBUseUserRoot->isChecked() );
}
}
} else {
qDebug() << "Executing command" << command << "only on chosen clients.";
QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->OpenTerminal( command, ui->RBUseUserRoot->isChecked() );
}
}
}
}
void lc::MainWindow::on_PBKillLocalzLeaf_clicked() {
QString program{ settings->killallCmd };
QStringList arguments;
@ -396,25 +297,6 @@ void lc::MainWindow::on_PBKillLocalzLeaf_clicked() {
qDebug() << program << arguments;
}
void lc::MainWindow::on_PBOpenFilesystem_clicked() {
// Determine the correct user to be used
QString * userToBeUsed = nullptr;
if ( ui->RBUseUserRoot->isChecked() ) {
userToBeUsed = new QString{ "root" };
} else {
userToBeUsed = new QString{ settings->userNameOnClients };
}
QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->OpenFilesystem( userToBeUsed );
}
}
delete userToBeUsed;
}
void lc::MainWindow::on_PBPrintPaymentFileManually_clicked() {
ManualPrintingSetup *manPrint = new ManualPrintingSetup{ this };
manPrint->setWindowFlags( Qt::Window );
@ -450,46 +332,6 @@ void lc::MainWindow::on_PBRunzLeaf_clicked() {
}
}
void lc::MainWindow::on_PBShowORSEE_clicked() {
lablib->ShowOrsee();
}
void lc::MainWindow::on_PBShowPreprints_clicked() {
lablib->ShowPreprints();
}
void lc::MainWindow::on_PBShutdown_clicked() {
// Confirmation dialog
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Confirm", "Really shutdown the selected clients?", QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::Yes) {
QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
// Do not shut down the server itself
if ( client->name == "self"){
QMessageBox::information(NULL, "Shutdown canceled", "It is not allowed to shutdown the server itself via labcontrol!");
} else {
client->Shutdown();
}
}
}
} else {
qDebug() << "Canceled shutting down the selected clients";
}
}
void lc::MainWindow::on_PBStartLocalzLeaf_clicked() {
LocalzLeafStarter *localzLeafStarter = new LocalzLeafStarter{ this };
localzLeafStarter->setWindowFlags( Qt::Window );
localzLeafStarter->show();
connect( localzLeafStarter, &LocalzLeafStarter::LocalzLeafRequested,
this, &MainWindow::StartLocalzLeaf );
connect( localzLeafStarter, SIGNAL( LocalzLeafRequested( QString, QString, int ) ),
localzLeafStarter, SLOT( deleteLater() ) );
}
void lc::MainWindow::on_RBUseLocalUser_toggled(bool checked) {
if ( checked ) {
qDebug() << "'RBUseLocalUser' got toggled.";
@ -599,10 +441,6 @@ void lc::MainWindow::SetupWidgets() {
"See the GNU General Public License for more details.\n\n"
"You should have received a copy of the GNU General Public License\n"
"along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.\n\n\n" );
// Fill settings tab
ui->LESettingsServerLocalzLeafSize->setText ( settings->localzLeafSize );
}
void lc::MainWindow::StartReceiptsHandler( QString argzTreeDataTargetPath,
@ -651,6 +489,82 @@ void lc::MainWindow::UpdateClientsTableView() {
/* Experiment tab functions */
void lc::MainWindow::on_PBBoot_clicked() {
QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->Boot();
}
}
}
void lc::MainWindow::on_PBChooseFile_clicked() {
QFileDialog *file_dialog = new QFileDialog{ this, tr( "Choose a file to beam" ), QDir::homePath() };
file_dialog->setFileMode( QFileDialog::Directory );
file_dialog->setOption( QFileDialog::DontUseNativeDialog, true );
file_dialog->setOption( QFileDialog::ReadOnly, true );
file_dialog->setOption( QFileDialog::ShowDirsOnly, true );
if(file_dialog->exec()) {
ui->LEFilePath->setText(file_dialog->selectedFiles().at(0));
qDebug() << "Chose file" << ui->LEFilePath->text() << "for beaming.";
}
else {
ui->LEFilePath->setText( tr( "File choosing cancelled" ) );
qDebug() << "File choosing cancelled";
}
delete file_dialog;
}
void lc::MainWindow::on_PBBeamFile_clicked() {
QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes();
const QString fileToBeam{ ui->LEFilePath->text() };
if(fileToBeam == ""){
QMessageBox::information(this, "Upload failed", "You didn't choose any folder to upload.");
} else {
//Iterate over the selected clients to upload the file
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->BeamFile( fileToBeam, &settings->pkeyPathUser, &settings->userNameOnClients );
}
}
// Inform the user about the path
QMessageBox::information(this, "Upload completed", "The folder was copied to all selected clients.\nThe path on every client is /home/ewfuser/media4ztree" + fileToBeam.mid(fileToBeam.lastIndexOf('/')) +".\nDon't forget to adjust the media path within zTree!");
}
}
void lc::MainWindow::on_PBShowORSEE_clicked() {
lablib->ShowOrsee();
}
void lc::MainWindow::on_PBShowPreprints_clicked() {
lablib->ShowPreprints();
}
void lc::MainWindow::on_PBShutdown_clicked() {
// Confirmation dialog
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Confirm", "Really shutdown the selected clients?", QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::Yes) {
QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
// Do not shut down the server itself
if ( client->name == "self"){
QMessageBox::information(NULL, "Shutdown canceled", "It is not allowed to shutdown the server itself via labcontrol!");
} else {
client->Shutdown();
}
}
}
} else {
qDebug() << "Canceled shutting down the selected clients";
}
}
void lc::MainWindow::on_CBWebcamChooser_activated( int argIndex ) {
if ( argIndex != 0 ) {
QString program{ settings->webcamDisplayCmd };
@ -732,6 +646,16 @@ void lc::MainWindow::on_PBStartzLeaf_clicked() {
}
}
void lc::MainWindow::on_PBStartLocalzLeaf_clicked() {
LocalzLeafStarter *localzLeafStarter = new LocalzLeafStarter{ this };
localzLeafStarter->setWindowFlags( Qt::Window );
localzLeafStarter->show();
connect( localzLeafStarter, &LocalzLeafStarter::LocalzLeafRequested,
this, &MainWindow::StartLocalzLeaf );
connect( localzLeafStarter, SIGNAL( LocalzLeafRequested( QString, QString, int ) ),
localzLeafStarter, SLOT( deleteLater() ) );
}
void lc::MainWindow::StartLocalzLeaf( QString argzLeafName, QString argzLeafVersion,
int argzTreePort ) {
if ( settings->tasksetCmd.isEmpty() || settings->wineCmd.isEmpty()
@ -877,6 +801,7 @@ void lc::MainWindow::on_PBStartSession_clicked() {
//Set port to +1
int newPort = ui->SBPort->text().toInt() + 1;
settings->SetChosenZTreePort(newPort);
ui->SBPort->setValue(newPort);
}
@ -893,6 +818,49 @@ void lc::MainWindow::on_PBKillzLeaf_clicked()
/* Admin tab functions */
void lc::MainWindow::on_PBOpenFilesystem_clicked() {
// Determine the correct user to be used
QString * userToBeUsed = nullptr;
if ( ui->RBUseUserRoot->isChecked() ) {
userToBeUsed = new QString{ "root" };
} else {
userToBeUsed = new QString{ settings->userNameOnClients };
}
QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->OpenFilesystem( userToBeUsed );
}
}
delete userToBeUsed;
}
void lc::MainWindow::on_PBExecute_clicked() {
// Get the command to be executed ...
QString command = ui->CBCommandToExecute->currentText();
// Set the correct public key
QString pkeyPathUser;
if ( ui->RBUseUserRoot->isChecked() ) {
pkeyPathUser = settings->pkeyPathRoot;
} else {
pkeyPathUser = settings->pkeyPathUser;
}
qDebug() << "Executing command" << command << " on chosen clients.";
QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->OpenTerminal( command, ui->RBUseUserRoot->isChecked() );
}
}
}
// Issue open terminal call
void lc::MainWindow::on_PBOpenTerminal_clicked() {
QString pkeyPathUser;
@ -909,11 +877,3 @@ void lc::MainWindow::on_PBOpenTerminal_clicked() {
}
}
}
/* Settings tab functions */
// Change settings temporarly call
void lc::MainWindow::on_PBChangeSettingsTemp_clicked()
{
settings->SetLocalzLeafSize( ui->LESettingsServerLocalzLeafSize->text() );
}

@ -129,9 +129,6 @@ private slots:
void on_CBReceiptsHeader_activated(int argIndex);
void on_ChBPrintanonymousreceipts_clicked();
void on_PBKillzLeaf_clicked();
/* Settings actions */
void on_PBChangeSettingsTemp_clicked();
};
}

@ -64,7 +64,7 @@
</font>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<property name="usesScrollButtons">
<bool>true</bool>
@ -487,7 +487,7 @@
<x>10</x>
<y>88</y>
<width>691</width>
<height>461</height>
<height>468</height>
</rect>
</property>
<layout class="QVBoxLayout" name="VLNewSession">
@ -707,6 +707,23 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>command line to be executed</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="PBStartzLeaf">
<property name="toolTip">
@ -778,6 +795,13 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Local zLeaf</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="HLLocalzLeaf">
<item>
@ -911,7 +935,7 @@
<item>
<widget class="QGroupBox" name="GBExecuteOnEveryClient">
<property name="title">
<string>Execute command on every client</string>
<string>Execute command on selected clients</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
@ -933,96 +957,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="TSettings">
<attribute name="title">
<string>Settings</string>
</attribute>
<widget class="QPushButton" name="PBChangeSettingsTemp">
<property name="geometry">
<rect>
<x>240</x>
<y>520</y>
<width>201</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Change settings temporarly</string>
</property>
</widget>
<widget class="QScrollArea" name="SASettings">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>691</width>
<height>501</height>
</rect>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="SAWCSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>675</width>
<height>499</height>
</rect>
</property>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>671</width>
<height>481</height>
</rect>
</property>
<layout class="QFormLayout" name="FLSettings">
<item row="0" column="0">
<widget class="QLabel" name="LSettingsServerSettings">
<property name="text">
<string>Server settings</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="LSettingsClientSettings">
<property name="text">
<string>Client settings</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="LSettingsServerLocalzLeafSize">
<property name="text">
<string>local_zleaf_size</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="LESettingsServerLocalzLeafSize"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="LSettingsServerIP">
<property name="text">
<string>server_ip</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="LESettingsServerIP"/>
</item>
</layout>
</widget>
</widget>
</widget>
</widget>
<widget class="QWidget" name="TInfo">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>

Loading…
Cancel
Save