Skip to content

Commit

Permalink
Merge pull request #42 from simonsobs/queue
Browse files Browse the repository at this point in the history
Add Queue
  • Loading branch information
TaiSakuma authored May 7, 2024
2 parents 338f60f + 99dba79 commit aefa479
Show file tree
Hide file tree
Showing 51 changed files with 1,504 additions and 210 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="icon" href="/favicon.ico">
<title>loading..</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@7.x/css/materialdesignicons.min.css">
</head>
<body>
<noscript>
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"dependencies": {
"@material/material-color-utilities": "^0.2.7",
"@urql/vue": "^1.1.2",
"@vuelidate/core": "^2.0.3",
"@vuelidate/validators": "^2.0.4",
"@vueuse/core": "^10.7.2",
"@vueuse/integrations": "^10.7.2",
"canvas": "^2.11.2",
Expand All @@ -24,7 +26,7 @@
"pinia": "^2.1.7",
"vue": "~3.4.18",
"vue-router": "^4.2.5",
"vuetify": "~3.5.3"
"vuetify": "~3.5.14"
},
"devDependencies": {
"@babel/core": "^7.23.9",
Expand Down Expand Up @@ -55,6 +57,6 @@
"vite": "~5.1.1",
"vite-plugin-monaco-editor": "^1.1.0",
"vite-plugin-package-version": "^1.1.0",
"vitest": "~1.2.2"
"vitest": "~1.4.0"
}
}
3 changes: 2 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export * from "./use-run-no-subscription";
export * from "./use-state-subscription";
export * from "./use-trace_ids-subscription";
export * from "./use-continuous-enabled-subscription";
export * from "./use-schedule-auto-mode-subscription";
export * from "./use-schedule-auto-mode-state-subscription";
export * from "./use-schedule-auto-mode-mode-subscription";
42 changes: 42 additions & 0 deletions src/api/use-schedule-auto-mode-mode-subscription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { computed } from "vue";
import type { ComputedRef } from "vue";
import {
useQScheduleAutoModeModeQuery,
useScheduleAutoModeModeSubscription,
} from "@/graphql/codegen/generated";

// type AutoMode = "off" | "scheduler" | "queue";

interface _ScheduleAutoModeModeSubscription {
autoModeMode: ComputedRef<string | undefined>;
error: ComputedRef<Error | undefined>;
subscription: ReturnType<typeof useScheduleAutoModeModeSubscription>;
query: ReturnType<typeof useQScheduleAutoModeModeQuery>;
}

type ScheduleAutoModeModeSubscription = _ScheduleAutoModeModeSubscription &
PromiseLike<_ScheduleAutoModeModeSubscription>;

export function useSubscribeScheduleAutoModeMode(): ScheduleAutoModeModeSubscription {
const query = useQScheduleAutoModeModeQuery({ requestPolicy: "network-only" });
const subscription = useScheduleAutoModeModeSubscription();

const error = computed(() => subscription.error?.value || query.error?.value);

const autoModeMode = computed(() =>
error.value
? undefined
: subscription.data?.value?.scheduleAutoModeMode ||
query.data?.value?.schedule.autoMode.mode
);

const ret = { autoModeMode, error, subscription, query };

return {
...ret,
async then(onFulfilled, onRejected) {
await query;
return Promise.resolve(ret).then(onFulfilled, onRejected);
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ import {
useScheduleAutoModeStateSubscription,
} from "@/graphql/codegen/generated";

interface _ScheduleAutoModeSubscription {
autoMode: ComputedRef<boolean | undefined>;
interface _ScheduleAutoModeStateSubscription {
autoModeState: ComputedRef<string | undefined>;
error: ComputedRef<Error | undefined>;
subscription: ReturnType<typeof useScheduleAutoModeStateSubscription>;
query: ReturnType<typeof useQScheduleAutoModeStateQuery>;
}

type ScheduleAutoModeSubscription = _ScheduleAutoModeSubscription &
PromiseLike<_ScheduleAutoModeSubscription>;
type ScheduleAutoModeStateSubscription = _ScheduleAutoModeStateSubscription &
PromiseLike<_ScheduleAutoModeStateSubscription>;

export function useSubscribeScheduleAutoMode(): ScheduleAutoModeSubscription {
export function useSubscribeScheduleAutoModeState(): ScheduleAutoModeStateSubscription {
const query = useQScheduleAutoModeStateQuery({ requestPolicy: "network-only" });
const subscription = useScheduleAutoModeStateSubscription();

Expand All @@ -29,13 +28,7 @@ export function useSubscribeScheduleAutoMode(): ScheduleAutoModeSubscription {
query.data?.value?.schedule.autoMode.state
);

const autoMode = computed(() => {
const s = autoModeState.value;
if (s === "off") return false;
if (s === "waiting" || s?.startsWith("auto")) return true;
return undefined;
});
const ret = { autoMode, autoModeState, error, subscription, query };
const ret = { autoModeState, error, subscription, query };

return {
...ret,
Expand Down
43 changes: 43 additions & 0 deletions src/api/use-schedule-queue-items-subscription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { computed } from "vue";
import type { ComputedRef } from "vue";
import {
useQScheduleQueueItemsQuery,
useSScheduleQueueItemsSubscription,
} from "@/graphql/codegen/generated";
import type { ScheduleQueueItem } from "@/graphql/codegen/generated";

interface _ScheduleQueueItemsSubscription {
items: ComputedRef<ScheduleQueueItem[] | undefined>;
loading: ComputedRef<boolean>;
error: ComputedRef<Error | undefined>;
subscription: ReturnType<typeof useSScheduleQueueItemsSubscription>;
query: ReturnType<typeof useQScheduleQueueItemsQuery>;
}

type ScheduleQueueItemsSubscription = _ScheduleQueueItemsSubscription &
PromiseLike<_ScheduleQueueItemsSubscription>;

export function useSubscribeScheduleQueueItems(): ScheduleQueueItemsSubscription {
const query = useQScheduleQueueItemsQuery({ requestPolicy: "network-only" });
const subscription = useSScheduleQueueItemsSubscription();

const loading = computed(() => query.fetching?.value);
const error = computed(() => subscription.error?.value || query.error?.value);

const items = computed(() =>
error.value
? undefined
: subscription.data?.value?.scheduleQueueItems ||
query.data?.value?.schedule.queue.items
);

const ret = { items, loading, error, subscription, query };

return {
...ret,
async then(onFulfilled, onRejected) {
await query;
return Promise.resolve(ret).then(onFulfilled, onRejected);
},
};
}
16 changes: 9 additions & 7 deletions src/app/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
</router-link>
</template>
<template v-slot:append>
<span v-if="!mobile"> {{ version }} </span>
<v-btn icon="mdi-graphql" :href="apiHttp" target="_blank"> </v-btn>
<toggle-dark-mode-button></toggle-dark-mode-button>
<schedule-ctrl></schedule-ctrl>
<template v-if="!mobile">
<span class="mx-4"> {{ version }} </span>
<v-btn icon="mdi-graphql" :href="apiHttp" target="_blank"> </v-btn>
<toggle-dark-mode-button></toggle-dark-mode-button>
</template>
<auto-mode-button></auto-mode-button>
</template>
<template v-slot:extension v-if="!mobile">
<tab-navi></tab-navi>
<tab-navi></tab-navi>
</template>
</v-app-bar>
</template>
Expand All @@ -29,10 +31,10 @@ import { ref, computed } from "vue";
import { useDisplay } from "vuetify";
import { useConfig } from "@/utils/config";
import ToggleDarkModeButton from "@/components/utils/ToggleDarkModeButtonWithTooltip.vue";
import AutoModeButton from "@/components/auto-mode-button/AutoModeButton.vue";
import TabNavi from "./TabNavi.vue";
import ToggleDarkModeButton from "@/components/utils/ToggleDarkModeButton.vue";
import ScheduleCtrl from "@/components/ScheduleCtrl.vue";
const { mobile } = useDisplay();
Expand Down
12 changes: 12 additions & 0 deletions src/app/AppMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
</div>
</div>
</template>
<!-- Note on transition and keep-alive:
The v-fade-transition component has options leave-absolute and hide-on-leave.
The combination of leave-absolute and keep-alive should work. However, the
component content might shift before the transition starts unless the
component's CSS is carefully designed. This shift can be quite distracting.
If that happens, instead of leave-absolute, hide-on-leave can be useful. However,
hide-on-leave doesn't work with keep-alive because the component content will
stay hidden.
-->

<script setup lang="ts">
import { useDisplay } from "vuetify";
Expand Down
5 changes: 4 additions & 1 deletion src/app/NavigationDrawer.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<template>
<v-navigation-drawer disable-resize-watcher comment="fallthrough attributes">
<div class="px-8 py-5">
<span class="text-primary font-weight-bold"> {{ appName }} </span>
<span class="text-primary font-weight-bold"> {{ appName }} : {{ apiName }} </span>
</div>
<list-navi></list-navi>
<template v-slot:append>
<div class="ma-4 d-flex justify-space-around align-center">
<toggle-dark-mode-button></toggle-dark-mode-button>
<span class="text-secondary text-body-2">v{{ version }}</span>
</div>
</template>
Expand All @@ -15,8 +16,10 @@
<script setup lang="ts">
import { ref, computed } from "vue";
import { useConfig } from "@/utils/config";
import ToggleDarkModeButton from "@/components/utils/ToggleDarkModeButton.vue";
import ListNavi from "./ListNavi.vue";
const { config } = useConfig();
const version = ref(import.meta.env.PACKAGE_VERSION);
const appName = computed(() => config.value.appName || "loading...");
const apiName = computed(() => config.value.apiName || "");
</script>
6 changes: 6 additions & 0 deletions src/app/navi-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export function useNaviItems() {
to: toValue(lastInDb),
exact: false,
},
{
icon: "mdi-list-box",
title: "Queue",
to: { name: "queue" },
exact: true,
}
]);

return { naviItems };
Expand Down
66 changes: 0 additions & 66 deletions src/components/DialogAutoMode.vue

This file was deleted.

29 changes: 0 additions & 29 deletions src/components/ScheduleCtrl.vue

This file was deleted.

17 changes: 17 additions & 0 deletions src/components/auto-mode-button/AutoModeButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<v-card-actions>
<button-off v-if="mode === 'off'"></button-off>
<button-scheduler v-else-if="mode === 'scheduler'"></button-scheduler>
<button-queue v-else-if="mode === 'queue'"></button-queue>
<button-error v-else></button-error>
</v-card-actions>
</template>

<script setup lang="ts">
import ButtonError from "./modes/error/Button.vue";
import ButtonOff from "./modes/off/Button.vue";
import ButtonScheduler from "./modes/scheduler/Button.vue";
import ButtonQueue from "./modes/queue/Button.vue";
import { useSubscribeScheduleAutoModeMode } from "@/api";
const { autoModeMode: mode } = await useSubscribeScheduleAutoModeMode();
</script>
12 changes: 12 additions & 0 deletions src/components/auto-mode-button/modes/error/Button.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<v-menu>
<template v-slot:activator="{ props }">
<v-btn v-bind="props" variant="tonal" color="error"> Auto Mode: Unknown </v-btn>
</template>
<dialog-error></dialog-error>
</v-menu>
</template>

<script setup lang="ts">
import DialogError from "./Dialog.vue";
</script>
Loading

0 comments on commit aefa479

Please sign in to comment.