Skip to content

Commit 8010fda

Browse files
authored
Use image timestamp instead of image index to show large view (#4591)
* Use image timestamp instead of image index to show large view * Fix failing test
1 parent bf86972 commit 8010fda

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

src/plugins/imagery/ImageryView.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export default class ImageryView {
1212

1313
show(element, isEditing, viewOptions) {
1414
let alternateObjectPath;
15-
let indexForFocusedImage;
15+
let focusedImageTimestamp;
1616
if (viewOptions) {
17-
indexForFocusedImage = viewOptions.indexForFocusedImage;
17+
focusedImageTimestamp = viewOptions.timestamp;
1818
alternateObjectPath = viewOptions.objectPath;
1919
}
2020

@@ -31,10 +31,10 @@ export default class ImageryView {
3131
},
3232
data() {
3333
return {
34-
indexForFocusedImage
34+
focusedImageTimestamp
3535
};
3636
},
37-
template: '<imagery-view :index-for-focused-image="indexForFocusedImage" ref="ImageryContainer"></imagery-view>'
37+
template: '<imagery-view :focused-image-timestamp="focusedImageTimestamp" ref="ImageryContainer"></imagery-view>'
3838

3939
});
4040
}

src/plugins/imagery/components/ImageryTimeView.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ export default {
119119
this.timeContext.off("bounds", this.updateViewBounds);
120120
}
121121
},
122-
expand(index) {
122+
expand(imageTimestamp) {
123123
const path = this.objectPath[0];
124124
this.previewAction.invoke([path], {
125-
indexForFocusedImage: index,
125+
timestamp: imageTimestamp,
126126
objectPath: this.objectPath
127127
});
128128
},
@@ -395,7 +395,7 @@ export default {
395395
//handle mousedown event to show the image in a large view
396396
imageWrapper.addEventListener('mousedown', (e) => {
397397
if (e.button === 0) {
398-
this.expand(index);
398+
this.expand(item.time);
399399
}
400400
});
401401

src/plugins/imagery/components/ImageryView.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export default {
201201
mixins: [imageryData],
202202
inject: ['openmct', 'domainObject', 'objectPath', 'currentView'],
203203
props: {
204-
indexForFocusedImage: {
204+
focusedImageTimestamp: {
205205
type: Number,
206206
default() {
207207
return undefined;
@@ -411,8 +411,11 @@ export default {
411411
watch: {
412412
imageHistorySize(newSize, oldSize) {
413413
let imageIndex;
414-
if (this.indexForFocusedImage !== undefined) {
415-
imageIndex = this.initFocusedImageIndex;
414+
if (this.focusedImageTimestamp !== undefined) {
415+
const foundImageIndex = this.imageHistory.findIndex(image => {
416+
return image.time === this.focusedImageTimestamp;
417+
});
418+
imageIndex = foundImageIndex > -1 ? foundImageIndex : newSize - 1;
416419
} else {
417420
imageIndex = newSize > 0 ? newSize - 1 : undefined;
418421
}
@@ -429,8 +432,7 @@ export default {
429432
},
430433
async mounted() {
431434
//We only need to use this till the user focuses an image manually
432-
if (this.indexForFocusedImage !== undefined) {
433-
this.initFocusedImageIndex = this.indexForFocusedImage;
435+
if (this.focusedImageTimestamp !== undefined) {
434436
this.isPaused = true;
435437
}
436438
@@ -701,10 +703,10 @@ export default {
701703
702704
if (thumbnailClick) {
703705
//We use the props till the user changes what they want to see
704-
this.initFocusedImageIndex = undefined;
706+
this.focusedImageTimestamp = undefined;
705707
}
706708
707-
if (this.isPaused && !thumbnailClick && this.initFocusedImageIndex === undefined) {
709+
if (this.isPaused && !thumbnailClick && this.focusedImageTimestamp === undefined) {
708710
this.nextImageIndex = focusedIndex;
709711
//this could happen if bounds changes
710712
if (this.focusedImageIndex > this.imageHistory.length - 1) {

src/plugins/imagery/pluginSpec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,10 @@ describe("The Imagery View Layouts", () => {
528528
const mouseDownEvent = createMouseEvent("mousedown");
529529
let imageWrapper = parent.querySelectorAll(`.c-imagery-tsv__image-wrapper`);
530530
imageWrapper[2].dispatchEvent(mouseDownEvent);
531-
532531
Vue.nextTick(() => {
532+
const timestamp = imageWrapper[2].id.replace('wrapper-', '');
533533
expect(componentView.previewAction.invoke).toHaveBeenCalledWith([componentView.objectPath[0]], {
534-
indexForFocusedImage: 2,
534+
timestamp: Number(timestamp),
535535
objectPath: componentView.objectPath
536536
});
537537
done();

0 commit comments

Comments
 (0)