Skip to content

Commit

Permalink
Fix production mode detection for dataset view (#73)
Browse files Browse the repository at this point in the history
* Fix production mode detection for dataset view

* Run linters

---------

Co-authored-by: Lint Bot <[email protected]>
  • Loading branch information
mewim and mewim authored Feb 8, 2024
1 parent 7bf8bb7 commit 2fc201e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/components/DatasetView/DatasetMainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,19 @@ export default {
},
methods: {
fetchDatasets() {
Axios.get('/api/mode').then((response) => {
const isProduction = response.mode.isProduction;
this.isProduction = isProduction;
}).catch((error) => {
console.error(error);
this.isProduction = true;
});
Axios.get('/api/datasets')
.then((response) => {
this.allDatasets = response.data;
if (!this.selectedDataset && this.allDatasets.length > 0) {
this.selectedDataset = this.allDatasets[0];
}
for (const dataset of this.allDatasets) {
if (!dataset.isProduction) {
this.isProduction = false;
break;
}
}
})
.catch((error) => {
console.error(error);
Expand Down
5 changes: 4 additions & 1 deletion src/server/Mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ const database = require("./utils/Database");
router.get("/", async (_, res) => {
try {
const mode = database.getAccessModeString();
res.send({ mode });
res.send({
mode,
isProduction: process.env.NODE_ENV === "production",
});
} catch (err) {
return res.status(400).send({ error: err.message });
}
Expand Down

0 comments on commit 2fc201e

Please sign in to comment.