Skip to content

Commit

Permalink
/deploy sit
Browse files Browse the repository at this point in the history
  • Loading branch information
jbyrne committed Mar 28, 2024
1 parent 32cebd0 commit a6f954b
Showing 1 changed file with 18 additions and 110 deletions.
128 changes: 18 additions & 110 deletions src/jpl/dijit/GranulesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ define([

if(obj["Granule-Footprint"]){
on(btn, "click", function(evt) {
console.log('footprint click')
console.log('obj:', obj)
obj.footprint = !obj.footprint;
_context.gridStore.put(obj)
_context.updateStateStoreObj(obj);
Expand Down Expand Up @@ -751,118 +749,44 @@ define([

response.items.map(function(x) {
GranuleMetadata.convertFootprintAndImageFromCMR(x);
var currentGridStore = _context.gridStore.query()
var currentStateStore = _context.stateStore.query()
var relevantStateStoreObject = {}
var replacementGridGranuleAdded = false
var granule_id = x["meta"]["concept-id"];
for(var i=0; i<_context.stateStore.query().length; i++) {
var currentGridStoreContainsCurrentStateGranule = false
for(var j=0; j<currentGridStore.length; j++) {
if(currentGridStore[j]["meta"]["concept-id"] === currentStateStore[i]["meta"]["concept-id"]) {
currentGridStoreContainsCurrentStateGranule = true
}
}
if(granule_id === currentStateStore[i]["meta"]["concept-id"]) {
relevantStateStoreObject = currentStateStore[i]
}
if(!currentGridStoreContainsCurrentStateGranule && (currentStateStore[i].footprint || currentStateStore[i].preview)) {
_context.gridStore.put(currentStateStore[i])
replacementGridGranuleAdded = true
}
}
var fpState = relevantStateStoreObject.footprint
var previewState = relevantStateStoreObject.preview
console.log('startup state store: ', _context.stateStore.query())
console.log('fpState: ',fpState)

x["Granule-DatasetId"] = _context.datasetId;
x["Granule-Name"] = x["meta"]["native-id"];

x.footprint = fpState ? fpState : false;
x.preview = previewState ? previewState : false;
console.log(fpState)

x["Granule-StartTime"] = moment.utc(x["umm"]["TemporalExtent"]["RangeDateTime"]["BeginningDateTime"]);
x["Granule-StopTime"] = moment.utc(x["umm"]["TemporalExtent"]["RangeDateTime"]["EndingDateTime"]);

x["source"] = "cmr";
console.log('adding: ',x)
_context.gridStore.add(x)
});

// if visible footprint is not in the grid, remove it from list
// make sure that visible footprint has display set to true
var gridStoreList = this.gridStore.query()
var stateStoreList = this.stateStore.query()
var stateStoreItemsToRemove = []
var gridStoreItemsToUpdate = []

for(var i=0; i<stateStoreList.length; i++) {
var visibleFootprintInCurrentGrid = false
for(var j=0; j<gridStoreList.length; j++) {
if (stateStoreList[i]["meta"]["concept-id"] === gridStoreList[j]["meta"]["concept-id"]){
visibleFootprintInCurrentGrid = true
}
}
if(visibleFootprintInCurrentGrid) {
// update grid state to what is in state store
gridStoreItemsToUpdate.push(stateStoreList[i])
} else {
// remove item from state store
stateStoreItemsToRemove.push(stateStoreList[i])
}
}

console.log(stateStoreItemsToRemove)
for(var k=0; k<stateStoreItemsToRemove.length; k++) {
var objectToRemove = stateStoreItemsToRemove[k]
objectToRemove.footprint = false
console.log(stateStoreItemsToRemove[k]["Granule-Id"])
_context.stateStore.remove(objectToRemove["Granule-Id"])
_context.toggleFootprintDisplay(objectToRemove)
// _context.updateStateStoreObj(objectToRemove)
}

for(var l=0; l<gridStoreItemsToUpdate.length; l++) {
console.log(_context.stateStore.query())
console.log(_context.gridStore.query())
// var stateStoreItemId = stateStoreItemsToUpdate[l]["meta"]["concept-id"]
// var objectToUpdate = _context.stateStore.get(gridStoreItemId)
var objectToUpdate = gridStoreItemsToUpdate[l]
console.log('object to update: ', objectToUpdate)
// _context.gridStore.put(objectToUpdate)
// _context.toggleFootprintDisplay(objectToUpdate)
// _context.gridStore.put(objectToUpdate)
// _context.updateStateStoreObj(objectToUpdate);
// _context.toggleFootprintDisplay(objectToUpdate);
}
console.log('updated state store: ',_context.stateStore.query())
console.log('updated grid store: ',_context.gridStore.query())

// for (var j=0; j<gridStoreList.length; j++) {
// // go through current grid list
// var currentGridGranule = gridStoreList[j]
// var visibleFootprintInCurrentGrid = false
// for(var i=0; i<stateStoreList.length; i++) {
// // go through state store list
// // if current state granule is not in the grid, remove it from map
// console.log('CURRENT STATE STORE LIST GRANULE: ', stateStoreList[i])
// console.log(currentGridGranule["meta"]["concept-id"], stateStoreList[i]["meta"]["concept-id"])
// if (currentGridGranule["meta"]["concept-id"] === stateStoreList[i]["meta"]["concept-id"]){
// console.log('EQUALLLLLLLL')
// visibleFootprintInCurrentGrid = true
// }
// // var newObj = updatedVisibleFootprints[i]
// // newObj.footprint = true
// // console.log(newObj.footprint)
// // newUpdatedVisibleFootprints.push(newObj)
// }
// if (!visibleFootprintInCurrentGrid) {
// stateStoreItemsToRemove.push(gridStoreList[j])
// }
// var newObj = gridStoreList[j]
// newObj.footprint = visibleFootprintInCurrentGrid
// // _context.gridStore.put(newObj)
// console.log('OBJECT OBJECT: ',newObj)
// console.log('currentGridGranule.footprint: ', currentGridGranule.footprint)
// console.log('visibleFootprintInCurrentGrid: ',visibleFootprintInCurrentGrid)
// _context.updateStateStoreObj(newObj)
// _context.toggleFootprintDisplay(newObj)
// }
// TODO
// console.log('currentlyVisibleFootprints: ',currentlyVisibleFootprints)
// console.log('currentlyVisiblePreviews: ',currentlyVisiblePreviews)
// _context.toggleFootprints(newUpdatedVisibleFootprints, true, true)
// _context.togglePreviews(Object.values(currentlyVisiblePreviews), false, true)
if(!replacementGridGranuleAdded) {
_context.gridStore.add(x)
}
});

this.granulesInGrid = this.gridStore.query().length;

Expand Down Expand Up @@ -986,9 +910,6 @@ define([
},

toggleFootprintDisplay: function(obj) {
console.log("toggling footprint display")
console.log('state store: ', this.stateStore.query())
console.log('grid store: ', this.gridStore.query())
if (obj.footprint) {
// if (!this.footprintGraphics[obj["Granule-Id"]]) {
var rgb = this.hexToRgb(this.datasetColor);
Expand All @@ -1006,21 +927,14 @@ define([
}
},

toggleFootprints: function(granuleObjs, active, inStoreAlready) {
console.log('TOGGLE FOOTPRINTS FUNCTION')
console.log(granuleObjs)
// if obj already in grid store, update and don't put
inStoreAlready = inStoreAlready || false
toggleFootprints: function(granuleObjs, active) {
for (var i = 0; i < granuleObjs.length; i++) {
// Update store
var obj = granuleObjs[i];

if (obj.footprint != active) {
if(obj["Granule-Footprint"]){
obj.footprint = active;
if (!inStoreAlready) {
this.gridStore.put(obj);
}
this.updateStateStoreObj(obj);

// Update fp
Expand All @@ -1031,19 +945,13 @@ define([
}
},

togglePreviews: function(granuleObjs, active, inStoreAlready) {
console.log('previews to show: ', granuleObjs)
// if obj already in grid store, update and don't put
inStoreAlready = inStoreAlready || false
togglePreviews: function(granuleObjs, active) {
for (var i = 0; i < granuleObjs.length; i++) {
// Update store
var obj = granuleObjs[i];
if (obj.preview != active) {
if(obj.has_image){
obj.preview = active;
if (!inStoreAlready) {
this.gridStore.put(obj);
}
this.updateStateStoreObj(obj);

// Update preview
Expand Down

0 comments on commit a6f954b

Please sign in to comment.