Skip to content

Commit

Permalink
loading bar added,image grid added & some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
diablo1408 committed Jan 2, 2021
2 parents 25e11e7 + f5e95ec commit 5bd2c55
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 191 deletions.
19 changes: 14 additions & 5 deletions controller/image/getGenre.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ const Vision = require("../../models/vision");


function compare( a, b ) {
if(a.label.length === b.label.length){return 0;}
return a.label.length > b.label.length;
if(a.label.length < b.label.length) return 1;
if(a.label.length > b.label.length) return -1;
return 0;
}

class GetGenre{
Expand All @@ -13,9 +14,17 @@ class GetGenre{
Vision.find({user_id : req.params.user_id})
.then((user) =>{
let labels = user[0].image_labels;
labels.sort(compare);
labels = labels.slice(0,5);
// console.log(labels);
labels.sort(compare);

// labels.forEach(element => {
// console.log(element.name,element.label.length);
// });


labels = labels.slice(0,6);

// console.log("asd",labels);
// return res.status(200);
return res.status(200).json(labels);
}
)
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/pages/MainPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ class MainPage extends React.Component {
Loading...
</button>
</div>


{this.state.isGenreDisplay ? (
<div className="card">

Expand Down Expand Up @@ -183,10 +185,11 @@ class MainPage extends React.Component {
{!!filteredImages.length ? `${filteredImages.length} ` : "0 "}
Images found.
</p>

<hr></hr>
<div className="row">


<hr/>



{!!filteredImages ? (
Expand All @@ -202,7 +205,7 @@ class MainPage extends React.Component {
: (
<h1 className="text-white">No Images</h1>
)}


<br />
<Pagination
Expand All @@ -211,7 +214,7 @@ class MainPage extends React.Component {
onPageChange={this.onPageChange}
currentPage={currentPage}
/>

</div>
</div>
</main>
<Footer />
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/Profile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ class Profile extends React.Component {
const { authMessage,userData} = this.props;
const { username, email, password, otp} = this.state.data;
const {errors} = this.state;
console.log("user",userData.user_image);
// console.log("user",userData);
if(localStorage.getItem('loggedIn') === 'false'){
return <Redirect to = {"/login"} />
}
}

let coverImage;

Expand Down
Loading

0 comments on commit 5bd2c55

Please sign in to comment.