mirror of https://github.com/nocodb/nocodb
Wing-Kam Wong
2 years ago
47 changed files with 1455 additions and 165 deletions
@ -0,0 +1,158 @@
|
||||
name: "Release : Timely Executables" |
||||
|
||||
on: |
||||
# Triggered manually |
||||
workflow_dispatch: |
||||
inputs: |
||||
tag: |
||||
description: "Timely version" |
||||
required: true |
||||
# Triggered by release-nightly-dev.yml / release-pr.yml |
||||
workflow_call: |
||||
inputs: |
||||
tag: |
||||
description: "Timely version" |
||||
required: true |
||||
type: string |
||||
secrets: |
||||
NC_GITHUB_TOKEN: |
||||
required: true |
||||
jobs: |
||||
build-executables: |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- uses: actions/checkout@v3 |
||||
with: |
||||
token: ${{ secrets.NC_GITHUB_TOKEN }} |
||||
repository: 'nocodb/nocodb-timely' |
||||
- name: Cache node modules |
||||
id: cache-npm |
||||
uses: actions/cache@v3 |
||||
env: |
||||
cache-name: cache-node-modules |
||||
with: |
||||
# npm cache files are stored in `~/.npm` on Linux/macOS |
||||
path: ~/.npm |
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
||||
restore-keys: | |
||||
${{ runner.os }}-build-${{ env.cache-name }}- |
||||
${{ runner.os }}-build- |
||||
${{ runner.os }}- |
||||
- name: Cache pkg modules |
||||
id: cache-pkg |
||||
uses: actions/cache@v3 |
||||
env: |
||||
cache-name: cache-pkg |
||||
with: |
||||
# pkg cache files are stored in `~/.pkg-cache` |
||||
path: ~/.pkg-cache |
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
||||
restore-keys: | |
||||
${{ runner.os }}-build-${{ env.cache-name }}- |
||||
${{ runner.os }}-build- |
||||
${{ runner.os }}- |
||||
- name: Install QEMU and ldid |
||||
run: | |
||||
sudo apt update |
||||
# Install qemu |
||||
sudo apt install qemu binfmt-support qemu-user-static |
||||
# install ldid |
||||
git clone https://github.com/daeken/ldid.git |
||||
cd ./ldid |
||||
./make.sh |
||||
sudo cp ./ldid /usr/local/bin |
||||
|
||||
- name: Update nocodb-timely |
||||
env: |
||||
TAG: ${{ github.event.inputs.tag || inputs.tag }} |
||||
run: | |
||||
npm i -E nocodb-daily@$TAG |
||||
|
||||
git config user.name 'github-actions[bot]' |
||||
git config user.email 'github-actions[bot]@users.noreply.github.com' |
||||
|
||||
git commit package.json -m "Update to $TAG" |
||||
git tag $TAG |
||||
git push --tags |
||||
|
||||
|
||||
- uses: actions/setup-node@v3 |
||||
with: |
||||
node-version: 16 |
||||
|
||||
- name : Install dependencies and build executables |
||||
run: | |
||||
# install npm dependendencies |
||||
npm i |
||||
|
||||
# Copy sqlite binaries |
||||
rsync -rvzhP ./binaries/binding/ ./node_modules/sqlite3/lib/binding/ |
||||
|
||||
# clean up code to optimize size |
||||
npx modclean --patterns="default:*" --ignore="nc-lib-gui-daily/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run |
||||
|
||||
# build executables |
||||
npm run build |
||||
|
||||
mkdir ./mac-dist |
||||
mv ./dist/Noco-macos-arm64 ./mac-dist/ |
||||
mv ./dist/Noco-macos-x64 ./mac-dist/ |
||||
|
||||
- name: Upload executables(except mac executables) to release |
||||
uses: svenstaro/upload-release-action@v2 |
||||
with: |
||||
repo_token: ${{ secrets.NC_GITHUB_TOKEN }} |
||||
file: dist/** |
||||
tag: ${{ github.event.inputs.tag || inputs.tag }} |
||||
overwrite: true |
||||
file_glob: true |
||||
repo_name: nocodb/nocodb-timely |
||||
|
||||
- uses: actions/upload-artifact@master |
||||
with: |
||||
name: ${{ github.event.inputs.tag || inputs.tag }} |
||||
path: mac-dist |
||||
retention-days: 1 |
||||
|
||||
sign-mac-executables: |
||||
runs-on: macos-latest |
||||
needs: build-executables |
||||
steps: |
||||
|
||||
- uses: actions/download-artifact@master |
||||
with: |
||||
name: ${{ github.event.inputs.tag || inputs.tag }} |
||||
path: mac-dist |
||||
|
||||
- name: Sign macOS executables |
||||
run: | |
||||
/usr/bin/codesign --force -s - ./mac-dist/Noco-macos-arm64 -v |
||||
/usr/bin/codesign --force -s - ./mac-dist/Noco-macos-x64 -v |
||||
|
||||
- uses: actions/upload-artifact@master |
||||
with: |
||||
name: ${{ github.event.inputs.tag || inputs.tag }} |
||||
path: mac-dist |
||||
retention-days: 1 |
||||
|
||||
|
||||
publish-mac-executables: |
||||
needs: sign-mac-executables |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- uses: actions/download-artifact@master |
||||
with: |
||||
name: ${{ github.event.inputs.tag || inputs.tag }} |
||||
path: mac-dist |
||||
|
||||
- name: Upload mac executables to release |
||||
uses: svenstaro/upload-release-action@v2 |
||||
with: |
||||
repo_token: ${{ secrets.NC_GITHUB_TOKEN }} |
||||
file: mac-dist/** |
||||
tag: ${{ github.event.inputs.tag || inputs.tag }} |
||||
overwrite: true |
||||
file_glob: true |
||||
repo_name: nocodb/nocodb-timely |
||||
|
||||
|
@ -0,0 +1,69 @@
|
||||
<template> |
||||
<input |
||||
v-model="localValue" |
||||
:placeholder="durationPlaceholder" |
||||
readonly |
||||
> |
||||
</template> |
||||
|
||||
<script> |
||||
import { durationOptions, convertMS2Duration } from '~/helpers/durationHelper' |
||||
|
||||
export default { |
||||
name: 'DurationCell', |
||||
props: { |
||||
column: Object, |
||||
value: [String, Number] |
||||
}, |
||||
data: () => ({ |
||||
showWarningMessage: false, |
||||
localValue: null |
||||
}), |
||||
computed: { |
||||
durationPlaceholder() { |
||||
return durationOptions[this.column?.meta?.duration || 0].title |
||||
} |
||||
}, |
||||
watch: { |
||||
'column.meta.duration'(newValue, oldValue) { |
||||
if (oldValue !== newValue) { |
||||
this.localValue = convertMS2Duration(this.value, newValue) |
||||
} |
||||
}, |
||||
value(val, oldVal) { |
||||
this.localValue = convertMS2Duration(val !== oldVal && (!val && val !== 0) ? oldVal : val, this.column?.meta?.duration || 0) |
||||
} |
||||
}, |
||||
created() { |
||||
this.localValue = convertMS2Duration(this.value, this.column?.meta?.duration || 0) |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
||||
|
||||
<!-- |
||||
/** |
||||
* @copyright Copyright (c) 2021, Xgene Cloud Ltd |
||||
* |
||||
* @author Wing-Kam Wong <wingkwong.code@gmail.com> |
||||
* |
||||
* @license GNU AGPL version 3 or any later version |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as |
||||
* published by the Free Software Foundation, either version 3 of the |
||||
* License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
--> |
@ -0,0 +1,72 @@
|
||||
<template> |
||||
<v-row class="duration-wrapper"> |
||||
<div class="caption"> |
||||
A duration of time in minutes or seconds (e.g. 1:23). |
||||
</div> |
||||
<!-- TODO: i18n --> |
||||
<v-autocomplete |
||||
v-model="colMeta.duration" |
||||
hide-details |
||||
class="caption ui-type nc-ui-dt-dropdown" |
||||
label="Duration Format" |
||||
dense |
||||
outlined |
||||
item-value="id" |
||||
item-text="title" |
||||
:items="durationOptionList" |
||||
> |
||||
<template #selection="{ item }"> |
||||
<div> |
||||
<span class="caption grey--text text--darken-4"> |
||||
{{ item.title }} |
||||
</span> |
||||
</div> |
||||
</template> |
||||
<template #item="{ item }"> |
||||
<div class="caption"> |
||||
{{ item.title }} |
||||
</div> |
||||
</template> |
||||
</v-autocomplete> |
||||
</v-row> |
||||
</template> |
||||
|
||||
<script> |
||||
import { durationOptions } from '~/helpers/durationHelper' |
||||
|
||||
export default { |
||||
name: 'DuractionOptions', |
||||
props: ['column', 'meta', 'value'], |
||||
data: () => ({ |
||||
durationOptionList: durationOptions.map(o => ({ |
||||
...o, |
||||
// h:mm:ss (e.g. 3:45, 1:23:40) |
||||
title: `${o.title} ${o.example}` |
||||
})), |
||||
colMeta: { |
||||
duration: 0 |
||||
} |
||||
}), |
||||
watch: { |
||||
value() { |
||||
this.colMeta = this.value || {} |
||||
}, |
||||
colMeta(v) { |
||||
this.$emit('input', v) |
||||
} |
||||
}, |
||||
created() { |
||||
this.colMeta = this.value ? { ...this.value } : { ...this.colMeta } |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
.duration-wrapper { |
||||
margin: 0; |
||||
} |
||||
|
||||
.duration-wrapper .caption:first-child { |
||||
margin: -10px 0px 10px 5px; |
||||
} |
||||
</style> |
@ -0,0 +1,139 @@
|
||||
<template> |
||||
<div class="duration-cell-wrapper"> |
||||
<input |
||||
ref="durationInput" |
||||
v-model="localState" |
||||
:placeholder="durationPlaceholder" |
||||
@blur="onBlur" |
||||
@keypress="checkDurationFormat($event)" |
||||
@keydown.enter="isEdited && $emit('input', durationInMS)" |
||||
v-on="parentListeners" |
||||
> |
||||
<div v-if="showWarningMessage == true" class="duration-warning"> |
||||
<!-- TODO: i18n --> |
||||
Please enter a number |
||||
</div> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { durationOptions, convertMS2Duration, convertDurationToSeconds } from '~/helpers/durationHelper' |
||||
|
||||
export default { |
||||
name: 'DurationCell', |
||||
props: { |
||||
column: Object, |
||||
value: [Number, String], |
||||
readOnly: Boolean |
||||
}, |
||||
data: () => ({ |
||||
// flag to determine to show warning message or not |
||||
showWarningMessage: false, |
||||
// duration in milliseconds |
||||
durationInMS: null, |
||||
// check if the cell is edited or not |
||||
isEdited: false |
||||
}), |
||||
computed: { |
||||
localState: { |
||||
get() { |
||||
return convertMS2Duration(this.value, this.durationType) |
||||
}, |
||||
set(val) { |
||||
this.isEdited = true |
||||
const res = convertDurationToSeconds(val, this.durationType) |
||||
if (res._isValid) { |
||||
this.durationInMS = res._sec |
||||
} |
||||
} |
||||
}, |
||||
durationPlaceholder() { |
||||
return durationOptions[this.durationType].title |
||||
}, |
||||
durationType() { |
||||
return this.column?.meta?.duration || 0 |
||||
}, |
||||
parentListeners() { |
||||
const $listeners = {} |
||||
|
||||
if (this.$listeners.blur) { |
||||
$listeners.blur = this.$listeners.blur |
||||
} |
||||
if (this.$listeners.focus) { |
||||
$listeners.focus = this.$listeners.focus |
||||
} |
||||
|
||||
return $listeners |
||||
} |
||||
}, |
||||
mounted() { |
||||
window.addEventListener('keypress', (_) => { |
||||
if (this.$refs.durationInput) { |
||||
this.$refs.durationInput.focus() |
||||
} |
||||
}) |
||||
}, |
||||
methods: { |
||||
checkDurationFormat(evt) { |
||||
evt = evt || window.event |
||||
const charCode = (evt.which) ? evt.which : evt.keyCode |
||||
// ref: http://www.columbia.edu/kermit/ascii.html |
||||
const PRINTABLE_CTL_RANGE = charCode > 31 |
||||
const NON_DIGIT = charCode < 48 || charCode > 57 |
||||
const NON_COLON = charCode !== 58 |
||||
const NON_PERIOD = charCode !== 46 |
||||
if (PRINTABLE_CTL_RANGE && NON_DIGIT && NON_COLON && NON_PERIOD) { |
||||
this.showWarningMessage = true |
||||
evt.preventDefault() |
||||
} else { |
||||
this.showWarningMessage = false |
||||
// only allow digits, '.' and ':' (without quotes) |
||||
return true |
||||
} |
||||
}, |
||||
onBlur() { |
||||
if (this.isEdited) { |
||||
this.$emit('input', this.durationInMS) |
||||
} |
||||
this.isEdited = false |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
.duration-cell-wrapper { |
||||
padding: 10px; |
||||
} |
||||
|
||||
.duration-warning { |
||||
text-align: left; |
||||
margin-top: 10px; |
||||
color: #E65100; |
||||
} |
||||
</style> |
||||
|
||||
<!-- |
||||
/** |
||||
* @copyright Copyright (c) 2021, Xgene Cloud Ltd |
||||
* |
||||
* @author Wing-Kam Wong <wingkwong.code@gmail.com> |
||||
* |
||||
* @license GNU AGPL version 3 or any later version |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as |
||||
* published by the Free Software Foundation, either version 3 of the |
||||
* License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
--> |
@ -0,0 +1,192 @@
|
||||
export const durationOptions = [ |
||||
{ |
||||
id: 0, |
||||
title: 'h:mm', |
||||
example: '(e.g. 1:23)', |
||||
regex: /(\d+)(?::(\d+))?/ |
||||
}, { |
||||
id: 1, |
||||
title: 'h:mm:ss', |
||||
example: '(e.g. 3:45, 1:23:40)', |
||||
regex: /(\d+)?(?::(\d+))?(?::(\d+))?/ |
||||
}, { |
||||
id: 2, |
||||
title: 'h:mm:ss.s', |
||||
example: '(e.g. 3:34.6, 1:23:40.0)', |
||||
regex: /(\d+)?(?::(\d+))?(?::(\d+))?(?:.(\d{0,4})?)?/ |
||||
}, { |
||||
id: 3, |
||||
title: 'h:mm:ss.ss', |
||||
example: '(e.g. 3.45.67, 1:23:40.00)', |
||||
regex: /(\d+)?(?::(\d+))?(?::(\d+))?(?:.(\d{0,4})?)?/ |
||||
}, { |
||||
id: 4, |
||||
title: 'h:mm:ss.sss', |
||||
example: '(e.g. 3.45.678, 1:23:40.000)', |
||||
regex: /(\d+)?(?::(\d+))?(?::(\d+))?(?:.(\d{0,4})?)?/ |
||||
} |
||||
] |
||||
|
||||
// pad zero
|
||||
// mm && ss
|
||||
// e.g. 3 -> 03
|
||||
// e.g. 12 -> 12
|
||||
// sss
|
||||
// e.g. 1 -> 001
|
||||
// e.g. 10 -> 010
|
||||
const padZero = (val, isSSS = false) => { |
||||
return (val + '').padStart(isSSS ? 3 : 2, '0') |
||||
} |
||||
|
||||
export const convertMS2Duration = (val, durationType) => { |
||||
if (val === "" || val === null || val === undefined) { return val } |
||||
// 600.000 s --> 10:00 (10 mins)
|
||||
const milliseconds = Math.round((val % 1) * 1000) |
||||
const centiseconds = Math.round(milliseconds / 10) |
||||
const deciseconds = Math.round(centiseconds / 10) |
||||
const hours = Math.floor(parseInt(val, 10) / (60 * 60)) |
||||
const minutes = Math.floor((parseInt(val, 10) - (hours * 60 * 60)) / 60) |
||||
const seconds = parseInt(val, 10) - (hours * 60 * 60) - (minutes * 60) |
||||
|
||||
if (durationType === 0) { |
||||
// h:mm
|
||||
return `${padZero(hours)}:${padZero(minutes + (seconds >= 30))}` |
||||
} else if (durationType === 1) { |
||||
// h:mm:ss
|
||||
return `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}` |
||||
} else if (durationType === 2) { |
||||
// h:mm:ss.s
|
||||
return `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}.${deciseconds}` |
||||
} else if (durationType === 3) { |
||||
// h:mm:ss.ss
|
||||
return `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}.${padZero(centiseconds)}` |
||||
} else if (durationType === 4) { |
||||
// h:mm:ss.sss
|
||||
return `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}.${padZero(milliseconds, true)}` |
||||
} |
||||
return val |
||||
} |
||||
|
||||
export const convertDurationToSeconds = (val, durationType) => { |
||||
// 10:00 (10 mins) -> 600.000 s
|
||||
const res = { |
||||
_ms: null, |
||||
_isValid: true |
||||
} |
||||
const durationRegex = durationOptions[durationType].regex |
||||
if (durationRegex.test(val)) { |
||||
let h, mm, ss |
||||
const groups = val.match(durationRegex) |
||||
if (groups[0] && groups[1] && !groups[2] && !groups[3] && !groups[4]) { |
||||
const val = parseInt(groups[1], 10) |
||||
if (groups.input.slice(-1) === ':') { |
||||
// e.g. 30:
|
||||
h = groups[1] |
||||
mm = 0 |
||||
ss = 0 |
||||
} else if (durationType === 0) { |
||||
// consider it as minutes
|
||||
// e.g. 360 -> 06:00
|
||||
h = Math.floor(val / 60) |
||||
mm = Math.floor((val - ((h * 3600)) / 60)) |
||||
ss = 0 |
||||
} else { |
||||
// consider it as seconds
|
||||
// e.g. 3600 -> 01:00:00
|
||||
h = Math.floor(groups[1] / 3600) |
||||
mm = Math.floor(groups[1] / 60) % 60 |
||||
ss = val % 60 |
||||
} |
||||
} else if (durationType !== 0 && groups[1] && groups[2] && !groups[3]) { |
||||
// 10:10 means mm:ss instead of h:mm
|
||||
// 10:10:10 means h:mm:ss
|
||||
h = 0 |
||||
mm = groups[1] |
||||
ss = groups[2] |
||||
} else { |
||||
h = groups[1] || 0 |
||||
mm = groups[2] || 0 |
||||
ss = groups[3] || 0 |
||||
} |
||||
|
||||
if (durationType === 0) { |
||||
// h:mm
|
||||
res._sec = h * 3600 + mm * 60 |
||||
} else if (durationType === 1) { |
||||
// h:mm:ss
|
||||
res._sec = h * 3600 + mm * 60 + ss * 1 |
||||
} else if (durationType === 2) { |
||||
// h:mm:ss.s (deciseconds)
|
||||
const ds = groups[4] || 0 |
||||
const len = Math.log(ds) * Math.LOG10E + 1 | 0 |
||||
const ms = ( |
||||
// e.g. len = 4: 1234 -> 1, 1456 -> 1
|
||||
// e.g. len = 3: 123 -> 1, 191 -> 2
|
||||
// e.g. len = 2: 12 -> 1 , 16 -> 2
|
||||
len === 4 |
||||
? Math.round(ds / 1000) |
||||
: len === 3 |
||||
? Math.round(ds / 100) |
||||
: len === 2 |
||||
? Math.round(ds / 10) |
||||
// take whatever it is
|
||||
: ds |
||||
) * 100 |
||||
res._sec = h * 3600 + mm * 60 + ss * 1 + ms / 1000 |
||||
} else if (durationType === 3) { |
||||
// h:mm:ss.ss (centiseconds)
|
||||
const cs = groups[4] || 0 |
||||
const len = Math.log(cs) * Math.LOG10E + 1 | 0 |
||||
const ms = ( |
||||
// e.g. len = 4: 1234 -> 12, 1285 -> 13
|
||||
// e.g. len = 3: 123 -> 12, 128 -> 13
|
||||
// check the third digit
|
||||
len === 4 |
||||
? Math.round(cs / 100) |
||||
: len === 3 |
||||
? Math.round(cs / 10) |
||||
// take whatever it is
|
||||
: cs |
||||
) * 10 |
||||
res._sec = h * 3600 + mm * 60 + ss * 1 + ms / 1000 |
||||
} else if (durationType === 4) { |
||||
// h:mm:ss.sss (milliseconds)
|
||||
let ms = groups[4] || 0 |
||||
const len = Math.log(ms) * Math.LOG10E + 1 | 0 |
||||
ms = ( |
||||
// e.g. 1235 -> 124
|
||||
// e.g. 1234 -> 123
|
||||
len === 4 |
||||
? Math.round(ms / 10) |
||||
// take whatever it is
|
||||
: ms |
||||
) * 1 |
||||
res._sec = h * 3600 + mm * 60 + ss * 1 + ms / 1000 |
||||
} |
||||
} else { |
||||
res._isValid = false |
||||
} |
||||
return res |
||||
} |
||||
|
||||
/** |
||||
* @copyright Copyright (c) 2021, Xgene Cloud Ltd |
||||
* |
||||
* @author Wing-Kam Wong <wingkwong.code@gmail.com> |
||||
* |
||||
* @license GNU AGPL version 3 or any later version |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as |
||||
* published by the Free Software Foundation, either version 3 of the |
||||
* License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
*/ |
@ -0,0 +1,42 @@
|
||||
--- |
||||
title: "Timely Build" |
||||
description: "Timely Build" |
||||
position: 5000 |
||||
category: "Engineering" |
||||
menuTitle: "Timely Build" |
||||
--- |
||||
|
||||
NocoDB provides timely build versions on Docker and Executables by compiling our source code and packaging as a deliverable so that it can |
||||
|
||||
- reduce pull request cycle time |
||||
- allow issue reporters / reviewers to verify the fix without setting up their local machines |
||||
|
||||
## Docker |
||||
|
||||
When a non-draft Pull Request is created, reopened or synchronized, a timely build for Docker would be triggered for the changes only included in the following paths. |
||||
|
||||
- `packages/nocodb-sdk/**` |
||||
- `packages/nc-gui/**` |
||||
- `packages/nc-plugin/**` |
||||
- `packages/nocodb/**` |
||||
|
||||
The docker images will be built and pushed to Docker Hub (See [nocodb/nocodb-timely](https://hub.docker.com/r/nocodb/nocodb-timely/tags) for the full list). Once the image is ready, Github bot will add a comment with the command in the pull request. The tag would be `<NOCODB_CURRENT_VERSION>-pr-<PR_NUMBER>-<YYYYMMDD>-<HHMM>`. |
||||
|
||||
![image](https://user-images.githubusercontent.com/35857179/175012097-240dab05-da93-4c4e-87c1-1c36fb1350bd.png) |
||||
|
||||
## Executables |
||||
|
||||
Similarly, we provide a timely build for executables for non-docker users. The source code will be built, packaged as binary files, and pushed to Github (See [nocodb/nocodb-timely](https://github.com/nocodb/nocodb-timely/releases) for the full list). |
||||
|
||||
Currently, we only support the following targets: |
||||
|
||||
- `node16-linux-arm64` |
||||
- `node16-macos-arm64` |
||||
- `node16-win-arm64` |
||||
- `node16-linux-x64` |
||||
- `node16-macos-x64` |
||||
- `node16-win-x64` |
||||
|
||||
Once the executables are ready, Github bot will add a comment with the commands in the pull request. |
||||
|
||||
![image](https://user-images.githubusercontent.com/35857179/175012070-f5f3e7b8-6dc5-4d1c-9f7e-654bc5039521.png) |
@ -0,0 +1,44 @@
|
||||
--- |
||||
title: "Primary Key" |
||||
description: "Primary Key" |
||||
position: 575 |
||||
category: "Product" |
||||
menuTitle: "Primary Key" |
||||
--- |
||||
|
||||
## What is a Primary Key ? |
||||
- A primary key is a special database table column designated to uniquely identify each table record. |
||||
|
||||
## What is the use of Primary Key ? |
||||
- As it uniquely identifies an individual record of a table, it is used internally by NocoDB for all operations associated with a record |
||||
|
||||
## Primary Key in NocoDB |
||||
- Primary Key that gets defined / used in NocoDB depends on how underlying table was created. Summary is captured below |
||||
1. From UI, Create new table / Import from Excel / Import from CSV |
||||
1. An `ID` [datatype: Integer] system field created by default during table creation is used as primary key |
||||
2. Additional system fields `created-at`, `updated-at` are inserted by default & can be omitted optionally; these fields can be deleted after table creation |
||||
2. Connect to existing external database |
||||
1. Existing `primary key` field defined for a table is retained as is; NocoDB doesn't insert a new ID field |
||||
2. Additional system fields `created-at`, `updated-at` are not inserted by default |
||||
3. Import from Airtable |
||||
1. Airtable record ID is marked as primary key for imported records, and is mapped to field `ncRecordId` [datatype: varchar] |
||||
2. If a new record is inserted after migration & if ncRecordId field was omitted during record insertion - auto generated string will be inserted by NocoDB |
||||
3. Computed hash value for the entire record is stored in system field `ncRecordHash` |
||||
4. Additional system fields `created-at`, `updated-at` are not inserted by default |
||||
4. Create new table using SDK / API |
||||
1. No default primary key field is introduced by NocoDB. It has to be explicitly specified during table creation (using attribute `pk: true`) |
||||
|
||||
## What if Primary Key was missing? |
||||
It is possible to have a table without any primary key. |
||||
- External database table can be created without primary key configuration. |
||||
- New table can be created using SDK / API without primary key |
||||
In such scenario's, new records can be created in NocoDB for this table, but records can't be updated or deleted [as there is now way for NocoDB to uniquely identify these records] |
||||
|
||||
#### Example : Primary Key & optional system fields during new table creation |
||||
![Screenshot 2022-06-16 at 12 15 43 PM](https://user-images.githubusercontent.com/86527202/174010350-8610b9c1-a761-4bff-a53d-dc728df47e1b.png) |
||||
|
||||
#### Example : Show System Fields |
||||
![Screenshot 2022-06-16 at 12 16 07 PM](https://user-images.githubusercontent.com/86527202/174010379-9e300d42-ad89-4653-afa2-f70fca407ca8.png) |
||||
|
||||
## Can I change the Primary Key to another column within tables ? |
||||
- You can't update Primary Key from NocoDB UI. You can reconfigure it at database level directly & trigger `metasync` explicitly |
@ -0,0 +1,275 @@
|
||||
import { mainPage } from "../../support/page_objects/mainPage"; |
||||
import { |
||||
isTestSuiteActive, |
||||
} from "../../support/page_objects/projectConstants"; |
||||
|
||||
export const genTest = (apiType, dbType) => { |
||||
if (!isTestSuiteActive(apiType, dbType)) return; |
||||
|
||||
describe(`${apiType.toUpperCase()} api - DURATION`, () => { |
||||
const tableName = "DurationTable"; |
||||
|
||||
// to retrieve few v-input nodes from their label
|
||||
//
|
||||
const fetchParentFromLabel = (label) => { |
||||
cy.get("label").contains(label).parents(".v-input").click(); |
||||
}; |
||||
|
||||
// Run once before test- create table
|
||||
//
|
||||
before(() => { |
||||
mainPage.tabReset(); |
||||
cy.createTable(tableName); |
||||
}); |
||||
|
||||
after(() => { |
||||
cy.deleteTable(tableName); |
||||
}); |
||||
|
||||
// Routine to create a new look up column
|
||||
//
|
||||
const addDurationColumn = (columnName, durationFormat) => { |
||||
// (+) icon at end of column header (to add a new column)
|
||||
// opens up a pop up window
|
||||
//
|
||||
cy.get(".new-column-header").click(); |
||||
|
||||
// Column name
|
||||
cy.get(".nc-column-name-input input").clear().type(`${columnName}`); |
||||
|
||||
// Column data type
|
||||
cy.get(".nc-ui-dt-dropdown").click(); |
||||
cy.getActiveMenu().contains("Duration").click(); |
||||
|
||||
// Configure Child table & column names
|
||||
fetchParentFromLabel("Duration Format"); |
||||
cy.getActiveMenu().contains(durationFormat).click(); |
||||
|
||||
// click on Save
|
||||
cy.get(".nc-col-create-or-edit-card").contains("Save").click(); |
||||
|
||||
// Verify if column exists.
|
||||
//
|
||||
cy.get(`th:contains(${columnName})`).should("exist"); |
||||
}; |
||||
|
||||
// routine to delete column
|
||||
//
|
||||
const deleteColumnByName = (columnName) => { |
||||
// verify if column exists before delete
|
||||
cy.get(`th:contains(${columnName})`).should("exist"); |
||||
|
||||
// delete opiton visible on mouse-over
|
||||
cy.get(`th:contains(${columnName}) .mdi-menu-down`) |
||||
.trigger("mouseover") |
||||
.click(); |
||||
|
||||
// delete/ confirm on pop-up
|
||||
cy.get(".nc-column-delete").click(); |
||||
cy.getActiveModal().find("button:contains(Confirm)").click(); |
||||
|
||||
// validate if deleted (column shouldnt exist)
|
||||
cy.get(`th:contains(${columnName})`).should("not.exist"); |
||||
}; |
||||
|
||||
// routine to edit column
|
||||
//
|
||||
const editColumnByName = (oldName, newName, newDurationFormat) => { |
||||
// verify if column exists before delete
|
||||
cy.get(`th:contains(${oldName})`).should("exist"); |
||||
|
||||
// delete opiton visible on mouse-over
|
||||
cy.get(`th:contains(${oldName}) .mdi-menu-down`) |
||||
.trigger("mouseover") |
||||
.click(); |
||||
|
||||
// edit/ save on pop-up
|
||||
cy.get(".nc-column-edit").click(); |
||||
cy.get(".nc-column-name-input input").clear().type(newName); |
||||
|
||||
// Configure Child table & column names
|
||||
fetchParentFromLabel("Duration Format"); |
||||
cy.getActiveMenu().contains(newDurationFormat).click(); |
||||
|
||||
cy.get(".nc-col-create-or-edit-card") |
||||
.contains("Save") |
||||
.click({ force: true }); |
||||
|
||||
cy.toastWait("Duration column updated successfully"); |
||||
|
||||
// validate if deleted (column shouldnt exist)
|
||||
cy.get(`th:contains(${oldName})`).should("not.exist"); |
||||
cy.get(`th:contains(${newName})`).should("exist"); |
||||
}; |
||||
|
||||
const addDurationData = (colName, index, cellValue, expectedValue, isNewRow = false) => { |
||||
if (isNewRow) { |
||||
cy.get(".nc-add-new-row-btn:visible").should("exist"); |
||||
cy.wait(500) |
||||
cy.get(".nc-add-new-row-btn").click({ force: true }); |
||||
} else { |
||||
mainPage.getRow(index).find(".nc-row-expand-icon").click({ force: true }); |
||||
} |
||||
cy.get(".duration-cell-wrapper > input").first().should('exist').type(cellValue); |
||||
cy.getActiveModal().find("button").contains("Save row").click({ force: true }); |
||||
cy.toastWait("Row updated successfully"); |
||||
mainPage.getCell(colName, index).find('input').then(($e) => { |
||||
expect($e[0].value).to.equal(expectedValue) |
||||
}) |
||||
} |
||||
|
||||
///////////////////////////////////////////////////
|
||||
// Test case
|
||||
{ |
||||
// Duration: h:mm
|
||||
it("Duration: h:mm", () => { |
||||
addDurationColumn("NC_DURATION_0", "h:mm (e.g. 1:23)"); |
||||
addDurationData("NC_DURATION_0", 1, "1:30", "01:30", true); |
||||
addDurationData("NC_DURATION_0", 2, "30", "00:30", true); |
||||
addDurationData("NC_DURATION_0", 3, "60", "01:00", true); |
||||
addDurationData("NC_DURATION_0", 4, "80", "01:20", true); |
||||
addDurationData("NC_DURATION_0", 5, "12:34", "12:34", true); |
||||
addDurationData("NC_DURATION_0", 6, "15:130", "17:10", true); |
||||
addDurationData("NC_DURATION_0", 7, "123123", "2052:03", true); |
||||
}); |
||||
|
||||
it("Duration: Edit Column NC_DURATION_0", () => { |
||||
editColumnByName( |
||||
"NC_DURATION_0", |
||||
"NC_DURATION_EDITED_0", |
||||
"h:mm:ss (e.g. 3:45, 1:23:40)" |
||||
); |
||||
}); |
||||
|
||||
it("Duration: Delete column", () => { |
||||
deleteColumnByName("NC_DURATION_EDITED_0"); |
||||
}); |
||||
} |
||||
|
||||
{ |
||||
// Duration: h:mm:ss
|
||||
it("Duration: h:mm:ss", () => { |
||||
addDurationColumn("NC_DURATION_1", "h:mm:ss (e.g. 3:45, 1:23:40)"); |
||||
addDurationData("NC_DURATION_1", 1, "11:22:33", "11:22:33"); |
||||
addDurationData("NC_DURATION_1", 2, "1234", "00:20:34"); |
||||
addDurationData("NC_DURATION_1", 3, "50", "00:00:50"); |
||||
addDurationData("NC_DURATION_1", 4, "1:1111", "00:19:31"); |
||||
addDurationData("NC_DURATION_1", 5, "1:11:1111", "01:29:31"); |
||||
addDurationData("NC_DURATION_1", 6, "15:130", "00:17:10"); |
||||
addDurationData("NC_DURATION_1", 7, "123123", "34:12:03"); |
||||
}); |
||||
|
||||
it("Duration: Edit Column NC_DURATION_1", () => { |
||||
editColumnByName( |
||||
"NC_DURATION_1", |
||||
"NC_DURATION_EDITED_1", |
||||
"h:mm:ss.s (e.g. 3:34.6, 1:23:40.0)" |
||||
); |
||||
}); |
||||
|
||||
it("Duration: Delete column", () => { |
||||
deleteColumnByName("NC_DURATION_EDITED_1"); |
||||
}); |
||||
} |
||||
|
||||
{ |
||||
// h:mm:ss.s
|
||||
it("Duration: h:mm:ss.s", () => { |
||||
addDurationColumn("NC_DURATION_2", "h:mm:ss.s (e.g. 3:34.6, 1:23:40.0)"); |
||||
addDurationData("NC_DURATION_2", 1, "1234", "00:20:34.0"); |
||||
addDurationData("NC_DURATION_2", 2, "12:34", "00:12:34.0"); |
||||
addDurationData("NC_DURATION_2", 3, "12:34:56", "12:34:56.0"); |
||||
addDurationData("NC_DURATION_2", 4, "12:34:999", "12:50:39.0"); |
||||
addDurationData("NC_DURATION_2", 5, "12:999:56", "28:39:56.0"); |
||||
addDurationData("NC_DURATION_2", 6, "12:34:56.12", "12:34:56.1"); |
||||
addDurationData("NC_DURATION_2", 7, "12:34:56.199", "12:34:56.2"); |
||||
}); |
||||
|
||||
it("Duration: Edit Column NC_DURATION_2", () => { |
||||
editColumnByName( |
||||
"NC_DURATION_2", |
||||
"NC_DURATION_EDITED_2", |
||||
"h:mm:ss (e.g. 3:45, 1:23:40)" |
||||
); |
||||
}); |
||||
|
||||
it("Duration: Delete column", () => { |
||||
deleteColumnByName("NC_DURATION_EDITED_2"); |
||||
}); |
||||
} |
||||
|
||||
{ |
||||
// h:mm:ss.ss
|
||||
it("Duration: h:mm:ss.ss", () => { |
||||
addDurationColumn("NC_DURATION_3", "h:mm:ss.ss (e.g. 3.45.67, 1:23:40.00)"); |
||||
addDurationData("NC_DURATION_3", 1, "1234", "00:20:34.00"); |
||||
addDurationData("NC_DURATION_3", 2, "12:34", "00:12:34.00"); |
||||
addDurationData("NC_DURATION_3", 3, "12:34:56", "12:34:56.00"); |
||||
addDurationData("NC_DURATION_3", 4, "12:34:999", "12:50:39.00"); |
||||
addDurationData("NC_DURATION_3", 5, "12:999:56", "28:39:56.00"); |
||||
addDurationData("NC_DURATION_3", 6, "12:34:56.12", "12:34:56.12"); |
||||
addDurationData("NC_DURATION_3", 7, "12:34:56.199", "12:34:56.20"); |
||||
}); |
||||
|
||||
it("Duration: Edit Column NC_DURATION_3", () => { |
||||
editColumnByName( |
||||
"NC_DURATION_3", |
||||
"NC_DURATION_EDITED_3", |
||||
"h:mm:ss.ss (e.g. 3.45.67, 1:23:40.00)" |
||||
); |
||||
}); |
||||
|
||||
it("Duration: Delete column", () => { |
||||
deleteColumnByName("NC_DURATION_EDITED_3"); |
||||
}); |
||||
} |
||||
|
||||
{ |
||||
// h:mm:ss.sss
|
||||
it("Duration: h:mm:ss.sss", () => { |
||||
addDurationColumn("NC_DURATION_4", "h:mm:ss.sss (e.g. 3.45.678, 1:23:40.000)"); |
||||
addDurationData("NC_DURATION_4", 1, "1234", "00:20:34.000"); |
||||
addDurationData("NC_DURATION_4", 2, "12:34", "00:12:34.000"); |
||||
addDurationData("NC_DURATION_4", 3, "12:34:56", "12:34:56.000"); |
||||
addDurationData("NC_DURATION_4", 4, "12:34:999", "12:50:39.000"); |
||||
addDurationData("NC_DURATION_4", 5, "12:999:56", "28:39:56.000"); |
||||
addDurationData("NC_DURATION_4", 6, "12:34:56.12", "12:34:56.012"); |
||||
addDurationData("NC_DURATION_4", 7, "12:34:56.199", "12:34:56.199"); |
||||
}); |
||||
|
||||
it("Duration: Edit Column NC_DURATION_4", () => { |
||||
editColumnByName( |
||||
"NC_DURATION_4", |
||||
"NC_DURATION_EDITED_4", |
||||
"h:mm (e.g. 1:23)" |
||||
); |
||||
}); |
||||
|
||||
it("Duration: Delete column", () => { |
||||
deleteColumnByName("NC_DURATION_EDITED_4"); |
||||
}); |
||||
} |
||||
}); |
||||
}; |
||||
|
||||
/** |
||||
* @copyright Copyright (c) 2021, Xgene Cloud Ltd |
||||
* |
||||
* @author Wing-Kam Wong <wingkwong.code@gmail.com> |
||||
* |
||||
* @license GNU AGPL version 3 or any later version |
||||
* |
||||
* This program is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as |
||||
* published by the Free Software Foundation, either version 3 of the |
||||
* License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* |
||||
*/ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,12 @@
|
||||
process.env.NC_BINARY_BUILD = 'true'; |
||||
(async () => { |
||||
try { |
||||
const app = require('express')(); |
||||
const {Noco} = require("nocodb"); |
||||
const httpServer = app.listen(process.env.PORT || 8080); |
||||
app.use(await Noco.init({}, httpServer, app)); |
||||
console.log(`Visit : localhost:${process.env.PORT}/dashboard`) |
||||
} catch(e) { |
||||
console.log(e) |
||||
} |
||||
})() |
@ -0,0 +1,33 @@
|
||||
{ |
||||
"name": "Noco", |
||||
"version": "1.0.0", |
||||
"description": "", |
||||
"main": "index.js", |
||||
"bin": "index.js", |
||||
"scripts": { |
||||
"test": "echo \"Error: no test specified\" && exit 1", |
||||
"start": "node index.js", |
||||
"upgrade": "npm uninstall --save nocodb && npm install --save nocodb", |
||||
"build": "npx pkg . --out-path dist --compress GZip" |
||||
}, |
||||
"pkg": { |
||||
"assets": [ |
||||
"node_modules/**/*" |
||||
], |
||||
"targets": [ |
||||
"node16-linux-arm64", |
||||
"node16-macos-arm64", |
||||
"node16-win-arm64", |
||||
"node16-linux-x64", |
||||
"node16-macos-x64", |
||||
"node16-win-x64" |
||||
] |
||||
}, |
||||
"keywords": [], |
||||
"author": "", |
||||
"license": "ISC", |
||||
"dependencies": { |
||||
"express": "^4.17.1", |
||||
"nocodb": "0.91.10" |
||||
} |
||||
} |
Loading…
Reference in new issue