mirror of
https://github.com/FAUSheppy/speech-server-client-qt
synced 2025-12-06 00:41:35 +01:00
implement clear cache option after context change
This commit is contained in:
@@ -99,6 +99,16 @@ void ServerConfig::addNewPP(){
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConfig::askFlushServerCache(){
|
||||
QMessageBox::StandardButton reply;
|
||||
reply = QMessageBox::question(this, "Server Cache",
|
||||
"Sollen alte Transcripte auf dem Server, die ohne diese Konfiguration erstellt wurden gelöscht werden?",
|
||||
QMessageBox::Yes|QMessageBox::No);
|
||||
if (reply == QMessageBox::Yes) {
|
||||
sc->flushCache();
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConfig::addNewContext()
|
||||
{
|
||||
QStringList *sl = new QStringList();
|
||||
@@ -112,6 +122,7 @@ void ServerConfig::addNewContext()
|
||||
auto lineEdit = static_cast<QLineEdit*>(wl->at(0));
|
||||
if(!lineEdit->text().isEmpty()){
|
||||
sc->submitSpeechContextPhraseChange(lineEdit->text());
|
||||
askFlushServerCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,10 +148,26 @@ void ServerConfig::finishedRequest(QNetworkReply *reply){
|
||||
|
||||
QString addPP = sc->buildURLFromLocation(PP_EDIT);
|
||||
QString addContext = sc->buildURLFromLocation(CONTEXT_EDIT);
|
||||
QString flushCache = sc->buildURLFromLocation(FLUSH_SERVER_CACHE);
|
||||
|
||||
if(QString::compare(reply->url().toString(), addPP) == 0){
|
||||
sc->getUnifiedServerConfig();
|
||||
}else if(QString::compare(reply->url().toString(), addContext) == 0){
|
||||
sc->getUnifiedServerConfig();
|
||||
}else if(QString::compare(reply->url().toString(), flushCache) == 0){
|
||||
qDebug("WTF");
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Server Cache Gelöscht");
|
||||
QJsonObject jsonFlushCache = QJsonDocument::fromJson(reply->readAll()).object();
|
||||
QJsonArray removals = jsonFlushCache["removals"].toArray();
|
||||
QString display = "";
|
||||
for(int i = 0; i < removals.size(); i++){
|
||||
display += removals[i].toString();
|
||||
display += "<br>";
|
||||
}
|
||||
msgBox.setInformativeText(display);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
}else{
|
||||
/* this is the unified server config query */
|
||||
/* get filename and tracking id from replay */
|
||||
|
||||
@@ -30,6 +30,7 @@ private:
|
||||
QTableWidget* ppTable;
|
||||
QTableWidget* contextTable;
|
||||
ServerConnection* sc;
|
||||
void askFlushServerCache();
|
||||
};
|
||||
|
||||
#endif // SERVERCONFIG_H
|
||||
|
||||
@@ -149,3 +149,10 @@ void ServerConnection::getUnifiedServerConfig(){
|
||||
request.setRawHeader(AUTH_HEADER_NAME, authHeaderData);
|
||||
networkManager->get(request);
|
||||
}
|
||||
|
||||
void ServerConnection::flushCache(){
|
||||
QUrl serviceUrl = QUrl(buildURLFromLocation(QString(FLUSH_SERVER_CACHE)));
|
||||
QNetworkRequest request(serviceUrl);
|
||||
request.setRawHeader(AUTH_HEADER_NAME, authHeaderData);
|
||||
networkManager->get(request);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
void getSpeechContextPhrases();
|
||||
void getUnifiedServerConfig();
|
||||
QString buildURLFromLocation(const char *location);
|
||||
void flushCache();
|
||||
public slots:
|
||||
void queryStatusAll();
|
||||
private slots:
|
||||
|
||||
Reference in New Issue
Block a user