Skip to content

Commit 501cf40

Browse files
#771 Bug - Mission name and msv.mission sometimes conflict (#772)
* #771 Bug - Mission name and msv.mission sometimes conflict * #771 minor 1
1 parent 76a5401 commit 501cf40

6 files changed

Lines changed: 72 additions & 15 deletions

File tree

API/Backend/Config/routes/configs.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,24 +183,30 @@ function get(req, res, next, cb) {
183183
},
184184
})
185185
.then((mission) => {
186+
// Apply fallback logic for missionFolderName
187+
const config = mission.config;
188+
if (config.msv && (!config.msv.missionFolderName || config.msv.missionFolderName === "")) {
189+
config.msv.missionFolderName = config.msv.mission || "";
190+
}
191+
186192
if (req.query.full) {
187193
if (cb)
188194
cb({
189195
status: "success",
190196
mission: mission.mission,
191-
config: mission.config,
197+
config: config,
192198
version: mission.version,
193199
});
194200
else
195201
res.send({
196202
status: "success",
197203
mission: mission.mission,
198-
config: mission.config,
204+
config: config,
199205
version: mission.version,
200206
});
201207
} else {
202-
if (cb) cb(mission.config);
203-
else res.send(mission.config);
208+
if (cb) cb(config);
209+
else res.send(config);
204210
}
205211
return null;
206212
})
@@ -244,6 +250,8 @@ function add(req, res, next, cb) {
244250
}
245251

246252
configTemplate.msv.mission = req.body.mission;
253+
// Set missionFolderName to match the mission name by default
254+
configTemplate.msv.missionFolderName = req.body.mission;
247255

248256
// Fix validation logic: use OR conditions instead of AND
249257
if (
@@ -729,6 +737,8 @@ if (fullAccess)
729737
get(req, res, next, function (r) {
730738
if (r.status == "success") {
731739
r.config.msv.mission = req.body.cloneMission;
740+
// Set missionFolderName to match the new mission name
741+
r.config.msv.missionFolderName = req.body.cloneMission;
732742
req.body.config =
733743
req.body.hasPaths == "true"
734744
? relativizePaths(r.config, req.body.existingMission)

API/templates/config_template.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
msv: {
33
mission: "Test",
4+
missionFolderName: "",
45
site: "",
56
masterdb: false,
67
view: ["0", "0", "0"],

configure/src/metaconfigs/tab-home-config.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@
5757
"units": "meters"
5858
}
5959
]
60+
},
61+
{
62+
"name": "Paths",
63+
"components": [
64+
{
65+
"field": "msv.missionFolderName",
66+
"name": "/Missions Folder Name",
67+
"description": "The actual folder name in the /Missions directory. This should match the physical folder name to ensure relative links work correctly. If the folder name differs from the mission name in the database, update this value accordingly.",
68+
"type": "text",
69+
"width": 4,
70+
"required": true
71+
}
72+
]
6073
}
6174
]
6275
}

src/essence/Basics/Layers_/Layers_.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3659,9 +3659,14 @@ async function parseConfig(configData, urlOnLayers) {
36593659
)
36603660
}
36613661

3662-
L_.mission = L_.configData.msv.mission
3662+
// Use DB mission name for L_.mission (for deeplinks)
3663+
// This will be set from the API response's mission field
3664+
// For now, keep backward compatibility
3665+
L_.mission = L_.configData._dbMissionName || L_.configData.msv.mission
36633666
L_.recentMissions.unshift(L_.mission)
3664-
L_.missionPath = 'Missions/' + L_.configData.msv.mission + '/'
3667+
// Use missionFolderName if available, otherwise fallback to msv.mission
3668+
L_.missionFolderName = L_.configData.msv.missionFolderName || L_.configData.msv.mission
3669+
L_.missionPath = 'Missions/' + L_.missionFolderName + '/'
36653670
L_.site = L_.configData.msv.site
36663671

36673672
L_.view = [

src/essence/LandingPage/LandingPage.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,15 @@ export default {
152152
'get',
153153
{
154154
mission: missionName,
155+
full: true,
155156
},
156-
function (data) {
157-
s.init(data, missions)
157+
function (response) {
158+
// Extract DB mission name and attach to config
159+
const config = response.config || response
160+
if (response.mission) {
161+
config._dbMissionName = response.mission
162+
}
163+
s.init(config, missions)
158164
},
159165
function (e) {
160166
console.log(
@@ -330,9 +336,15 @@ export default {
330336
'get',
331337
{
332338
mission: missionUrl,
339+
full: true,
333340
},
334-
function (data) {
335-
s.init(data, missions)
341+
function (response) {
342+
// Extract DB mission name and attach to config
343+
const config = response.config || response
344+
if (response.mission) {
345+
config._dbMissionName = response.mission
346+
}
347+
s.init(config, missions)
336348
},
337349
function (e) {
338350
console.error(

src/essence/essence.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ var essence = {
209209
if (data.data) {
210210
try {
211211
const parsed = JSON.parse(data.data)
212-
const mission = essence.configData.msv.mission
212+
// Use DB mission name for comparison (L_.mission now contains DB name)
213+
const mission = L_.mission || essence.configData.msv.mission
213214

214215
if (
215216
!parsed.body.mission ||
@@ -230,8 +231,15 @@ var essence = {
230231
'get',
231232
{
232233
mission,
234+
full: true,
233235
},
234-
async function (data) {
236+
async function (response) {
237+
// Extract DB mission name and attach to config
238+
const data = response.config || response
239+
if (response.mission) {
240+
data._dbMissionName = response.mission
241+
}
242+
235243
if (Array.isArray(layerName)) {
236244
// If we're adding an array of new layers, add each layer to the queue individually
237245
for (let layer in layerName) {
@@ -318,10 +326,12 @@ var essence = {
318326
(urlSplit[1] && urlSplit[1].split('=')[0] === '_preview')
319327
) {
320328
//then no parameters or old ones
329+
// Use DB mission name for deeplinks (config._dbMissionName if available)
330+
const missionForUrl = config._dbMissionName || config.msv.mission
321331
url =
322332
window.location.href.split('?')[0] +
323333
'?mission=' +
324-
config.msv.mission
334+
missionForUrl
325335
window.history.replaceState('', '', url)
326336
L_.url = window.location.href
327337
}
@@ -427,9 +437,15 @@ var essence = {
427437
'get',
428438
{
429439
mission: to,
440+
full: true,
430441
},
431-
function (data) {
432-
essence.makeMission(data)
442+
function (response) {
443+
// Extract DB mission name and attach to config
444+
const config = response.config || response
445+
if (response.mission) {
446+
config._dbMissionName = response.mission
447+
}
448+
essence.makeMission(config)
433449
},
434450
function (e) {
435451
console.log(

0 commit comments

Comments
 (0)