Skip to content

Commit

Permalink
fix: Add more helpful error messages when files don't load
Browse files Browse the repository at this point in the history
  • Loading branch information
billyc committed Feb 8, 2022
1 parent 8e42dec commit 53f994f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 26 deletions.
18 changes: 11 additions & 7 deletions src/charts/map-polygons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,19 @@ export default class VueComponent extends Vue {
}
private async mounted() {
this.expColors = this.config.exponentColors
try {
this.expColors = this.config.exponentColors
this.fileApi = new HTTPFileSystem(this.fileSystemConfig)
// bulmaSlider.attach()
this.fileApi = new HTTPFileSystem(this.fileSystemConfig)
// bulmaSlider.attach()
// load the boundaries and the dataset, use promises so we can clear
// the spinner when things are finished
await Promise.all([this.loadBoundaries(), this.loadDataset()])
this.updateChart()
// load the boundaries and the dataset, use promises so we can clear
// the spinner when things are finished
await Promise.all([this.loadBoundaries(), this.loadDataset()])
this.updateChart()
} catch (e) {
this.$store.commit('error', 'Mapview ' + e)
}
this.$emit('isLoaded')
}
Expand Down
46 changes: 28 additions & 18 deletions src/plugins/links-gl/LinkVolumes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -575,17 +575,22 @@ class MyPlugin extends Vue {
const filename = this.vizDetails.network || this.vizDetails.geojsonFile
const networkPath = `/${this.myState.subfolder}/${filename}`
const network = await this.myDataManager.getRoadNetwork(networkPath)
try {
const network = await this.myDataManager.getRoadNetwork(networkPath)
this.numLinks = network.linkIds.length
this.geojsonData = network
this.numLinks = network.linkIds.length
this.geojsonData = network
this.setMapCenter() // this could be off main thread
this.setMapCenter() // this could be off main thread
this.myState.statusMessage = ''
this.myState.statusMessage = ''
// then load CSVs in background
this.loadCSVFiles()
// then load CSVs in background
this.loadCSVFiles()
} catch (e) {
this.$store.commit('error', `Could not load ${networkPath}`)
this.$emit('isLoaded')
}
}
private dataLoaderWorkers: Worker[] = []
Expand Down Expand Up @@ -835,20 +840,25 @@ class MyPlugin extends Vue {
private async loadOneCSVFile(key: string, filename: string) {
if (!this.myState.fileApi) return
const dataset = await this.myDataManager.getDataset({ dataset: filename })
const dataTable = dataset.allRows
try {
const dataset = await this.myDataManager.getDataset({ dataset: filename })
const dataTable = dataset.allRows
console.log('loaded', key)
this.myState.statusMessage = 'Analyzing...'
console.log('loaded', key)
this.myState.statusMessage = 'Analyzing...'
// remove columns without names; we can't use them
const cleanTable: DataTable = {}
for (const key of Object.keys(dataTable)) {
if (key) cleanTable[key] = dataTable[key]
}
// remove columns without names; we can't use them
const cleanTable: DataTable = {}
for (const key of Object.keys(dataTable)) {
if (key) cleanTable[key] = dataTable[key]
}
this.datasets = Object.assign({ ...this.datasets }, { [key]: cleanTable })
this.handleNewDataset({ key, dataTable: cleanTable })
this.datasets = Object.assign({ ...this.datasets }, { [key]: cleanTable })
this.handleNewDataset({ key, dataTable: cleanTable })
} catch (e) {
this.$store.commit('error', 'Could not load ' + filename)
this.$emit('isLoaded')
}
}
private handleNewDataColumn(value: { dataset: LookupDataset; column: string }) {
Expand Down
5 changes: 4 additions & 1 deletion src/views/DashBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,10 @@ export default class VueComponent extends Vue {
let numCard = 1
for (const rowId of Object.keys(this.yaml.layout)) {
const cards: any[] = this.yaml.layout[rowId]
let cards: any[] = this.yaml.layout[rowId]
// row must be an array - if it isn't, assume it is an array of length one
if (!cards.forEach) cards = [cards]
cards.forEach(card => {
card.id = `card-id-${numCard}`
Expand Down

0 comments on commit 53f994f

Please sign in to comment.