Commit f4dc789c authored by Arturo Hernandez's avatar Arturo Hernandez

fix test value flow

parent f1245abd
......@@ -125,14 +125,21 @@ $(function() {
if (data.data){
$("#mensaje").text("Block " + data.data.block + " : " + (data.data.isValue ? ("V=" + data.data.value + " adr=" + data.data.value_adr) : data.data.string));
}else{
if (data.message != "OK")
$("#mensaje").removeClass('alert-success').addClass('alert-danger');
$("#mensaje").text(data.message);
console.log("trynig mes", data.message);
if (data.message != "OK"){
$("#mensaje").removeClass('alert-success').addClass('alert-danger');
return $.Deferred().reject({responseJSON:{message:data.message}});
}
}
}else{
let mess = data.error || data.message || "Error al recabar respuesta " + data.toString();
$("#mensaje").removeClass('alert-success').addClass('alert-danger');
$("#mensaje").text(data.error || data.message || "Error al recabar respuesta " + data.toString());
$("#mensaje").text(mess);
console.log("trynig errr");
return $.Deferred().reject({responseJSON:{message:mess}});
}
return $.Deferred().resolve("read ok");
}
function check_uiid(){
if ($("#uiid").text().trim().length == 0){
......@@ -153,11 +160,11 @@ $(function() {
}
function read_card_data(){
spin();
$.ajax('https://127.0.0.1:8000/api/read-card', {
return $.ajax('https://127.0.0.1:8000/api/read-card', {
method: 'GET',
data: {block: DEFAULT_BLOCK},
timeout: 2000
}).done(parse_data).fail(fail);
}).then(parse_data).fail(fail);
}
function init_card(){
let uiid = check_uiid();
......@@ -224,7 +231,7 @@ $(function() {
value : DEFAULT_TEST_VALUE_DELTA,
},
timeout: 2000 }
).done(parse_data).done(read_card_data).fail(fail);
).then(parse_data).then(read_card_data).fail(fail);
}
function decrement_value(){
let uiid = check_uiid();
......@@ -238,7 +245,7 @@ $(function() {
value : DEFAULT_TEST_VALUE_DELTA,
},
timeout: 2000 }
).done(parse_data).done(read_card_data).fail(fail);
).then(parse_data).then(read_card_data).fail(fail);
}
$("#btn1").click(function(){read_card()});
$("#btn2").click(function(){init_card()});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment