Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ff18fdd8bd | |||
| 4c4631e89b | |||
| 7480717cac | |||
| a29d32fd0f | |||
| 942e98199e | |||
| 482caf9650 |
+1
-1
@@ -5,7 +5,7 @@
|
||||
"description": "Vue.js admin template",
|
||||
"author": "smartapant <smartapant@gmail.com>",
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"serve": "vue-cli-service serve --mode development",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint",
|
||||
"lint:style": "stylelint --fix src/**/*.{vue,htm,html,css,sss,less,scss}",
|
||||
|
||||
+13
-5
@@ -44,13 +44,22 @@ import '../registerServiceWorker'
|
||||
|
||||
localforage.config({ name: 'bioprovue' })
|
||||
|
||||
let MqttUrl
|
||||
// for developer
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
MqttUrl = 'ws://192.168.5.240:8083'
|
||||
} else {
|
||||
// for user
|
||||
MqttUrl = `ws://${location.href.split('/')[2]}:8083`
|
||||
}
|
||||
|
||||
if (process.env.VUE_APP_BUILD_VERSION) {
|
||||
// eslint-disable-next-line
|
||||
const message = `%c${'Build_information:'}\n %c${'Version'}: %c${VERSION},\n %c${'Timestamp'}: %c${TIMESTAMP},\n %c${'Commit'}: %c${COMMIT}`
|
||||
const message = `%c${'Build_information:'}\n %c${'Version'}: %c${VERSION},\n %c${'Timestamp'}: %c${TIMESTAMP},\n %c${'Commit'}: %c${COMMIT} %c${'Mqtt'}: %c${MqttUrl}`
|
||||
// eslint-disable-next-line
|
||||
console.info(
|
||||
message,
|
||||
'color: blue;', 'color: red;', 'color: blue;', 'color: red;', 'color: blue;', 'color: red;', 'color: blue;',
|
||||
'color: blue;', 'color: red;', 'color: blue;', 'color: red;', 'color: blue;', 'color: red;', 'color: blue;', 'color: red;', 'color: blue;',
|
||||
)
|
||||
}
|
||||
|
||||
@@ -61,11 +70,10 @@ Vue.component('chart', ECharts)
|
||||
Vue.use(VueWorker)
|
||||
Vue.use(VueAxios, axios)
|
||||
Vue.use(Toast)
|
||||
|
||||
// Vue.use(VueMqtt, 'ws://52.194.17.114:8083')
|
||||
Vue.use(VueMqtt, 'ws://' + location.href.split('/')[2] + ':8083')
|
||||
// Vue.use(VueMqtt, 'ws://' + location.href.split('/')[2] + ':8083')
|
||||
// Vue.use(VueMqtt, 'ws://' + '192.168.151.125' + ':8083')
|
||||
// Vue.use(VueMqtt, 'ws://' + '192.168.3.211' + ':8083')
|
||||
Vue.use(VueMqtt, MqttUrl)
|
||||
|
||||
Vue.prototype.API = api
|
||||
Vue.prototype.GLOBAL = global_
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<template>
|
||||
<va-card class="flex xl3 md3 sm12 xs12" title="MQTT">
|
||||
<div class="row ma-1 text-center">
|
||||
<va-button @click="getControllerID">Controller-ID</va-button>
|
||||
<div class="flex-center">
|
||||
{{ controllerID }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row ma-1 text-start" v-if="controllerID !== ''">
|
||||
<va-button @click="getHardwareInfo">HardwareInfo</va-button>
|
||||
<div class="">
|
||||
{{ responseMessage }}
|
||||
</div>
|
||||
</div>
|
||||
</va-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import api from '@/data/api'
|
||||
|
||||
export default {
|
||||
name: 'Developer',
|
||||
components: {
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
controllerID: '',
|
||||
responseMessage: '',
|
||||
}
|
||||
},
|
||||
mqtt: {
|
||||
async '+/get_device_info_all/+' (data, topic) {
|
||||
console.log('get_device_info_all', String.fromCharCode.apply(null, data))
|
||||
},
|
||||
async '+/hardware_device/+' (data, topic) {
|
||||
console.log('hardware_device', String.fromCharCode.apply(null, data))
|
||||
},
|
||||
async '+/hardware_datetime/+' (data, topic) {
|
||||
console.log('hardware_datetime', String.fromCharCode.apply(null, data))
|
||||
},
|
||||
async '+/hardware_info/+' (data, topic) {
|
||||
console.log('hardware_info', String.fromCharCode.apply(null, data))
|
||||
this.responseMessage = String.fromCharCode.apply(null, data)
|
||||
},
|
||||
async '+/broadcast/+' (data, topic) {
|
||||
console.log('broadcast', String.fromCharCode.apply(null, data))
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
mqttPub: function (topic, mes) {
|
||||
this.$mqtt.publish(topic, mes)
|
||||
},
|
||||
mqttSub: function (val) {
|
||||
this.$mqtt.subscribe(val)
|
||||
},
|
||||
mqttUnSub: function (val) {
|
||||
this.$mqtt.unsubscribe(val)
|
||||
},
|
||||
pageMqttSub: function (id) {
|
||||
this.mqttSub(id + '/hardware_datetime/+')
|
||||
this.mqttSub(id + '/hardware_device/+')
|
||||
this.mqttSub(id + '/hardware_info/+')
|
||||
this.mqttSub(id + '/broadcast')
|
||||
this.mqttSub(id + '/get_device_info_all/+')
|
||||
},
|
||||
pageMqttUnSub: function (id) {
|
||||
this.mqttUnSub(id + '/hardware_datetime/+')
|
||||
this.mqttUnSub(id + '/hardware_device/+')
|
||||
this.mqttUnSub(id + '/hardware_info/+')
|
||||
this.mqttUnSub(id + '/broadcast')
|
||||
this.mqttUnSub(id + '/get_device_info_all/+')
|
||||
},
|
||||
getControllerID: async function () {
|
||||
try {
|
||||
const response = await api.controller.getAll()
|
||||
if (response.status === 200) {
|
||||
if (response.data.length > 0) {
|
||||
this.controllerID = response.data[0].mqtt_id
|
||||
this.pageMqttSub(this.controllerID)
|
||||
return true
|
||||
}
|
||||
this.controllerID = 'No Controller Info'
|
||||
return false
|
||||
}
|
||||
this.controllerID = 'Wrong status ' + response.status
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
this.controllerID = e
|
||||
}
|
||||
},
|
||||
getHardwareDatetime: function () {
|
||||
this.mqttPub(this.controllerID + '_user', JSON.stringify({
|
||||
header: 'hardware_datetime/0',
|
||||
content: String(Date.now()),
|
||||
}))
|
||||
},
|
||||
getHardwareInfo: function () {
|
||||
this.mqttPub(this.controllerID + '_user', JSON.stringify({
|
||||
header: 'hardware_info/0',
|
||||
}))
|
||||
},
|
||||
},
|
||||
async mounted () {
|
||||
},
|
||||
destroyed () {
|
||||
if (this.controllerID !== '') {
|
||||
this.pageMqttUnSub(this.controllerID)
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<va-card class="" title="LED">
|
||||
<div class="row ma-1">
|
||||
<va-button v-for="color in colors" :key="color" :color="colorMapping[color]" @click="changeLedColor(color)">
|
||||
{{color}}
|
||||
</va-button>
|
||||
<va-button :color="'gray'" @click="testLed()">test</va-button>
|
||||
</div>
|
||||
</va-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { taskInfo } from '@/data/task/TaskInfo'
|
||||
|
||||
export default {
|
||||
name: 'Developer',
|
||||
components: {
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
colors: ['red', 'orange', 'yellow', 'green', 'blue', 'cyan', 'magenta'],
|
||||
colorMapping: {
|
||||
red: 'danger',
|
||||
orange: 'Orange',
|
||||
blue: 'primary',
|
||||
yellow: 'warning',
|
||||
green: 'success',
|
||||
cyan: 'info',
|
||||
magenta: 'violet',
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
mqttPub: function (topic, mes) {
|
||||
this.$mqtt.publish(topic, mes)
|
||||
},
|
||||
testLed: function () {
|
||||
this.changeLedColor('red')
|
||||
setTimeout(() => { this.changeLedColor('blue') }, 2000)
|
||||
setTimeout(() => { this.changeLedColor('green') }, 4000)
|
||||
},
|
||||
changeLedColor: function (color) {
|
||||
this.mqttPub(taskInfo.getTaskInfo().controllerID + '_user', JSON.stringify({
|
||||
header: 'hardware_send/0',
|
||||
command: 'led',
|
||||
state: color,
|
||||
}))
|
||||
},
|
||||
},
|
||||
async mounted () {
|
||||
await taskInfo.updateTaskInfo(this.$route.params.taskID)
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -82,9 +82,9 @@
|
||||
<va-card class="flex sm12 xl12 md12 xs12">
|
||||
<template slot="header">
|
||||
<div class="flex sm12 xl12 md12 xs12" style="text-align: end;">
|
||||
<!-- <va-button class="" color="success" v-if="selected.length" @click="downloadSelected" target="_blank" small>
|
||||
<va-button class="" color="success" v-if="selected.length" @click="downloadSelected" target="_blank" small>
|
||||
DOWNLOAD
|
||||
</va-button> -->
|
||||
</va-button>
|
||||
<va-button class="" color="danger" v-if="selected.length" @click="deleteMultiFilesConfirm" target="_blank" small>
|
||||
DELETE
|
||||
</va-button>
|
||||
@@ -673,12 +673,12 @@ export default {
|
||||
// this.$refs.datatable_ref.refresh()
|
||||
// this.$refs.datatable_ref.currentPage = 1
|
||||
},
|
||||
// downloadSelected: function () {
|
||||
// for (let i = 0; i < this.selected.length; i++) {
|
||||
// const meta = this.selected[i]
|
||||
// this.downloadCsv(meta)
|
||||
// }
|
||||
// },
|
||||
downloadSelected: function () {
|
||||
for (let i = 0; i < this.selected.length; i++) {
|
||||
const meta = this.selected[i]
|
||||
this.downloadExcel(meta)
|
||||
}
|
||||
},
|
||||
async deleteSelected () {
|
||||
for (let i = 0; i < this.selected.length; i++) {
|
||||
const meta = this.selected[i]
|
||||
|
||||
@@ -79,7 +79,6 @@ async function getAll () {
|
||||
}
|
||||
|
||||
async function getByParentName (collectionType, parent, name) {
|
||||
console.log(collectionType, parent, name)
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/collection/get_by_parent_name/${collectionType}/${parent}/${name}`, { headers: _header })
|
||||
|
||||
@@ -13,7 +13,6 @@ async function create (_data) {
|
||||
|
||||
async function getAll () {
|
||||
const _header = auth.getHeader()
|
||||
console.log(_header)
|
||||
try {
|
||||
return await api.axios.get('/api/controller/get/all', { headers: _header })
|
||||
} catch (e) {
|
||||
|
||||
@@ -13,7 +13,6 @@ async function create (_data) {
|
||||
|
||||
async function getAll () {
|
||||
const _header = auth.getHeader()
|
||||
console.log(_header)
|
||||
try {
|
||||
return await api.axios.get('/api/task/get/all', { headers: _header })
|
||||
} catch (e) {
|
||||
|
||||
@@ -148,6 +148,16 @@ export default new Router({
|
||||
path: 'project',
|
||||
component: () => import('../components/project/Project.vue'),
|
||||
},
|
||||
{
|
||||
name: 'developer',
|
||||
path: 'developer',
|
||||
component: () => import('../components/developer/Developer.vue'),
|
||||
},
|
||||
{
|
||||
name: 'debug',
|
||||
path: 'debug',
|
||||
component: () => import('../components/debug/Debug.vue'),
|
||||
},
|
||||
{
|
||||
name: 'statistics',
|
||||
path: 'statistics',
|
||||
|
||||
@@ -54,6 +54,9 @@ module.exports = {
|
||||
TIMESTAMP: JSON.stringify(timeStamp),
|
||||
COMMIT: JSON.stringify(getLastCommitHash()),
|
||||
}),
|
||||
new webpack.EnvironmentPlugin({
|
||||
VUE_APP_BUILD_VERSION: '1.0.0',
|
||||
}),
|
||||
],
|
||||
},
|
||||
css: {
|
||||
|
||||
Reference in New Issue
Block a user