Skip to content

Commit

Permalink
fix(view): remove default json url from GET params
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Dec 24, 2020
1 parent ab3c892 commit 512b67d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
},

env: {
itemsJsonUrl: process.env.JSON_URL || 'http://localhost:3001/data.json',
itemsJsonUrl: process.env.JSON_URL,
SERVER_URL: process.env.SERVER_URL
},

Expand Down
23 changes: 19 additions & 4 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@
</header>
<br>

<div v-if="jsonLoadError">
<div class="msg danger">Failed to load {{ itemsJsonUrl}}</div>
<div v-if="itemsJsonUrl">
<div v-if="jsonLoadError">
<div class="msg danger">Failed to load {{ itemsJsonUrl}}</div>
</div>
<div v-if="jsonLoading">Loading...</div>
</div>
<div v-else>
No reports, start <NuxtLink class="el-button el-button--primary" to="/scan">Scan</NuxtLink>
</div>
<div v-if="jsonLoading">Loading...</div>

<div v-if="!jsonLoading && !jsonLoadError">
<el-collapse v-model="openedPanels" class="panels">

Expand Down Expand Up @@ -568,7 +574,10 @@ export default {
if (this.q) query.q = this.q;
if (updateFields) query.fields = this.columns.join(",");
query.url = this.itemsJsonUrl;
// don't add default json url
if (this.itemsJsonUrl !== process.env.itemsJsonUrl) {
query.url = this.itemsJsonUrl;
}
let order = { column: false, ascending: true };
if (this.$refs.table && this.$refs.table.orderBy.column) {
Expand Down Expand Up @@ -763,17 +772,23 @@ export default {
this.$store.commit("tests", itemsJson.fields);
this.$store.dispatch("items", itemsJson.items);
// filter
const defaultFilter = itemsJson.filters.find(filter => filter.default);
if (defaultFilter && !this.$route.query["q"]) {
this.$route.query["q"] = defaultFilter.q;
}
// q
this.$store.dispatch("q", this.$route.query["q"]);
// columns
if (forceDefaultColumns) {
this.setDefaultFields();
}
// update url
this.updateUrlQuery();
this.jsonLoadError = false;
this.jsonLoading = false;
} catch(e) {
Expand Down
4 changes: 2 additions & 2 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const state = () => ({
filteredItems: [],

// constants
itemsJsonUrl: process.env.itemsJsonUrl || 'http://localhost:3001/data.json',
itemsJsonUrl: process.env.itemsJsonUrl || '',
jsonUrlHistory: {},
name: pjson.name,
version: pjson.version,
Expand All @@ -97,7 +97,7 @@ export const state = () => ({
user: false,
uid: '', // only for anonymous
url: 'https://blog.popstas.ru',
args: '-m 1000',
args: '-m 50',
serverUrl: process.env.SERVER_URL || false
});

Expand Down

0 comments on commit 512b67d

Please sign in to comment.