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

Vue3 Nuxt3 #41

Open
wants to merge 24 commits into
base: main
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
24 changes: 24 additions & 0 deletions pvtools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example
13 changes: 13 additions & 0 deletions pvtools/Dockerfile.backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG NODE_BASEIMAGE=node:21.4.0-alpine3.19

FROM ${NODE_BASEIMAGE} AS builder
WORKDIR /app
COPY . .
RUN npm ci && \
npm run build
FROM ${NODE_BASEIMAGE}
WORKDIR /app
USER node
COPY --from=builder /app .
CMD ["node", ".output/server/index.mjs" ]
EXPOSE 3000
13 changes: 13 additions & 0 deletions pvtools/Dockerfile.frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:21.4.0-alpine3.19 AS builder
ARG APP_URL="localhost:8082"
ARG GOOGLE_ANALYTICS_ID
ENV APP_URL=${APP_URL}
ENV GOOGLE_ANALYTICS_ID=${GOOGLE_ANALYTICS_ID}
ENV NODE_ENV=${NODE_ENV}
WORKDIR /app
COPY . /app
RUN npm ci && \
npm run generate
FROM nginxinc/nginx-unprivileged:stable-alpine3.18
COPY --from=builder /app/.output/public /usr/share/nginx/html
EXPOSE 8080
112 changes: 47 additions & 65 deletions pvtools/README.md
Original file line number Diff line number Diff line change
@@ -1,93 +1,75 @@
# pvtools
# Nuxt 3 Minimal Starter

## Requirements
Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.

- Node.js >= 20
- NPM
## Setup

## Build Setup
Make sure to install the dependencies:

```bash
# install dependencies
$ npm install
# npm
npm install

# serve with hot reload at localhost:3000
$ npm run dev
# pnpm
pnpm install

# build for production and launch server
$ npm run build
$ npm run start
# yarn
yarn install

# generate static project
$ npm run generate
# bun
bun install
```

For detailed explanation on how things work, check out the [documentation](https://nuxtjs.org).
## Development Server

## Enviroment variables
Start the development server on `http://localhost:3000`:

| Variable | Description | Default if not set |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| APP_URL | Domain name and Port that is used to access the API backend when NODE_ENV='production' | localhost:8082 |
| NODE_ENV | Using the value 'production' changes the API backend URL to https://APP_URL. Attention: in production mode 'https' is always set as protocol | (not set) |
| GOOGLE_ANALYTICS_ID | Google Analytics ID that is embeded in the UI | (not set) |

## Docker
```bash
# Build image with defaults
$ docker build --tag pvtools-frontend:latest .

# Build image for production with custom settings
$ docker build --build-arg APP_URL=backend.exmaple.com:8443 --build-arg NODE_ENV=production --build-arg GOOGLE_ANALYTICS_ID=example123 --tag pvtools-frontend:latest .

# Run image
$ docker run --publish 8080:8080 pvtools-frontend:latest
```

## Special Directories

You can create the following extra directories, some of which have special behaviors. Only `pages` is required; you can delete them if you don't want to use their functionality.

### `assets`

The assets directory contains your uncompiled assets such as Stylus or Sass files, images, or fonts.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/assets).
# npm
npm run dev

### `components`
# pnpm
pnpm run dev

The components directory contains your Vue.js components. Components make up the different parts of your page and can be reused and imported into your pages, layouts and even other components.
# yarn
yarn dev

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/components).

### `layouts`

Layouts are a great help when you want to change the look and feel of your Nuxt app, whether you want to include a sidebar or have distinct layouts for mobile and desktop.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/layouts).

### `pages`
# bun
bun run dev
```

This directory contains your application views and routes. Nuxt will read all the `*.vue` files inside this directory and setup Vue Router automatically.
## Production

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/get-started/routing).
Build the application for production:

### `plugins`
```bash
# npm
npm run build

The plugins directory contains JavaScript plugins that you want to run before instantiating the root Vue.js Application. This is the place to add Vue plugins and to inject functions or constants. Every time you need to use `Vue.use()`, you should create a file in `plugins/` and add its path to plugins in `nuxt.config.js`.
# pnpm
pnpm run build

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/plugins).
# yarn
yarn build

### `static`
# bun
bun run build
```

This directory contains your static files. Each file inside this directory is mapped to `/`.
Locally preview production build:

Example: `/static/robots.txt` is mapped as `/robots.txt`.
```bash
# npm
npm run preview

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/static).
# pnpm
pnpm run preview

### `store`
# yarn
yarn preview

This directory contains your Vuex store files. Creating a file in this directory automatically activates Vuex.
# bun
bun run preview
```

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/store).
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
4 changes: 4 additions & 0 deletions pvtools/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import FAQ from './components/FAQ.vue';
<template>
<div><NuxtPage /></div>
</template>
133 changes: 49 additions & 84 deletions pvtools/components/BarChart.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<template>
<Bar
:chart-options="chartOptions"
:chart-data="chartData"
:chart-id="chartId"
:dataset-id-key="datasetIdKey"
:plugins="plugins"
:css-classes="cssClasses"
:options="chartOptions"
:data="chartData"
:id="props.chartId"
:dataset-id-key="props.datasetIdKey"
:plugins="props.plugins"
:css-classes="props.cssClasses"
:styles="styles"
:width="width"
:height="height"
:width="props.width"
:height="props.height"
/>
</template>

<script>
import { Bar } from 'vue-chartjs/legacy'
<script setup lang="ts">
import { Bar } from 'vue-chartjs'
import {
Chart as ChartJS,
Title,
Expand All @@ -24,83 +24,48 @@ import {
LinearScale,
} from 'chart.js'

import type { ChartOptions } from 'chart.js'

ChartJS.register(Title, Tooltip, Legend, BarElement, CategoryScale, LinearScale)

export default {
name: 'BarChart',
components: { Bar },
props: {
chartId: {
type: String,
default: 'bar-chart',
},
datasetIdKey: {
type: String,
default: 'label',
},
// chartData: {
// type: Object,
// required: true
// // },
// chartOptions: {
// type: Object,
// default: () => {}
// },
width: {
type: Number,
default: 400,
},
height: {
type: Number,
default: 400,
},
cssClasses: {
default: '',
type: String,
},
styles: {
type: Object,
default: () => {},
},
plugins: {
type: Object,
default: () => {},
},
labels: {
type: Array,
default: [],
},
datasets: {
type: Array,
default: [],
interface Props {
chartId?: string
datasetIdKey?: string
width?: number
height?: number
cssClasses?: string
plugins: any
labels: string[]
datasets: string[]
}

const props = withDefaults(defineProps<Props>(), {
chartId: 'bar-chart',
datasetIdKey: 'label',
width: 400,
height: 400,
cssClasses: '',
plugins: {},
labels: [],
datasets: [],
})

const chartData = computed(() => {
return {
labels: props.labels,
datasets: props.datasets,
}
})

const chartOptions = ref<ChartOptions>({
responsive: true,
scales: {
x: {
stacked: true,
},
},
computed: {
chartData() {
return {
labels: this.labels,
datasets: this.datasets,
}
y: {
stacked: true,
},
},
data() {
return {
// chartData: {
// labels: [ 'January', 'February', 'March' ],
// datasets: [ { data: [40, 20, 12] } ]
// },
chartOptions: {
responsive: true,
scales: {
x: {
stacked: true,
},
y: {
stacked: true,
},
},
},
}
},
}
})
</script>
Loading