mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-21 23:41:01 +00:00
Adding a notification after sending
This commit is contained in:
parent
130aaecb76
commit
b8f41c8d94
2 changed files with 31 additions and 1 deletions
|
@ -613,6 +613,13 @@ def create_app(args):
|
|||
def spec():
|
||||
return jsonify(swag)
|
||||
|
||||
|
||||
@app.route("/suggest", methods=["POST"])
|
||||
@limiter.exempt
|
||||
def suggest():
|
||||
# TODO:
|
||||
return jsonify({"success": True})
|
||||
|
||||
SWAGGER_URL = "/docs" # URL for exposing Swagger UI (without trailing '/')
|
||||
API_URL = "/spec"
|
||||
|
||||
|
|
|
@ -511,6 +511,8 @@
|
|||
sendSuggestion: function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var self = this;
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
self.transRequest = request;
|
||||
|
||||
|
@ -520,7 +522,28 @@
|
|||
data.append("source", self.sourceLang);
|
||||
data.append("target", self.targetLang);
|
||||
|
||||
request.open('POST', BaseUrl + '/translate', true);
|
||||
request.open('POST', BaseUrl + '/suggest', true);
|
||||
request.onload = function() {
|
||||
try{
|
||||
var res = JSON.parse(this.response);
|
||||
if (res.success){
|
||||
M.toast({html: 'Thanks for your correction.'})
|
||||
self.closeSuggestTranslation(e)
|
||||
}else{
|
||||
throw new Error(res.error || "Unknown error");
|
||||
}
|
||||
}catch(e){
|
||||
self.error = e.message;
|
||||
self.closeSuggestTranslation(e)
|
||||
}
|
||||
};
|
||||
|
||||
request.onerror = function() {
|
||||
self.error = "Error while calling /suggest";
|
||||
self.loadingTranslation = false;
|
||||
};
|
||||
|
||||
request.send(data);
|
||||
},
|
||||
deleteText: function(e){
|
||||
e.preventDefault();
|
||||
|
|
Loading…
Reference in a new issue