mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-24 14:23:36 -05:00
improved UI for jsonapi and webui pages
This commit is contained in:
parent
9007d266a8
commit
1b8f137dee
@ -141,6 +141,7 @@ void JsonApiServer::start(uint16_t port, const std::string& bindAddress, const s
|
|||||||
mBindAddress = bindAddress;
|
mBindAddress = bindAddress;
|
||||||
mNewAccessRequestCallback = callback;
|
mNewAccessRequestCallback = callback;
|
||||||
|
|
||||||
|
std::cerr << "(II) Srtating Json API on port " << port << ", address " << bindAddress << std::endl;
|
||||||
RsThread::start("JsonApiServer");
|
RsThread::start("JsonApiServer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,14 +32,26 @@
|
|||||||
JsonApiPage::JsonApiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
|
JsonApiPage::JsonApiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
connect( ui.addTokenPushButton, &QPushButton::clicked,
|
connect( ui.enableCheckBox, SIGNAL(toggled(bool)), this, SLOT(enableJsonApi(bool)));
|
||||||
this, &JsonApiPage::addTokenClicked);
|
connect( ui.addTokenPushButton, SIGNAL(clicked()), this, SLOT(addTokenClicked()));
|
||||||
connect( ui.removeTokenPushButton, &QPushButton::clicked,
|
connect( ui.removeTokenPushButton, SIGNAL(clicked()), this, SLOT(removeTokenClicked() ));
|
||||||
this, &JsonApiPage::removeTokenClicked );
|
connect( ui.tokensListView, SIGNAL(clicked()), this, SLOT(tokenClicked() ));
|
||||||
connect( ui.tokensListView, &QListView::clicked,
|
connect( ui.applyConfigPushButton, SIGNAL(clicked()), this, SLOT(onApplyClicked() ));
|
||||||
this, &JsonApiPage::tokenClicked );
|
}
|
||||||
connect( ui.applyConfigPushButton, &QPushButton::clicked,
|
|
||||||
this, &JsonApiPage::onApplyClicked );
|
void JsonApiPage::enableJsonApi(bool checked)
|
||||||
|
{
|
||||||
|
ui.addTokenPushButton->setEnabled(checked);
|
||||||
|
ui.applyConfigPushButton->setEnabled(checked);
|
||||||
|
ui.removeTokenPushButton->setEnabled(checked);
|
||||||
|
ui.tokensListView->setEnabled(checked);
|
||||||
|
|
||||||
|
Settings->setJsonApiEnabled(checked);
|
||||||
|
|
||||||
|
if(checked)
|
||||||
|
checkStartJsonApi();
|
||||||
|
else
|
||||||
|
checkShutdownJsonApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JsonApiPage::updateParams(QString &errmsg)
|
bool JsonApiPage::updateParams(QString &errmsg)
|
||||||
@ -64,19 +76,13 @@ bool JsonApiPage::updateParams(QString &errmsg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString listenAddress = ui.listenAddressLineEdit->text();
|
QString listenAddress = ui.listenAddressLineEdit->text();
|
||||||
|
|
||||||
if(listenAddress != Settings->getJsonApiListenAddress())
|
if(listenAddress != Settings->getJsonApiListenAddress())
|
||||||
{
|
{
|
||||||
Settings->setJsonApiListenAddress(listenAddress);
|
Settings->setJsonApiListenAddress(listenAddress);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(changed)
|
|
||||||
{
|
|
||||||
checkShutdownJsonApi();
|
|
||||||
ok = checkStartJsonApi();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ok) errmsg = "Could not start JSON API Server!";
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,8 +104,6 @@ QString JsonApiPage::helpText() const { return ""; }
|
|||||||
|
|
||||||
/*static*/ bool JsonApiPage::checkStartJsonApi()
|
/*static*/ bool JsonApiPage::checkStartJsonApi()
|
||||||
{
|
{
|
||||||
checkShutdownJsonApi();
|
|
||||||
|
|
||||||
if(Settings->getJsonApiEnabled())
|
if(Settings->getJsonApiEnabled())
|
||||||
JsonApiServer::instance().start( Settings->getJsonApiPort(), Settings->getJsonApiListenAddress().toStdString() );
|
JsonApiServer::instance().start( Settings->getJsonApiPort(), Settings->getJsonApiListenAddress().toStdString() );
|
||||||
|
|
||||||
@ -141,8 +145,10 @@ QString JsonApiPage::helpText() const { return ""; }
|
|||||||
|
|
||||||
void JsonApiPage::onApplyClicked(bool)
|
void JsonApiPage::onApplyClicked(bool)
|
||||||
{
|
{
|
||||||
QString errmsg;
|
// restart
|
||||||
updateParams(errmsg);
|
|
||||||
|
checkShutdownJsonApi();
|
||||||
|
checkStartJsonApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonApiPage::addTokenClicked(bool)
|
void JsonApiPage::addTokenClicked(bool)
|
||||||
|
@ -53,6 +53,7 @@ public slots:
|
|||||||
void addTokenClicked(bool);
|
void addTokenClicked(bool);
|
||||||
void removeTokenClicked(bool);
|
void removeTokenClicked(bool);
|
||||||
void tokenClicked(const QModelIndex& index);
|
void tokenClicked(const QModelIndex& index);
|
||||||
|
void enableJsonApi(bool checked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::JsonApiPage ui; /// Qt Designer generated object
|
Ui::JsonApiPage ui; /// Qt Designer generated object
|
||||||
|
@ -50,8 +50,6 @@ WebuiPage::WebuiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/)
|
|||||||
connect(ui.password_LE, SIGNAL(textChanged(QString)), this, SLOT(onPasswordValueChanged(QString)));
|
connect(ui.password_LE, SIGNAL(textChanged(QString)), this, SLOT(onPasswordValueChanged(QString)));
|
||||||
connect(ui.startWebBrowser_PB, SIGNAL(clicked()), this, SLOT(onStartWebBrowserClicked()));
|
connect(ui.startWebBrowser_PB, SIGNAL(clicked()), this, SLOT(onStartWebBrowserClicked()));
|
||||||
connect(ui.webInterfaceFilesDirectory_PB, SIGNAL(clicked()), this, SLOT(selectWebInterfaceDirectory()));
|
connect(ui.webInterfaceFilesDirectory_PB, SIGNAL(clicked()), this, SLOT(selectWebInterfaceDirectory()));
|
||||||
|
|
||||||
checkStartWebui();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebuiPage::~WebuiPage()
|
WebuiPage::~WebuiPage()
|
||||||
@ -159,6 +157,8 @@ void WebuiPage::onEnableCBClicked(bool checked)
|
|||||||
ui.startWebBrowser_PB->setEnabled(checked);
|
ui.startWebBrowser_PB->setEnabled(checked);
|
||||||
QString S;
|
QString S;
|
||||||
|
|
||||||
|
Settings->setWebinterfaceEnabled(checked);
|
||||||
|
|
||||||
if(checked)
|
if(checked)
|
||||||
checkStartWebui();
|
checkStartWebui();
|
||||||
else
|
else
|
||||||
|
@ -572,6 +572,10 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
|||||||
|
|
||||||
notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt.
|
notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt.
|
||||||
|
|
||||||
|
#ifdef RS_WEBUI
|
||||||
|
WebuiPage::checkStartWebui(); // normally we should rather save the UI flags internally to p3webui
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef RS_JSONAPI
|
#ifdef RS_JSONAPI
|
||||||
JsonApiPage::checkStartJsonApi();
|
JsonApiPage::checkStartJsonApi();
|
||||||
#endif // RS_JSONAPI
|
#endif // RS_JSONAPI
|
||||||
|
Loading…
Reference in New Issue
Block a user