Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static version build errors caused by incorrect merge on last PR #45

Merged
merged 16 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ package-lock.json
__pycache__
node_modules
.DS_Store
dist
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
oblib
Werkzeug==0.16.1
flask
flask_cors
flask_testing
Expand Down
5 changes: 3 additions & 2 deletions scripts/dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ rm -rf node_modules
npm install
npm run-script build
cd ..
mv web-build/dist dist
mkdir dist
mv web-build/dist dist/orange-button-taxonomy-viewer
rm -rf resources
#rm -rf web-build
rm -rf web-build
18 changes: 15 additions & 3 deletions viewer/generate_static_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@
import viewer

import json
from oblib import taxonomy
from flask import Flask


app = Flask(__name__)
tax = taxonomy.Taxonomy()


with app.app_context():
data = viewer.entrypoints().data.decode('UTF-8')
with open("../resources/entrypoints.json", "w") as outfile:
outfile.write(data)

entrypoints = json.loads(data)
with open("../resources/entrypoints-details.json", "w") as outfile:
entrypoints = json.loads(data)
data = {}
for entrypoint in entrypoints:
try:
Expand All @@ -32,7 +36,15 @@
pass
outfile.write(json.dumps(data))

data = viewer.concepts().data.decode('UTF-8')
with open("../resources/entrypoints-concepts.json", "w") as outfile:
data = {}
for entrypoint in entrypoints:
data[entrypoint["entrypoint"]] = []
for concept in tax.semantic.get_entrypoint_concepts(entrypoint["entrypoint"]):
data[entrypoint["entrypoint"]].append(concept.split(":")[1])
outfile.write(json.dumps(data))

data = viewer.concepts("none").data.decode('UTF-8')
with open("../resources/concepts.json", "w") as outfile:
outfile.write(data)

Expand All @@ -51,6 +63,6 @@
with open("../resources/units.json", "w") as outfile:
outfile.write(data)

data = viewer.references().data.decode('UTF-8')
data = viewer.glossary().data.decode('UTF-8')
with open("../resources/references.json", "w") as outfile:
outfile.write(data)
1 change: 1 addition & 0 deletions web/resources/entrypoints-concepts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions web/resources/entrypoints_concepts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
13 changes: 2 additions & 11 deletions web/src/components/ConceptFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</label>
<label for="entryPointSelector">
<h1>Select entrypoint:</h1>
<b-form-select v-model="entryPointSelected" :options="entryPointList" />
<b-form-select v-model="entryPointSelected" :options="$store.state.entryPointList" />
</label>
</div>
<div class="button-group">
Expand All @@ -60,20 +60,11 @@ import axios from "axios";
export default {
data() {
return {
entryPointList: [],
entryPointSelected: ''
}
},
beforeCreate() {
axios
.get(this.$store.state.apiURL + "entrypoints/", {
})
.then(response => {
let entrypoint_data = response.data;
for (let i in entrypoint_data) {
this.entryPointList.push(entrypoint_data[i]["entrypoint"])
}
});
this.$store.commit("callAPIentrypoints");
},
methods: {
updateQuery() {
Expand Down
69 changes: 53 additions & 16 deletions web/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import unitsJson from '../resources/units.json'
import referencesJson from '../resources/references.json'
import entrypointsDetailsJson from '../resources/entrypoints-details.json'
import conceptsDetailsJson from '../resources/concepts-details.json'
import entrypointConceptsJson from '../resources/entrypoints-concepts.json'

Vue.use(Vuex);

Expand All @@ -39,6 +40,8 @@ export default new Vuex.Store({
apiDetailLoading: false,
apiDetailDataReady: false,

entryPointList: [],

chkDocuments: true,
chkData: true,
chkProcess: true,
Expand Down Expand Up @@ -89,19 +92,36 @@ export default new Vuex.Store({

if (entrypointsJson.length > 0){
// This will be encountered if the system was built with static pages (otherwise
if (payload == "entrypoints") {
if (payload.startsWith("entrypoints")) {
state.apiData = entrypointsJson;
state.returnItemsCount = entrypointsJson.length;
} else if (payload == "concepts") {
state.apiData = conceptsJson;
state.returnItemsCount = conceptsJson.length;
} else if (payload == "types") {
} else if (payload.startsWith("concepts")) {
if (payload.endsWith("none")) {
state.apiData = conceptsJson;
state.returnItemsCount = conceptsJson.length;
} else {
let entrypoint = payload.split("/")[1]
state.apiData = [];
state.returnItemsCount = 0;
let conceptsInEntrypoint = entrypointConceptsJson[entrypoint];
for (let i = 0; i < conceptsJson.length; i++) {
let c = conceptsJson[i];
for (let j = 0; j < conceptsInEntrypoint.length; j++) {
if (c.name == conceptsInEntrypoint[j]) {
state.apiData.push(c);
state.returnItemsCount++;
break;
}
}
}
}
} else if (payload.startsWith("types")) {
state.apiData = typesJson;
state.returnItemsCount = typesJson.length;
} else if (payload == "units") {
} else if (payload.startsWith("units")) {
state.apiData = unitsJson;
state.returnItemsCount = unitsJson.length;
} else if (payload == "references") {
} else if (payload.startsWith("glossary")) {
state.apiData = referencesJson;
state.returnItemsCount = referencesJson.length;
}
Expand All @@ -119,15 +139,6 @@ export default new Vuex.Store({
state.dataReady = true;
});
}
axios
.get(state.apiURL + payload, {
})
.then(response => {
state.apiLoading = false;
state.apiData = response.data;
state.returnItemsCount = response.data.length;
state.dataReady = true;
});
} else {
var data = JSON.parse(process.env.TEST_JSON);
state.apiLoading = false;
Expand Down Expand Up @@ -175,6 +186,32 @@ export default new Vuex.Store({
state.dataReady = true;
}
},
callAPIentrypoints(state) {
if (process.env.JEST_WORKER_ID == undefined) {
// Skip call during jest unit tests. Please note that this is not elegant (using Mocks correctly
// would be better) and hopefully improvements can be applied later.

if (entrypointsJson.length > 0){
// This will be encountered if the system was built with static pages (otherwise
let entrypoint_data = entrypointsJson;
for (let i in entrypoint_data) {
state.entryPointList.push(entrypoint_data[i]["entrypoint"])
}

} else {
// This version calls the web service interface.
axios
.get(state.apiURL + "entrypoints/", {
})
.then(response => {
let entrypoint_data = response.data;
for (let i in entrypoint_data) {
state.entryPointList.push(entrypoint_data[i]["entrypoint"])
}
});
}
}
},

toggleAPILoading(state) {
state.apiLoading = !state.apiLoading;
Expand Down
1 change: 1 addition & 0 deletions web/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ module.exports = {
disableHostCheck: true,
public: ""
},
publicPath: "/orange-button-taxonomy-viewer/",
lintOnSave: false
};