Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: pcbsd/pcbsd-projects
base: b98ade447b3d
...
head fork: pcbsd/pcbsd-projects
compare: eb30fda764a4
Checking mergeability… Don't worry, you can still create the pull request.
  • 5 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Commits on Oct 17, 2013
@beanpole135 beanpole135 Add output dialogs to the disk attach routine. af3a84e
@beanpole135 beanpole135 Add in the missing refresh.png image ef2151a
@beanpole135 beanpole135 Get the package/extract home dir working properly now. It will curren…
…tly exclude any *flashplayer* file, but I can narrow that down or add additional excludes later if necessary
b66d0f2
@beanpole135 beanpole135 Get the configuration UI plugged into the new main UI. Pretty much ev…
…erything is done now. Just need to test and make minor improvements as necessary.
4774e2c
@beanpole135 beanpole135 Add a "waitbox" to the GUI that will display a notification while a l…
…ong process is running.
eb30fda
View
32 lp-gui/LPGUtils.cpp
@@ -192,15 +192,21 @@ QString LPGUtils::packageHomeDir(QString username, QString packageName){
//qDebug() << "Start package dir:" << username << packageName;
if(!QFile::exists("/usr/home/"+username)){ return ""; }
//Check that the package has the right extension
- if(!packageName.endsWith(".tar.gz")){ packageName.append(".tar.gz"); }
+ if(!packageName.endsWith(".home.tar.gz")){ packageName.append(".home.tar.gz"); }
//Generate any additional files to be contained in the package
//Generate the command
QString cmd = "tar -czf /usr/home/"+packageName+" -C /usr/home "+username;
+ //Create the exclude list and skip these files
+ QStringList excludes;
+ excludes << "*flashplayer*"; //Don't overwrite the flash plugin
+ for(int i=0; i<excludes.length(); i++){
+ cmd.replace("-czf /usr/home", " --exclude \'"+excludes[i]+"\' -czf /usr/home");
+ }
//Run the command
- //qDebug() << "Run command:" << cmd;
- LPBackend::runCmd(cmd);
+ qDebug() << "Package command:" << cmd;
+ system(cmd.toUtf8()); //need to be careful with the exclude syntax (quotes) so use system command
//qDebug() << "Command return:" << QString::number(ret);
//Check that the package was created
QString packagePath;
@@ -209,21 +215,27 @@ QString LPGUtils::packageHomeDir(QString username, QString packageName){
return packagePath;
}
-QString LPGUtils::checkPackageUserPath(QString packagePath){
+bool LPGUtils::checkPackageUserPath(QString packagePath, QString *user){
+ user->clear();
//Determine if the file exists
- if( !QFile::exists(packagePath) ){ return ""; }
+ if( !QFile::exists(packagePath) ){ return false; }
//Check the username of the home dir in the package
QStringList ret = LPBackend::getCmdOutput("tar -tvf "+packagePath);
- if(ret.isEmpty()){ return ""; }
- QString username = ret[0].section(" ",2,2,QString::SectionSkipEmpty);
- return username;
+ if(ret.isEmpty()){ return false; }
+ QString username = ret[0].section(" ",2,2,QString::SectionSkipEmpty).simplified();
+ QString dirname = ret[0].section(" ",8,8,QString::SectionSkipEmpty).section("/",0,0).simplified();
+ user->append(username); //additional output
+ //Now check for the user on the local system
+ //This is just a simple check that the user directory exists, and the user/directory are the same within the package
+ return (username == dirname && QFile::exists("/usr/home/"+dirname) );
}
bool LPGUtils::extractHomeDirPackage(QString packagePath){
//Determine if the file exists
if( !QFile::exists(packagePath) ){ return false; }
- //Now extract the archive in the home directory (no overwriting of existing files)
- QString cmd = "tar -xkf "+packagePath+" -C /usr/home";
+ //Now extract the archive in the home directory
+ QString cmd = "tar -xpf "+packagePath+" -C /usr/home";
+ qDebug() << "Extract command:" << cmd;
int ret = LPBackend::runCmd(cmd);
return (ret == 0);
}
View
2  lp-gui/LPGUtils.h
@@ -19,7 +19,7 @@ class LPGUtils{
static QStringList revertDir(QString oldPath, QString newPath); //copy a dir out of a snapshot
//Functions for packaging up a user's home directory and extracting it later
static QString packageHomeDir(QString username, QString packageName);
- static QString checkPackageUserPath(QString packagePath);
+ static bool checkPackageUserPath(QString packagePath, QString *user);
static bool extractHomeDirPackage(QString packagePath);
//Function to scan the system for available harddisks/devices
static QStringList listAvailableHardDisks();
View
122 lp-gui/LPMain.cpp
@@ -16,11 +16,7 @@ LPMain::LPMain(QWidget *parent) : QMainWindow(parent), ui(new Ui::LPMain){
//Create the filesystem model and tie it to the treewidget
fsModel = new QFileSystemModel(this);
fsModel->setReadOnly(true);
- //fsModel->setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot );
ui->treeView->setModel(fsModel);
- //Create the menu's for the special menu actions
-
-
//Connect the UI to all the functions
connect(ui->tool_refresh, SIGNAL(clicked()), this, SLOT(updatePoolList()) );
connect(ui->combo_pools, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTabs()) );
@@ -31,7 +27,6 @@ LPMain::LPMain(QWidget *parent) : QMainWindow(parent), ui(new Ui::LPMain){
connect(ui->check_hidden, SIGNAL(stateChanged(int)), this, SLOT(setFileVisibility()) );
connect(ui->push_restore, SIGNAL(clicked()), this, SLOT(restoreFiles()) );
connect(ui->push_configure, SIGNAL(clicked()), this, SLOT(openConfigGUI()) );
- connect(ui->push_configBackups, SIGNAL(clicked()), this, SLOT(openBackupGUI()) );
//Connect the Menu buttons
connect(ui->menuManage_Pool, SIGNAL(triggered(QAction*)), this, SLOT(menuAddPool(QAction*)) );
connect(ui->menuUnmanage_Pool, SIGNAL(triggered(QAction*)), this, SLOT(menuRemovePool(QAction*)) );
@@ -48,7 +43,8 @@ LPMain::LPMain(QWidget *parent) : QMainWindow(parent), ui(new Ui::LPMain){
connect(ui->action_newSnapshot, SIGNAL(triggered()), this, SLOT(menuNewSnapshot()) );
connect(ui->menuDelete_Snapshot, SIGNAL(triggered(QAction*)), this, SLOT(menuRemoveSnapshot(QAction*)) );
//Update the interface
- updatePoolList();
+ QTimer::singleShot(0,this,SLOT(updatePoolList()) );
+
//Make sure the status tab is shown initially
ui->tabWidget->setCurrentWidget(ui->tab_status);
}
@@ -74,6 +70,26 @@ void LPMain::showErrorDialog(QString title, QString message, QString errors){
MB.exec();
}
+void LPMain::showWaitBox(QString message){
+ if(waitBox == 0){
+ qDebug() << "New Wait Box";
+ waitBox = new QMessageBox(QMessageBox::NoIcon, tr("Please Wait"), message, QMessageBox::NoButton, this);
+ waitBox->setWindowModality(Qt::WindowModal);
+ }else{
+ qDebug() << "Update Wait Box:" << message;
+ waitBox->setText(message);
+ }
+ if(!waitBox->isVisible()){ waitBox->show(); waitBox->raise(); }
+ QCoreApplication::processEvents();
+}
+
+void LPMain::hideWaitBox(){
+ if(waitBox != 0){
+ if(waitBox->isVisible()){ waitBox->hide(); }
+ }
+
+}
+
// ==============
// PRIVATE SLOTS
// ==============
@@ -141,17 +157,18 @@ void LPMain::viewChanged(){
}
void LPMain::updateTabs(){
- qDebug() << "Update Tabs" << poolSelected;
+ //qDebug() << "Update Tabs" << poolSelected;
viewChanged();
ui->tabWidget->setEnabled(poolSelected);
ui->menuView->setEnabled(poolSelected);
ui->menuDisks->setEnabled(poolSelected);
ui->menuSnapshots->setEnabled(poolSelected);
ui->push_configure->setVisible(poolSelected);
- ui->push_configBackups->setVisible(poolSelected);
ui->action_SaveKeyToUSB->setEnabled(poolSelected);
if(poolSelected){
+ showWaitBox(tr("Loading zpool information"));
POOLDATA = LPGUtils::loadPoolData(ui->combo_pools->currentText());
+ hideWaitBox();
//Now list the status information
ui->label_status->setText(POOLDATA.poolStatus);
ui->label_numdisks->setText( QString::number(POOLDATA.harddisks.length()) );
@@ -288,7 +305,9 @@ void LPMain::restoreFiles(){
QStringList errors;
if(QFileInfo(filePath).isDir()){
//Is a directory
+ showWaitBox( QString(tr("Restoring Directory: %1")).arg(newFilePath) );
errors = LPGUtils::revertDir(filePath, newFilePath);
+ hideWaitBox();
if(!errors.isEmpty()){
qDebug() << "Failed Reversions:" << errors;
errors.prepend(tr("File destination(s) that could not be restored:")+"\n");
@@ -299,7 +318,9 @@ void LPMain::restoreFiles(){
}
}else{
//Just a single file
+ showWaitBox( QString(tr("Restoring file: %1")).arg(newFilePath) );
bool ok = LPGUtils::revertFile(filePath, newFilePath);
+ hideWaitBox();
if( !ok ){
qDebug() << "Failed Reversion:" << newFilePath;
errors << QString(tr("Snapshot file: %1")).arg(filePath);
@@ -316,12 +337,35 @@ void LPMain::restoreFiles(){
void LPMain::openConfigGUI(){
qDebug() << "Open Configuration UI";
-
-}
-
-void LPMain::openBackupGUI(){
- qDebug() << "Open Backup UI";
-
+ QString ds = ui->combo_pools->currentText();
+ if(ds.isEmpty()){ return; }
+ LPConfig CFG(this);
+ CFG.loadDataset(ds, LPBackend::listReplicationTargets().contains(ds));
+ CFG.exec();
+ //Now check for return values and update appropriately
+ bool change = false;
+ if(CFG.localChanged){
+ ui->statusbar->showMessage(QString(tr("Configuring dataset: %1")).arg(ds),0);
+ LPBackend::setupDataset(ds, CFG.localSchedule, CFG.localSnapshots);
+ ui->statusbar->clearMessage();
+ change = true;
+ }
+ if(CFG.remoteChanged){
+ change = true;
+ if(CFG.isReplicated){
+ ui->statusbar->showMessage(QString(tr("Configuring replication: %1")).arg(ds),0);
+ LPBackend::setupReplication(ds, CFG.remoteHost, CFG.remoteUser, CFG.remotePort, CFG.remoteDataset, CFG.remoteFreq);
+ QMessageBox::information(this,tr("Reminder"),tr("Don't forget to save your SSH key to a USB stick so that you can restore your system from the remote host later!!"));
+ }else{
+ ui->statusbar->showMessage(QString(tr("Removing replication: %1")).arg(ds),0);
+ LPBackend::removeReplication(ds);
+ }
+ ui->statusbar->clearMessage();
+ }
+ //Now update the UI if appropriate
+ if(change){
+ updateTabs();
+ }
}
// -----------------------------------------------
@@ -362,6 +406,7 @@ void LPMain::menuRemovePool(QAction *act){
if( QMessageBox::Yes == QMessageBox::question(this,tr("Verify Snapshot Deletion"),tr("Do you wish to remove the local snapshots for this dataset?")+"\n"+tr("WARNING: This is a permanant change that cannot be reversed"),QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){
//Remove all the snapshots
ui->statusbar->showMessage(QString(tr("%1: Removing snapshots")).arg(ds),0);
+ showWaitBox(tr("Removing snapshots"));
for(int i=0; i<snaps.length(); i++){
LPBackend::removeSnapshot(ds,snaps[i]);
}
@@ -371,13 +416,16 @@ void LPMain::menuRemovePool(QAction *act){
//Remove the dataset from life-preserver management
if(LPBackend::listReplicationTargets().contains(ds)){
ui->statusbar->showMessage(QString(tr("%1: Disabling Replication")).arg(ds),0);
+ showWaitBox(tr("Disabling Replication"));
LPBackend::removeReplication(ds);
ui->statusbar->clearMessage();
}
ui->statusbar->showMessage(QString(tr("%1: Disabling Life-Preserver Management")).arg(ds),0);
+ showWaitBox(tr("Removing Life Preserver Schedules"));
LPBackend::removeDataset(ds);
ui->statusbar->clearMessage();
updatePoolList();
+ hideWaitBox();
}
} //end check for empty ds
@@ -422,12 +470,14 @@ void LPMain::menuCompressHomeDir(QAction* act){
QString user = act->text();
qDebug() << "Compress Home Dir:" << user;
//Prompt for the package name
- QString pkgName = user+"-homedir-"+QDateTime::currentDateTime().toString("yyyyMMdd-hhmm");
+ QString pkgName = user+"-"+QDateTime::currentDateTime().toString("yyyyMMdd-hhmm");
bool ok;
pkgName = QInputDialog::getText(this, tr("Package Name"), tr("Name of the package to create:"), QLineEdit::Normal, pkgName, &ok);
if(!ok || pkgName.isEmpty() ){ return; } //cancelled
//Now create the package
+ showWaitBox(tr("Packaging home directory"));
QString pkgPath = LPGUtils::packageHomeDir(user, pkgName);
+ hideWaitBox();
//Now inform the user of the result
if(pkgPath.isEmpty()){
qDebug() << "No Package created";
@@ -440,7 +490,27 @@ void LPMain::menuCompressHomeDir(QAction* act){
void LPMain::menuExtractHomeDir(){
qDebug() << "Extract Home Dir";
-
+ //Get the file path from the user
+ QString filePath = QFileDialog::getOpenFileName(this,tr("Find Home Dir Package"), "/usr/home", tr("Home Dir Package (*.home.tar.gz)") );
+ if(filePath.isEmpty() || !QFile::exists(filePath)){ return; } //cancelled
+ //Now check if the user in the package is also on the system
+ QString username;
+ bool ok = LPGUtils::checkPackageUserPath(filePath, &username);
+ if(!ok){
+ QMessageBox::warning(this,tr("User Missing"),QString(tr("The user (%1) does not exist on this system. Please create this user first and then try again.")).arg(username) );
+ return;
+ }
+ //Now extract the package
+ showWaitBox(tr("Extracting Home Directory"));
+ ok = LPGUtils::extractHomeDirPackage(filePath);
+ hideWaitBox();
+ //Now report the results
+ if(ok){
+ QMessageBox::information(this,tr("Package Extracted"), QString(tr("The package was successfully extracted within %1")).arg("/usr/home/"+username) );
+ }else{
+ QMessageBox::warning(this, tr("Package Failure"), QString(tr("The package could not be extracted within %1")).arg("/usr/home/"+username) );
+ }
+
}
// ==== Disks Menu ====
@@ -460,12 +530,14 @@ void LPMain::menuAddDisk(){
QString disk = QInputDialog::getItem(this, tr("Attach New Disk"),tr("Detected Disks:"), adisks,0,false, &ok);
if( !ok || disk.isEmpty() ){ return; }
qDebug() << "Add Disk:" << disk << pool;
+ showWaitBox(tr("Attaching disk"));
ok = LPBackend::attachDisk(pool, disk);
+ hideWaitBox();
if(ok){
- QMessageBox::information(this,tr(""),tr(""));
+ QMessageBox::information(this,tr("Disk Attached"),QString(tr("Success: %1 was added to %2")).arg(disk,pool) );
QTimer::singleShot(0,this,SLOT(updateTabs()) );
}else{
- QMessageBox::warning(this,tr(""),tr(""));
+ QMessageBox::warning(this,tr("Disk Attach Error"),QString(tr("Failure: %1 could not be attached to %2.")).arg(disk,pool) );
}
}
@@ -477,7 +549,9 @@ void LPMain::menuRemoveDisk(QAction *act){
return; //cancelled
}
qDebug() << "Remove Disk:" << disk << pool;
+ showWaitBox(tr("Detaching disk"));
bool ok = LPBackend::detachDisk(pool, disk);
+ hideWaitBox();
if(ok){
QMessageBox::information(this,tr("Disk Removal Success"),QString(tr("Success: %1 was removed from %2")).arg(disk, pool) );
QTimer::singleShot(0,this,SLOT(updateTabs()) );
@@ -494,7 +568,9 @@ void LPMain::menuOfflineDisk(QAction *act){
return; //cancelled
}
qDebug() << "Offline Disk:" << disk << pool;
- bool ok = LPBackend::detachDisk(pool, disk);
+ showWaitBox(tr("Setting disk offline"));
+ bool ok = LPBackend::setDiskOffline(pool, disk);
+ hideWaitBox();
if(ok){
QMessageBox::information(this,tr("Disk Offline Success"),QString(tr("Success: %1 has been taken offline.")).arg(disk) );
QTimer::singleShot(0,this,SLOT(updateTabs()) );
@@ -511,7 +587,9 @@ void LPMain::menuOnlineDisk(QAction *act){
return; //cancelled
}
qDebug() << "Online Disk:" << disk << pool;
- bool ok = LPBackend::detachDisk(pool, disk);
+ showWaitBox(tr("Setting disk online"));
+ bool ok = LPBackend::setDiskOnline(pool, disk);
+ hideWaitBox();
if(ok){
QMessageBox::information(this,tr("Disk Online Success"),QString(tr("Success: %1 has been set online.")).arg(disk) );
QTimer::singleShot(0,this,SLOT(updateTabs()) );
@@ -528,7 +606,9 @@ void LPMain::menuStartScrub(){
}
qDebug() << "Start Scrub:" << pool;
QString cmd = "zpool scrub "+pool;
+ showWaitBox(tr("Trying to start a scrub"));
int ret = system(cmd.toUtf8());
+ hideWaitBox();
if(ret == 0){
//Now let te user know that one has been triggered
QMessageBox::information(this,tr("Scrub Started"),QString(tr("A scrub has just been started on %1")).arg(pool));
@@ -546,7 +626,9 @@ void LPMain::menuStopScrub(){
}
qDebug() << "Stop Scrub:" << pool;
QString cmd = "zpool scrub -s "+pool;
+ showWaitBox(tr("Trying to stop scrub"));
int ret = system(cmd.toUtf8());
+ hideWaitBox();
if(ret == 0){
//Now let te user know that one has been triggered
QMessageBox::information(this,tr("Scrub Stopped"),QString(tr("The scrub on %1 has been stopped.")).arg(pool));
View
6 lp-gui/LPMain.h
@@ -13,11 +13,13 @@
#include <QInputDialog>
#include <QDateTime>
#include <QTimer>
+#include <QFileDialog>
#include "LPBackend.h"
#include "LPContainers.h"
#include "LPGUtils.h"
#include "LPWizard.h"
+#include "LPConfig.h"
namespace Ui{
class LPMain;
@@ -38,8 +40,11 @@ public slots:
QFileSystemModel *fsModel;
bool poolSelected;
LPDataset POOLDATA;
+ QMessageBox *waitBox;
void showErrorDialog(QString title, QString message, QString errors);
+ void showWaitBox(QString message);
+ void hideWaitBox();
private slots:
void updatePoolList(); //re-load available pools
@@ -52,7 +57,6 @@ private slots:
void setFileVisibility();
void restoreFiles();
void openConfigGUI();
- void openBackupGUI();
// -- Menu Actions --
//File Menu
void menuAddPool(QAction*);
View
31 lp-gui/LPMain.ui
@@ -23,6 +23,9 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="tool_refresh">
+ <property name="statusTip">
+ <string>Refresh the UI</string>
+ </property>
<property name="text">
<string>...</string>
</property>
@@ -64,7 +67,7 @@
<item>
<widget class="QPushButton" name="push_configure">
<property name="statusTip">
- <string>Configure local data backup schedules</string>
+ <string>Configure snapshot and replication schedules</string>
</property>
<property name="text">
<string>Configure</string>
@@ -75,20 +78,6 @@
</property>
</widget>
</item>
- <item>
- <widget class="QPushButton" name="push_configBackups">
- <property name="statusTip">
- <string>Configure off-disk data backup solutions</string>
- </property>
- <property name="text">
- <string>Backups</string>
- </property>
- <property name="icon">
- <iconset resource="lPreserve.qrc">
- <normaloff>:/images/drive-removable-media.png</normaloff>:/images/drive-removable-media.png</iconset>
- </property>
- </widget>
- </item>
</layout>
</item>
<item>
@@ -265,6 +254,9 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="push_prevsnap">
+ <property name="statusTip">
+ <string>Select the previous (older) snapshot</string>
+ </property>
<property name="text">
<string/>
</property>
@@ -306,6 +298,9 @@
</item>
<item>
<widget class="QPushButton" name="push_nextsnap">
+ <property name="statusTip">
+ <string>Select the next (more recent) snapshot</string>
+ </property>
<property name="text">
<string/>
</property>
@@ -331,6 +326,9 @@
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="check_hidden">
+ <property name="statusTip">
+ <string>Display any hidden files/folders</string>
+ </property>
<property name="text">
<string>Show Hidden Files</string>
</property>
@@ -351,6 +349,9 @@
</item>
<item>
<widget class="QPushButton" name="push_restore">
+ <property name="statusTip">
+ <string>Restore the selected file/folder to the live system.</string>
+ </property>
<property name="text">
<string>Restore</string>
</property>
View
BIN  lp-gui/images/refresh.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

No commit comments for this range

Something went wrong with that request. Please try again.