mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-09-12 07:30:16 +02:00
Adding a notification after sending
This commit is contained in:
parent
130aaecb76
commit
b8f41c8d94
@ -613,6 +613,13 @@ def create_app(args):
|
|||||||
def spec():
|
def spec():
|
||||||
return jsonify(swag)
|
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 '/')
|
SWAGGER_URL = "/docs" # URL for exposing Swagger UI (without trailing '/')
|
||||||
API_URL = "/spec"
|
API_URL = "/spec"
|
||||||
|
|
||||||
|
@ -511,6 +511,8 @@
|
|||||||
sendSuggestion: function(e) {
|
sendSuggestion: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
var request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
self.transRequest = request;
|
self.transRequest = request;
|
||||||
|
|
||||||
@ -520,7 +522,28 @@
|
|||||||
data.append("source", self.sourceLang);
|
data.append("source", self.sourceLang);
|
||||||
data.append("target", self.targetLang);
|
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){
|
deleteText: function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
Loading…
Reference in New Issue
Block a user