What happens in vegas stays in vegas
This commit is contained in:
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
.idea/
|
18
README.md
Normal file
18
README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Vue 3 + TypeScript + Vite
|
||||
|
||||
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
|
||||
|
||||
## Type Support For `.vue` Imports in TS
|
||||
|
||||
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
|
||||
|
||||
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
|
||||
|
||||
1. Disable the built-in TypeScript Extension
|
||||
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
|
||||
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
|
||||
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
|
14
index.html
Normal file
14
index.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Load Data Manager</title>
|
||||
<script src="https://kit.fontawesome.com/1a962b66c9.js" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
2060
package-lock.json
generated
Normal file
2060
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
27
package.json
Normal file
27
package.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vue-tsc && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.4.0",
|
||||
"primevue": "^3.30.2",
|
||||
"sass": "^1.62.1",
|
||||
"vue": "^3.3.4",
|
||||
"vue-router": "^4.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.1.0",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"postcss": "^8.4.23",
|
||||
"tailwindcss": "^3.3.3",
|
||||
"typescript": "^5.0.2",
|
||||
"vite": "^4.3.2",
|
||||
"vue-tsc": "^1.4.2"
|
||||
}
|
||||
}
|
6
postcss.config.js
Normal file
6
postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
1
public/vite.svg
Normal file
1
public/vite.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
After Width: | Height: | Size: 1.5 KiB |
17
src/App.vue
Normal file
17
src/App.vue
Normal file
@@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<div class="flex flex-row m-10 justify-around">
|
||||
<router-view />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from "vue";
|
||||
|
||||
export default defineComponent({})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-family: var(--font-family);
|
||||
}
|
||||
</style>
|
1
src/assets/vue.svg
Normal file
1
src/assets/vue.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
|
After Width: | Height: | Size: 496 B |
0
src/axios/index.ts
Normal file
0
src/axios/index.ts
Normal file
42
src/main.ts
Normal file
42
src/main.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { createApp } from 'vue'
|
||||
// @ts-ignore
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import PrimeVue from 'primevue/config';
|
||||
import "primevue/resources/primevue.min.css";
|
||||
import "primevue/resources/themes/viva-dark/theme.css";
|
||||
import "./styles.css"
|
||||
|
||||
const app = createApp(App)
|
||||
app.use(router)
|
||||
app.use(PrimeVue)
|
||||
|
||||
import Menubar from 'primevue/menubar';
|
||||
import Button from "primevue/button"
|
||||
import Card from 'primevue/card';
|
||||
import Calendar from "primevue/calendar";
|
||||
import Dropdown from 'primevue/dropdown';
|
||||
import InputNumber from 'primevue/inputnumber';
|
||||
import Textarea from 'primevue/textarea';
|
||||
import FileUpload from 'primevue/fileupload';
|
||||
import InputText from 'primevue/inputtext';
|
||||
import DataTable from 'primevue/datatable';
|
||||
import Column from 'primevue/column';
|
||||
import ColumnGroup from 'primevue/columngroup';
|
||||
import Row from 'primevue/row';
|
||||
|
||||
app.component('Button', Button);
|
||||
app.component('Card', Card);
|
||||
app.component('Menubar', Menubar);
|
||||
app.component('Dropdown', Dropdown);
|
||||
app.component('InputNumber', InputNumber);
|
||||
app.component('FileUpload', FileUpload);
|
||||
app.component('InputText', InputText);
|
||||
app.component('DataTable', DataTable);
|
||||
app.component('Column', Column);
|
||||
app.component('ColumnGroup', ColumnGroup);
|
||||
app.component('Calendar', Calendar);
|
||||
app.component('Row', Row);
|
||||
app.component('Textarea', Textarea);
|
||||
|
||||
app.mount('#app')
|
118
src/pages/Add.vue
Normal file
118
src/pages/Add.vue
Normal file
@@ -0,0 +1,118 @@
|
||||
<template>
|
||||
<Card class="w-full md:w-2/3">
|
||||
<template #header>
|
||||
<div class="ml-5 mt-7">
|
||||
<h2 class="text-3xl">Add Gun</h2>
|
||||
</div>
|
||||
</template>
|
||||
<template #content>
|
||||
<div class="flex flex-row flex-wrap">
|
||||
<div class="w-full">
|
||||
<div class="flex gap-2" style="flex-direction: column">
|
||||
<label for="make">Make</label>
|
||||
<InputText v-model="gun.make" id="make"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full mt-5">
|
||||
<div class="flex gap-2" style="flex-direction: column">
|
||||
<label for="model">Model</label>
|
||||
<InputText v-model="gun.model" id="model"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full mt-5">
|
||||
<div class="flex gap-2" style="flex-direction: column">
|
||||
<label for="serial_number">Serial Number</label>
|
||||
<InputText v-model="gun.serial_number" id="serial_number"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full mt-5">
|
||||
<div class="flex gap-2" style="flex-direction: column">
|
||||
<label for="purchase_amount">Purchase Amount</label>
|
||||
<InputNumber
|
||||
v-model="gun.purchase_amount"
|
||||
:maxFractionDigits="0"
|
||||
:minFractionDigits="0"
|
||||
:min="0"
|
||||
id="purchase_amount"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full mt-5">
|
||||
<div class="flex gap-2" style="flex-direction: column">
|
||||
<label for="value_amount">Value Amount</label>
|
||||
<InputNumber
|
||||
v-model="gun.value_amount"
|
||||
:maxFractionDigits="0"
|
||||
:minFractionDigits="0"
|
||||
:min="0"
|
||||
id="value_amount"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full mt-5">
|
||||
<div class="flex gap-2" style="flex-direction: column">
|
||||
<label for="date_purchased">Date Purchased</label>
|
||||
<Calendar v-model="gun.date_purchased"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full mt-5">
|
||||
<div class="flex gap-2" style="flex-direction: column">
|
||||
<label for="value_amount">Notes</label>
|
||||
<Textarea v-model="gun.notes"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full mt-5">
|
||||
<div class="flex gap-2" style="flex-direction: column">
|
||||
<label for="value_amount">Photos</label>
|
||||
<FileUpload :showUploadButton="false" :showCancelButton="false" accept="image/*" multiple/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full mt-5">
|
||||
<Button @click="save" class="p-button-success" icon="fa-sharp fa-light fa-floppy-disk" label="Save"/>
|
||||
<router-link to="/guns">
|
||||
<Button class="p-button-warning ml-3" icon="fa-sharp fa-light fa-times" label="Cancel"/>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</Card>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import {defineComponent} from "vue";
|
||||
import {Nullable} from "primevue/ts-helpers";
|
||||
import axios from "axios";
|
||||
import {Response} from "../types/Response";
|
||||
|
||||
interface Data {
|
||||
gun: {
|
||||
make: string
|
||||
model: string
|
||||
serial_number: string
|
||||
purchase_amount: Nullable<number>
|
||||
value_amount: Nullable<number>
|
||||
date_purchased: string
|
||||
notes: string
|
||||
}
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
data: (): Data => ({
|
||||
gun: {
|
||||
make: "",
|
||||
model: "",
|
||||
serial_number: "",
|
||||
purchase_amount: 0,
|
||||
value_amount: 0,
|
||||
date_purchased: "",
|
||||
notes: ""
|
||||
}
|
||||
}),
|
||||
methods: {
|
||||
save() {
|
||||
axios.post(import.meta.env.VITE_API + '/gun', this.gun).then((r: Response<{ id: number }>) => {
|
||||
this.$router.push('/gun/' + r.data.payload.id)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
18
src/pages/Edit.vue
Normal file
18
src/pages/Edit.vue
Normal file
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<img :src="`${remoteUrl}/gun/photo/1/IMG_0436.jpg`" />
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import {defineComponent} from "vue";
|
||||
import axios from "axios"
|
||||
|
||||
export default defineComponent({
|
||||
created() {
|
||||
axios.get(import.meta.env.VITE_API + `/gun/${this.$route.params.id}`)
|
||||
},
|
||||
computed: {
|
||||
remoteUrl() {
|
||||
return import.meta.env.VITE_API
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
65
src/pages/Guns.vue
Normal file
65
src/pages/Guns.vue
Normal file
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<Card>
|
||||
<template #title>
|
||||
Gun List
|
||||
</template>
|
||||
<template #content>
|
||||
<DataTable class="p-datatable-sm" :value="guns">
|
||||
<Column sortable field="id" header="ID"></Column>
|
||||
<Column sortable field="make" header="Make"></Column>
|
||||
<Column sortable field="model" header="Model"></Column>
|
||||
<Column sortable field="value_amount" header="Value">
|
||||
<template #body="slotProps">
|
||||
${{ slotProps.data.value_amount }}
|
||||
</template>
|
||||
</Column>
|
||||
<Column>
|
||||
<template #body="slotProps">
|
||||
<router-link :to="`/edit/${slotProps.data.id}`">edit</router-link>
|
||||
</template>
|
||||
</Column>
|
||||
<template #footer>
|
||||
Total Value: ${{ total }}
|
||||
</template>
|
||||
</DataTable>
|
||||
</template>
|
||||
<template #footer>
|
||||
<router-link to="/add">
|
||||
<Button class="p-button-secondary">Add Gun</Button>
|
||||
</router-link>
|
||||
</template>
|
||||
</Card>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import {defineComponent} from "vue";
|
||||
import {Guns} from "../types/guns";
|
||||
import {Response} from "../types/Response";
|
||||
import axios from 'axios'
|
||||
|
||||
interface Data {
|
||||
guns: Array<Guns>
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
data: (): Data => ({
|
||||
guns: []
|
||||
}),
|
||||
computed: {
|
||||
total() {
|
||||
let total = 0;
|
||||
|
||||
this.guns.map(g => {
|
||||
total += g.value_amount
|
||||
})
|
||||
|
||||
return total
|
||||
}
|
||||
},
|
||||
created() {
|
||||
axios.get(import.meta.env.VITE_API + '/gun')
|
||||
.then((r: Response<Array<Guns>>) => {
|
||||
this.guns = r.data.payload
|
||||
})
|
||||
},
|
||||
})
|
||||
</script>
|
15
src/pages/Index.vue
Normal file
15
src/pages/Index.vue
Normal file
@@ -0,0 +1,15 @@
|
||||
<template>
|
||||
<Card class="w-full lg:w-1/2 text-center">
|
||||
<template #title> Welcome to Your Gun Database </template>
|
||||
<template #content>
|
||||
<router-link to="/guns">
|
||||
<Button>Go To Gun List</Button>
|
||||
</router-link>
|
||||
</template>
|
||||
</Card>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import {defineComponent} from "vue";
|
||||
|
||||
export default defineComponent({})
|
||||
</script>
|
37
src/router/index.ts
Normal file
37
src/router/index.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import {createRouter, createWebHashHistory, RouteRecordRaw} from "vue-router";
|
||||
|
||||
// @ts-ignore
|
||||
import Index from "../pages/Index.vue";
|
||||
// @ts-ignore
|
||||
import BulletCreate from "../pages/bullets/Create.vue";
|
||||
// @ts-ignore
|
||||
import BulletList from "../pages/bullets/List.vue";
|
||||
import Guns from "../pages/Guns.vue";
|
||||
import Add from "../pages/Add.vue";
|
||||
import Edit from "../pages/Edit.vue";
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
component: Index
|
||||
},
|
||||
{
|
||||
path: '/guns',
|
||||
component: Guns
|
||||
},
|
||||
{
|
||||
path: '/add',
|
||||
component: Add
|
||||
},
|
||||
{
|
||||
path: '/edit/:id',
|
||||
component: Edit
|
||||
}
|
||||
] as RouteRecordRaw[]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes,
|
||||
})
|
||||
|
||||
export default router
|
3
src/styles.css
Normal file
3
src/styles.css
Normal file
@@ -0,0 +1,3 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
8
src/types/Response.d.ts
vendored
Normal file
8
src/types/Response.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import {AxiosResponse} from "axios";
|
||||
|
||||
export interface Response<T> extends AxiosResponse {
|
||||
data: {
|
||||
payload: T
|
||||
status: string
|
||||
}
|
||||
}
|
6
src/types/guns.d.ts
vendored
Normal file
6
src/types/guns.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export interface Guns {
|
||||
id: Number
|
||||
make: string
|
||||
model: string
|
||||
value_amount: Number
|
||||
}
|
1
src/vite-env.d.ts
vendored
Normal file
1
src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
7
tailwind.config.js
Normal file
7
tailwind.config.js
Normal file
@@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
content: ["./src/**/*.{html,js,vue}"],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
}
|
26
tsconfig.json
Normal file
26
tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "preserve",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
10
tsconfig.node.json
Normal file
10
tsconfig.node.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"skipLibCheck": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
7
vite.config.ts
Normal file
7
vite.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
})
|
Reference in New Issue
Block a user