Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
joelebwf committed Jan 23, 2020
2 parents 0cea8f2 + 8c54cf6 commit ac01cfc
Show file tree
Hide file tree
Showing 21 changed files with 226 additions and 156 deletions.
2 changes: 1 addition & 1 deletion viewer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__all__ = ['reference', 'viewer']
__all__ = ['glossary', 'viewer']
6 changes: 3 additions & 3 deletions viewer/tests/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_concepts(self):

app = Flask(__name__)
app.config['TESTING'] = True
data = json.loads(viewer.concepts().data.decode('UTF-8'))
data = json.loads(viewer.concepts("none").data.decode('UTF-8'))
self.assertEqual(3404, len(data))
self.assertTrue("name" in data[0])
self.assertTrue("taxonomy" in data[0])
Expand All @@ -61,8 +61,8 @@ def test_units(self):
self.assertTrue("standard" in data[0])
self.assertTrue("definition" in data[0])

def test_references(self):
data = json.loads(viewer.references().data.decode('UTF-8'))
def test_glossary(self):
data = json.loads(viewer.glossary().data.decode('UTF-8'))
self.assertEqual(305, len(data))
self.assertTrue("type" in data[0])
self.assertTrue("code" in data[0])
Expand Down
61 changes: 41 additions & 20 deletions viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,46 @@ def exception(e):
return response


@app.route('/concepts/', methods=['GET'])
def concepts():
@app.route('/concepts/<entrypoint>', methods=['GET'])
def concepts(entrypoint):
"""Flask Read Handler for concepts API Endpoint"""

data = []
for concept in tax.semantic.get_all_concepts(details=True):
details = tax.semantic.get_concept_details(concept)
if not details.abstract:
t = "SOLAR"
if details.id.startswith("us-gaap:"):
t = "US-GAAP"
elif details.id.startswith("dei:"):
t = "DEI"
data.append({
"name": details.name,
"taxonomy": t,
"itemtype": details.type_name.split(":")[1].replace("ItemType", ""),
"period": details.period_type.value
})
if entrypoint == "none":
data = []
for concept in tax.semantic.get_all_concepts(details=True):
details = tax.semantic.get_concept_details(concept)
if not details.abstract:
t = "SOLAR"
if details.id.startswith("us-gaap:"):
t = "US-GAAP"
elif details.id.startswith("dei:"):
t = "DEI"
data.append({
"name": details.name,
"taxonomy": t,
"itemtype": details.type_name.split(":")[1].replace("ItemType", ""),
"period": details.period_type.value
})
else:
data = []
entrypoint_concepts = []
for concept in tax.semantic.get_entrypoint_concepts(entrypoint):
entrypoint_concepts.append(concept)
for concept in tax.semantic.get_all_concepts(details=True):
if concept in entrypoint_concepts:
details = tax.semantic.get_concept_details(concept)
if not details.abstract:
t = "SOLAR"
if details.id.startswith("us-gaap:"):
t = "US-GAAP"
elif details.id.startswith("dei:"):
t = "DEI"
data.append({
"name": details.name,
"taxonomy": t,
"itemtype": details.type_name.split(":")[1].replace("ItemType", ""),
"period": details.period_type.value
})

return jsonify(data)

Expand Down Expand Up @@ -187,9 +208,9 @@ def entrypoints():
return jsonify(data)


@app.route('/references/', methods=['GET'])
def references():
"""Flask Read Handler for types API Endpoint"""
@app.route('/glossary/', methods=['GET'])
def glossary():
"""Flask Read Handler for glossary API Endpoint"""

data = []
for item in reference.ACRONYMS.items():
Expand Down
4 changes: 1 addition & 3 deletions web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div id="app">
<Navbar id="navbar"></Navbar>
<router-view id="router-v"/>
<Footer id="footer"></Footer>
<!-- <Footer id="footer"></Footer> -->
</div>
</template>

Expand All @@ -40,14 +40,12 @@ html {
}
#app {
font-family: "Montserrat";
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
background-color: white;
display: grid;
grid-template-rows: 70px 0px 1000px 10px 60px;
height: 100vh;
}
#footer {
Expand Down
33 changes: 32 additions & 1 deletion web/src/components/ConceptFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
<label for="process">
<input type="checkbox" id="dei" value="DEI" v-model="$store.state.chkDEI"/> DEI
</label>
<label for="entryPointSelector">
<h1>Select entrypoint:</h1>
<b-form-select v-model="entryPointSelected" :options="entryPointList" />
</label>
</div>
<div class="button-group">
<button type="button" class="btn btn-primary" @click="updateQuery">
Expand All @@ -51,7 +55,26 @@
</template>

<script>
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"])
}
});
},
methods: {
updateQuery() {
// TODO: Remove - currently referenced in other code.
Expand All @@ -61,7 +84,15 @@ export default {
this.$store.state.searchTerm = "";
this.$store.commit("clearQueryString");
this.$store.commit("clearConceptsChks");
this.$store.commit("callAPI", "concepts");
this.entryPointSelected = '';
this.$store.commit("callAPI", "concepts/none");
}
},
watch: {
entryPointSelected() {
if (this.entryPointSelected) {
this.$store.commit("callAPI", "concepts/" + this.entryPointSelected);
}
}
}
};
Expand Down
32 changes: 17 additions & 15 deletions web/src/components/ConceptList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
</template>

<script>
export default {
props: ["admin_page"],
data() {
Expand Down Expand Up @@ -84,7 +83,7 @@ export default {
beforeCreate() {
this.$store.state.actvChk = false;
this.$store.state.searchTerm = "";
this.$store.commit("callAPI", "concepts");
this.$store.commit("callAPI", "concepts/none");
},
computed: {
apiData() {
Expand All @@ -108,10 +107,14 @@ export default {
(node.taxonomy.toLowerCase()=="us-gaap" && !this.$store.state.actvChk) ||
(node.taxonomy.toLowerCase()=="dei" && !this.$store.state.actvChk))
});
this.numOfElem = 100
this.showLoadMore = true
this.filteredCount = tableData.length;
this.$store.state.returnItemsCount = this.filteredCount;
this.$store.state.returnItemsCount = tableData.length;
if (this.numOfElem + 1 >= this.$store.state.returnItemsCount) {
this.showLoadMore = false
} else {
this.showLoadMore = true
}
return tableData;
}
},
Expand All @@ -122,21 +125,20 @@ export default {
},
loadMore() {
this.numOfElem += 100;
if (this.numOfElem >= this.$store.state.returnItemsCount
|| this.numOfElem >= this.filteredCount) {
if (this.numOfElem + 1 >= this.$store.state.returnItemsCount) {
this.showLoadMore = false
} else {
this.showLoadMore = true
}
}
},
watch: {
filteredCount() {
if (this.numOfElem >= this.filteredCount) {
this.showLoadMore = false
}
},
"$store.state.returnItemsCount"() {
if (this.numOfElem >= this.$store.state.returnItemsCount) {
this.numOfElem = 100
if (this.numOfElem + 1 >= this.$store.state.returnItemsCount) {
this.showLoadMore = false
} else {
this.showLoadMore = true
}
},
"$store.state.chkSolar"() {
Expand Down Expand Up @@ -176,6 +178,7 @@ export default {
height: 100%;
padding-top: 5px;
width: 1163px;
overflow-y: auto;
}
li {
Expand Down Expand Up @@ -224,7 +227,6 @@ ul {
grid-row: 2 / 3;
grid-column: 1 /2;
width: 1163px;
//overflow-y: auto;
}
a.nav-link {
Expand Down
6 changes: 4 additions & 2 deletions web/src/components/EntrypointDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
-->

<template>
<div class="public-filter">
<div class="entrypoint-detail-container">
<entrypoint-child v-bind:abstract="apiData" v-bind:key="apiData.name"></entrypoint-child>
</div>
</template>
Expand Down Expand Up @@ -67,9 +67,11 @@ h2 {
font-weight: bold;
}
.public-filter {
.entrypoint-detail-container {
padding-left: 20px;
padding-top: 5px;
height: 100vh;
overflow-y: scroll;
}
.form-group {
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/EntrypointFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default {
this.$store.state.searchTerm = "";
this.$store.commit("clearQueryString");
this.$store.commit("clearEntrypointsChks")
this.$store.commit("callAPI", "entrypoints");
this.$store.commit("callAPI", "entrypoints/");
}
}
};
Expand Down
32 changes: 18 additions & 14 deletions web/src/components/EntrypointList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default {
beforeCreate() {
this.$store.state.actvChk = false;
this.$store.state.searchTerm = "";
this.$store.commit("callAPI", "entrypoints");
this.$store.commit("callAPI", "entrypoints/");
},
computed: {
apiData() {
Expand All @@ -100,10 +100,14 @@ export default {
(node.type.toLowerCase()=="documents" && !this.$store.state.actvChk) ||
(node.type.toLowerCase()=="process" && !this.$store.state.actvChk))
});
this.numOfElem = 100
this.showLoadMore = true
this.filteredCount = tableData.length;
this.$store.state.returnItemsCount = this.filteredCount;
this.$store.state.returnItemsCount = tableData.length;
if (this.numOfElem + 1 >= this.$store.state.returnItemsCount) {
this.showLoadMore = false
} else {
this.showLoadMore = true
}
return tableData;
}
Expand All @@ -115,21 +119,20 @@ export default {
},
loadMore() {
this.numOfElem += 100;
if (this.numOfElem >= this.$store.state.returnItemsCount
|| this.numOfElem >= this.filteredCount) {
if (this.numOfElem + 1 >= this.$store.state.returnItemsCount) {
this.showLoadMore = false
} else {
this.showLoadMore = true
}
}
},
watch: {
filteredCount() {
if (this.numOfElem >= this.filteredCount) {
this.showLoadMore = false
}
},
"$store.state.returnItemsCount"() {
if (this.numOfElem >= this.$store.state.returnItemsCount) {
this.numOfElem = 100
if (this.numOfElem + 1 >= this.$store.state.returnItemsCount) {
this.showLoadMore = false
} else {
this.showLoadMore = true
}
},
"$store.state.chkDocuments"() {
Expand Down Expand Up @@ -217,7 +220,8 @@ ul {
grid-row: 2 / 3;
grid-column: 1 /2;
width: 1163px;
//overflow-y: auto;
height: 100%;
overflow-y: auto;
}
a.nav-link {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/>
</div>

<h1>References Type</h1>
<h1>Glossary Items Type</h1>
<div class="form-group">
<label for="acronym">
<input type="checkbox" id="acronym" value="Acronym" v-model="$store.state.chkAcronym"/> Acronym
Expand Down Expand Up @@ -57,8 +57,8 @@ export default {
this.$store.commit("toggleAPILoading");
this.$store.state.searchTerm = "";
this.$store.commit("clearQueryString");
this.$store.commit("clearReferencesChks")
this.$store.commit("callAPI", "references");
this.$store.commit("clearGlossaryChks")
this.$store.commit("callAPI", "glossary/");
}
}
};
Expand Down
Loading

0 comments on commit ac01cfc

Please sign in to comment.