Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
"env": {
"browser": true,
"node": true,
"es2022": true
"es2020": true
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2022
},
"extends": "eslint:recommended",
"extends": ["eslint:recommended", "plugin:vue/vue3-recommended"],
"plugins": ["vue"],
"rules": {
"no-unused-vars": "off",
"no-console": "warn",
"no-undef": "off"
"no-undef": "off",
"vue/multi-word-component-names": "off",
"vue/no-reserved-component-names": "off"
},
"root": true,
"globals": {
Expand Down
112 changes: 112 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: CI

on:
push:
branches:
- version-16

pull_request:
branches:
- version-16

env:
BRANCH: ${{ github.base_ref || github.ref_name }}

concurrency:
group: develop-projectit-${{ github.event.number || github.sha }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
name: Server

services:
redis-cache:
image: redis:alpine
ports:
- 13000:6379
redis-queue:
image: redis:alpine
ports:
- 11000:6379
mariadb:
image: mariadb:10.6
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3

steps:
- name: Clone
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.14"

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 24
check-latest: true

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py', '**/setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install MariaDB Client
run: |
sudo apt update
sudo apt-get install mariadb-client

- name: Setup
run: |
pip install frappe-bench
bench init --skip-redis-config-generation --skip-assets --python "$(which python)" --frappe-branch "$BRANCH" ~/frappe-bench
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'"
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"

- name: Install
working-directory: /home/runner/frappe-bench
run: |
bench get-app erpnext --branch "$BRANCH"
bench get-app hrms --branch "$BRANCH"
bench get-app projectit $GITHUB_WORKSPACE
bench setup requirements --dev
bench new-site --db-root-password root --admin-password admin test_site
bench --site test_site install-app erpnext
bench --site test_site install-app hrms
bench --site test_site install-app projectit
bench build
env:
CI: "Yes"

- name: Run Tests
working-directory: /home/runner/frappe-bench
run: |
bench --site test_site set-config allow_tests true
bench --site test_site run-tests --app projectit --skip-test-records
env:
TYPE: server
62 changes: 62 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Linters

on:
pull_request:
branches:
- version-16
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
linter:
name: "Frappe Linter"
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'

steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.14"
cache: pip
- uses: pre-commit/action@v3.0.0

- name: Download Semgrep rules
run: git clone --depth 1 https://github.com/frappe/semgrep-rules.git frappe-semgrep-rules

- name: Run Semgrep rules
run: |
pip install semgrep
semgrep ci --config ./frappe-semgrep-rules/rules --config r/python.lang.correctness

deps-vulnerable-check:
name: "Vulnerable Dependency Check"
runs-on: ubuntu-latest

steps:
- uses: actions/setup-python@v6
with:
python-version: "3.14"

- uses: actions/checkout@v4

- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-

- name: Install and run pip-audit
run: |
pip install pip-audit
cd ${GITHUB_WORKSPACE}
pip-audit --desc on .
25 changes: 14 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude: 'node_modules|.git'
exclude: "node_modules|.git"
default_stages: [pre-commit]
fail_fast: false

Expand Down Expand Up @@ -28,22 +28,25 @@ repos:
- id: prettier
types_or: [javascript, vue, scss]
exclude: |
(?x)^(
.*/dist/.*|
.*node_modules.*
)$
(?x)^(
.*/dist/.*|
.*node_modules.*
)$

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.44.0
hooks:
- id: eslint
types_or: [javascript]
args: ['--quiet']
args: ["--quiet"]
additional_dependencies:
- eslint@8.44.0
- eslint-plugin-vue@9
exclude: |
(?x)^(
.*/dist/.*|
.*node_modules.*
)$
(?x)^(
.*/dist/.*|
.*node_modules.*
)$

ci:
autoupdate_schedule: weekly
autoupdate_schedule: weekly
8 changes: 5 additions & 3 deletions mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"dev": "vite",
"build": "vite build && yarn copy-icon",
"preview": "vite preview",
"copy-html-entry": "cp ../projectit/public/projectit/index.html ../projectit/www/projectit.html",
"copy-icon": "cp -r ../mobile/src/images/ ../projectit/public/projectit/images/"
"copy-icon": "cp -r ../mobile/src/images/ ../projectit/public/projectit/images/",
"lint": "eslint 'src/**/*.{js,vue}' --quiet"
},
"dependencies": {
"@internationalized/date": "^3.7.0",
"dayjs": "^1.11.13",
"feather-icons": "^4.29.2",
"firebase": "^11.4.0",
"frappe-ui": "^0.1.72",
"frappe-ui": "0.1.278",
"vite-plugin-pwa": "^0.21.1",
"vue": "^3.5.12",
"vue-router": "^4.4.5",
Expand All @@ -30,6 +30,8 @@
"devDependencies": {
"@vitejs/plugin-vue": "^5.1.4",
"autoprefixer": "^10.4.2",
"eslint": "^8.57.0",
"eslint-plugin-vue": "^9.30.0",
"postcss": "^8.4.5",
"tailwindcss": "^3.4.14",
"vite": "^6.0.0"
Expand Down
29 changes: 15 additions & 14 deletions mobile/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<template>
<div class="sm:w-96">
<div v-show="!showCamera">
<Header></Header>
<Toast />
<router-view />
<FrappeUIProvider>
<div class="sm:w-96">
<div v-show="!showCamera">
<Header></Header>
<router-view />
</div>
<div v-if="showCamera">
<Camera
:mode="cameraMode"
@close-event="showCamera = false"
@capture-event="imageFile = $event"
></Camera>
</div>
</div>
<div v-if="showCamera">
<Camera
:mode="cameraMode"
@close-event="showCamera = false"
@capture-event="imageFile = $event"
></Camera>
</div>
</div>
</FrappeUIProvider>
</template>
<script setup>
import { watch, inject } from 'vue'
import Header from './components/Header.vue'
import { Toast } from 'frappe-ui'
import { FrappeUIProvider } from 'frappe-ui'
import Camera from './components/Camera.vue'

import { showCamera, cameraMode, imageFile } from './data/camera_context'
Expand Down
10 changes: 8 additions & 2 deletions mobile/src/components/Camera.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const constraints = ref({

const showPreview = ref(false)
const imageFile = ref(null)
let animationFrameId = null

onMounted(async () => {
if (video.value && canvas.value) {
Expand All @@ -82,16 +83,21 @@ onMounted(async () => {
})

onBeforeUnmount(() => {
if (animationFrameId !== null) {
cancelAnimationFrame(animationFrameId)
animationFrameId = null
}
if (video.value) {
stopCamera()
}
})

function Draw() {
if (!video.value || !canvas.value) return
height.value =
video.value.videoHeight / (video.value.videoWidth / canvas.value.width)
ctx.value.drawImage(video.value, 0, 0, canvas.value.width, height.value)
requestAnimationFrame(Draw)
animationFrameId = requestAnimationFrame(Draw)
}

function stopCamera() {
Expand Down Expand Up @@ -143,7 +149,7 @@ function getCamera() {
navigator.mediaDevices.getUserMedia(constraints.value).then((stream) => {
video.value.srcObject = stream
video.value.play()
requestAnimationFrame(Draw)
animationFrameId = requestAnimationFrame(Draw)
})
}
</script>
12 changes: 4 additions & 8 deletions mobile/src/composables/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ export class FileAttachment {
url: 'projectit.api.upload_base64_file',
onSuccess: (fileDoc) => resolve(fileDoc),
onError: (error) => {
toast({
title: 'Error',
text: `File upload failed for ${this.fileName}. ${
toast.error(
`File upload failed for ${this.fileName}. ${
error.messages?.[0] || ''
}`,
icon: 'alert-circle',
position: 'bottom-center',
iconClasses: 'text-red-500',
})
}`
)
reject(error)
},
})
Expand Down
9 changes: 6 additions & 3 deletions mobile/src/data/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ export const session = reactive({
router.replace(data.default_route || '/home')
},
onError(error) {
if (error.exc_type == 'AuthenticationError') {
showAuthenticationError.value = true
}
showAuthenticationError.value = true
loginError.value =
error.exc_type == 'AuthenticationError'
? 'Invalid credentials. Please try again.'
: error.message || 'Login failed. Please try again.'
},
}),
logout: createResource({
Expand All @@ -47,3 +49,4 @@ export const session = reactive({
})

export const showAuthenticationError = ref(false)
export const loginError = ref('')
Loading
Loading