@ -0,0 +1,53 @@
|
||||
<script lang="ts" setup> |
||||
const props = defineProps<{ |
||||
baseId: string |
||||
sourceId: string |
||||
modelValue: boolean |
||||
}>() |
||||
|
||||
const emit = defineEmits(['update:modelValue']) |
||||
|
||||
const isOpen = useVModel(props, 'modelValue', emit) |
||||
|
||||
const activeSourceId = computed(() => props.sourceId) |
||||
|
||||
const { openedProject: base } = storeToRefs(useBases()) |
||||
|
||||
const { baseTables } = storeToRefs(useTablesStore()) |
||||
const { loadProjectTables } = useTablesStore() |
||||
|
||||
const isLoading = ref(true) |
||||
|
||||
const { getMeta } = useMetas() |
||||
|
||||
const baseId = computed(() => props.baseId || base.value?.id) |
||||
|
||||
onMounted(async () => { |
||||
if (baseId.value && baseTables.value.get(baseId.value)) { |
||||
return (isLoading.value = false) |
||||
} |
||||
|
||||
try { |
||||
await loadProjectTables(baseId.value!) |
||||
|
||||
await Promise.all( |
||||
baseTables.value.get(baseId.value!)!.map(async (table) => { |
||||
await getMeta(table.id!, false, false, baseId.value!) |
||||
}), |
||||
) |
||||
} catch (e) { |
||||
message.error('Failed to load tables/bases. Please try again later.') |
||||
console.error(e) |
||||
} finally { |
||||
isLoading.value = false |
||||
} |
||||
}) |
||||
</script> |
||||
|
||||
<template> |
||||
<GeneralModal v-model:visible="isOpen" size="large" class="!w-[70rem]"> |
||||
<div class="p-6"> |
||||
<DashboardSettingsBaseAudit v-if="!isLoading" :source-id="activeSourceId" :base-id="baseId" :show-all-columns="false" /> |
||||
</div> |
||||
</GeneralModal> |
||||
</template> |
@ -0,0 +1,159 @@
|
||||
<script lang="ts" setup> |
||||
import dayjs from 'dayjs' |
||||
|
||||
interface Props { |
||||
size?: 'medium' | 'small' |
||||
selectedDate?: dayjs.Dayjs | null |
||||
pageDate?: dayjs.Dayjs |
||||
activeDates?: Array<dayjs.Dayjs> |
||||
isMondayFirst?: boolean |
||||
} |
||||
|
||||
const props = withDefaults(defineProps<Props>(), { |
||||
size: 'medium', |
||||
selectedDate: null, |
||||
isMondayFirst: true, |
||||
pageDate: dayjs(), |
||||
activeDates: [] as Array<dayjs.Dayjs>, |
||||
}) |
||||
const emit = defineEmits(['dblClick', 'update:selectedDate', 'update:pageDate']) |
||||
// Page date is the date we use to manage which month/date that is currently being displayed |
||||
const pageDate = useVModel(props, 'pageDate', emit) |
||||
|
||||
const selectedDate = useVModel(props, 'selectedDate', emit) |
||||
|
||||
const activeDates = useVModel(props, 'activeDates', emit) |
||||
|
||||
const days = computed(() => { |
||||
if (props.isMondayFirst) { |
||||
return ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'] |
||||
} else { |
||||
return ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'] |
||||
} |
||||
}) |
||||
|
||||
const currentMonthYear = computed(() => { |
||||
return dayjs(pageDate.value).format('MMMM') |
||||
}) |
||||
|
||||
// Generates all dates should be displayed in the calendar |
||||
// Includes all blank days at the start and end of the month |
||||
const dates = computed(() => { |
||||
const startOfMonth = dayjs(pageDate.value).startOf('month') |
||||
const dayOffset = +props.isMondayFirst |
||||
const firstDayOfWeek = startOfMonth.day() |
||||
const startDay = startOfMonth.subtract((firstDayOfWeek - dayOffset + 7) % 7, 'day') |
||||
|
||||
const datesArray = [] |
||||
for (let i = 0; i < 42; i++) { |
||||
datesArray.push(startDay.add(i, 'day')) |
||||
} |
||||
|
||||
return datesArray |
||||
}) |
||||
|
||||
// Used to check if two dates are the same |
||||
const isSameDate = (date1: dayjs.Dayjs, date2: dayjs.Dayjs) => { |
||||
if (!date1 || !date2) return false |
||||
return date1.isSame(date2, 'day') |
||||
} |
||||
|
||||
// Used in DatePicker for checking if the date is currently selected |
||||
const isSelectedDate = (dObj: dayjs.Dayjs) => { |
||||
if (!selectedDate.value) return false |
||||
const propDate = dayjs(selectedDate.value) |
||||
return props.selectedDate ? isSameDate(propDate, dObj) : false |
||||
} |
||||
|
||||
const isDayInPagedMonth = (date: dayjs.Dayjs) => { |
||||
return date.month() === dayjs(pageDate.value).month() |
||||
} |
||||
|
||||
// Since we are using the same component for week picker and date picker we need to handle the date selection differently |
||||
const handleSelectDate = (date: dayjs.Dayjs) => { |
||||
if (!isDayInPagedMonth(date)) { |
||||
pageDate.value = date |
||||
emit('update:pageDate', date) |
||||
} |
||||
selectedDate.value = date |
||||
emit('update:selectedDate', date) |
||||
} |
||||
|
||||
// Used to check if a date is in the current month |
||||
const isDateInCurrentMonth = (date: dayjs.Dayjs) => { |
||||
return date.month() === dayjs(pageDate.value).month() |
||||
} |
||||
|
||||
// Used to Check if an event is in the date |
||||
const isActiveDate = (date: dayjs.Dayjs) => { |
||||
return activeDates.value.some((d) => isSameDate(d, date)) |
||||
} |
||||
|
||||
const emitDblClick = (date: dayjs.Dayjs) => { |
||||
emit('dblClick', date) |
||||
} |
||||
</script> |
||||
|
||||
<template> |
||||
<div> |
||||
<div class="flex justify-center px-2 nc-date-week-header text-gray-700 text-sm py-2 font-semibold items-center"> |
||||
{{ currentMonthYear }} |
||||
</div> |
||||
<div |
||||
:class="{ |
||||
'rounded-lg': size === 'small', |
||||
'rounded-y-xl': size !== 'small', |
||||
}" |
||||
class="max-w-[320px]" |
||||
> |
||||
<div class="px-2.5"> |
||||
<div class="flex border-b-1 justify-between gap-0.5 border-gray-200"> |
||||
<span |
||||
v-for="(day, index) in days" |
||||
:key="index" |
||||
:class="{ |
||||
'w-8 h-8 text-sm': size === 'medium', |
||||
'text-xs w-6 h-6': size === 'small', |
||||
}" |
||||
class="flex items-center uppercase py-1 font-medium justify-center text-gray-500" |
||||
>{{ day[0] }}</span |
||||
> |
||||
</div> |
||||
</div> |
||||
<div class="grid gap-x-0.5 gap-y-2 px-2.5 py-1 nc-date-week-grid-wrapper grid-cols-7"> |
||||
<span |
||||
v-for="(date, index) in dates" |
||||
:key="index" |
||||
:class="{ |
||||
'bg-gray-300 border-1 !font-semibold': isSelectedDate(date) && isDayInPagedMonth(date), |
||||
'hover:(border-1 border-gray-200 bg-gray-100)': !isSelectedDate(date), |
||||
'text-gray-400': !isDateInCurrentMonth(date), |
||||
'text-brand-500 !font-semibold nc-calendar-today': isSameDate(date, dayjs()) && isDateInCurrentMonth(date), |
||||
'text-gray-500': date.get('day') === 0 || date.get('day') === 6, |
||||
'h-8 w-8 text-sm': size === 'medium', |
||||
'h-6 w-6 text-xs': size === 'small', |
||||
}" |
||||
class="px-1 py-1.5 relative rounded border-transparent transition border-1 font-medium flex text-gray-700 items-center cursor-pointer justify-center" |
||||
data-testid="nc-calendar-date" |
||||
@click="handleSelectDate(date)" |
||||
@dblclick="emitDblClick(date)" |
||||
> |
||||
<span |
||||
v-if="isActiveDate(date)" |
||||
:class="{ |
||||
'h-1.25 w-1.25 top-0.5 right-0.5': size === 'small', |
||||
'!border-white': isSelectedDate(date), |
||||
'!border-brand-50': isSameDate(date, dayjs()), |
||||
}" |
||||
class="absolute z-2 h-1.5 top-1 right-1 w-1.5 transition border-1 rounded-full border-white bg-brand-500" |
||||
></span> |
||||
<span class="z-2"> |
||||
{{ date.get('date') }} |
||||
</span> |
||||
</span> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
|
||||
<style lang="scss" scoped></style> |
After Width: | Height: | Size: 195 KiB |
Before Width: | Height: | Size: 175 KiB After Width: | Height: | Size: 128 KiB |
After Width: | Height: | Size: 323 KiB |
Before Width: | Height: | Size: 175 KiB After Width: | Height: | Size: 278 KiB |
After Width: | Height: | Size: 403 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 118 KiB |
After Width: | Height: | Size: 267 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 330 KiB |
After Width: | Height: | Size: 195 KiB |
After Width: | Height: | Size: 131 KiB |
After Width: | Height: | Size: 268 KiB |
After Width: | Height: | Size: 148 KiB |
@ -0,0 +1,22 @@
|
||||
# Docs: https://litestream.io/reference/config/ |
||||
|
||||
dbs: |
||||
- path: ${NC_TOOL_DIR}noco.db |
||||
replicas: |
||||
- type: s3 |
||||
endpoint: ${LITESTREAM_S3_ENDPOINT} |
||||
force-path-style: true |
||||
skip-verify: ${LITESTREAM_S3_SKIP_VERIFY} |
||||
bucket: ${LITESTREAM_S3_BUCKET} |
||||
path: ${LITESTREAM_S3_PATH} |
||||
access-key-id: ${LITESTREAM_S3_ACCESS_KEY_ID} |
||||
secret-access-key: ${LITESTREAM_S3_SECRET_ACCESS_KEY} |
||||
retention: ${LITESTREAM_RETENTION} |
||||
retention-check-interval: ${LITESTREAM_RETENTION_CHECK_INTERVAL} |
||||
snapshot-interval: ${LITESTREAM_SNAPSHOT_INTERVAL} |
||||
sync-interval: ${LITESTREAM_SYNC_INTERVAL} |
||||
# age: |
||||
# identities: |
||||
# - ${LITESTREAM_AGE_SECRET_KEY} |
||||
# recipients: |
||||
# - ${LITESTREAM_AGE_PUBLIC_KEY} |
@ -1,26 +1,37 @@
|
||||
#!/bin/sh |
||||
|
||||
#sleep 5 |
||||
|
||||
if [ -n "${NC_TOOL_DIR}" ]; then |
||||
if [ ! -d "${NC_TOOL_DIR}" ] ; then |
||||
mkdir -p "$NC_TOOL_DIR" |
||||
fi |
||||
|
||||
if [ -n "${AWS_ACCESS_KEY_ID}" ] && [ -n "${AWS_SECRET_ACCESS_KEY}" ] && [ -n "${AWS_BUCKET}" ] && [ -n "${AWS_BUCKET_PATH}" ]; then |
||||
use_litestream() { |
||||
[ -z "${NC_DB}" ] \ |
||||
&& [ -z "${NC_DB_JSON}" ] \ |
||||
&& [ -z "${NC_DB_JSON_FILE}" ] \ |
||||
&& [ -z "${DATABASE_URL}" ] \ |
||||
&& [ -z "${DATABASE_URL_FILE}" ] \ |
||||
&& [ -z "${NC_MINIMAL_DBS}" ] \ |
||||
&& [ -n "${LITESTREAM_S3_ENDPOINT}" ] \ |
||||
&& [ -n "${LITESTREAM_S3_BUCKET}" ] \ |
||||
&& [ -n "${LITESTREAM_ACCESS_KEY_ID}" ] \ |
||||
&& [ -n "${LITESTREAM_SECRET_ACCESS_KEY}" ] |
||||
} |
||||
|
||||
if use_litestream ; then |
||||
|
||||
if [ -f "${NC_TOOL_DIR}noco.db" ] |
||||
then |
||||
if [ -f "${NC_TOOL_DIR}noco.db" ] ; then |
||||
rm "${NC_TOOL_DIR}noco.db" |
||||
rm "${NC_TOOL_DIR}noco.db-shm" |
||||
rm "${NC_TOOL_DIR}noco.db-wal" |
||||
rm -f "${NC_TOOL_DIR}noco.db-shm" |
||||
rm -f "${NC_TOOL_DIR}noco.db-wal" |
||||
fi |
||||
|
||||
/usr/src/appEntry/litestream restore -o "${NC_TOOL_DIR}noco.db" "s3://$AWS_BUCKET/$AWS_BUCKET_PATH" |
||||
if [ ! -f "${NC_TOOL_DIR}noco.db" ] |
||||
then |
||||
litestream restore "${NC_TOOL_DIR}noco.db" |
||||
|
||||
if [ ! -f "${NC_TOOL_DIR}noco.db" ] ; then |
||||
touch "${NC_TOOL_DIR}noco.db" |
||||
fi |
||||
/usr/src/appEntry/litestream replicate "${NC_TOOL_DIR}noco.db" "s3://$AWS_BUCKET/$AWS_BUCKET_PATH" & |
||||
|
||||
litestream replicate & |
||||
fi |
||||
|
||||
node docker/main.js |
||||
|
@ -1,96 +0,0 @@
|
||||
FROM golang:alpine3.18 as lt |
||||
|
||||
WORKDIR /usr/src/ |
||||
|
||||
RUN apk add --no-cache git make musl-dev gcc |
||||
|
||||
# build litestream |
||||
RUN git clone https://github.com/benbjohnson/litestream.git litestream |
||||
RUN cd litestream ; go install ./cmd/litestream |
||||
|
||||
RUN cp $GOPATH/bin/litestream /usr/src/lt |
||||
|
||||
|
||||
|
||||
FROM node:18.19.1-alpine as builder |
||||
WORKDIR /usr/src/app |
||||
|
||||
# install pnpm |
||||
RUN corepack enable && corepack prepare pnpm@latest --activate |
||||
|
||||
# Copy application dependency manifests to the container image. |
||||
COPY ./package*.json ./ |
||||
COPY ./docker/main.js ./docker/main.js |
||||
#COPY ./docker/start.sh /usr/src/appEntry/start.sh |
||||
COPY ./docker/start-litestream.sh /usr/src/appEntry/start.sh |
||||
|
||||
# for pnpm to generate a flat node_modules without symlinks |
||||
# so that modclean could work as expected |
||||
RUN echo "node-linker=hoisted" > .npmrc |
||||
|
||||
# install production dependencies, |
||||
# reduce node_module size with modclean & removing sqlite deps, |
||||
# and add execute permission to start.sh |
||||
RUN pnpm install --prod --shamefully-hoist --reporter=silent |
||||
RUN pnpm dlx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**" --run |
||||
RUN rm -rf ./node_modules/sqlite3/deps |
||||
RUN chmod +x /usr/src/appEntry/start.sh |
||||
|
||||
FROM alpine:3.19 |
||||
|
||||
#ENV AWS_ACCESS_KEY_ID= |
||||
#ENV AWS_SECRET_ACCESS_KEY= |
||||
#ENV AWS_BUCKET= |
||||
|
||||
|
||||
|
||||
#WORKDIR /usr/src/ |
||||
# |
||||
## Install go lang |
||||
#RUN apk add --no-cache git make musl-dev go |
||||
# |
||||
## Configure Go |
||||
#ENV GOROOT /usr/lib/go |
||||
#ENV GOPATH /go |
||||
#ENV PATH /go/bin:$PATH |
||||
# |
||||
#RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin |
||||
# |
||||
## build litestream |
||||
# |
||||
#RUN git clone https://github.com/benbjohnson/litestream.git litestream |
||||
#RUN cd litestream ; go install ./cmd/litestream |
||||
|
||||
|
||||
# Bug fix for segfault ( Convert PT_GNU_STACK program header into PT_PAX_FLAGS ) |
||||
#RUN apk --update --no-cache add paxctl \ |
||||
# && paxctl -cm $(which node) |
||||
|
||||
WORKDIR /usr/src/app |
||||
|
||||
ENV NC_DOCKER 0.6 |
||||
ENV PORT 8080 |
||||
ENV NC_TOOL_DIR=/usr/app/data/ |
||||
|
||||
|
||||
# Copy application dependency manifests to the container image. |
||||
# A wildcard is used to ensure both package.json AND package-lock.json are copied. |
||||
# Copying this separately prevents re-running npm install on every code change. |
||||
#COPY ./build/ ./build/ |
||||
#COPY ./docker/main.js ./docker/main.js |
||||
#COPY ./package.json ./ |
||||
|
||||
RUN apk --update --no-cache add \ |
||||
nodejs \ |
||||
tar |
||||
|
||||
# Copy litestream binary build |
||||
COPY --from=lt /usr/src/lt /usr/src/appEntry/litestream |
||||
# Copy production code & main entry file |
||||
COPY --from=builder /usr/src/app/ /usr/src/app/ |
||||
COPY --from=builder /usr/src/appEntry/ /usr/src/appEntry/ |
||||
|
||||
|
||||
# Run the web service on container startup. |
||||
#CMD [ "node", "docker/index.js" ] |
||||
ENTRYPOINT ["sh", "/usr/src/appEntry/start.sh"] |
@ -0,0 +1,28 @@
|
||||
import { Process, Processor } from '@nestjs/bull'; |
||||
import { Inject, Logger } from '@nestjs/common'; |
||||
import type { Queue } from 'bull'; |
||||
import { JOBS_QUEUE, JobTypes } from '~/interface/Jobs'; |
||||
|
||||
@Processor(JOBS_QUEUE) |
||||
export class HealthCheckProcessor { |
||||
private logger = new Logger(HealthCheckProcessor.name); |
||||
|
||||
constructor(@Inject('JobsService') protected readonly jobsService) {} |
||||
|
||||
@Process(JobTypes.HealthCheck) |
||||
async healthCheck() { |
||||
const queue = this.jobsService.jobsQueue as Queue; |
||||
|
||||
if (queue) { |
||||
queue |
||||
.getJobCounts() |
||||
.then((stats) => { |
||||
// log stats periodically
|
||||
this.logger.log({ stats }); |
||||
}) |
||||
.catch((err) => { |
||||
this.logger.error(err); |
||||
}); |
||||
} |
||||
} |
||||
} |