Skip to content

Commit

Permalink
fix(#117): ts fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukashornych committed Sep 29, 2024
1 parent a5a37ab commit 7d964bc
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 97 deletions.
2 changes: 1 addition & 1 deletion src/modules/backup-viewer/components/BackupViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async function downloadBackup(file: File){
:connection="params.connection"
:subheader="t('backupViewer.tasks.title')"
:states="[TaskState.Running, TaskState.Queued]"
:task-type="backupTaskName"
:task-types="[backupTaskName, restoreTaskName]"
:page-size="5"
hideable-pagination
@update:active-jobs-present="backupsInPreparationPresent = $event"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/connection/driver/EvitaDBDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export interface EvitaDBDriver {
pageNumber: number,
pageSize: number,
states?: TaskState[],
taskType?: string
taskTypes?: string[]
): Promise<TaskStatuses>
//TODO: Add doc
restoreCatalog(connection: Connection, fileId: Uuid, catalogName: string): Promise<TaskStatus>
Expand Down
6 changes: 3 additions & 3 deletions src/modules/connection/driver/grpc/EvitaDBDriverGrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Catalog } from '../../model/Catalog'
import { Connection } from '../../model/Connection'
import { Response } from '../../model/data/Response'
import { CatalogSchema } from '../../model/schema/CatalogSchema'
import { Empty } from '@bufbuild/protobuf'
import { Empty, StringValue } from '@bufbuild/protobuf'
import { CatalogSchemaConverter } from '../grpc/service/CatalogSchemaConverter'
import { CatalogConverter } from '../grpc/service/CatalogConverter'
import { ResponseConverter } from './service/ResponseConverter'
Expand Down Expand Up @@ -524,7 +524,7 @@ export class EvitaDBDriverGrpc implements EvitaDBDriver {
pageNumber: number,
pageSize: number,
states?: TaskState[],
taskType?: string
taskTypes?: string[]
): Promise<TaskStatuses> {
const params = states && states.length > 0
? this.taskStateConverter.convertTaskStatesToGrpc(states)
Expand All @@ -534,7 +534,7 @@ export class EvitaDBDriverGrpc implements EvitaDBDriver {
.listTaskStatuses({
pageNumber,
pageSize,
taskType,
taskType: taskTypes?.map(taskType => StringValue.fromJson(taskType)) || undefined,
simplifiedState: params
})
const jobs = this.taskStatusConverter.convertJobs(result)
Expand Down
4 changes: 4 additions & 0 deletions src/modules/connection/driver/grpc/service/ScalarConverter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Scalar } from "@/modules/connection/model/data-type/Scalar"
import { GrpcEvitaAssociatedDataDataType_GrpcEvitaDataType, GrpcEvitaDataType } from '../gen/GrpcEnums_pb'
import { UnexpectedError } from '@/modules/base/exception/UnexpectedError'

//TODO: Add docs
export class ScalarConverter{
Expand Down Expand Up @@ -75,6 +76,7 @@ export class ScalarConverter{
return Scalar.OffsetDateTimeArray
case GrpcEvitaDataType.PREDECESSOR:
return Scalar.Predecessor
// todo lho implemented referenced predecesor
case GrpcEvitaDataType.SHORT:
return Scalar.Short
case GrpcEvitaDataType.SHORT_ARRAY:
Expand All @@ -91,6 +93,8 @@ export class ScalarConverter{
return Scalar.UUID
case GrpcEvitaDataType.UUID_ARRAY:
return Scalar.UUIDArray
default:
throw new UnexpectedError(`Unsupported scalar type '${scalar}'.`)
}
}
public static convertAssociatedDataScalar(scalar: GrpcEvitaAssociatedDataDataType_GrpcEvitaDataType): Scalar {
Expand Down
3 changes: 3 additions & 0 deletions src/modules/connection/model/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const hasher: HashObject = XXH.h64()
*/
export class Connection {

// todo lho introduce type: USER, PRECONFIGURED, TEMP to not cache temp connection
// so that i can use entire driver stack without caching temp connection

readonly id: ConnectionId
readonly name: string
readonly preconfigured: boolean
Expand Down
2 changes: 1 addition & 1 deletion src/modules/jfr-viewer/components/JfrViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async function downloadRecording(file: File) {
:connection="params.connection"
:subheader="t('jfrViewer.tasks.title')"
:states="[TaskState.Running, TaskState.Queued]"
:task-type="jfrRecorderTaskName"
:task-types="[jfrRecorderTaskName]"
:page-size="5"
hideable-pagination
@update:active-jobs-present="runningRecordingsPresent = $event"
Expand Down
119 changes: 46 additions & 73 deletions src/modules/server-status/component/ServerStatus.vue
Original file line number Diff line number Diff line change
@@ -1,68 +1,50 @@
<script setup lang="ts">
import { TabComponentEvents } from '@/modules/workspace/tab/model/TabComponentEvents'
import { useServerStatusService } from '../service/ServerStatusService'
import { ServerStatusService, useServerStatusService } from '../service/ServerStatusService'
import { ref } from 'vue'
import { TabComponentProps } from '@/modules/workspace/tab/model/TabComponentProps'
import { ServerStatusTabParams } from '../model/ServerStatusTabParams'
import { VoidTabData } from '@/modules/workspace/tab/model/void/VoidTabData'
import { Duration } from 'luxon'
import { List } from 'immutable'
import Immutable, { List } from 'immutable'
import { useI18n } from 'vue-i18n'
import VTabToolbar from '@/modules/base/component/VTabToolbar.vue'
import RuntimeConfigurationDialog from '@/modules/server-status/component/RuntimeConfigurationDialog.vue'
import { EvitaLabConfig, useEvitaLabConfig } from '@/modules/config/EvitaLabConfig'
import { ServerStatus } from '@/modules/connection/model/status/ServerStatus'
import { ApiReadiness } from '@/modules/connection/model/status/ApiReadiness'
import { ApiServerStatus } from '@/modules/connection/model/status/ApiServerStatus'
import { ApiEndpoint } from '@/modules/connection/model/status/ApiEndpoint'
const serverStatusService: ServerStatusService = useServerStatusService()
const evitaLabConfig: EvitaLabConfig = useEvitaLabConfig()
const { t } = useI18n()
const emit = defineEmits<TabComponentEvents>()
const props = defineProps<TabComponentProps<ServerStatusTabParams, VoidTabData>>()
const { t } = useI18n()
const path: List<string> = List([t('serverStatus.toolbar.title')])
const serverDetailLoaded = ref<boolean>(false)
const serverDetail = ref<ServerStatus>()
const apiReadinessLoaded = ref<boolean>(false)
const apiReadiness = ref<ApiReadiness>()
const apiStatus = ref<ApiServerStatus>()
const apiStatusLoaded = ref<boolean>()
const visibleYamlDialog = ref<boolean>(false)
const runtimeConfigLoaded = ref<boolean>(false)
const runtimeConfig = ref<string>()
const serverStatusLoaded = ref<boolean>(false)
const serverStatus = ref<ServerStatus>()
const path: List<string> = List([t('serverStatus.toolbar.title')])
const serverStatusService = useServerStatusService()
const evitaLabConfig: EvitaLabConfig = useEvitaLabConfig()
const runtimeConfigurationLoaded = ref<boolean>(false)
const runtimeConfiguration = ref<string>()
const showRuntimeConfigurationDialog = ref<boolean>(false)
serverStatusService
.getServerStatistics(props.params.connection)
.getServerStatus(props.params.connection)
.then((x) => loadedServerStatus(x))
serverStatusService
.getApiReadiness(props.params.connection)
.then((x) => loadedApiReadiness(x))
serverStatusService
.getRuntimeConfiguration(props.params.connection)
.then((x) => loadedRuntimeConfig(x))
serverStatusService
.getServerStatus(props.params.connection)
.then((x) => loadedApiServerStatus(x))
.then((x) => loadedRuntimeConfiguration(x))
function loadedServerStatus(serverStatus: ServerStatus) {
serverDetail.value = serverStatus
serverDetailLoaded.value = true
function loadedServerStatus(fetchedServerStatus: ServerStatus): void {
serverStatus.value = fetchedServerStatus
serverStatusLoaded.value = true
checkAllDataLoaded()
}
function loadedApiReadiness(apiStatusValue: ApiReadiness) {
apiReadiness.value = apiStatusValue
apiReadinessLoaded.value = true
checkAllDataLoaded()
}
function loadedApiServerStatus(serverStatus: ApiServerStatus) {
apiStatus.value = serverStatus
apiStatusLoaded.value = true
function loadedRuntimeConfiguration(fetchedRuntimeConfiguration: string) {
runtimeConfiguration.value = fetchedRuntimeConfiguration
runtimeConfigurationLoaded.value = true
checkAllDataLoaded()
}
Expand All @@ -73,44 +55,30 @@ function getFormattedUptime(uptime: bigint | undefined): string {
)
}
function loadedRuntimeConfig(config: string) {
runtimeConfig.value = config
runtimeConfigLoaded.value = true
checkAllDataLoaded()
}
function checkAllDataLoaded(): void {
if (
serverDetailLoaded.value === true &&
apiReadinessLoaded.value === true &&
runtimeConfigLoaded.value === true &&
apiStatusLoaded.value === true
serverStatusLoaded.value === true &&
runtimeConfigurationLoaded.value === true
) {
emit('ready')
}
}
function findApiUrls(apiName: keyof ApiEndpoint): string[] | undefined {
return apiStatus.value?.apis.find((api) => api[apiName])?.[apiName]
function findApiUrls(apiType: ApiType): Immutable.List<string> | undefined {
return serverStatus.value?.apis.get(apiType)?.baseUrls
}
function formatUrl(url: string): string {
return url.replace('0.0.0.0', '127.0.0.1')
}
function refresh() {
serverStatusService
.getServerStatistics(props.params.connection)
.then((x) => loadedServerStatus(x))
serverStatusService
.getApiReadiness(props.params.connection)
.then((x) => loadedApiReadiness(x))
serverStatusService
.getRuntimeConfiguration(props.params.connection)
.then((x) => loadedRuntimeConfig(x))
.then((x) => loadedRuntimeConfiguration(x))
serverStatusService
.getServerStatus(props.params.connection)
.then((x) => loadedApiServerStatus(x))
.then((x) => loadedServerStatus(x))
}
</script>

Expand All @@ -124,14 +92,15 @@ function refresh() {
</VBtn>
</template>
</VTabToolbar>
<VSheet>
<div v-if="serverDetailLoaded">
<!-- todo lho reimplement -->
<!-- <VSheet>
<div v-if="serverStatusLoaded">
<VCard variant="tonal" class="w-75 a-5 container">
<VCardText>
<p class="main-title">{{ serverDetail?.instanceId }}</p>
<p class="main-title">{{ serverStatus?.instanceId }}</p>
<div class="version">
<VChip>
{{ t('serverStatus.detail.flags.version', { version: serverDetail?.version || '?' }) }}
{{ t('serverStatus.detail.flags.version', { version: serverStatus?.version || '?' }) }}
</VChip>
</div>
<div class="informative-container">
Expand All @@ -141,16 +110,20 @@ function refresh() {
</div>
<div class="informative-items">
<p>
{{ t('serverStatus.detail.stats.started', { started: serverDetail?.started?.getPrettyPrintableString() || '?' }) }}
{{ t('serverStatus.detail.stats.started', { started: serverStatus?.started?.getPrettyPrintableString() || '?' })
}}
</p>
<p>
{{ t('serverStatus.detail.stats.uptime', { uptime: getFormattedUptime(serverDetail?.uptime) || '?' }) }}
{{ t('serverStatus.detail.stats.uptime', { uptime: getFormattedUptime(serverStatus?.uptime) || '?' })
}}
</p>
<p>
{{ t('serverStatus.detail.stats.catalogsOk', { catalogCount: serverDetail?.catalogsOk || '?' }) }}
{{ t('serverStatus.detail.stats.catalogsOk', { catalogCount: serverStatus?.catalogsOk || '?' })
}}
</p>
<p>
{{ t('serverStatus.detail.stats.catalogsCorrupted', { catalogCount: serverDetail?.catalogsCorrupted || '?' }) }}
{{ t('serverStatus.detail.stats.catalogsCorrupted', { catalogCount: serverStatus?.catalogsCorrupted || '?' })
}}
</p>
<div class="log"></div>
</div>
Expand All @@ -163,7 +136,7 @@ function refresh() {
<span
:class="[
'status-circle',
apiReadiness?.apis.gRPC === 'ready'
serverStatus?.apis.get(ApiType.Grpc) === 'ready'
? 'active'
: 'inactive',
]"
Expand Down Expand Up @@ -244,10 +217,10 @@ function refresh() {
</VChip>
</VChipGroup>
</p>
<!-- todo lho: temporary disable flag, we will later introduce some kind of "demo" mode instead -->
&lt;!&ndash; todo lho: temporary disable flag, we will later introduce some kind of "demo" mode instead &ndash;&gt;
<VChip
:disabled="evitaLabConfig.readOnly"
@click="visibleYamlDialog = true"
@click="showRuntimeConfigurationDialog = true"
variant="outlined"
class="w-75 bottom-title"
>
Expand All @@ -258,12 +231,12 @@ function refresh() {
</VCardText>
</VCard>
<RuntimeConfigurationDialog
v-if="runtimeConfigLoaded"
v-model="visibleYamlDialog"
:runtime-configuration="runtimeConfig!"
v-if="runtimeConfigurationLoaded"
v-model="showRuntimeConfigurationDialog"
:runtime-configuration="runtimeConfiguration!"
/>
</div>
</VSheet>
</VSheet>-->
</div>
</template>

Expand Down
16 changes: 2 additions & 14 deletions src/modules/server-status/service/ServerStatusService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { Connection } from '@/modules/connection/model/Connection'
import { mandatoryInject } from '@/utils/reactivity'
import { InjectionKey } from 'vue'
import { ServerStatus } from '@/modules/connection/model/status/ServerStatus'
import { ApiReadiness } from '@/modules/connection/model/status/ApiReadiness'
import { ApiServerStatus } from '@/modules/connection/model/status/ApiServerStatus'

export const serverStatusServiceInjectionKey: InjectionKey<ServerStatusService> = Symbol('serverStatusService')

Expand All @@ -16,22 +14,12 @@ export class ServerStatusService {
this.evitaDBDriverResolver = evitaDBDriver
}

async getServerStatistics(connection: Connection): Promise<ServerStatus> {
const driver = await this.evitaDBDriverResolver.resolveDriver(connection)
return await driver.getServerDetails(connection)
}

async getApiReadiness(connection: Connection): Promise<ApiReadiness> {
const driver = await this.evitaDBDriverResolver.resolveDriver(connection)
return await driver.getApiReadiness(connection);
}

async getServerStatus(connection: Connection):Promise<ApiServerStatus> {
async getServerStatus(connection: Connection):Promise<ServerStatus> {
const driver = await this.evitaDBDriverResolver.resolveDriver(connection)
return await driver.getServerStatus(connection)
}

async getRuntimeConfiguration(connection: Connection):Promise<string> {
async getRuntimeConfiguration(connection: Connection): Promise<string> {
const driver = await this.evitaDBDriverResolver.resolveDriver(connection)
return await driver.getRuntimeConfiguration(connection)
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/task-viewer/components/TasksVisualizer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const props = withDefaults(
subheader?: string,
connection: Connection
states?: TaskState[]
taskType?: string,
taskTypes?: string[],
pageSize?: number,
hideablePagination?: boolean,
}>(),
Expand Down Expand Up @@ -82,7 +82,7 @@ async function loadTaskStatuses(): Promise<void> {
pageNumber.value,
props.pageSize,
props.states,
props.taskType
props.taskTypes
)
taskStatuses.value = fetchedTaskStatuses
Expand Down
4 changes: 2 additions & 2 deletions src/modules/task-viewer/services/TaskViewerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export class TaskViewerService {
pageNumber: number,
pageSize: number,
states?: TaskState[],
taskType?: string): Promise<TaskStatuses>{
taskTypes?: string[]): Promise<TaskStatuses>{
const driver = await this.connectionService.getDriver(connection)
return await driver.getTaskStatuses(connection, pageNumber, pageSize, states, taskType)
return await driver.getTaskStatuses(connection, pageNumber, pageSize, states, taskTypes)
}

async cancelTask(connection: Connection, taskId: Uuid): Promise<boolean> {
Expand Down

0 comments on commit 7d964bc

Please sign in to comment.