Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VIN field to vehicle data #76

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 8 additions & 5 deletions .github/workflows/hub.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: ci
name: Build docker image

on:
push:
branches: master
release:
types: [published]

jobs:
multi:
Expand All @@ -26,6 +26,9 @@ jobs:
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Parse the git tag
id: get_tag
run: echo ::set-output name=TAG::$(echo $GITHUB_REF | cut -d / -f 3)
- name: Login to DockerHub
uses: docker/login-action@v1
with:
Expand All @@ -50,6 +53,6 @@ jobs:
# cache-to: type=local,dest=/tmp/.buildx-cache
tags: |
akhilrex/hammond:latest
akhilrex/hammond:1.0.0
akhilrex/hammond:${{ steps.get_tag.outputs.TAG }}
ghcr.io/akhilrex/hammond:latest
ghcr.io/akhilrex/hammond:1.0.0
ghcr.io/akhilrex/hammond:${{ steps.get_tag.outputs.TAG }}
16 changes: 16 additions & 0 deletions .github/workflows/test-go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on: [push, pull_request]
name: Test server
jobs:
test:
strategy:
matrix:
go-version: [1.17.x, 1.18.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- run: go test ./...
working-directory: server
22 changes: 22 additions & 0 deletions .github/workflows/test-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test UI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
working-directory: ui
- run: npm run build --if-present
working-directory: ui
- run: npm test
working-directory: ui
4 changes: 4 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
*.out
*.db

# MS VSCode
.vscode
__debug_bin

# Dependency directories (remove the comment below to include it)
# vendor/
assets/*
Expand Down
1 change: 1 addition & 0 deletions server/db/dbModels.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Vehicle struct {
Base
Nickname string `json:"nickname"`
Registration string `json:"registration"`
VIN string `json:"vin"`
Make string `json:"make"`
Model string `json:"model"`
YearOfManufacture int `json:"yearOfManufacture"`
Expand Down
5 changes: 5 additions & 0 deletions server/db/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ var migrations = []localMigration{
{
Name: "2021_02_07_00_09_LowerCaseEmails",
Query: "update users set email=lower(email)",

},
{
Name: "2022_03_08_13_16_AddVIN",
Query: "ALTER TABLE vehicles ADD COLUMN vin text",
},
}

Expand Down
1 change: 1 addition & 0 deletions server/models/vehicle.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type SubItemQuery struct {
type CreateVehicleRequest struct {
Nickname string `form:"nickname" json:"nickname" binding:"required"`
Registration string `form:"registration" json:"registration" binding:"required"`
VIN string `form:"vin" json:"vin"`
Make string `form:"make" json:"make" binding:"required"`
Model string `form:"model" json:"model" binding:"required"`
YearOfManufacture int `form:"yearOfManufacture" json:"yearOfManufacture"`
Expand Down
2 changes: 2 additions & 0 deletions server/service/vehicleService.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func CreateVehicle(model models.CreateVehicleRequest, userId string) (*db.Vehicl
Nickname: model.Nickname,
Registration: model.Registration,
Model: model.Model,
VIN: model.VIN,
Make: model.Make,
YearOfManufacture: model.YearOfManufacture,
EngineSize: model.EngineSize,
Expand Down Expand Up @@ -100,6 +101,7 @@ func UpdateVehicle(vehicleID string, model models.UpdateVehicleRequest) error {
//return db.DB.Model(&toUpdate).Updates(db.Vehicle{
toUpdate.Nickname = model.Nickname
toUpdate.Registration = model.Registration
toUpdate.VIN = model.VIN
toUpdate.Model = model.Model
toUpdate.Make = model.Make
toUpdate.YearOfManufacture = model.YearOfManufacture
Expand Down
5 changes: 5 additions & 0 deletions ui/src/router/views/createVehicle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default {
fuelUnit: null,
fuelType: null,
registration: '',
vin: '',
nickname: '',
engineSize: null,
make: '',
Expand All @@ -58,6 +59,7 @@ export default {
fuelUnit: veh.fuelUnit,
fuelType: veh.fuelType,
registration: veh.registration,
vin: veh.vin,
nickname: veh.nickname,
engineSize: veh.engineSize,
make: veh.make,
Expand Down Expand Up @@ -138,6 +140,9 @@ export default {
<b-field label="Registration*">
<b-input v-model="vehicleModel.registration" type="text" expanded required></b-input>
</b-field>
<b-field label="VIN">
<b-input v-model="vehicleModel.vin" type="text" expanded></b-input>
</b-field>
<b-field label="Fuel Type*">
<b-select v-model.number="vehicleModel.fuelType" placeholder="Fuel Type" required expanded>
<option v-for="(option, key) in fuelTypeMasters" :key="key" :value="key">
Expand Down