Files
api/web/components/UserProfile/DropdownConnectStatus.vue
Michael Datelle 741e8532ab refactor: unraid-ui-web-migration (#1106)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced enhanced stepper components for smoother multi-step
interactions.
- Added new loading indicators and improved the loading experience with
customizable variants.
  
- **UI Improvements**
- Refreshed the global color palette and updated styling across buttons,
badges, and loading indicators for a more modern, consistent experience.
- Improved the organization and readability of templates and styles
across various components.

- **Code & Dependency Updates**
- Updated key dependencies and revised the theme and configuration
settings to improve performance and maintainability.
- Introduced new environment variables for better configuration
management.

- **Legacy Cleanup**
- Removed deprecated components and streamlined registrations to
simplify the codebase without affecting end-user functionality.
- Eliminated unused utility functions and legacy code to enhance overall
code quality.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mdatelle <mike@datelle.net>
Co-authored-by: Eli Bosley <ekbosley@gmail.com>
2025-02-12 18:00:06 -05:00

73 lines
2.1 KiB
Vue

<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { CheckCircleIcon, ExclamationTriangleIcon, UserCircleIcon } from '@heroicons/vue/24/solid';
import { BrandLoading } from '@unraid/ui';
import type { ComposerTranslation } from 'vue-i18n';
import { useServerStore } from '~/store/server';
import { useUnraidApiStore } from '~/store/unraidApi';
const props = defineProps<{ t: ComposerTranslation }>();
const { username } = storeToRefs(useServerStore());
const unraidApiStore = useUnraidApiStore();
const { unraidApiStatus, unraidApiRestartAction } = storeToRefs(unraidApiStore);
interface StatusOutput {
icon: typeof BrandLoading | typeof ExclamationTriangleIcon | typeof CheckCircleIcon;
iconClasses?: string;
text: string;
textClasses?: string;
}
const status = computed((): StatusOutput | undefined => {
if (unraidApiStatus.value === 'connecting') {
return {
icon: BrandLoading,
iconClasses: 'w-16px',
text: props.t('Loading…'),
textClasses: 'italic',
};
}
if (unraidApiStatus.value === 'restarting') {
return {
icon: BrandLoading,
iconClasses: 'w-16px',
text: props.t('Restarting unraid-api…'),
textClasses: 'italic',
};
}
if (unraidApiStatus.value === 'offline') {
return {
icon: ExclamationTriangleIcon,
iconClasses: 'text-red-500 w-16px h-16px',
text: props.t('unraid-api is offline'),
};
}
if (unraidApiStatus.value === 'online') {
return {
icon: CheckCircleIcon,
iconClasses: 'text-green-600 w-16px h-16px',
text: props.t('Connected'),
};
}
return undefined;
});
</script>
<template>
<li v-if="username" class="flex flex-row justify-start items-center gap-8px mt-8px px-8px">
<UserCircleIcon class="w-16px h-16px" aria-hidden="true" />
{{ username }}
</li>
<li v-if="status" class="flex flex-row justify-start items-center gap-8px mt-8px px-8px">
<component :is="status.icon" :class="status.iconClasses" aria-hidden="true" />
{{ status.text }}
</li>
<li v-if="unraidApiRestartAction" class="w-full">
<UpcDropdownItem :item="unraidApiRestartAction" :t="t" />
</li>
</template>