Skip to content

Commit b00ab53

Browse files
committed
feat: Add spinner when waiting for commit response
1 parent b435d09 commit b00ab53

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

pages/index.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Created Date: 2024-03-23 13:03:16
66
* Author: 3urobeat
77
*
8-
* Last Modified: 2024-09-01 12:23:58
8+
* Last Modified: 2024-10-02 20:47:43
99
* Modified By: 3urobeat
1010
*
1111
* Copyright (c) 2024 3urobeat <https://github.com/3urobeat>
@@ -124,7 +124,8 @@
124124
<!-- Commit button -->
125125
<button class="lg:max-w-[15%] self-center py-1 px-3 lg:mt-12 w-fit h-fit rounded-sm bg-bg-input-light dark:bg-bg-input-dark outline outline-border-primary-light dark:outline-border-primary-dark outline-2 hover:bg-bg-input-hover-light hover:dark:bg-bg-input-hover-dark hover:transition-all" @click="makeCommit">
126126
<div class="flex items-center justify-center">
127-
<PhCheck class="mr-2 size-5 text-green-600"></PhCheck>
127+
<PhCheck v-if="!awaitingCommitResponse" class="mr-2 size-5 text-green-600"></PhCheck>
128+
<PhSpinnerGap v-if="awaitingCommitResponse" class="mr-2 size-5 text-orange-500 animate-spin"></PhSpinnerGap>
128129
Commit
129130
</div>
130131
</button>
@@ -194,20 +195,22 @@
194195

195196

196197
<script setup lang="ts">
197-
import { PhCheck, PhCaretRight, PhCaretDown, PhX } from "@phosphor-icons/vue";
198+
import { PhCheck, PhSpinnerGap, PhCaretRight, PhCaretDown, PhX } from "@phosphor-icons/vue";
198199
import { type Project, type StoredProjects, type ProjectHistory, DetailType } from "../model/projects";
199200
import { responseIndicatorFailure, responseIndicatorSuccess } from "./helpers/responseIndicator";
200201
201202
202203
// Cache all stored projects, reference the currently selected project and cache shallow histories of all projects that have been selected in the current session
203-
const storedProjects: Ref<StoredProjects> = ref(null!);
204-
const selectedProject: Ref<Project> = ref(null!);
204+
const storedProjects: Ref<StoredProjects> = ref(null!);
205+
const selectedProject: Ref<Project> = ref(null!);
205206
206-
const projectHistories: ProjectHistory[] = [];
207-
const selectedHistory: Ref<ProjectHistory> = ref(null!);
207+
const projectHistories: ProjectHistory[] = [];
208+
const selectedHistory: Ref<ProjectHistory> = ref(null!);
208209
209210
const historyPopupContent: Ref<{ projectName: string, timestamp: number, gitShow: string, gitVerifyCommit: string } | null> = ref(null);
210211
212+
const awaitingCommitResponse: Ref<boolean> = ref(false);
213+
211214
212215
// Get all projects and their details on load
213216
let res = await useFetch<StoredProjects>("/api/get-projects");
@@ -392,6 +395,9 @@
392395
};
393396
394397
398+
// Replace check mark with spinner in commit button
399+
awaitingCommitResponse.value = true;
400+
395401
// Dispatch request to the server
396402
let makeCommitResponse = await useFetch<{ dummyCommitResponse: string | null, commitResponse: string | null }>("/api/make-commit", {
397403
method: "POST",
@@ -434,6 +440,9 @@
434440
responseIndicatorFailure();
435441
}
436442
443+
// Disable spinner again
444+
awaitingCommitResponse.value = false;
445+
437446
// Refresh history, even on failure as maybe an compensation commit was made either way
438447
setTimeout(() => {
439448
selectProject(selectedProject.value, true);

0 commit comments

Comments
 (0)