Merge remote-tracking branch 'origin/develop' into staging

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-12-12 16:40:02 +07:00
commit 1926088489
No known key found for this signature in database
GPG Key ID: BD80F68D68D8F7F2
29 changed files with 197 additions and 144 deletions

7
.vscode/launch.json vendored
View File

@ -181,7 +181,6 @@
"request": "launch",
"args": ["src/__start.ts"],
"env": {
"ELASTIC_URL": "http://localhost:9200",
"MONGO_URL": "mongodb://localhost:27017",
"METRICS_CONSOLE": "false",
"STORAGE_CONFIG": "minio|localhost?accessKey=minioadmin&secretKey=minioadmin",
@ -264,8 +263,7 @@
"SERVER_SECRET": "secret",
"MONGO_URL": "mongodb://localhost:27017",
"ACCOUNTS_URL": "http://localhost:3000",
"TELEGRAM_DATABASE": "telegram-service",
"ELASTIC_URL": "http://localhost:9200"
"TELEGRAM_DATABASE": "telegram-service"
},
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"sourceMaps": true,
@ -290,7 +288,6 @@
"DB_URL": "mongodb://localhost:27017",
"ACCOUNTS_URL": "http://localhost:3000",
"TELEGRAM_DATABASE": "telegram-service",
"ELASTIC_URL": "http://localhost:9200",
"REKONI_URL": "http://localhost:4004",
"MODEL_VERSION": "0.6.287"
},
@ -318,7 +315,6 @@
"DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable",
"MONGO_URL": "mongodb://localhost:27017",
"TELEGRAM_DATABASE": "telegram-service",
"ELASTIC_URL": "http://localhost:9200",
"REKONI_URL": "http://localhost:4004",
"MODEL_VERSION": "0.6.287"
},
@ -342,7 +338,6 @@
"DB_URL": "postgresql://postgres:example@localhost:5432",
"ACCOUNTS_URL": "http://localhost:3000",
"TELEGRAM_DATABASE": "telegram-service",
"ELASTIC_URL": "http://localhost:9200",
"REKONI_URL": "http://localhost:4004"
},
"runtimeVersion": "20",

View File

@ -232,7 +232,6 @@ services:
- ACCOUNTS_URL=http://host.docker.internal:3000
- STATS_URL=http://host.docker.internal:4900
- UPLOAD_URL=/files
- ELASTIC_URL=http://host.docker.internal:9200
- GMAIL_URL=http://host.docker.internal:8088
- CALENDAR_URL=http://host.docker.internal:8095
- TELEGRAM_URL=http://host.docker.internal:8086

View File

@ -19,8 +19,8 @@
"docker:tbuild": "docker build -t hardcoreeng/import-tool . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/import-tool",
"docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/import-tool staging",
"docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/import-tool",
"run-local": "rush bundle --to @hcengineering/import-tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost MONGO_URL=mongodb://localhost:27017 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --max-old-space-size=18000 ./bundle/bundle.js",
"run-local-brk": "rush bundle --to @hcengineering/import-tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost MONGO_URL=mongodb://localhost:27017 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --inspect-brk --enable-source-maps --max-old-space-size=18000 ./bundle/bundle.js",
"run-local": "rush bundle --to @hcengineering/import-tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost MONGO_URL=mongodb://localhost:27017 TELEGRAM_DATABASE=telegram-service REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --max-old-space-size=18000 ./bundle/bundle.js",
"run-local-brk": "rush bundle --to @hcengineering/import-tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost MONGO_URL=mongodb://localhost:27017 TELEGRAM_DATABASE=telegram-service REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --inspect-brk --enable-source-maps --max-old-space-size=18000 ./bundle/bundle.js",
"run": "rush bundle --to @hcengineering/import-tool >/dev/null && cross-env node --max-old-space-size=8000 ./bundle/bundle.js",
"upgrade": "rushx run-local upgrade",
"format": "format src",

View File

@ -87,7 +87,6 @@ services:
- 'MONGO_OPTIONS={"appName":"front","maxPoolSize":1}'
- ACCOUNTS_URL=http://localhost:3000
- UPLOAD_URL=/files
- ELASTIC_URL=http://elastic:9200
- GMAIL_URL=http://localhost:8088
- CALENDAR_URL=http://localhost:8095
- TELEGRAM_URL=http://localhost:8086
@ -121,7 +120,6 @@ services:
- SERVER_PORT=3333
- SERVER_SECRET=secret
- ENABLE_COMPRESSION=true
- ELASTIC_URL=http://elastic:9200
- MONGO_URL=mongodb://host.docker.internal:27017?compressors=snappy
- 'MONGO_OPTIONS={"appName": "transactor", "maxPoolSize": 10}'
- METRICS_CONSOLE=false

View File

@ -19,10 +19,10 @@
"docker:tbuild": "docker build -t hardcoreeng/tool . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/tool",
"docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/tool staging",
"docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/tool",
"run-local": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ACCOUNT_DB_URL=mongodb://localhost:27017 DB_URL=mongodb://localhost:27017 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --expose-gc --max-old-space-size=18000 ./bundle/bundle.js",
"run-local-pg": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ACCOUNT_DB_URL=mongodb://localhost:27017 DB_URL=postgresql://postgres:example@localhost:5432 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --expose-gc --max-old-space-size=18000 ./bundle/bundle.js",
"run-local-cr": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3332 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ACCOUNT_DB_URL=mongodb://localhost:27017 DB_URL=postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --expose-gc --max-old-space-size=18000 ./bundle/bundle.js",
"run-local-brk": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ACCOUNT_DB_URL=mongodb://localhost:27017 DB_URL=mongodb://localhost:27017 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --inspect-brk --enable-source-maps --max-old-space-size=18000 ./bundle/bundle.js",
"run-local": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ACCOUNT_DB_URL=mongodb://localhost:27017 DB_URL=mongodb://localhost:27017 TELEGRAM_DATABASE=telegram-service REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --expose-gc --max-old-space-size=18000 ./bundle/bundle.js",
"run-local-pg": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ACCOUNT_DB_URL=mongodb://localhost:27017 DB_URL=postgresql://postgres:example@localhost:5432 TELEGRAM_DATABASE=telegram-service REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --expose-gc --max-old-space-size=18000 ./bundle/bundle.js",
"run-local-cr": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3332 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ACCOUNT_DB_URL=mongodb://localhost:27017 DB_URL=postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable TELEGRAM_DATABASE=telegram-service REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --expose-gc --max-old-space-size=18000 ./bundle/bundle.js",
"run-local-brk": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ACCOUNT_DB_URL=mongodb://localhost:27017 DB_URL=mongodb://localhost:27017 TELEGRAM_DATABASE=telegram-service REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --inspect-brk --enable-source-maps --max-old-space-size=18000 ./bundle/bundle.js",
"run": "rush bundle --to @hcengineering/tool >/dev/null && cross-env node --max-old-space-size=8000 ./bundle/bundle.js",
"upgrade": "rushx run-local upgrade",
"format": "format src",

View File

@ -82,7 +82,6 @@ export async function cleanWorkspace (
mongoUrl: string,
workspaceId: WorkspaceId,
storageAdapter: StorageAdapter,
elasticUrl: string,
transactorUrl: string,
opt: { recruit: boolean, tracker: boolean, removedTx: boolean }
): Promise<void> {

View File

@ -167,15 +167,6 @@ export function devTool (
console.error('please provide transactor url.')
}
function getElasticUrl (): string {
const elasticUrl = process.env.ELASTIC_URL
if (elasticUrl === undefined) {
console.error('please provide elastic url')
process.exit(1)
}
return elasticUrl
}
const initScriptUrl = process.env.INIT_SCRIPT_URL
if (initScriptUrl !== undefined) {
setMetadata(toolPlugin.metadata.InitScriptURL, initScriptUrl)
@ -1443,7 +1434,7 @@ export function devTool (
await withDatabase(dbUrl, async (db) => {
const wsid = getWorkspaceId(workspace)
const endpoint = await getTransactorEndpoint(generateToken(systemAccountEmail, wsid), 'external')
await cleanWorkspace(toolCtx, dbUrl, wsid, adapter, getElasticUrl(), endpoint, cmd)
await cleanWorkspace(toolCtx, dbUrl, wsid, adapter, endpoint, cmd)
})
})
})

View File

@ -435,6 +435,26 @@ export function createModel (builder: Builder): void {
},
recruit.viewlet.TableApplicant
)
const applicationDoneOption: ViewOptionModel = {
key: 'hideDoneState',
type: 'toggle',
defaultValue: true,
actionTarget: 'query',
action: recruit.function.HideDoneState,
label: recruit.string.HideDoneState
}
// hiding applicants related to archived vacancies from applicants view
const hideApplicantsFromArchivedVacanciesOption: ViewOptionModel = {
key: 'hideArchivedVacancies',
type: 'toggle',
defaultValue: true,
actionTarget: 'query',
action: recruit.function.HideArchivedVacancies,
label: recruit.string.HideApplicantsFromArchivedVacancies
}
builder.createDoc(
view.class.Viewlet,
core.space.Model,
@ -479,9 +499,10 @@ export function createModel (builder: Builder): void {
hiddenKeys: ['name', 'attachedTo'],
sortable: true
},
baseQuery: {
isDone: false,
'$lookup.space.archived': false
viewOptions: {
groupBy: [],
orderBy: [],
other: [applicationDoneOption, hideApplicantsFromArchivedVacanciesOption]
}
},
recruit.viewlet.ApplicantTable
@ -519,25 +540,6 @@ export function createModel (builder: Builder): void {
]
}
const applicationDoneOption: ViewOptionModel = {
key: 'hideDoneState',
type: 'toggle',
defaultValue: true,
actionTarget: 'query',
action: recruit.function.HideDoneState,
label: recruit.string.HideDoneState
}
// hiding applicants related to archived vacancies from applicants view
const hideApplicantsFromArchivedVacanciesOption: ViewOptionModel = {
key: 'hideArchivedVacancies',
type: 'toggle',
defaultValue: true,
actionTarget: 'query',
action: recruit.function.HideArchivedVacancies,
label: recruit.string.HideApplicantsFromArchivedVacancies
}
const applicantViewOptions = (colors: boolean, hides: boolean): ViewOptionsModel => {
const model: ViewOptionsModel = {
groupBy: ['status', 'assignee', 'space', 'createdBy', 'modifiedBy'],
@ -794,13 +796,8 @@ export function createModel (builder: Builder): void {
{
attachTo: recruit.class.Applicant,
descriptor: task.viewlet.Kanban,
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
baseQuery: {
isDone: false,
'$lookup.space.archived': false
},
viewOptions: {
...applicantViewOptions(false, false),
...applicantViewOptions(false, true),
groupDepth: 1
},
options: {

View File

@ -65,6 +65,10 @@ export function clone (obj: any, as?: (doc: any, m: any) => any, needAs?: (value
}
}
}
if (typeOf === 'Object') {
const m = needAs?.(obj)
return m !== undefined && as !== undefined ? as(result, m) : result
}
return result
} else {
return obj

View File

@ -27,6 +27,7 @@ import core, {
IndexingUpdateEvent,
Lookup,
LookupData,
Mixin,
ModelDb,
Ref,
ReverseLookups,
@ -150,6 +151,13 @@ export class LiveQuery implements WithTx, Client {
}
private match (q: Query, doc: Doc, skipLookup = false): boolean {
if (this.getHierarchy().isMixin(q._class)) {
if (this.getHierarchy().hasMixin(doc, q._class)) {
doc = this.getHierarchy().as(doc, q._class)
} else {
return false
}
}
if (!this.getHierarchy().isDerived(doc._class, q._class)) {
// Check if it is not a mixin and not match class
const mixinClass = Hierarchy.mixinClass(doc)
@ -518,20 +526,30 @@ export class LiveQuery implements WithTx, Client {
return current
}
private asMixin (doc: Doc, mixin: Ref<Mixin<Doc>>): Doc {
if (this.getHierarchy().isMixin(mixin)) {
return this.getHierarchy().as(doc, mixin)
}
return doc
}
private async getCurrentDoc (
q: Query,
_id: Ref<Doc>,
space: Ref<Space>,
docCache: Map<string, Doc>
): Promise<boolean> {
const current = await this.getDocFromCache(docCache, _id, q._class, space, q)
let current = await this.getDocFromCache(docCache, _id, q._class, space, q)
if (q.result instanceof Promise) {
q.result = await q.result
}
const pos = q.result.findDoc(_id)
if (current !== undefined) {
current = this.asMixin(current, q._class)
}
if (current !== undefined && this.match(q, current)) {
q.result.updateDoc(current)
q.result.updateDoc(current, false)
this.refs.updateDocuments(q, [current])
} else {
if (q.options?.limit === q.result.length) {
@ -543,7 +561,6 @@ export class LiveQuery implements WithTx, Client {
if (q.options?.total === true) {
q.total--
}
return true
}
}
return false
@ -597,7 +614,7 @@ export class LiveQuery implements WithTx, Client {
if (q.result instanceof Promise) {
q.result = await q.result
}
const updatedDoc = q.result.findDoc(tx.objectId)
let updatedDoc = q.result.findDoc(tx.objectId)
if (updatedDoc !== undefined) {
// If query contains search we must check use fulltext
if (q.query.$search != null && q.query.$search.length > 0) {
@ -608,6 +625,7 @@ export class LiveQuery implements WithTx, Client {
} else {
if (updatedDoc.modifiedOn < tx.modifiedOn) {
await this.__updateMixinDoc(q, updatedDoc, tx)
updatedDoc = this.asMixin(updatedDoc, q._class)
const updateRefresh = this.checkUpdatedDocMatch(q, q.result, updatedDoc)
if (updateRefresh) {
continue

View File

@ -17,7 +17,7 @@ import {
type ViewQueryOption,
type Viewlet
} from '@hcengineering/view'
import { getCategories, getCategorySpaces } from '@hcengineering/view-resources'
import { getCategories, getCategorySpaces, concatCategories } from '@hcengineering/view-resources'
/**
* @public
@ -55,7 +55,7 @@ export async function updateTaskKanbanCategories (
viewlet.descriptor
)
if (res !== undefined) {
categories = res
categories = concatCategories(res, categories)
break
}
}
@ -78,7 +78,7 @@ export async function getTaskKanbanResultQuery (
if (viewOption.actionTarget !== 'query') continue
const queryOption = viewOption as ViewQueryOption
const f = await getResource(queryOption.action)
result = f(viewOptionsStore[queryOption.key] ?? queryOption.defaultValue, query)
result = f(viewOptionsStore[queryOption.key] ?? queryOption.defaultValue, result)
}
return result
}

View File

@ -24,9 +24,11 @@
Ref,
SortingOrder,
TxOperations,
getObjectValue
getObjectValue,
mergeQueries
} from '@hcengineering/core'
import notification from '@hcengineering/notification'
import { getResource } from '@hcengineering/platform'
import { createQuery, getClient, reduceCalls, updateAttribute } from '@hcengineering/presentation'
import ui, {
Button,
@ -39,7 +41,14 @@
mouseAttractor,
resizeObserver
} from '@hcengineering/ui'
import { AttributeModel, BuildModelKey, BuildModelOptions } from '@hcengineering/view'
import {
AttributeModel,
BuildModelKey,
BuildModelOptions,
ViewOptionModel,
ViewOptions,
ViewQueryOption
} from '@hcengineering/view'
import { deepEqual } from 'fast-equals'
import { createEventDispatcher } from 'svelte'
import { showMenu } from '../actions'
@ -59,6 +68,8 @@
export let tableId: string | undefined = undefined
export let readonly = false
export let showFooter = false
export let viewOptionsConfig: ViewOptionModel[] | undefined = undefined
export let viewOptions: ViewOptions | undefined = undefined
export let totalQuery: DocumentQuery<Doc> | undefined = undefined
@ -117,6 +128,29 @@
: { ...(options?.sort ?? {}), [sortKey]: sortOrder }
}
async function getResultQuery (
query: DocumentQuery<Doc>,
viewOptions: ViewOptionModel[] | undefined,
viewOptionsStore: ViewOptions | undefined
): Promise<DocumentQuery<Doc>> {
if (viewOptions === undefined || viewOptionsStore === undefined) {
return query
}
let result: DocumentQuery<Doc> = hierarchy.clone(query)
for (const viewOption of viewOptions) {
if (viewOption.actionTarget !== 'query') continue
const queryOption = viewOption as ViewQueryOption
const f = await getResource(queryOption.action)
const resultP = f(viewOptionsStore[queryOption.key] ?? queryOption.defaultValue, result)
if (resultP instanceof Promise) {
result = await resultP
} else {
result = resultP
}
}
return result
}
const update = reduceCalls(async function (
_class: Ref<Class<Doc>>,
query: DocumentQuery<Doc>,
@ -126,9 +160,11 @@
limit: number,
options?: FindOptions<Doc>
) {
const p = await getResultQuery(query, viewOptionsConfig, viewOptions)
const resultQuery = mergeQueries(p, query)
loading += q.query(
_class,
query,
resultQuery,
(result) => {
if (sortingFunction !== undefined) {
const sf = sortingFunction

View File

@ -16,7 +16,7 @@
import type { Class, Doc, DocumentQuery, FindOptions, Ref } from '@hcengineering/core'
import { ActionContext } from '@hcengineering/presentation'
import { FadeOptions, Scroller, tableSP } from '@hcengineering/ui'
import { BuildModelKey } from '@hcengineering/view'
import { BuildModelKey, ViewOptions, Viewlet } from '@hcengineering/view'
import { onMount } from 'svelte'
import { focusStore, ListSelectionProvider, SelectDirection } from '../selection'
import { LoadingProps } from '../utils'
@ -34,6 +34,8 @@
export let tableId: string | undefined = undefined
export let fade: FadeOptions = tableSP
export let prefferedSorting: string = 'modifiedOn'
export let viewOptions: ViewOptions | undefined = undefined
export let viewlet: Viewlet | undefined = undefined
// If defined, will show a number of dummy items before real data will appear.
export let loadingProps: LoadingProps | undefined = undefined
@ -79,6 +81,8 @@
checked={$selection ?? []}
{prefferedSorting}
{tableId}
{viewOptions}
viewOptionsConfig={viewlet?.viewOptions?.other}
selection={listProvider.current($focusStore)}
on:row-focus={(evt) => {
listProvider.updateFocus(evt.detail)

View File

@ -22,12 +22,18 @@
const preferenceQuery = createQuery()
const objectConfigurations = createQuery()
let preference: ViewletPreference[] = []
let loading = true
let configurationsLoading = true
let preferencesLoading = true
$: loading = configurationsLoading || preferencesLoading
let configurationRaw: Viewlet[] = []
let configurations: Record<Ref<Class<Doc>>, Viewlet['config']> = {}
$: viewlet &&
function fetchConfigurations (viewlet: Viewlet): void {
configurationsLoading = true
configurations = {}
objectConfigurations.query(
view.class.Viewlet,
{
@ -37,11 +43,13 @@
},
(res) => {
configurationRaw = res
loading = false
configurationsLoading = false
}
)
}
$: viewlet &&
function fetchPreferences (viewlet: Viewlet): void {
preferencesLoading = true
preferenceQuery.query(
view.class.ViewletPreference,
{
@ -50,9 +58,10 @@
},
(res) => {
preference = res
loading = false
preferencesLoading = false
}
)
}
function updateConfiguration (configurationRaw: Viewlet[], preference: ViewletPreference[]): void {
const newConfigurations: Record<Ref<Class<Doc>>, Viewlet['config']> = {}
@ -74,6 +83,9 @@
configurations = newConfigurations
}
$: fetchConfigurations(viewlet)
$: fetchPreferences(viewlet)
$: updateConfiguration(configurationRaw, preference)
$: config = preference.find((it) => it.attachedTo === viewlet._id)?.config ?? viewlet.config

View File

@ -2,7 +2,6 @@
export ACCOUNTS_URL=http://localhost:3333
export UPLOAD_URL=http://localhost:3333/files
export ELASTIC_URL=http://elastic:9200
export COLLABORATOR_URL=ws://localhost:3078
export MINIO_ENDPOINT=minio
export MINIO_ACCESS_KEY=minioadmin

View File

@ -99,7 +99,6 @@ services:
- ACCOUNTS_URL=http://host.docker.internal:3003
- MONGO_URL=mongodb://mongodb:27018
- UPLOAD_URL=/files
- ELASTIC_URL=http://elastic:9200
- GMAIL_URL=http://host.docker.internal:8088
- CALENDAR_URL=http://host.docker.internal:8095
- REKONI_URL=http://rekoni:4007

View File

@ -3,7 +3,6 @@ export MINIO_ACCESS_KEY=minioadmin
export MINIO_SECRET_KEY=minioadmin
export MINIO_ENDPOINT=localhost:9000
export MONGO_URL=mongodb://localhost:27017
export ELASTIC_URL=http://localhost:9200
export SERVER_SECRET=secret
# Restore workspace contents in mongo/elastic

View File

@ -7,7 +7,6 @@ export DB_URL=mongodb://localhost:27017
export ACCOUNT_DB_URL=mongodb://localhost:27017
export ACCOUNTS_URL=http://localhost:3000
export TRANSACTOR_URL=ws://localhost:3333
export ELASTIC_URL=http://localhost:9200
export SERVER_SECRET=secret
# Restore workspace contents in mongo/elastic

View File

@ -8,7 +8,6 @@ export TRANSACTOR_URL=ws://localhost:3334
export MONGO_URL=mongodb://localhost:27018
export ACCOUNT_DB_URL=mongodb://localhost:27018
export DB_URL=mongodb://localhost:27018
export ELASTIC_URL=http://localhost:9201
export SERVER_SECRET=secret
export STORAGE_CONFIG="minio|localhost:9002?accessKey=minioadmin&secretKey=minioadmin"

View File

@ -50,7 +50,7 @@ export async function OnStateUpdate (txes: TxCUD<Doc>[], control: TriggerControl
}
}
}
return []
return result
}
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type

View File

@ -405,7 +405,7 @@ export async function OnToDoUpdate (txes: Tx[], control: TriggerControl): Promis
)
if (funcs !== undefined) {
const func = await getResource(funcs.onDone)
const todoRes = await func(control, resEvents, todo)
const todoRes = await func(control, resEvents, todo, tx.space === core.space.DerivedTx)
await control.apply(control.ctx, todoRes)
}
continue
@ -459,7 +459,12 @@ export async function IssueToDoFactory (actualTx: TxCUD<Issue>, control: Trigger
/**
* @public
*/
export async function IssueToDoDone (control: TriggerControl, workslots: WorkSlot[], todo: ToDo): Promise<Tx[]> {
export async function IssueToDoDone (
control: TriggerControl,
workslots: WorkSlot[],
todo: ToDo,
isDerived: boolean
): Promise<Tx[]> {
const res: Tx[] = []
let total = 0
for (const workslot of workslots) {
@ -470,6 +475,7 @@ export async function IssueToDoDone (control: TriggerControl, workslots: WorkSlo
await control.findAll<Issue>(control.ctx, todo.attachedToClass, { _id: todo.attachedTo as Ref<Issue> })
)[0]
if (issue !== undefined) {
if (!isDerived) {
const project = (await control.findAll(control.ctx, task.class.Project, { _id: issue.space }))[0]
if (project !== undefined) {
const type = (await control.modelDb.findAll(task.class.ProjectType, { _id: project.type }))[0]
@ -515,6 +521,7 @@ export async function IssueToDoDone (control: TriggerControl, workslots: WorkSlo
}
}
}
}
if (total > 0) {
// round to nearest 15 minutes

View File

@ -36,7 +36,7 @@ export interface ToDoFactory extends Class<Task> {
* @public
*/
export interface OnToDo extends Class<Doc> {
onDone: Resource<(control: TriggerControl, workslots: WorkSlot[], todo: ToDo) => Promise<Tx[]>>
onDone: Resource<(control: TriggerControl, workslots: WorkSlot[], todo: ToDo, isDerived: boolean) => Promise<Tx[]>>
}
/**
@ -49,7 +49,9 @@ export default plugin(serverTimeId, {
},
function: {
IssueToDoFactory: '' as Resource<(tx: Tx, control: TriggerControl) => Promise<Tx[]>>,
IssueToDoDone: '' as Resource<(control: TriggerControl, workslots: WorkSlot[], todo: ToDo) => Promise<Tx[]>>
IssueToDoDone: '' as Resource<
(control: TriggerControl, workslots: WorkSlot[], todo: ToDo, isDerived: boolean) => Promise<Tx[]>
>
},
trigger: {
OnTask: '' as Resource<TriggerFunc>,

View File

@ -6,7 +6,6 @@ Front service is suited to deliver application bundles and resource assets, it a
* SERVER_PORT: Specifies the port number on which the server will listen.
* MONGO_URL: Specifies the URL of the MongoDB database.
* ELASTIC_URL: Specifies the URL of the Elasticsearch service.
* ACCOUNTS_URL: Specifies the URL of the accounts service.
* UPLOAD_URL: Specifies the URL for uploading files.
* GMAIL_URL: Specifies the URL of the Gmail service.

View File

@ -2,7 +2,6 @@
export ACCOUNTS_URL=http://localhost:3333
export UPLOAD_URL=http://localhost:3333/files
export ELASTIC_URL=http://elastic:9200
export MINIO_ENDPOINT=minio
export MINIO_ACCESS_KEY=minioadmin
export MINIO_SECRET_KEY=minioadmin

View File

@ -243,7 +243,6 @@ async function getFile (
export function start (
ctx: MeasureContext,
config: {
elasticUrl: string
storageAdapter: StorageAdapter
accountsUrl: string
uploadUrl: string

View File

@ -24,12 +24,6 @@ import { start } from '.'
export function startFront (ctx: MeasureContext, extraConfig?: Record<string, string | undefined>): void {
const SERVER_PORT = parseInt(process.env.SERVER_PORT ?? '8080')
const elasticUrl = process.env.ELASTIC_URL
if (elasticUrl === undefined) {
console.error('please provide elastic url')
process.exit(1)
}
const storageConfig: StorageConfiguration = storageConfigFromEnv()
const storageAdapter = buildStorageFromConfig(storageConfig)
@ -120,7 +114,6 @@ export function startFront (ctx: MeasureContext, extraConfig?: Record<string, st
const disableSignUp = process.env.DISABLE_SIGNUP
const config = {
elasticUrl,
storageAdapter,
accountsUrl,
uploadUrl,

View File

@ -49,17 +49,20 @@ export class QueryJoiner {
): Promise<FindResult<T>> {
// Will find a query or add + 1 to callbacks
const q = this.findQuery(_class, query, options) ?? this.createQuery(_class, query, options)
try {
if (q.result === undefined) {
q.result = this._findAll(ctx, _class, query, options)
}
if (q.result instanceof Promise) {
q.result = await q.result
}
return q.result as FindResult<T>
} finally {
q.callbacks--
this.removeFromQueue(q)
return q.result as FindResult<T>
}
}
private findQuery<T extends Doc>(

View File

@ -576,15 +576,8 @@ abstract class PostgresAdapterBase implements DbAdapter {
}
sqlChunks.push(`WHERE ${this.buildQuery(_class, domain, query, joins, options)}`)
return (await this.mgr.read(ctx.id, async (connection) => {
let total = options?.total === true ? 0 : -1
if (options?.total === true) {
const totalReq = `SELECT COUNT(${domain}._id) as count FROM ${domain}`
const totalSql = [totalReq, ...sqlChunks].join(' ')
const totalResult = await connection.unsafe(totalSql)
const parsed = Number.parseInt(totalResult[0].count)
total = Number.isNaN(parsed) ? 0 : parsed
}
const totalSqlChunks = [...sqlChunks]
if (options?.sort !== undefined) {
sqlChunks.push(this.buildOrder(_class, domain, options.sort, joins))
}
@ -592,6 +585,16 @@ abstract class PostgresAdapterBase implements DbAdapter {
sqlChunks.push(`LIMIT ${options.limit}`)
}
return (await this.mgr.read(ctx.id, async (connection) => {
let total = options?.total === true ? 0 : -1
if (options?.total === true) {
const totalReq = `SELECT COUNT(${domain}._id) as count FROM ${domain}`
const totalSql = [totalReq, ...totalSqlChunks].join(' ')
const totalResult = await connection.unsafe(totalSql)
const parsed = Number.parseInt(totalResult[0].count)
total = Number.isNaN(parsed) ? 0 : parsed
}
const finalSql: string = [select, ...sqlChunks].join(' ')
fquery = finalSql
const result = await connection.unsafe(finalSql)

View File

@ -50,7 +50,7 @@ export async function withPostgres<T> (
fn: (db: BlobDB) => Promise<T>
): Promise<T> {
const sql = metrics.withSync('db.connect', () => {
return postgres(env.DB_URL, {
return postgres(env.HYPERDRIVE.connectionString, {
connection: {
application_name: 'datalake'
},