diff --git a/.github/ISSUE_TEMPLATE/feature_story.md b/.github/ISSUE_TEMPLATE/feature_story.md new file mode 100644 index 0000000..8d94d66 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_story.md @@ -0,0 +1,21 @@ +--- +name: Feature +about: Feature plan +title: Feature title +labels: enhancement improvement +assignees: 'Krr0ptioN' + +--- + +## Description +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +### User Interface Specification +- User interface and Design Specification of the feature + +### Technical Interface Specification +- Domain business logic and technical specification + +### Tasks + +- [ ] Tasks diff --git a/.github/workflows/pylint.yml b/.github/workflows/api-ci.yml similarity index 50% rename from .github/workflows/pylint.yml rename to .github/workflows/api-ci.yml index e44f0a7..b4a006d 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/api-ci.yml @@ -7,18 +7,31 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.10"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install --upgrade pip pip install pylint pip install -r requirements.txt - - name: Analysing the code with pylint + + - name: Lint with pylint run: | - pylint $(git ls-files '*.py') + pip install pylint + OUTPUT=$(pylint ./src --exit-zero) + echo "MESSAGE=$OUTPUT" >> $GITHUB_ENV + + - name: Post Lint result to PR + uses: mshick/add-pr-comment@v1 + with: + message: ${{ env.MESSAGE }} + repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token-user-login: 'github-actions[bot]' + allow-repeats: false + diff --git a/.github/workflows/node.js.yml b/.github/workflows/dashboard-ci.yml similarity index 69% rename from .github/workflows/node.js.yml rename to .github/workflows/dashboard-ci.yml index dbba541..5292952 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/dashboard-ci.yml @@ -1,15 +1,14 @@ -name: Node.js CI +name: Dashboard CI on: push: paths: - 'app/dashboard/**' - # branches: [ "master" ] + branches: [ "master" ] pull_request: paths: - 'app/dashboard/**' - # branches: [ "master" ] jobs: build: @@ -20,17 +19,23 @@ jobs: run: working-directory: ./app/dashboard steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Use Node.js uses: actions/setup-node@v3 with: node-version: '21.0' cache: 'npm' cache-dependency-path: 'app/dashboard/package-lock.json' - - run: npm ci - - run: npm run build --if-present -- --outDir build --base '/dashboard/' - - run: npm test - + + - name: Install dependencies + run: npm ci + + - name: Lint Dashboard + run: npm ci + + - name: Build Dashboard + run: npm run build --if-present -- --outDir build --base '/dashboard/' - name: Upload a Build Artifact uses: actions/upload-artifact@v4.2.0 diff --git a/.github/workflows/build.yml b/.github/workflows/package.yml similarity index 65% rename from .github/workflows/build.yml rename to .github/workflows/package.yml index ea4f204..c70a110 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/package.yml @@ -1,4 +1,4 @@ -name: Build +name: Package on: push: @@ -18,12 +18,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: @@ -38,7 +32,5 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: | - gozargah/marzban:latest - gozargah/marzban:${{github.ref_name}} - ghcr.io/gozargah/marzban:latest - ghcr.io/gozargah/marzban:${{github.ref_name}} + ghcr.io/khodedawsh/marzneshin:latest + ghcr.io/khodedawsh/marzneshin:${{github.ref_name}} diff --git a/app/dashboard/src/components/UserDialog/DataLimitField.tsx b/app/dashboard/src/components/UserDialog/DataLimitField.tsx new file mode 100644 index 0000000..3c39a8b --- /dev/null +++ b/app/dashboard/src/components/UserDialog/DataLimitField.tsx @@ -0,0 +1,40 @@ +import { FormControl, FormLabel } from '@chakra-ui/react'; +import { Input } from '../Input'; +import { TFunction } from 'i18next'; +import { Controller } from 'react-hook-form'; + + +interface DataLimitFieldProps { + form: any; + disabled: boolean; + t: TFunction<"translation", undefined, "translation">; +} + + +export const DataLimitField = ({ form, disabled, t }: DataLimitFieldProps) => { + return ( + + {t("userDialog.dataLimit")} + { + return ( + + ); + }} + /> + + ) +} diff --git a/app/dashboard/src/components/UserDialog/ExpireDateField.tsx b/app/dashboard/src/components/UserDialog/ExpireDateField.tsx new file mode 100644 index 0000000..69bebf7 --- /dev/null +++ b/app/dashboard/src/components/UserDialog/ExpireDateField.tsx @@ -0,0 +1,91 @@ +import { + FormControl, + FormHelperText, + FormLabel, +} from "@chakra-ui/react"; +import dayjs from "dayjs"; +import { i18n, TFunction } from "i18next"; +import ReactDatePicker from "react-datepicker"; +import { Controller } from "react-hook-form"; +import { relativeExpiryDate } from "utils/dateFormatter"; +import { Input } from "../Input"; + +interface ExpireDateFieldProps { + form: any; + disabled: boolean; + t: TFunction<"translation", undefined, "translation">; + i18n: i18n; +} + +export const ExpireDateField = ({ form, t, i18n, disabled }: ExpireDateFieldProps) => { + return ( + + {t("userDialog.expiryDate")} + { + function createDateAsUTC(num: number) { + return dayjs( + dayjs(num * 1000).utc() + // .format("MMMM D, YYYY") // exception with: dayjs.locale(lng); + ).toDate(); + } + const { status, time } = relativeExpiryDate( + field.value + ); + return ( + <> + { + field.onChange({ + target: { + value: date + ? dayjs( + dayjs(date) + .set("hour", 23) + .set("minute", 59) + .set("second", 59) + ) + .utc() + .valueOf() / 1000 + : 0, + name: "expire", + }, + }); + }} + customInput={ + + } + /> + {field.value ? ( + + {t(status, { time: time })} + + ) : ( + "" + )} + + ); + }} + /> + + ) +} diff --git a/app/dashboard/src/components/UserDialog/NoteField.tsx b/app/dashboard/src/components/UserDialog/NoteField.tsx new file mode 100644 index 0000000..39a7544 --- /dev/null +++ b/app/dashboard/src/components/UserDialog/NoteField.tsx @@ -0,0 +1,22 @@ +import { FormControl, FormLabel, Textarea, FormErrorMessage } from '@chakra-ui/react'; +import { TFunction } from 'i18next'; + +interface NoteFieldProps { + form: any; + t: TFunction<"translation", undefined, "translation">; +} + +export const NoteField = ({ t, form }: NoteFieldProps) => { + return ( + + {t("userDialog.note")} +