|
5 | 5 | * Created Date: 2024-03-23 13:03:16
|
6 | 6 | * Author: 3urobeat
|
7 | 7 | *
|
8 |
| - * Last Modified: 2024-09-01 12:23:58 |
| 8 | + * Last Modified: 2024-10-02 20:47:43 |
9 | 9 | * Modified By: 3urobeat
|
10 | 10 | *
|
11 | 11 | * Copyright (c) 2024 3urobeat <https://github.com/3urobeat>
|
|
124 | 124 | <!-- Commit button -->
|
125 | 125 | <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">
|
126 | 126 | <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> |
128 | 129 | Commit
|
129 | 130 | </div>
|
130 | 131 | </button>
|
|
194 | 195 |
|
195 | 196 |
|
196 | 197 | <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"; |
198 | 199 | import { type Project, type StoredProjects, type ProjectHistory, DetailType } from "../model/projects";
|
199 | 200 | import { responseIndicatorFailure, responseIndicatorSuccess } from "./helpers/responseIndicator";
|
200 | 201 |
|
201 | 202 |
|
202 | 203 | // 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!); |
205 | 206 |
|
206 |
| - const projectHistories: ProjectHistory[] = []; |
207 |
| - const selectedHistory: Ref<ProjectHistory> = ref(null!); |
| 207 | + const projectHistories: ProjectHistory[] = []; |
| 208 | + const selectedHistory: Ref<ProjectHistory> = ref(null!); |
208 | 209 |
|
209 | 210 | const historyPopupContent: Ref<{ projectName: string, timestamp: number, gitShow: string, gitVerifyCommit: string } | null> = ref(null);
|
210 | 211 |
|
| 212 | + const awaitingCommitResponse: Ref<boolean> = ref(false); |
| 213 | +
|
211 | 214 |
|
212 | 215 | // Get all projects and their details on load
|
213 | 216 | let res = await useFetch<StoredProjects>("/api/get-projects");
|
|
392 | 395 | };
|
393 | 396 |
|
394 | 397 |
|
| 398 | + // Replace check mark with spinner in commit button |
| 399 | + awaitingCommitResponse.value = true; |
| 400 | +
|
395 | 401 | // Dispatch request to the server
|
396 | 402 | let makeCommitResponse = await useFetch<{ dummyCommitResponse: string | null, commitResponse: string | null }>("/api/make-commit", {
|
397 | 403 | method: "POST",
|
|
434 | 440 | responseIndicatorFailure();
|
435 | 441 | }
|
436 | 442 |
|
| 443 | + // Disable spinner again |
| 444 | + awaitingCommitResponse.value = false; |
| 445 | +
|
437 | 446 | // Refresh history, even on failure as maybe an compensation commit was made either way
|
438 | 447 | setTimeout(() => {
|
439 | 448 | selectProject(selectedProject.value, true);
|
|
0 commit comments