Skip to content

Commit

Permalink
Updates to the code and also added shell script
Browse files Browse the repository at this point in the history
  • Loading branch information
VidyasagarMSC committed Jun 18, 2020
1 parent 7798001 commit c3ef47a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,6 @@ dist
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.pnp.*
.pnp.*

deploy.sh
11 changes: 8 additions & 3 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@ var upload = multer({
if (err) {
next(err);
}
if (req.files.length > 1) {
if (req.files.length === 0) {
res.send(
"Successfully uploaded " + req.files.length + " files to Object Storage"
"Upload an image..."
);
}
else{
else if (req.files.length > 1){
res.send(
"Successfully uploaded " + req.files.length + " files to Object Storage"
);
}
else {
res.send(
"Successfully uploaded " + req.files.length + " file to Object Storage"
);
}
Expand Down
18 changes: 15 additions & 3 deletions frontend/public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,16 @@ function readResults(){
success: function (response) {
console.log(response);
var data = JSON.parse(response.data);
//console.log(data);
console.log(data);
//var matched = $("#column-multiline footer").length;
$("p.card-footer-item").each(function (index) {
//console.log( index + ": " + $( this ).text() );
var id = $(this).attr("id");
//console.log(id);
var value = "results/" + id.toString() + ".json";
//console.log(value);
if(data[value] !== undefined) {
console.log(Object.keys(data).length);
if (Object.keys(data).length !== 0 && data[value] !== undefined) {
var result = data[value].images[0].classifiers[0].classes.sort(
function (a, b) {
return b.score - a.score;
Expand Down Expand Up @@ -165,6 +166,7 @@ function readResults(){
}
});
toggleTable();
$('.loader-wrapper').removeClass('is-active');
},
error: function (data) {
$("p.error").text(data.statusText + ":" + "Check logs for more info");
Expand Down Expand Up @@ -194,9 +196,19 @@ function readResults(){
url: "/items",
success: function (response) {
$("#column-multiline").empty();
//console.log(response);
console.log(response);
if(response.data.includes("error") ) {
showNotification("An error occurred, check your backend.", "is-danger");
$('.loader-wrapper').removeClass('is-active');
return false;
}
var data = JSON.parse(response.data);
console.log(data);

if(Object.keys(data).length === 0) {
$('.loader-wrapper').removeClass('is-active');
return false;
}
//var matched = $("#column-multiline footer").length;
//var imageElem = document.createElement('img');
// Just use the toString() method from your buffer instance
Expand Down

0 comments on commit c3ef47a

Please sign in to comment.