mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-17 13:02:26 +00:00
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
* UBERF-9731 Recorder initial version Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> * fix: rush validate issues Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com> --------- Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
// Copyright © 2025 Hardcore Engineering Inc.
|
|
//
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License. You may
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
//
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
import drive, { createFile } from '@hcengineering/drive'
|
|
import { translate } from '@hcengineering/platform'
|
|
import { getClient } from '@hcengineering/presentation'
|
|
import { type FileUploadCallback, type FileUploadCallbackParams } from '@hcengineering/uploader'
|
|
import recorder from './plugin'
|
|
|
|
export function formatElapsedTime (elapsed: number): string {
|
|
const seconds = Math.floor(elapsed / 1000)
|
|
const minutes = Math.floor(seconds / 60)
|
|
const hours = Math.floor(minutes / 60)
|
|
|
|
const displaySeconds = (seconds % 60).toString().padStart(2, '0')
|
|
const displayMinutes = (minutes % 60).toString().padStart(2, '0')
|
|
|
|
return hours > 0 ? `${hours}:${displayMinutes}:${displaySeconds}` : `${displayMinutes}:${displaySeconds}`
|
|
}
|
|
|
|
export async function formatRecordingName (date: Date): Promise<string> {
|
|
const timeStr = date.toLocaleTimeString()
|
|
const dateStr = date.toLocaleDateString(undefined, {
|
|
day: 'numeric',
|
|
month: 'long',
|
|
year: 'numeric'
|
|
})
|
|
|
|
return await translate(recorder.string.RecordingTitle, { date: dateStr + ' ' + timeStr })
|
|
}
|
|
|
|
export const createRecordingInDrive: FileUploadCallback = async (params: FileUploadCallbackParams): Promise<void> => {
|
|
const { uuid, name, file, metadata } = params
|
|
|
|
const client = getClient()
|
|
const data = {
|
|
file: uuid,
|
|
size: file.size,
|
|
type: file.type,
|
|
lastModified: file instanceof File ? file.lastModified : Date.now(),
|
|
title: name,
|
|
metadata
|
|
}
|
|
|
|
await createFile(client, recorder.space.Drive, drive.ids.Root, data)
|
|
}
|