Groundnet Scan

This commit is contained in:
portree_kid
2019-12-17 21:10:58 +01:00
parent b81348bdb8
commit 6adffb8878
29 changed files with 1744 additions and 1496 deletions
+54
View File
@@ -0,0 +1,54 @@
<template>
<section class="edit-layer">
<h1>edit-layer Component</h1>
</section>
</template>
<script lang="js">
import L from 'leaflet'
export default {
name: 'edit-layer',
props: [],
mounted () {
this.add()
},
beforeDestroy () {
this.remove()
},
data () {
return {
}
},
methods: {
deferredMountedTo (parent) {
this.sidebar = L.control.sidebar({
autopan: false, // whether to maintain the centered map point when opening the sidebar
closeButton: true, // whether t add a close button to the panes
container: 'sidebar', // the DOM container or #ID of a predefined sidebar container that should be used
position: 'left' // left or right
})
parent.addControl(this.sidebar)
},
remove () {
if (this.sidebar) {
this.$parent.removeLayer(this.sidebar)
}
},
add () {
if (this.$parent._isMounted) {
this.deferredMountedTo(this.$parent.mapObject)
}
}
},
computed: {
}
}
</script>
<style scoped lang="scss">
.edit-layer {
}
</style>
@@ -0,0 +1,40 @@
<template>
<label class="directory-select">
<div class="select-button">
...
</div>
<input type="file" @change="handleFileChange" webkitdirectory directory/>
</label>
</template>
<script>
export default {
props: {
value: File
},
methods: {
handleFileChange (e) {
this.$emit('input', e.target.files[0])
}
}
}
</script>
<style scoped>
.directory-select > .select-button {
padding: 0rem;
color: white;
background-color: #2EA169;
border-radius: .3rem;
text-align: center;
font-weight: bold;
}
.directory-select > input[type="file"] {
display: none;
}
</style>
+54
View File
@@ -0,0 +1,54 @@
<template>
<section class="edit-layer">
<h1>edit-layer Component</h1>
</section>
</template>
<script lang="js">
import L from 'leaflet'
export default {
name: 'edit-layer',
props: [],
mounted () {
this.add()
},
beforeDestroy () {
this.remove()
},
data () {
return {
}
},
methods: {
deferredMountedTo (parent) {
this.sidebar = L.control.sidebar({
autopan: false, // whether to maintain the centered map point when opening the sidebar
closeButton: true, // whether t add a close button to the panes
container: 'sidebar', // the DOM container or #ID of a predefined sidebar container that should be used
position: 'left' // left or right
})
parent.addControl(this.sidebar)
},
remove () {
if (this.sidebar) {
this.$parent.removeLayer(this.sidebar)
}
},
add () {
if (this.$parent._isMounted) {
this.deferredMountedTo(this.$parent.mapObject)
}
}
},
computed: {
}
}
</script>
<style scoped lang="scss">
.edit-layer {
}
</style>
+41
View File
@@ -0,0 +1,41 @@
<template>
<label class="file-select">
<div class="select-button">
<span v-if="value">Selected File: {{value.name}}</span>
<span v-else>Select File</span>
</div>
<input type="file" @change="handleFileChange"/>
</label>
</template>
<script>
export default {
props: {
value: File
},
methods: {
handleFileChange (e) {
this.$emit('input', e.target.files[0])
}
}
}
</script>
<style scoped>
.file-select > .select-button {
padding: 1rem;
color: white;
background-color: #2EA169;
border-radius: .3rem;
text-align: center;
font-weight: bold;
}
.file-select > input[type="file"] {
display: none;
}
</style>
+3 -1
View File
@@ -3,6 +3,7 @@
<l-tile-layer :url="url" :attribution="attribution"></l-tile-layer>
<l-marker :lat-lng="marker"></l-marker>
<LeafletSidebar></LeafletSidebar>
<EditLayer></EditLayer>
</l-map>
</template>
@@ -10,6 +11,7 @@
import 'leaflet/dist/leaflet.css'
import { LMap, LTileLayer, LMarker } from 'vue2-leaflet'
import LeafletSidebar from './LeafletSidebar'
import EditLayer from './EditLayer'
import L from 'leaflet'
// https://github.com/KoRiGaN/Vue2Leaflet/issues/103
@@ -22,7 +24,7 @@
})
export default {
name: 'flightgear-map',
components: { LMap, LTileLayer, LMarker, LeafletSidebar },
components: { LMap, LTileLayer, LMarker, LeafletSidebar, EditLayer },
props: [],
mounted () {
@@ -1,73 +0,0 @@
<template>
<div>
<div class="title">Information</div>
<div class="items">
<div class="item">
<div class="name">Path:</div>
<div class="value">{{ path }}</div>
</div>
<div class="item">
<div class="name">Route Name:</div>
<div class="value">{{ name }}</div>
</div>
<div class="item">
<div class="name">Vue.js:</div>
<div class="value">{{ vue }}</div>
</div>
<div class="item">
<div class="name">Electron:</div>
<div class="value">{{ electron }}</div>
</div>
<div class="item">
<div class="name">Node:</div>
<div class="value">{{ node }}</div>
</div>
<div class="item">
<div class="name">Platform:</div>
<div class="value">{{ platform }}</div>
</div>
</div>
</div>
</template>
<script>
export default {
data () {
return {
electron: process.versions.electron,
name: this.$route.name,
node: process.versions.node,
path: this.$route.path,
platform: require('os').platform(),
vue: require('vue/package.json').version
}
}
}
</script>
<style scoped>
.title {
color: #888;
font-size: 18px;
font-weight: initial;
letter-spacing: .25px;
margin-top: 10px;
}
.items { margin-top: 8px; }
.item {
display: flex;
margin-bottom: 6px;
}
.item .name {
color: #6a6a6a;
margin-right: 6px;
}
.item .value {
color: #35495e;
font-weight: bold;
}
</style>
+10 -43
View File
@@ -4,8 +4,7 @@
<div class="leaflet-sidebar-tabs">
<ul role="tablist"> <!-- top aligned tabs -->
<li><a href="#home" role="tab"><i class="fa fa-bars"></i></a></li>
<li><a href="#messages" role="tab"><i class="fa fa-envelope"></i></a></li>
<li><a href="#profile" role="tab"><i class="fa fa-user"></i></a></li>
<li><a href="#scan" role="tab"><i class="fa fa-search"></i></a></li>
</ul>
<ul role="tablist"> <!-- bottom aligned tabs -->
@@ -22,14 +21,11 @@
</h1>
<p>A responsive sidebar for mapping libraries</p>
</div>
<div class="leaflet-sidebar-pane" id="messages">
<h1 class="leaflet-sidebar-header">Messages<div class="leaflet-sidebar-close"><i class="fa fa-caret-left"></i></div></h1>
<el-select v-model="value" placeholder="Select"><el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option> </el-select>
<div class="leaflet-sidebar-pane" id="scan">
<RunScan></RunScan>
</div>
<div class="leaflet-sidebar-pane" id="profile">
<h1 class="leaflet-sidebar-header">Profile<div class="leaflet-sidebar-close"><i class="fa fa-caret-left"></i></div></h1>
<div class="leaflet-sidebar-pane" id="settings">
<SettingsPanel></SettingsPanel>
</div>
</div>
</div>
@@ -41,10 +37,12 @@
import {} from 'leaflet-sidebar-v2'
import L from 'leaflet'
import SettingsPanel from './SettingsPanel'
import RunScan from './RunScan'
import FileSelect from './FileSelect'
export default {
name: 'leaflet-sidebar',
components: { SettingsPanel },
components: { SettingsPanel, RunScan, FileSelect },
props: [],
mounted () {
this.add()
@@ -54,25 +52,6 @@
},
data () {
return {
message: 'BLBL',
checkbox: true,
options: [{
value: 'Option1',
label: 'Option1'
}, {
value: 'Option2',
label: 'Option2'
}, {
value: 'Option3',
label: 'Option3'
}, {
value: 'Option4',
label: 'Option4'
}, {
value: 'Option5',
label: 'Option5'
}],
value: ''
}
},
methods: {
@@ -84,20 +63,6 @@
position: 'left' // left or right
})
parent.addControl(this.sidebar)
this.sidebar.addPanel({
id: 'properties',
tab: '<i class="fa fa-road vertical-center"/>',
title: 'Properties',
pane: '<div id="properties-tab"></div>'
})
this.sidebar.addPanel({
id: 'settings',
tab: '<i class="fa fa-gear vertical-center"/>',
title: 'Settings',
pane: '<div id="settings-div"></div>'
})
},
remove () {
if (this.sidebar) {
@@ -108,6 +73,8 @@
if (this.$parent._isMounted) {
this.deferredMountedTo(this.$parent.mapObject)
}
},
scan () {
}
},
computed: {
+104
View File
@@ -0,0 +1,104 @@
<template>
<div>
<el-container direction='vertical'>
<el-button @click="scanAPT()">Scan APT File</el-button>
<el-button @click="scanGroundnets()">Scan Groundnet Files</el-button>
<el-button @click="scanTraffic()">Scan Traffic Files</el-button>
</el-container>
</div>
</template>
<script lang="js">
// import scanner from '../utils/scan'
import fileUrl from 'file-url'
const path = require('path')
export default {
name: 'run-scan',
components: {},
props: [],
mounted () {
},
beforeDestroy () {
},
data () {
return {
}
},
methods: {
scanAPT () {
try {
const winURL = process.env.NODE_ENV === 'development'
? `http://localhost:9080/src/renderer/utils/worker.js`
: `file://${__dirname}/worker.js`
console.log('make a worker: ', path.resolve(__dirname, 'worker.js'))
const worker = new Worker(winURL)
console.log(fileUrl('src/renderer/utils/worker.js'))
// var worker = new Worker(fileUrl('src/renderer/utils/worker.js'))
worker.postMessage('scanapt')
// the reply
worker.onmessage = function (e) {
if (e.data === 'DONE') {
console.log('DONE')
}
console.log(e.data)
}
} catch (err) {
console.error(err)
}
},
scanGroundnets () {
try {
const winURL = process.env.NODE_ENV === 'development'
? `http://localhost:9080/src/renderer/utils/worker.js`
: `file://${__dirname}/worker.js`
console.log('make a worker: ', path.resolve(__dirname, 'worker.js'))
const worker = new Worker(winURL)
console.log(fileUrl('src/renderer/utils/worker.js'))
// var worker = new Worker(fileUrl('src/renderer/utils/worker.js'))
worker.postMessage('scan')
// the reply
worker.onmessage = function (e) {
if (e.data === 'DONE') {
console.log('DONE')
}
console.log(e.data)
}
} catch (err) {
console.error(err)
}
},
scanTraffic () {
// let flightgearDirectory = this.$store.state.settings.flightgearDirectory
try {
const winURL = process.env.NODE_ENV === 'development'
? `http://localhost:9080/src/renderer/utils/worker.js`
: `file://${__dirname}/worker.js`
console.log('make a worker: ', path.resolve(__dirname, 'worker.js'))
const worker = new Worker(winURL)
console.log(fileUrl('src/renderer/utils/worker.js'))
// var worker = new Worker(fileUrl('src/renderer/utils/worker.js'))
worker.postMessage('scanai')
// the reply
worker.onmessage = function (e) {
if (e.data === 'DONE') {
console.log('DONE')
}
console.log(e.data)
}
} catch (err) {
console.error(err)
}
}
},
computed: {
}
}
</script>
+41 -13
View File
@@ -1,34 +1,62 @@
<template>
<div>
<h1 class="leaflet-sidebar-header">
Settings
<div class="leaflet-sidebar-close">
<i class="fa fa-caret-left"></i>
</div>
</h1>
<div id="panel" width="100%">
<el-row>
<el-col :span="7">Flightgear Directory</el-col>
<el-col :span="15">{{ flightgear_directory }}</el-col>
<el-col :span="2">
<directory-select @input="directorySelect"></directory-select>
</el-col>
</el-row>
</div>
</div>
</template>
<script lang="js">
import FileSelect from './FileSelect'
import DirectorySelect from './DirectorySelect'
export default {
name: 'settings-panel',
components: { DirectorySelect, FileSelect },
props: [],
mounted () {
if (this.$parent._isMounted) {
this.$parent.sidebar.addPanel({
id: 'settings',
tab: '<i class="fa fa-gear vertical-center"/>',
title: 'Settings',
pane: '<div id="settings-div"></div>'
})
}
},
data () {
return {
selected: 'Undefined'
}
},
methods: {
buttonClick: function () {
this.$store.commit('TOGGLE_HYDRATED')
},
directorySelect: function (flightgearDirectory) {
console.log(flightgearDirectory)
this.$store.commit('SETTINGS_DIRECTORY', flightgearDirectory.path)
}
},
computed: {
hydrated: function () {
return this.$store.state.hydrated
},
flightgear_directory: function () {
return this.$store.state.settings.flightgearDirectory
}
}
}
}
</script>
<style scoped lang="scss">
<style>
.el-row {
margin-bottom: 20px;
}
.el-col {
border-radius: 4px;
}
</style>