Skip to content

Commit 43525c9

Browse files
author
Hooram Nam
committed
necessary changes for hooram/ownphotos@8a13cea
1 parent 16168e2 commit 43525c9

File tree

13 files changed

+163
-46
lines changed

13 files changed

+163
-46
lines changed

src/actions/photosActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export function setPhotosPublic(image_hashes, val_public) {
162162
// console.log(image_hashes.map(ih=>{return serverAddress+'/media/photos/'+ih+'.jpg'}).join(' '))
163163
const linksToCopy = image_hashes
164164
.map(ih => {
165-
return serverAddress + "/media/photos/" + ih + ".jpg";
165+
return serverAddress.slice(2,serverAddress.length) + "/media/photos/" + ih + ".jpg";
166166
})
167167
.join(" ");
168168

src/actions/searchActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function searchPhotos(query) {
1515
.then((response) => {
1616
var groupedByDate = _.groupBy(response.data.results,(el)=>{
1717
if (el.exif_timestamp) {
18-
return moment(el.exif_timestamp).format('YYYY-MM-DD')
18+
return moment.utc(el.exif_timestamp).format('YYYY-MM-DD')
1919
} else {
2020
return "No Timestamp"
2121
}

src/actions/utilActions.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ export function fetchJobList(page,page_size=10) {
1818
}
1919
}
2020

21+
export function deleteJob(job_id,page=1,page_size=10) {
22+
return function(dispatch) {
23+
dispatch({ type: "DELETE_JOB" })
24+
Server.delete(`jobs/${job_id}`)
25+
.then(response=>{
26+
dispatch(fetchJobList(page,page_size))
27+
dispatch({ type: 'DELETE_JOB_FULFILLED', payload: response.data })
28+
})
29+
.catch(error=>{
30+
dispatch({ type: 'DELETE_JOB_REJECTED', payload: error})
31+
})
32+
}
33+
}
34+
2135

2236
export function setSiteSettings(siteSettings) {
2337
return function(dispatch) {
@@ -189,6 +203,7 @@ export function fetchWorkerAvailability(prevRunningJob) {
189203
}
190204
if (prevRunningJob.job_type_str.toLowerCase() === "scan photos") {
191205
dispatch(fetchDateAlbumsPhotoHashList());
206+
dispatch(rebuildSimilarityIndex())
192207
}
193208
}
194209

@@ -435,3 +450,16 @@ export function fetchWordCloud() {
435450
});
436451
};
437452
}
453+
454+
export function rebuildSimilarityIndex() {
455+
return function(dispatch) {
456+
dispatch({ type: "REBUILD_SIMILARITY_INDEX" });
457+
Server.get(`rebuildfaissindex/`)
458+
.then(response => {
459+
dispatch({ type: "REBUILD_SIMILARITY_INDEX_FULFILLED", payload: response.data });
460+
})
461+
.catch(err => {
462+
dispatch({ type: "REBUILD_SIMILARITY_INDEX_REJECTED", payload: err });
463+
});
464+
};
465+
}

src/components/lightBox.js

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import styles from "../App.css";
5050
import Draggable from "react-draggable";
5151
import debounce from "lodash/debounce";
5252
import * as moment from "moment";
53+
import { Link } from "react-router-dom";
5354

5455
var topMenuHeight = 55; // don't change this
5556
var leftMenuWidth = 85; // don't change this
@@ -100,7 +101,7 @@ export class LightBox extends Component {
100101
console.log("light box has got main photo detail");
101102
var mainSrc =
102103
serverAddress +
103-
"/media/photos/" +
104+
"/media/thumbnails_big/" +
104105
this.props.idx2hash.slice(this.props.lightboxImageIndex)[0] +
105106
".jpg";
106107
var mainSrcThumbnail =
@@ -126,15 +127,15 @@ export class LightBox extends Component {
126127
mainSrc={mainSrc}
127128
nextSrc={
128129
serverAddress +
129-
"/media/photos/" +
130+
"/media/thumbnails_big/" +
130131
this.props.idx2hash.slice(
131132
(this.props.lightboxImageIndex + 1) % this.props.idx2hash.length
132133
)[0] +
133134
".jpg"
134135
}
135136
prevSrc={
136137
serverAddress +
137-
"/media/photos/" +
138+
"/media/thumbnails_big/" +
138139
this.props.idx2hash.slice(
139140
(this.props.lightboxImageIndex - 1) % this.props.idx2hash.length
140141
)[0] +
@@ -266,7 +267,7 @@ export class LightBox extends Component {
266267
const val = !this.props.photoDetails[image_hash].public;
267268
this.props.dispatch(setPhotosPublic([image_hash], val));
268269
copyToClipboard(
269-
serverAddress + "/media/photos/" + image_hash + ".jpg"
270+
serverAddress.replace('//','') + "/media/thumbnails_big/" + image_hash + ".jpg"
270271
);
271272
}}
272273
color="black"
@@ -377,7 +378,7 @@ export class LightBox extends Component {
377378
<Icon name="calendar" /> Time Taken
378379
</Item.Header>
379380
<Item.Description>
380-
{moment(
381+
{moment.utc(
381382
this.props.photoDetails[
382383
this.props.idx2hash[this.props.lightboxImageIndex]
383384
].exif_timestamp
@@ -393,6 +394,9 @@ export class LightBox extends Component {
393394
</Item.Header>
394395
<Item.Description>
395396
<Breadcrumb
397+
as={Link}
398+
to={serverAddress+'/media/photos/'+this.props.idx2hash[this.props.lightboxImageIndex]+'.jpg'}
399+
target='_blank'
396400
divider="/"
397401
sections={this.props.photoDetails[
398402
this.props.idx2hash[this.props.lightboxImageIndex]
@@ -406,7 +410,10 @@ export class LightBox extends Component {
406410
</Item.Content>
407411
</Item>
408412

409-
<Item>
413+
{ this.props.photoDetails[
414+
this.props.idx2hash[this.props.lightboxImageIndex]
415+
].people.length > 0 &&
416+
(<Item>
410417
<Item.Content verticalAlign="middle">
411418
<Item.Header>
412419
<Icon name="users" /> People
@@ -439,9 +446,14 @@ export class LightBox extends Component {
439446
</Label.Group>
440447
</Item.Description>
441448
</Item.Content>
442-
</Item>
449+
</Item>)
450+
}
443451

444-
<Item>
452+
{
453+
this.props.photoDetails[
454+
this.props.idx2hash[this.props.lightboxImageIndex]
455+
].search_location &&
456+
(<Item>
445457
<Item.Content verticalAlign="middle">
446458
<Item.Header>
447459
<Icon name="point" /> Location
@@ -454,7 +466,8 @@ export class LightBox extends Component {
454466
}
455467
</Item.Description>
456468
</Item.Content>
457-
</Item>
469+
</Item>)
470+
}
458471

459472
<div
460473
style={{
@@ -625,6 +638,28 @@ export class LightBox extends Component {
625638
</Item.Description>
626639
</Item.Content>
627640
</Item>
641+
<Item>
642+
<Item.Content verticalAlign="middle">
643+
<Item.Header>
644+
<Icon name="images"/>Similar Photos
645+
</Item.Header>
646+
<Item.Description>
647+
<Image.Group>
648+
{
649+
this.props.photoDetails[
650+
this.props.idx2hash[
651+
this.props.lightboxImageIndex
652+
]
653+
].similar_photos.slice(0,30).map(el=>(
654+
<Image width={95} height={95}
655+
src={serverAddress+"/media/square_thumbnails_small/"+el.image_hash+".jpg"}/>
656+
))
657+
}
658+
</Image.Group>
659+
</Item.Description>
660+
</Item.Content>
661+
</Item>
662+
628663
</Item.Group>
629664
</div>
630665
</div>

src/layouts/AdminPage.js

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import {
2222
Dropdown,
2323
Popup,
2424
Divider,
25-
Pagination
25+
Pagination,
26+
2627
} from "semantic-ui-react";
2728
import { connect } from "react-redux";
2829
import { Link } from "react-router-dom";
@@ -43,6 +44,7 @@ import {
4344
updateUser,
4445
fetchNextcloudDirectoryTree,
4546
fetchJobList,
47+
deleteJob,
4648
fetchUserList,
4749
fetchDirectoryTree,
4850
manageUpdateUser
@@ -155,7 +157,7 @@ export class AdminPage extends Component {
155157
/>
156158
</Header>
157159

158-
<Table compact>
160+
<Table compact celled>
159161
<Table.Header>
160162
<Table.Row>
161163
<Table.HeaderCell>Username</Table.HeaderCell>
@@ -247,22 +249,33 @@ class JobList extends Component {
247249
}
248250
}
249251

252+
253+
250254
render() {
251255
return (
252256
<div>
253-
<Table compact attached="top">
257+
<Table compact attached="top" celled>
254258
<Table.Header>
255259
<Table.Row>
256260
<Table.HeaderCell>Status</Table.HeaderCell>
257261
<Table.HeaderCell>Job Type</Table.HeaderCell>
258-
<Table.HeaderCell>Time Started</Table.HeaderCell>
259-
<Table.HeaderCell>Time Finished</Table.HeaderCell>
262+
<Table.HeaderCell width={5}>Progress</Table.HeaderCell>
263+
<Table.HeaderCell>Started</Table.HeaderCell>
260264
<Table.HeaderCell>Duration</Table.HeaderCell>
261265
<Table.HeaderCell>Started By</Table.HeaderCell>
266+
<Table.HeaderCell>Delete</Table.HeaderCell>
262267
</Table.Row>
263268
</Table.Header>
264269
<Table.Body>
265270
{this.props.jobList.map(job => {
271+
let progressPerc = 0
272+
if (job.result.progress) {
273+
progressPerc = job.result.progress.current.toFixed()/job.result.progress.target*100
274+
}
275+
if (job.finished && !job.failed){
276+
progressPerc = 100
277+
}
278+
const jobSuccess = job.finished && !job.failed
266279
return (
267280
<Table.Row
268281
key={job.job_id}
@@ -282,19 +295,22 @@ class JobList extends Component {
282295
</Table.Cell>
283296
<Table.Cell>{job.job_type_str}</Table.Cell>
284297
<Table.Cell>
285-
{moment(job.started_at).format("YYYY-MM-DD") +
286-
" (" +
287-
moment(job.started_at).fromNow() +
288-
")"}
298+
{job.result.progress ? (
299+
<Progress
300+
indicating
301+
size='small'
302+
progress='ratio'
303+
value={job.result.progress.current}
304+
total={job.result.progress.target}
305+
active={!job.finished}
306+
success={jobSuccess}>
307+
{(job.result.progress.current.toFixed(2)/job.result.progress.target).toFixed(2)*100}%
308+
</Progress>) : null}
289309
</Table.Cell>
290310
<Table.Cell>
291-
{job.finished_at
292-
? moment(job.finished_at).format("YYYY-MM-DD") +
293-
" (" +
294-
moment(job.finished_at).fromNow() +
295-
")"
296-
: "still running..."}
311+
{moment(job.started_at).fromNow()}
297312
</Table.Cell>
313+
298314
<Table.Cell>
299315
{job.finished
300316
? moment
@@ -305,6 +321,19 @@ class JobList extends Component {
305321
: "still running..."}
306322
</Table.Cell>
307323
<Table.Cell>{job.started_by.username}</Table.Cell>
324+
<Table.Cell>
325+
<Popup
326+
trigger={
327+
<Button
328+
onClick={()=>{
329+
this.props.dispatch(
330+
deleteJob(job.id, this.state.activatePage, this.state.pageSize)
331+
)}}
332+
color='red' size='tiny'>
333+
Remove
334+
</Button>}
335+
content="Does not actually stop the job, only removes this entry from DB. Use only in cases when you know that a job failed ungracefully, by inspecting the logs, etc."/>
336+
</Table.Cell>
308337
</Table.Row>
309338
);
310339
})}

src/layouts/FaceDashboardV3.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,12 @@ class ModalPersonEdit extends Component {
117117
this.props.labeledFacesList
118118
);
119119

120-
var selectedImageSrcs = this.props.selectedFaces.map(faceID => {
121-
return allFaces.filter(face => face.id === faceID)[0].image;
120+
var selectedImageIDs = this.props.selectedFaces.map(faceID => {
121+
const res = allFaces.filter(face => face.id === faceID)[0].image;
122+
const splitBySlash = res.split('/')
123+
console.log(splitBySlash[splitBySlash.length-1])
124+
const faceImageID = splitBySlash[splitBySlash.length-1]
125+
return faceImageID
122126
});
123127
return (
124128
<Modal
@@ -146,8 +150,10 @@ class ModalPersonEdit extends Component {
146150
style={{ height: 100, padding: 5, height: 50, overflowY: "hidden" }}
147151
>
148152
<Image.Group>
149-
{selectedImageSrcs.map(image => (
150-
<SecuredImageJWT key={'selected_image'+image} height={40} width={40} src={image} />
153+
{selectedImageIDs.map(image => (
154+
<SecuredImageJWT
155+
key={'selected_image'+image}
156+
height={40} width={40} src={serverAddress + '/media/faces/' +image} />
151157
))}
152158
</Image.Group>
153159
</div>

src/layouts/ReusablePhotoListView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ export class PhotoListView extends Component {
501501
setPhotosPublic([cell.image_hash], true)
502502
);
503503
copyToClipboard(
504-
serverAddress +
504+
serverAddress.replace('//','') +
505505
"/media/photos/" +
506506
cell.image_hash +
507507
".jpg"
@@ -1048,7 +1048,7 @@ export class PhotoListView extends Component {
10481048
);
10491049
const linksToCopy = this.state.selectedImageHashes
10501050
.map(
1051-
ih => serverAddress + "/media/photos/" + ih + ".jpg"
1051+
ih => serverAddress.replace('//','') + "/media/photos/" + ih + ".jpg"
10521052
)
10531053
.join("\n");
10541054
copyToClipboard(linksToCopy);

src/layouts/UserPublicPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class UserPublicPage extends Component {
4141
var t0 = performance.now();
4242
var groupedByDate = _.groupBy(photos, el => {
4343
if (el.exif_timestamp) {
44-
return moment(el.exif_timestamp).format("YYYY-MM-DD");
44+
return moment.utc(el.exif_timestamp).format("YYYY-MM-DD");
4545
} else {
4646
return "No Timestamp";
4747
}

src/layouts/albumPersonGallery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class AlbumPersonGallery extends Component {
5555
var t0 = performance.now();
5656
var groupedByDate = _.groupBy(photos,(el)=>{
5757
if (el.exif_timestamp) {
58-
return moment(el.exif_timestamp).format('YYYY-MM-DD')
58+
return moment.utc(el.exif_timestamp).format('YYYY-MM-DD')
5959
} else {
6060
return "No Timestamp"
6161
}

src/layouts/albumPlaceGallery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class AlbumPlaceGallery extends Component {
5050
var t0 = performance.now();
5151
var groupedByDate = _.groupBy(photos,(el)=>{
5252
if (el.exif_timestamp) {
53-
return moment(el.exif_timestamp).format('YYYY-MM-DD')
53+
return moment.utc(el.exif_timestamp).format('YYYY-MM-DD')
5454
} else {
5555
return "No Timestamp"
5656
}

0 commit comments

Comments
 (0)