Skip to content

Commit 30874c0

Browse files
chore: wip
1 parent 3a146b5 commit 30874c0

File tree

16 files changed

+146
-66
lines changed

16 files changed

+146
-66
lines changed

storage/framework/.stacks/core/api/src/index.ts

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
import { ofetch } from 'ofetch'
2+
import type { FetchOptions } from 'ofetch'
23
interface Params {
34
[key: string]: any // Replace 'any' with more specific types if possible
45
}
56

6-
interface FetchParams {
7-
headers: {
8-
Accept: string
9-
Authorization: string
10-
}
11-
parseResponse: (text: string) => any
12-
method: string
13-
baseURL: string
14-
[key: string]: any // To account for the spread of the '...params'
15-
}
16-
17-
interface FetchResponse {
18-
data: any // Replace 'any' with more specific types if possible
19-
}
7+
type FetchResponse = string | Blob | ArrayBuffer | ReadableStream<Uint8Array>
208

219
const loading = ref(false)
2210
const token = ref('')
@@ -28,10 +16,16 @@ export async function useHttpFetch(endpoint = '') {
2816
baseURL = endpoint
2917

3018
async function post(url: string, params?: Params): Promise<any> {
31-
const parameters: FetchParams = {
19+
const headers: any = { Accept: 'application/json' };
20+
21+
if (token.value) {
22+
headers.Authorization = `Bearer ${token.value}`;
23+
}
24+
25+
const parameters: FetchOptions = {
3226
...params,
3327
...{
34-
headers: { Accept: 'application/json', Authorization: `Bearer ${token.value}` },
28+
headers,
3529
parseResponse: JSON.parse,
3630
method: 'POST',
3731
baseURL,
@@ -41,7 +35,7 @@ export async function useHttpFetch(endpoint = '') {
4135
loading.value = true
4236

4337
try {
44-
const result: FetchResponse = await ofetch(url, parameters)
38+
const result: string | FetchResponse | Blob | ArrayBuffer | ReadableStream<Uint8Array> = await ofetch(url, parameters)
4539

4640
loading.value = false
4741
return result
@@ -54,10 +48,16 @@ export async function useHttpFetch(endpoint = '') {
5448
}
5549

5650
async function get(url: string, params?: Params): Promise<any> {
57-
const parameters: FetchParams = {
51+
const headers: any = { Accept: 'application/json' };
52+
53+
if (token.value) {
54+
headers.Authorization = `Bearer ${token.value}`;
55+
}
56+
57+
const parameters: FetchOptions = {
5858
...params,
5959
...{
60-
headers: { Accept: 'application/json' },
60+
headers,
6161
parseResponse: JSON.parse,
6262
method: 'GET',
6363
baseURL,
@@ -74,10 +74,16 @@ export async function useHttpFetch(endpoint = '') {
7474
}
7575

7676
async function patch(url: string, params?: Params): Promise<any> {
77-
const parameters: FetchParams = {
77+
const headers: any = { Accept: 'application/json' };
78+
79+
if (token.value) {
80+
headers.Authorization = `Bearer ${token.value}`;
81+
}
82+
83+
const parameters: FetchOptions = {
7884
...params,
7985
...{
80-
headers: { Accept: 'application/json', Authorization: `Bearer ${token.value}` },
86+
headers,
8187
parseResponse: JSON.parse,
8288
method: 'PATCH',
8389
baseURL,
@@ -97,10 +103,16 @@ export async function useHttpFetch(endpoint = '') {
97103
}
98104

99105
async function destroy(url: string, params?: Params): Promise<any> {
100-
const parameters: FetchParams = {
106+
const headers: any = { Accept: 'application/json' };
107+
108+
if (token.value) {
109+
headers.Authorization = `Bearer ${token.value}`;
110+
}
111+
112+
const parameters: FetchOptions = {
101113
...params,
102114
...{
103-
headers: { Accept: 'application/json', Authorization: `Bearer ${token.value}` },
115+
headers,
104116
method: 'DELETE',
105117
baseURL,
106118
},

storage/framework/.stacks/core/vite/src/desktop.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ export const pagesConfig = {
3434
}),
3535
AutoImport({
3636
imports: [
37-
'pinia',
3837
'vue',
38+
'vue-router',
3939
'vue-i18n',
40+
'@vueuse/head',
41+
'@vueuse/core'
4042
],
4143
dts: p.projectStoragePath('framework/stacks/auto-imports.d.ts'),
4244
dirs: [
4345
p.projectStoragePath('framework/stacks/dashboard/src/functions'),
44-
p.projectStoragePath('framework/stacks/dashboard/src/store'),
4546
],
4647
}),
4748
pages({

storage/framework/.stacks/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
"import": "./core/ai/dist/index.js"
5252
},
5353
"./api": {
54-
"bun": "./core/ai/src/index.ts",
55-
"types": "./core/ai/dist/index.d.ts",
56-
"import": "./core/ai/dist/index.js"
54+
"bun": "./core/api/src/index.ts",
55+
"types": "./core/api/dist/index.d.ts",
56+
"import": "./core/api/dist/index.js"
5757
},
5858
"./alias": {
5959
"bun": "./core/alias/src/index.ts",

storage/framework/stacks/dashboard/src/App.vue

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
<script setup lang="ts">
2-
// import { onMounted } from 'vue'
3-
// import { listen } from '@tauri-apps/api/event'
42
5-
// onMounted(async () => {
6-
// await listen<string>('settings', (event) => {
7-
// // eslint-disable-next-line no-console
8-
// console.log(`Got error in window ${event.windowLabel}, payload: ${event.payload}`)
9-
// })
10-
11-
// // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
12-
// })
133
</script>
144

155
<template>

storage/framework/stacks/dashboard/src/components/Deployments/ActivityFeed.vue

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2+
<script setup lang="ts">
3+
import { useGitStore } from '../../stores/git';
4+
const githubStore = useGitStore()
5+
const github = useGithub()
6+
7+
onMounted(async () => {
8+
await githubStore.fetchCommits()
9+
})
10+
</script>
11+
112
<template>
213
<aside class="bg-black/2 lg:fixed lg:bottom-0 lg:right-0 lg:top-16 lg:w-96 lg:overflow-y-auto lg:border-l lg:border-white/5">
314
<header class="flex items-center justify-between border-b border-white/5 px-4 py-4 sm:px-6 sm:py-6 lg:px-8">
@@ -15,13 +26,3 @@
1526
</ul>
1627
</aside>
1728
</template>
18-
19-
<script setup lang="ts">
20-
import { useGitStore } from '../../stores/git';
21-
const githubStore = useGitStore()
22-
const github = useGithub()
23-
24-
onMounted(async () => {
25-
await githubStore.fetchCommits()
26-
})
27-
</script>

storage/framework/stacks/dashboard/src/components/Deployments/DeploymentList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@
7373
7474
return 'text-gray-500 bg-gray-100/10'
7575
}
76-
</script>
76+
</script>../../stores/gitHelper

storage/framework/stacks/dashboard/src/functions/github.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ export function useGithub() {
3636

3737
return `${weeksDifference}w`;
3838
}
39+
40+
function formatDuration(durationInSeconds: number): string {
41+
const minutes = Math.floor(durationInSeconds / 60);
42+
const seconds = durationInSeconds % 60;
43+
44+
if (minutes > 1)
45+
return `${minutes}m ${seconds}s`;
46+
47+
return `${seconds}s`;
48+
}
49+
50+
function getActionRunDuration(startTime: Date, endTime: Date): string {
51+
const start = new Date(startTime)
52+
const end = new Date(endTime)
53+
const durationInSeconds = Math.floor((end.getTime() - start.getTime()) / 1000)
54+
55+
return formatDuration(durationInSeconds)
56+
}
3957

40-
return { getTimeDifference }
58+
return { getTimeDifference, formatDuration, getActionRunDuration }
4159
}

storage/framework/stacks/dashboard/src/pages/commands/index.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<script setup lang="ts">
2+
useHead({
3+
title: 'Dashboard - Commands',
4+
})
5+
26
import { ref } from 'vue'
37
import AppButton from '../../components/Buttons/AppButton.vue'
48

storage/framework/stacks/dashboard/src/pages/dependencies/index.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<script lang="ts" setup>
2+
useHead({
3+
title: 'Dashboard - Dependencies',
4+
})
5+
26
import AppButton from '../../components/Buttons/AppButton.vue'
37
</script>
48

storage/framework/stacks/dashboard/src/pages/deployments/[id].vue

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
<script setup lang="ts">
2+
import { useGitStore } from '../../stores/git'
3+
4+
const gitStore = useGitStore()
5+
const github = useGithub()
6+
const route = useRoute()
7+
8+
onMounted(async () =>{
9+
await gitStore.fetchWorkflowAction(route.params.id)
10+
})
11+
12+
useHead({
13+
title: `Deployments - ${route.params.id}`,
14+
})
15+
216
import { ref } from 'vue'
317
418
const flag = ref(false)
19+
20+
function getStatus(conclusion: string) {
21+
if (conclusion === 'success') return 'Ready'
22+
23+
return 'Failed'
24+
}
525
</script>
626

727
<template>
8-
<div class="px-4 sm:px-6 lg:px-8 py-8">
28+
<div v-if="gitStore.workflowRun" class="px-4 sm:px-6 lg:px-8 py-8">
929
<div class="rounded-lg bg-white px-6 py-8 text-sm dark:bg-blue-gray-800">
1030
<div class="px-4 sm:px-0">
1131
<h3 class="text-base font-semibold leading-7 text-gray-900 dark:text-gray-100">
@@ -18,24 +38,20 @@ const flag = ref(false)
1838
<dt class="text-sm font-medium leading-6 text-gray-900 dark:text-gray-100">
1939
Status
2040
</dt>
21-
<dd class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0 dark:text-gray-200 dark:text-gray-200">
22-
Ready
23-
</dd>
24-
</div>
25-
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
26-
<dt class="text-sm font-medium leading-6 text-gray-900 dark:text-gray-100">
27-
Environment
28-
</dt>
29-
<dd class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0 dark:text-gray-200 dark:text-gray-200">
30-
Production
41+
<dd class="mt-1 text-sm leading-6 text-gray-700 flex items-center sm:col-span-2 sm:mt-0 dark:text-gray-200 dark:text-gray-200">
42+
<span> {{ getStatus(gitStore.workflowRun.conclusion) }} </span>
43+
<svg fill="none" class="text-green-500 w-5 h-5 ml-2" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
44+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
45+
</svg>
3146
</dd>
3247
</div>
48+
3349
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
3450
<dt class="text-sm font-medium leading-6 text-gray-900 dark:text-gray-100">
3551
Duration
3652
</dt>
3753
<dd class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0 dark:text-gray-200 dark:text-gray-200">
38-
50s
54+
{{ github.getActionRunDuration(gitStore.workflowRun.created_at, gitStore.workflowRun.updated_at) }}
3955
</dd>
4056
</div>
4157
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
@@ -103,10 +119,11 @@ const flag = ref(false)
103119
<a
104120
href="#"
105121
class="hover:underline"
122+
v-if="gitStore.workflowRun.head_commit"
106123
>
107124

108-
<code class="text-xs">b0f6755</code>
109-
<span class="pl-1">chore: readme</span>
125+
<code class="text-xs">{{ gitStore.workflowRun.head_commit.id.slice(0, 10) }}</code>
126+
<span class="pl-1">{{ gitStore.workflowRun.head_commit.message }}</span>
110127
</a>
111128
</div>
112129
</dd>

0 commit comments

Comments
 (0)