From 3f9afe5059eb71df1485ee24b20392d39772af13 Mon Sep 17 00:00:00 2001 From: fauxpark Date: Mon, 22 May 2023 10:18:15 +1000 Subject: [PATCH] Use new build log endpoints for some speed improvements --- src/App.vue | 71 ++++++++++++++++++++++++++---------- src/components/ErrorPane.vue | 10 ++++- 2 files changed, 61 insertions(+), 20 deletions(-) diff --git a/src/App.vue b/src/App.vue index b358de8..693da09 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,7 +13,7 @@ Builds Passing - + @@ -35,34 +35,67 @@ const filter = ref('') const passingKeyboards = ref([]) const failingKeyboards = ref([]) const errorLog = ref('') +const errorLogLoading = ref(false) const showErrorPane = ref(false) onMounted(() => { - downloadBuildLog() + loadBuildSummary() }) -function downloadBuildLog() { +async function loadBuildSummary() { const start = performance.now() - axios - .get(`${import.meta.env.VITE_QMK_API_BASEURL}/v1/keyboards/build_log`, { - onDownloadProgress: (e) => { - loadProgress.value = Math.floor((e.loaded / e.total) * 100) - } - }) - .then((res) => { - if (res.status === 200) { - buildLog = res.data - binKeyboards() + + try { + const { status, data } = await axios.get( + `${import.meta.env.VITE_QMK_API_BASEURL}/v1/keyboards/build_summary`, + { + onDownloadProgress: (e) => { + loadProgress.value = Math.floor((e.loaded / e.total) * 100) + } } - }) - .then(() => { - loading.value = false - loadTime.value = ((performance.now() - start) / 1000).toFixed(2) - }) + ) + + if (status === 200) { + buildLog = data + binKeyboards() + } + } catch (e) { + console.log(e.message) + } + + loading.value = false + loadTime.value = ((performance.now() - start) / 1000).toFixed(2) +} + +async function loadBuildLog(keyboard) { + errorLogLoading.value = true + + try { + const { status, statusText, data } = await axios.get( + `${import.meta.env.VITE_QMK_API_BASEURL}/v1/keyboards/${keyboard}/build_log` + ) + + if (status === 200) { + buildLog[keyboard].message = data.message + errorLog.value = data.message + } else { + buildLog[keyboard].message = `ERROR ${status}: ${statusText}` + } + } catch (e) { + buildLog[keyboard].message = `ERROR: ${e.message}` + } + + errorLogLoading.value = false; + errorLog.value = buildLog[keyboard].message } function showErrors(key) { - errorLog.value = buildLog[key].message + if (!('message' in buildLog[key])) { + loadBuildLog(key) + } else { + errorLog.value = buildLog[key].message + } + showErrorPane.value = true } diff --git a/src/components/ErrorPane.vue b/src/components/ErrorPane.vue index b0f3f49..c3b0126 100644 --- a/src/components/ErrorPane.vue +++ b/src/components/ErrorPane.vue @@ -8,7 +8,8 @@

Detailed Error Log

-

+        

Loading…

+

       
@@ -26,6 +27,10 @@ const props = defineProps({ type: String, required: true }, + loading: { + type: Boolean, + required: true + }, visible: { type: Boolean, required: true @@ -65,6 +70,9 @@ const colorizedErrorLog = computed(() => ansiConverter.toHtml(props.errorLog)) overflow: auto; margin: 6px; } +#error-loading { + text-align: center; +} #backdrop { position: fixed;