Skip to content
This repository has been archived by the owner on May 15, 2021. It is now read-only.

Commit

Permalink
0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nnsdev committed Jun 21, 2018
1 parent 7617e9d commit 58f1eed
Show file tree
Hide file tree
Showing 24 changed files with 866 additions and 152 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ npm-debug.log
npm-debug.log.*
thumbs.db
!.gitkeep
src/renderer/env.js
661 changes: 661 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# install dependencies
npm install

# copy `env.example.js` to `.env.js` and modify accordingly

# serve with hot reload at localhost:9080
npm run dev

Expand All @@ -18,8 +20,4 @@ npm run build
# lint all JS/Vue component files in `src/`
npm run lint

```

---

This project was generated with [electron-vue](https://github.com/SimulatedGREG/electron-vue)@[4c6ee7b](https://github.com/SimulatedGREG/electron-vue/tree/4c6ee7bf4f9b4aa647a22ec1c1ca29c2e59c3645) using [vue-cli](https://github.com/vuejs/vue-cli). Documentation about the original structure can be found [here](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html).
```
Binary file removed build/icons/256x256.png
Binary file not shown.
Binary file modified build/icons/icon.icns
Binary file not shown.
Binary file modified build/icons/icon.ico
Binary file not shown.
Binary file added build/icons/png/1024x1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/png/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/png/16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/png/24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/png/256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/png/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/png/48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/png/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/png/64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dokdrop",
"version": "0.0.0",
"version": "0.1.0",
"author": "Julien Gelmar <[email protected]>",
"description": "Dokdrop",
"license": null,
Expand All @@ -16,11 +16,12 @@
"pack": "npm run pack:main && npm run pack:renderer",
"pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js",
"pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",
"postinstall": "npm run lint:fix"
"postinstall": "npm run lint:fix",
"publish": "electron-builder --x64 --win -p always"
},
"build": {
"productName": "dokdrop",
"appId": "org.simulatedgreg.electron-vue",
"appId": "org.juliengelmar.dokdrop",
"directories": {
"output": "build"
},
Expand All @@ -45,11 +46,17 @@
"mac": {
"icon": "build/icons/icon.icns"
},
"publish": {
"provider": "github"
},
"win": {
"icon": "build/icons/icon.ico"
},
"linux": {
"icon": "build/icons"
"icon": "build/icons/png"
},
"nsis": {
"oneClick": true
}
},
"dependencies": {
Expand Down
40 changes: 6 additions & 34 deletions src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { app, BrowserWindow } from 'electron' // eslint-disable-line
import path from 'path'
import { autoUpdater } from 'electron-updater'

/**
* Set `__static` path to static files in production
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
*/
if (process.env.NODE_ENV !== 'development') {
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\') // eslint-disable-line
global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\') // eslint-disable-line
}
const {
ipcMain
} = require('electron')

let mainWindow
const winURL = process.env.NODE_ENV === 'development'
Expand All @@ -23,35 +22,12 @@ function createWindow () {
mainWindow = new BrowserWindow({
height: 420,
useContentSize: true,
width: 500
width: 700,
resizable: false,
icon: path.join(__dirname, '../../build/icons/png/1024x1024.png')
})
mainWindow.setMenu(null)
mainWindow.loadURL(winURL)

mainWindow.on('closed', () => {
mainWindow = null
})
mainWindow.on('drag-enter', () => {
console.log('drag-enter!')
})

mainWindow.on('drag-leave', () => {
console.log('drag-leave!')
})

mainWindow.on('drag-end', () => {
console.log('drag-end!')
})
mainWindow.on('drop', (evt, files) => {
console.log('drop')
})
ipcMain.on('ondragstart', (event, filePath) => {
console.log(event, filePath)
event.sender.startDrag({
file: filePath,
icon: '/path/to/icon.png'
})
})
}

app.on('ready', createWindow)
Expand All @@ -76,14 +52,10 @@ app.on('activate', () => {
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-builder.html#auto-updating
*/

/*
import { autoUpdater } from 'electron-updater'
autoUpdater.on('update-downloaded', () => {
autoUpdater.quitAndInstall()
})

app.on('ready', () => {
if (process.env.NODE_ENV === 'production') autoUpdater.checkForUpdates()
})
*/
30 changes: 21 additions & 9 deletions src/renderer/components/Fix.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

<form @submit.prevent="update">
<label for="car">Car</label>
<multiselect v-model="form.car" track-by="search" label="name" value="search" :options="response.cars"></multiselect>
<multiselect v-model="form.car" track-by="search" label="name" value="search" :options="cars"></multiselect>
<div v-if="saving !== 'car'" class="mt-2">
<label for="track">Track</label>
<multiselect v-model="form.track" track-by="search" label="name" value="search" :options="response.tracks"></multiselect>
<multiselect v-model="form.track" track-by="search" label="name" value="search" :options="tracks"></multiselect>
</div>
<div v-if="saving === 'season'" class="mt-2">
<label for="season">Season</label>
<multiselect v-model="form.season" track-by="search" label="name" value="search" :options="response.seasons"></multiselect>
<multiselect v-model="form.season" track-by="search" label="name" value="search" :options="seasons"></multiselect>
</div>
<button class="btn btn-block btn-primary mt-2" type="submit">Save and Move File</button>
</form>
Expand All @@ -30,7 +30,9 @@
return {
path: null,
filename: null,
response: null,
cars: [],
tracks: [],
seasons: [],
form: {car: null, track: null, season: null},
saving: null
}
Expand All @@ -49,8 +51,16 @@
this.notify('error', 'Please set a season.')
return false
}
let path = this.createFolders(this.form.car.folder, this.form.track.search, this.form.season.search)
this.$fs.copy(this.path, path + this.name).then(() => {
var newpath
if (this.saving === 'season') {
newpath = this.createFolders(this.form.car.folder, this.form.track.search, this.form.season.search)
} else if (this.saving === 'track') {
newpath = this.createFolders(this.form.car.folder, this.form.track.search)
} else {
newpath = this.createFolders(this.form.car.folder)
}
console.log(newpath + this.filename)
this.$fs.copy(this.path, newpath + this.filename).then(() => {
this.notify('success', 'File successfully copied')
this.$router.push('landing-page')
}).catch(err => {
Expand All @@ -59,13 +69,15 @@
})
}
},
mounted () {
this.saving = localStorage.getItem('saving')
created () {
console.log(this.$route.query)
this.saving = localStorage.getItem('saving')
this.path = this.$route.query.path
this.filename = this.$route.query.filename
this.$axios.get(this.$backend + 'data').then(res => {
this.response = res.data
this.cars = res.data.cars
this.tracks = res.data.tracks
this.seasons = res.data.seasons
}).catch(err => {
console.log(err)
this.notify('error', 'Error while fetching information')
Expand Down
51 changes: 33 additions & 18 deletions src/renderer/components/LandingPage.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
<template>
<div>
<div id="content" style="height: 100vh; text-align: center;" class="pt-4">
<div class="card" v-if="!folder">
<div class="card-body">
<h4 class="card-title">Please set your iRacing folder and saving</h4>
<setting-card :buttons="false"></setting-card>
</div>
</div>
<div id="content" style="height: 100vh; text-align: center;" class="pt-4" v-else>
<router-link to="/settings">Settings</router-link><br>
Drop your setup here
</div>
<modal name="guess">
<div class="container mt-4">
<h3>Your Setup</h3>
<div class="row">
<div class="col-xs-6 ml-3 mr-5">
<strong>Track</strong><br>
{{ guess.track ? guess.track[1] : 'Not guessed' }}<br>
<p class="mt-4">
<div class="col-xs-4">
<strong>Car</strong><br>
{{ guess.car ? guess.car[1] : 'Not guessed' }}<br>
<p class="mt-4" v-if="(saving === 'car' && guess.car) || (saving === 'track' && guess.car && guess.track) || (saving === 'season' && guess.car && guess.track && guess.season)">
<a @click="copyFile" class="text-primary">Correct!</a> or <a @click="fix" class="text-primary">Wrong :(</a>
</p>
<p class="mt-4" v-else>
<a @click="fix" class="text-primary">Fix</a>
</p>
</div>
<div class="col-xs-6 ml-5">
<strong>Car</strong><br>
{{ guess.car ? guess.car[1] : 'Not guessed' }}<br>
<div class="col-xs-4 mx-2" v-if="saving !== 'car'">
<strong>Track</strong><br>
{{ guess.track ? guess.track[1] : 'Not guessed' }}<br>
</div>
<div class="col-xs-4 mx-2" v-if="saving === 'season'">
<strong>Season</strong><br>
{{ guess.season ? guess.season[1] : 'Not guessed'}}
</div>
</div>
</div>
Expand All @@ -26,22 +39,23 @@
</template>

<script>
import SettingCard from './partials/SettingCard.vue'
export default {
name: 'landing-page',
components: { SettingCard },
data: () => {
return {
folder: null,
saving: null,
inputs: { folder: null, saving: null },
guess: {path: null, name: null, car: null, track: null}
guess: {path: null, name: null, car: null, track: null, season: null}
}
},
methods: {
hide (modal) {
this.$modal.hide(modal)
},
guessInfo (path, filename) {
this.guess = {path: null, name: null, car: null, track: null}
this.guess = {path: null, name: null, car: null, track: null, season: null}
this.$axios.post(this.$backend + 'guess', {path: path, filename: filename}).then(res => {
this.guess = res.data
this.guess.name = filename
Expand All @@ -53,8 +67,9 @@
this.$modal.show('guess')
},
copyFile () {
let path = this.createFolders(this.guess.car[2], this.guess.track[0])
this.$fs.copy(this.guess.path, path + this.guess.name).then(() => {
let season = (typeof this.guess.season === 'undefined') ? null : this.guess.season[1]
var newpath = this.createFolders(this.guess.car[2], this.guess.track[0], season)
this.$fs.copy(this.guess.path, newpath + this.guess.name).then(() => {
this.notify('success', 'File successfully copied')
}).catch(err => {
console.log(err)
Expand All @@ -66,12 +81,12 @@
}
},
mounted () {
if (localStorage.getItem('folder')) {
this.folder = localStorage.getItem('folder')
} else {
this.$route.push('settings')
}
this.folder = (localStorage.getItem('folder')) ? localStorage.getItem('folder') : null
this.saving = (localStorage.getItem('saving')) ? localStorage.getItem('saving') : 'track'
this.$on('saved', () => {
this.folder = localStorage.getItem('folder')
this.saving = localStorage.getItem('saving')
})
},
updated () {
document.ondragover = () => {
Expand Down
68 changes: 16 additions & 52 deletions src/renderer/components/Settings.vue
Original file line number Diff line number Diff line change
@@ -1,69 +1,33 @@
<template>
<div>
<div class="card">
<div class="card-body">
<h4 class="card-title">Please set your iRacing folder and saving</h4>
<p class="card-text">
Your default folder should be something like "C:\Users\User\Documents\iRacing\setups"
<form>
<label for="folder" class="grey-text">Folder</label>
<input type="text" v-model="inputs.folder" class="form-control" placeholder="Folder">
<label for="saving" class="grey-text mt-2">Saving Method</label>
<div class="md-form mt-2">
<div class="col-sm-12">
<input type="radio" v-model="inputs.saving" value="season"> car\track\season\setup.sto
</div>
<div class="col-sm-12">
<input type="radio" v-model="inputs.saving" value="track"> car\track\setup.sto
</div>
<div class="col-sm-12">
<input type="radio" v-model="inputs.saving" value="car"> car\setup.sto
</div>
</div>
<div class="text-center mt-4">
<button class="btn btn-primary" type="button" @click="set">Set</button>
<router-link to="/" class="btn btn-secondary">Back</router-link>
</div>
</form>
<setting-card :buttons="true"></setting-card>
</div>
</div>
<div class="card mt-4">
<div class="card-body">
<h4 class="card-title">About</h4>
<p class="card-body">
Made by <a class="text-primary" @click="external('https://gelmar.app')">Julien Gelmar</a><br>
Version 0.1
</p>
</div>
</div>
</div>
</template>

<script>
import SettingCard from './partials/SettingCard.vue'
const {shell} = require('electron')
export default {
name: 'settings',
data: () => {
return {
folder: null,
saving: null,
inputs: { folder: null, saving: null }
}
},
components: { SettingCard },
methods: {
set () {
if (!this.inputs.folder) {
this.notify('error', 'Please set a folder.')
}
if (!this.inputs.saving) {
this.notify('error', 'Please set a saving method.')
}
if (this.inputs.folder && this.inputs.saving) {
this.saving = this.inputs.saving
localStorage.setItem('saving', this.saving)
if (this.$fs.existsSync(this.inputs.folder)) {
this.folder = this.inputs.folder
localStorage.setItem('folder', this.folder)
} else {
this.folder = null
localStorage.removeItem('folder')
this.notify('error', 'Folder does not seem to exist. Please double check.')
}
}
external (url) {
shell.openExternal(url)
}
},
mounted () {
this.saving = this.inputs.saving = (localStorage.getItem('saving')) ? localStorage.getItem('saving') : 'season'
this.folder = this.inputs.folder = (localStorage.getItem('folder')) ? localStorage.getItem('folder') : null
}
}
</script>
Loading

0 comments on commit 58f1eed

Please sign in to comment.