Skip to content

Commit

Permalink
Add basic error modal
Browse files Browse the repository at this point in the history
  • Loading branch information
deslaughter committed Jul 19, 2024
1 parent 0b6164d commit dd699dc
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 2 deletions.
10 changes: 10 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"devDependencies": {
"@babel/types": "^7.18.10",
"@types/bootstrap": "^5.2.10",
"@types/chroma-js": "^2.4.4",
"@types/three": "^0.158.2",
"@vitejs/plugin-vue": "^3.0.3",
Expand All @@ -29,4 +30,4 @@
"vite": "^3.0.7",
"vue-tsc": "^1.8.27"
}
}
}
2 changes: 1 addition & 1 deletion frontend/package.json.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2676432337f7cceab17a289a8cf656eb
9033e10d7355cd19ee74ae19116cf9e3
42 changes: 42 additions & 0 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,55 @@
<script lang="ts" setup>
import MainNav from './components/MainNav.vue'
import { storeToRefs } from 'pinia'
import { ref, reactive, onMounted, watch } from 'vue'
import { useProjectStore } from './project';
import { Modal } from 'bootstrap';
const project = useProjectStore()
const { errMsg } = storeToRefs(project)
const modalInstance = ref<Modal | null>();
onMounted(() => {
modalInstance.value = new Modal(document.getElementById("errorModal") as Element);
})
watch(errMsg, () => {
if (errMsg != null) modalInstance.value?.show()
})
function closeModal() {
project.errMsg = null;
modalInstance.value?.hide()
}
</script>

<template>
<MainNav />
<div class="container-fluid">
<router-view />
</div>

<div class="modal fade" id="errorModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header text-bg-danger">
<h1 class="modal-title fs-5" id="staticBackdropLabel">Error</h1>
<button type="button" class="btn-close" @click="closeModal()" aria-label="Close"></button>
</div>
<div class="modal-body">
{{ project.errMsg }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" @click="closeModal()">Close</button>
</div>
</div>
</div>
</div>

</template>

<style></style>
28 changes: 28 additions & 0 deletions frontend/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class Loading {

export const useProjectStore = defineStore('project', () => {

const errMsg = ref<any | null>(null)

const status = reactive<Loading>(new Loading)
const config = ref<main.Config | null>(null)
const info = ref<main.Info | null>(null)
Expand Down Expand Up @@ -69,6 +71,7 @@ export const useProjectStore = defineStore('project', () => {
config.value = result
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})

Expand All @@ -83,6 +86,7 @@ export const useProjectStore = defineStore('project', () => {
status.project = LOADED
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -94,6 +98,7 @@ export const useProjectStore = defineStore('project', () => {
status.project = LOADED
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -109,6 +114,7 @@ export const useProjectStore = defineStore('project', () => {
status.project = LOADED
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -130,6 +136,7 @@ export const useProjectStore = defineStore('project', () => {
// Save config
SaveConfig(config.value).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -144,6 +151,7 @@ export const useProjectStore = defineStore('project', () => {
model.value = result
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -153,6 +161,7 @@ export const useProjectStore = defineStore('project', () => {
model.value = result
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -163,6 +172,7 @@ export const useProjectStore = defineStore('project', () => {
model.value = result
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -177,6 +187,7 @@ export const useProjectStore = defineStore('project', () => {
analysis.value = result
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -187,6 +198,7 @@ export const useProjectStore = defineStore('project', () => {
analysis.value = result
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -197,6 +209,7 @@ export const useProjectStore = defineStore('project', () => {
currentCaseID.value = result.Cases.length
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -207,6 +220,7 @@ export const useProjectStore = defineStore('project', () => {
currentCaseID.value = result.Cases.length
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -217,6 +231,7 @@ export const useProjectStore = defineStore('project', () => {
if (currentCaseID.value > 1) currentCaseID.value = currentCaseID.value - 1
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -226,6 +241,7 @@ export const useProjectStore = defineStore('project', () => {
analysis.value = result
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -240,6 +256,7 @@ export const useProjectStore = defineStore('project', () => {
evaluate.value = result
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -250,6 +267,7 @@ export const useProjectStore = defineStore('project', () => {
evaluate.value = result
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -259,6 +277,7 @@ export const useProjectStore = defineStore('project', () => {
evaluate.value = result
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -268,13 +287,15 @@ export const useProjectStore = defineStore('project', () => {
Object.assign(evalStatus, result)
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}

function cancelEvaluate() {
CancelEvaluate().catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -300,6 +321,7 @@ export const useProjectStore = defineStore('project', () => {
if (res.Diagram != null) diagram.value = res.Diagram
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -312,6 +334,7 @@ export const useProjectStore = defineStore('project', () => {
if (res.Diagram != null) diagram.value = res.Diagram
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -323,6 +346,7 @@ export const useProjectStore = defineStore('project', () => {
console.log(result)
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand All @@ -340,6 +364,7 @@ export const useProjectStore = defineStore('project', () => {
status.results = LOADED
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
status.results = NOT_LOADED
})
Expand All @@ -357,6 +382,7 @@ export const useProjectStore = defineStore('project', () => {
status.diagram = LOADED
}).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
status.diagram = NOT_LOADED
})
Expand All @@ -366,6 +392,7 @@ export const useProjectStore = defineStore('project', () => {
if (diagram.value == null) return
UpdateDiagram(diagram.value).catch(err => {
LogError(err)
errMsg.value = err
console.log(err)
})
}
Expand Down Expand Up @@ -408,6 +435,7 @@ export const useProjectStore = defineStore('project', () => {
//--------------------------------------------------------------------------

return {
errMsg,
$reset,
status: status,
// Project
Expand Down

0 comments on commit dd699dc

Please sign in to comment.