Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 120553f8c0 | |||
| e50f2b5efc | |||
| c780fd7a57 | |||
| bd298b73bc | |||
| c3e2f7f6e5 | |||
| c8c1abc2a5 | |||
| dd5a8bfe27 | |||
| ac889e5410 | |||
| 9584d751fe | |||
| fd31d41bdb |
+2
-2
@@ -49,9 +49,9 @@ Vue.component('chart', ECharts)
|
||||
Vue.use(VueWorker)
|
||||
Vue.use(VueAxios, axios)
|
||||
|
||||
Vue.use(VueMqtt, 'ws://52.194.17.114:8083')
|
||||
// Vue.use(VueMqtt, 'ws://52.194.17.114:8083')
|
||||
// Vue.use(VueMqtt, 'ws://' + location.href.split('/')[2] + ':8083')
|
||||
// Vue.use(VueMqtt, 'ws://' + '192.168.0.120' + ':8083')
|
||||
Vue.use(VueMqtt, 'ws://' + '192.168.3.48' + ':8083')
|
||||
|
||||
Vue.prototype.GLOBAL = global_
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ export default {
|
||||
},
|
||||
async mounted () {
|
||||
this.initController({ api: api })
|
||||
console.log(this.getAllController())
|
||||
},
|
||||
destroyed () {
|
||||
},
|
||||
|
||||
@@ -60,6 +60,8 @@ export default {
|
||||
'currentScale',
|
||||
'axisXDataType',
|
||||
'axisYDataType',
|
||||
'startTimeCurrent',
|
||||
'endTimeCurrent',
|
||||
]),
|
||||
},
|
||||
props: {
|
||||
@@ -87,8 +89,6 @@ export default {
|
||||
showOverviewChart: false,
|
||||
dataInfo: {},
|
||||
maxTime: 0,
|
||||
startTimeCurrent: 0,
|
||||
endTimeCurrent: 0,
|
||||
startTime: 0,
|
||||
endTime: 0,
|
||||
zoomTime: 0,
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
<download-file style="display: inline;"/>
|
||||
<delete-file style="display: inline;"/>
|
||||
<br/>
|
||||
<change-axis class="box_inline-block" :ref="'change_axis_x'" deviceName="elite" axis="x" @changeAxis="changeAxis" @changeUnit="changeUnit" @clearCycle="clearCycle"/>
|
||||
<change-axis class="box_inline-block" :ref="'change_axis_x'" deviceName="elite" axis="x" @changeAxis="changeAxis" @changeUnit="changeUnit" @clearCycle="clearCycle" @resetScale="resetScale"/>
|
||||
<change-unit class="box_inline-block" :ref="'change_unit_x'" deviceName="elite" axis="x" @refreshChart="refreshChart"/>
|
||||
<change-scale class="box_inline-block" :ref="'change_scale_x'" deviceName="elite" axis="x" @refreshChart="refreshChart"/>
|
||||
<br/>
|
||||
<change-axis class="box_inline-block" :ref="'change_axis_y'" deviceName="elite" axis="y" @changeAxis="changeAxis" @changeUnit="changeUnit" @clearCycle="clearCycle"/>
|
||||
<change-axis class="box_inline-block" :ref="'change_axis_y'" deviceName="elite" axis="y" @changeAxis="changeAxis" @changeUnit="changeUnit" @clearCycle="clearCycle" @resetScale="resetScale"/>
|
||||
<change-unit class="box_inline-block" :ref="'change_unit_y'" deviceName="elite" axis="y" @refreshChart="refreshChart"/>
|
||||
<change-scale class="box_inline-block" :ref="'change_scale_y'" deviceName="elite" axis="y" @refreshChart="refreshChart"/>
|
||||
<change-cycle style="margin: 3px;" :ref="'change_cycle'" @refreshChart="refreshChart"/>
|
||||
@@ -83,6 +83,10 @@ export default {
|
||||
clearCycle () {
|
||||
this.$refs.change_cycle.clear()
|
||||
},
|
||||
resetScale () {
|
||||
this.$refs.change_scale_x.reset()
|
||||
this.$refs.change_scale_y.reset()
|
||||
},
|
||||
},
|
||||
// use watch because va-select with @change will have bug
|
||||
watch: {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<div class="row" >
|
||||
<div class="flex sm12 xl12 md12 xs12">
|
||||
<neulive-replay-overview-chart :ref="'chart_overview'" class="mb-1" :cardheight="'7vh'" :data="chartOverviewData" @dataZoomEvent="dataZoomEvent($event)"/>
|
||||
<neulive-replay-chart :ref="'chart_detail'" @dblclick.native="distribute()" :cardheight="'88vh'" :data="chartDetailData" />
|
||||
<neulive-replay-chart :ref="'chart_detail'" @dblclick.native="distribute()" :cardheight="'80vh'" :data="chartDetailData" @dataZoomEvent="updateMarkArea($event)" />
|
||||
<change-channel-value-min-max :ref="'set_min_max'"/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -56,6 +56,8 @@ export default {
|
||||
'chartOverviewData',
|
||||
'chartDetailData',
|
||||
'currentScale',
|
||||
'startTimeCurrent',
|
||||
'endTimeCurrent',
|
||||
]),
|
||||
},
|
||||
props: {
|
||||
@@ -83,12 +85,12 @@ export default {
|
||||
metaList: null,
|
||||
dataInfo: {},
|
||||
maxTime: 0,
|
||||
startTimeCurrent: 0,
|
||||
endTimeCurrent: 0,
|
||||
startTime: 0,
|
||||
endTime: 0,
|
||||
zoomTime: 0,
|
||||
chartAreaClass: ['flex', 'xs12', 'sm12', 'md12', 'xl9', 'pa-0'],
|
||||
dataZoomStart: 0,
|
||||
dataZoomEnd: 100,
|
||||
}
|
||||
},
|
||||
mqtt: {
|
||||
@@ -199,6 +201,35 @@ export default {
|
||||
chartID: 1,
|
||||
})
|
||||
},
|
||||
updateMarkArea: function (e) {
|
||||
console.log(e)
|
||||
if (e.batch != null) {
|
||||
// console.log(e.batch)
|
||||
e.batch.forEach(dataZoom => {
|
||||
const id = parseInt(dataZoom.dataZoomId.substr(dataZoom.dataZoomId.length - 3, dataZoom.dataZoomId.length - 1))
|
||||
if (id === 1) {
|
||||
this.dataZoomStart = dataZoom.start
|
||||
this.dataZoomEnd = dataZoom.end
|
||||
const startTime = (this.endTime - this.startTime) * dataZoom.start / 100
|
||||
const endTime = (this.endTime - this.startTime) * dataZoom.end / 100
|
||||
this.chartOverviewData.series[0].markArea.data[0][0].xAxis = this.startTime + startTime
|
||||
this.chartOverviewData.series[0].markArea.data[0][1].xAxis = this.startTime + endTime
|
||||
// console.log(this.startTime, this.endTime)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const id = parseInt(e.dataZoomId.substr(e.dataZoomId.length - 3, e.dataZoomId.length - 1))
|
||||
if (id === 0) {
|
||||
this.dataZoomStart = e.start
|
||||
this.dataZoomEnd = e.end
|
||||
const startTime = (this.endTime - this.startTime) * e.start / 100
|
||||
const endTime = (this.endTime - this.startTime) * e.end / 100
|
||||
this.chartOverviewData.series[0].markArea.data[0][0].xAxis = this.startTime + startTime
|
||||
this.chartOverviewData.series[0].markArea.data[0][1].xAxis = this.startTime + endTime
|
||||
// console.log(this.startTime, this.endTime)
|
||||
}
|
||||
}
|
||||
},
|
||||
dataZoomEvent: function (e) {
|
||||
// console.log(e)
|
||||
if (e.batch != null) {
|
||||
@@ -219,6 +250,8 @@ export default {
|
||||
// console.log(this.startTime, this.endTime)
|
||||
}
|
||||
}
|
||||
this.chartOverviewData.series[0].markArea.data[0][0].xAxis = this.startTime + ((this.endTime - this.startTime) * (this.dataZoomStart / 100))
|
||||
this.chartOverviewData.series[0].markArea.data[0][1].xAxis = this.startTime + ((this.endTime - this.startTime) * (this.dataZoomEnd / 100))
|
||||
this.zoomTime = 0
|
||||
},
|
||||
drawOverviewData: async function () {
|
||||
@@ -415,7 +448,7 @@ export default {
|
||||
overflow-x: hidden;
|
||||
|
||||
@include media-breakpoint-only(xl) {
|
||||
height: 88vh;
|
||||
height: 93vh;
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
@@ -115,6 +115,7 @@ export default {
|
||||
} else if (this.deviceName === 'elite') {
|
||||
this.$emit('changeAxis', this.metaIndex) // temporarily use metaIndex for gridIndex
|
||||
this.$emit('changeUnit', this.axis)
|
||||
this.$emit('resetScale')
|
||||
this.$emit('clearCycle')
|
||||
}
|
||||
},
|
||||
|
||||
@@ -35,7 +35,7 @@ export default {
|
||||
metaID: 0,
|
||||
showWhichCycles: '',
|
||||
cycleNum: 0,
|
||||
eachSliceNum: 0, // 每一等分data數量
|
||||
cycleDataID: 3, // [TODO] manage by data type factory
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -83,26 +83,50 @@ export default {
|
||||
setCycle () {
|
||||
console.log('setCycle')
|
||||
if (this.cycleNum !== 0) {
|
||||
// get cycle data
|
||||
const allCycleData = this.recInfo[this.metaID][this.cycleDataID][this.currentScale][this.metaIndex].data
|
||||
var cycleDict = {}
|
||||
var cycleStartIndex = 0
|
||||
var cycleEndIndex = 0
|
||||
var currentCycleIndex = 0
|
||||
for (let index = 0; index < allCycleData.length; index++) {
|
||||
const value = allCycleData[index]
|
||||
const cycleIndex = parseInt(value[1])
|
||||
if (cycleIndex === currentCycleIndex) {
|
||||
if (currentCycleIndex in cycleDict) {
|
||||
cycleEndIndex = index
|
||||
cycleDict[cycleIndex][1] = cycleEndIndex
|
||||
} else {
|
||||
cycleDict[cycleIndex] = [cycleStartIndex, cycleEndIndex]
|
||||
}
|
||||
} else {
|
||||
cycleStartIndex = index
|
||||
currentCycleIndex++
|
||||
}
|
||||
}
|
||||
// get recording data
|
||||
let allXData
|
||||
if (this.axisXDataType.description !== 'Time') {
|
||||
allXData = this.recInfo[this.metaID][this.axisXDataType.id][this.currentScale][this.metaIndex].data
|
||||
}
|
||||
const allYData = this.recInfo[this.metaID][this.axisYDataType.id][this.currentScale][this.metaIndex].data
|
||||
const len = allYData.length
|
||||
const eachSliceNum = parseInt(len / this.cycleNum)
|
||||
const data = []
|
||||
for (let sliceIndex = 0; sliceIndex < this.cycleNum; sliceIndex++) {
|
||||
// console.log(this.slices)
|
||||
if (this.slices === '' || this.slices.includes((sliceIndex + 1).toString())) {
|
||||
const sliceYData = allYData.slice(sliceIndex * eachSliceNum, (sliceIndex + 1) * eachSliceNum)
|
||||
// slice data
|
||||
const value = cycleDict[sliceIndex + 1]
|
||||
const start = value[0]
|
||||
const end = value[1] + 1
|
||||
const sliceYData = allYData.slice(start, end)
|
||||
const sliceLen = sliceYData.length
|
||||
if (allXData !== undefined) {
|
||||
const sliceXData = allXData.slice(sliceIndex * eachSliceNum, (sliceIndex + 1) * eachSliceNum)
|
||||
const sliceXData = allXData.slice(start, end)
|
||||
for (let j = 0; j < sliceLen; j++) {
|
||||
data.push([sliceXData[j][1], sliceYData[j][1]])
|
||||
}
|
||||
} else {
|
||||
const sliceYData = allYData.slice(sliceIndex * eachSliceNum, (sliceIndex + 1) * eachSliceNum)
|
||||
const sliceYData = allYData.slice(start, end)
|
||||
for (let j = 0; j < sliceLen; j++) {
|
||||
data.push(sliceYData[j])
|
||||
}
|
||||
@@ -112,7 +136,7 @@ export default {
|
||||
this.updateSeriesChart({
|
||||
chartID: this.chartID,
|
||||
seriesIndex: this.metaIndex,
|
||||
data: data,
|
||||
data: JSON.parse(JSON.stringify(data)),
|
||||
})
|
||||
}
|
||||
this.$emit('refreshChart', this.chartData[this.chartID])
|
||||
|
||||
@@ -21,6 +21,10 @@ export default {
|
||||
deviceName: {
|
||||
type: String, // elite or neulive
|
||||
},
|
||||
chartID: {
|
||||
type: Number, // detail data
|
||||
default: 1,
|
||||
},
|
||||
axis: {
|
||||
type: String, // x or y
|
||||
},
|
||||
@@ -34,13 +38,20 @@ export default {
|
||||
computed: {
|
||||
...mapFields('replay', [
|
||||
'chartData',
|
||||
'recInfo',
|
||||
'metaList',
|
||||
'axisXLabelScale',
|
||||
'axisYLabelScale',
|
||||
'axisXDataType',
|
||||
'axisYDataType',
|
||||
'startTimeCurrent',
|
||||
'endTimeCurrent',
|
||||
'currentScale',
|
||||
]),
|
||||
},
|
||||
methods: {
|
||||
init () {
|
||||
this.metaID = this.metaList[this.metaIndex].id
|
||||
if (this.axis === 'x') {
|
||||
this.axisXLabelScale = this.scaleOptions[0] // 0 mean use default unit
|
||||
this.scaleFormat = this.axisXLabelScale
|
||||
@@ -48,7 +59,6 @@ export default {
|
||||
this.axisYLabelScale = this.scaleOptions[0] // 0 mean use default unit
|
||||
this.scaleFormat = this.axisYLabelScale
|
||||
}
|
||||
this.changeScale()
|
||||
},
|
||||
changeScale () {
|
||||
if (this.axis === 'x') {
|
||||
@@ -56,36 +66,70 @@ export default {
|
||||
} else if (this.axis === 'y') {
|
||||
this.axisYLabelScale = this.scaleFormat
|
||||
}
|
||||
const chartID = 1 // detail data
|
||||
if (this.deviceName === 'neulive') {
|
||||
const keys = Object.keys(this.metaList[this.metaIndex].mini_data)
|
||||
for (let axisIndex = 0; axisIndex < keys.length; axisIndex++) {
|
||||
const key = keys[axisIndex]
|
||||
for (let gridIndex = 0; gridIndex < keys.length; gridIndex++) {
|
||||
const key = keys[gridIndex]
|
||||
if (parseInt(key) < 255) { // 256: x, 257: y, 258: z, 259: mag
|
||||
this.updateAxisLabelChart({
|
||||
chartID: chartID,
|
||||
axis: this.axis,
|
||||
axisIndex: axisIndex,
|
||||
})
|
||||
this.calculateScaleHelper(gridIndex)
|
||||
}
|
||||
}
|
||||
} else if (this.deviceName === 'elite') {
|
||||
this.updateAxisLabelChart({
|
||||
chartID: chartID,
|
||||
axis: this.axis,
|
||||
axisIndex: this.metaIndex,
|
||||
})
|
||||
this.calculateScaleHelper(this.metaIndex)
|
||||
}
|
||||
this.$emit('refreshChart', this.chartData[chartID])
|
||||
this.$emit('refreshChart', this.chartData[this.chartID])
|
||||
},
|
||||
// call vuex to mutate chart label formatter by unit and axis
|
||||
...mapMutations('replay', [types.chart.updateAxisLabel]),
|
||||
calculateScaleHelper (gridIndex) {
|
||||
let seriesData
|
||||
if (this.scaleFormat.description === 'Log') {
|
||||
seriesData = JSON.parse(JSON.stringify(this.chartData[this.chartID].series[gridIndex].data))
|
||||
for (let i = 0; i < seriesData.length; i++) {
|
||||
if (this.axis === 'x') {
|
||||
seriesData[i][0] = Math.log10(Math.abs(seriesData[i][0]))
|
||||
} else if (this.axis === 'y') {
|
||||
seriesData[i][1] = Math.log10(Math.abs(seriesData[i][1]))
|
||||
}
|
||||
}
|
||||
} else if (this.scaleFormat.description === 'Linear') {
|
||||
let allXData
|
||||
if (this.axisXDataType.description !== 'Time') {
|
||||
allXData = this.recInfo[this.metaID][this.axisXDataType.id][this.currentScale][gridIndex].data
|
||||
}
|
||||
const allYData = this.recInfo[this.metaID][this.axisYDataType.id][this.currentScale][gridIndex].data
|
||||
seriesData = []
|
||||
for (let i = 0, len = allYData.length; i < len; i++) {
|
||||
if (parseInt(allYData[i][0]) >= this.startTimeCurrent && parseInt(allYData[i][0]) <= this.endTimeCurrent) {
|
||||
const processedData = JSON.parse(JSON.stringify(allYData[i]))
|
||||
if (allXData !== undefined) {
|
||||
processedData[0] = allXData[i][1]
|
||||
}
|
||||
seriesData.push(processedData)
|
||||
}
|
||||
}
|
||||
}
|
||||
this.updateSeriesChart({
|
||||
chartID: this.chartID,
|
||||
seriesIndex: gridIndex,
|
||||
data: JSON.parse(JSON.stringify(seriesData)),
|
||||
})
|
||||
},
|
||||
reset () {
|
||||
if (this.axis === 'x') {
|
||||
this.axisXLabelScale = this.scaleOptions[0] // 0 mean use default unit
|
||||
this.scaleFormat = this.axisXLabelScale
|
||||
} else if (this.axis === 'y') {
|
||||
this.axisYLabelScale = this.scaleOptions[0] // 0 mean use default unit
|
||||
this.scaleFormat = this.axisYLabelScale
|
||||
}
|
||||
},
|
||||
...mapMutations('replay', [types.chart.updateSeries]),
|
||||
},
|
||||
mounted () {
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
scaleFormat: {},
|
||||
metaID: 0,
|
||||
scaleFormat: { id: 0, description: 'Linear' },
|
||||
scaleOptions: [
|
||||
{
|
||||
id: 0,
|
||||
|
||||
@@ -74,17 +74,17 @@ export default {
|
||||
for (const item of deleteInfo.rawChannelAndIDArrays) {
|
||||
const channel = item[0]
|
||||
const id = item[1]
|
||||
await api.updateRawFile(channel, id, { deleted: true })
|
||||
await api.clearDeleteRawFile(channel, id)
|
||||
await api.raw.update(channel, id, { deleted: true })
|
||||
await api.raw.clearDel(channel, id)
|
||||
}
|
||||
for (const item of deleteInfo.miniChannelAndIDArrays) {
|
||||
const channel = item[0]
|
||||
const id = item[1]
|
||||
await api.updateMiniFile(channel, id, { deleted: true })
|
||||
await api.clearDeleteMiniFile(channel, id)
|
||||
await api.mini.update(channel, id, { deleted: true })
|
||||
await api.mini.clearDel(channel, id)
|
||||
}
|
||||
await api.updateMetaFile(deleteInfo.metaID, { deleted: true })
|
||||
await api.clearDeleteMetaFile(deleteInfo.metaID)
|
||||
await api.meta.update(deleteInfo.metaID, { deleted: true })
|
||||
await api.meta.clearDel(deleteInfo.metaID)
|
||||
}
|
||||
await this.deleteFileDone()
|
||||
},
|
||||
|
||||
@@ -80,7 +80,7 @@ export default {
|
||||
// [TODO] 0: not sure future UX design
|
||||
const meta = this.metaList[0]
|
||||
file.clearFileList()
|
||||
const files = await api.getFolderMetaFileByParent('folder', meta.parent.folder[0])
|
||||
const files = await api.meta.getCollectionByParent('folder', meta.parent.folder[0])
|
||||
file.updateFileList(files)
|
||||
const tmpFiles = file.getFileList()
|
||||
for (let i = 0; i < tmpFiles.length; i++) {
|
||||
@@ -90,7 +90,7 @@ export default {
|
||||
},
|
||||
editFile: async function () {
|
||||
if (this.editInfo.success === true) {
|
||||
await api.updateMetaFile(this.editInfo.info.id, { name: this.editInfo.changedName })
|
||||
await api.meta.update(this.editInfo.info.id, { name: this.editInfo.changedName })
|
||||
this.editInfo.name = this.editInfo.changedName
|
||||
this.filename = this.editInfo.changedName
|
||||
}
|
||||
|
||||
@@ -208,16 +208,27 @@ export default {
|
||||
})
|
||||
// console.log(this.controllerList)
|
||||
},
|
||||
'+/hardware_info/+' (data, topic) {
|
||||
async '+/hardware_info/+' (data, topic) {
|
||||
const topicSplit = topic.split('/')
|
||||
const rawDevices = JSON.parse(String.fromCharCode.apply(null, data)).data
|
||||
this.controllerList.forEach(controller => {
|
||||
for (let i = 0; i < this.controllerList.length; i++) {
|
||||
const controller = this.controllerList[i]
|
||||
if (controller.id === topicSplit[0]) {
|
||||
if (rawDevices.device_mac !== null) {
|
||||
controller.mac = rawDevices.device_mac.toUpperCase()
|
||||
// const info = await api.controller.getByMac(controller.mac)
|
||||
// if (info.data.length === 0) {
|
||||
// const req = {
|
||||
// mac_address: controller.mac,
|
||||
// mqtt_id: controller.id,
|
||||
// status: controller.status,
|
||||
// }
|
||||
// api.controller.create(req)
|
||||
// }
|
||||
// console.log(info)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
// console.log(this.controllerList)
|
||||
},
|
||||
'+/hardware_device_connect/+' (data, topic) {
|
||||
@@ -471,9 +482,9 @@ export default {
|
||||
}
|
||||
},
|
||||
createInitialCollection: async function (user) {
|
||||
const root = await api.getCollectionsByParentName('folder', 0, 'root')
|
||||
const root = await api.collection.getByParentName('folder', 0, 'root')
|
||||
if (root.data.length === 0) {
|
||||
await api.createCollection({
|
||||
await api.collection.create({
|
||||
name: 'root',
|
||||
type: 'folder',
|
||||
parent: { folder: [0] },
|
||||
@@ -482,10 +493,10 @@ export default {
|
||||
}
|
||||
|
||||
// init check and create collection
|
||||
const _root = await api.getCollectionsByName('root')
|
||||
const USER = await api.getCollectionsByName(user)
|
||||
const _root = await api.collection.getByName('root')
|
||||
const USER = await api.collection.getByName(user)
|
||||
if (USER.data.length === 0) {
|
||||
api.createCollection({
|
||||
api.collection.create({
|
||||
name: user,
|
||||
parent: { folder: [_root.data[0].id] },
|
||||
type: 'folder',
|
||||
|
||||
@@ -70,15 +70,15 @@ export default {
|
||||
this.$refs.file_ref.currentPathIndex = file.getPathMaxIndex()
|
||||
file.clearFileList()
|
||||
|
||||
const initCollection = await api.getCollectionsByName('admin')
|
||||
const initCollection = await api.collection.getByName('admin')
|
||||
|
||||
if (initCollection.data !== 0) {
|
||||
file.addPath(initCollection.data[0])
|
||||
this.$refs.file_ref.currentPathIndex = file.getPathMaxIndex()
|
||||
this.$refs.file_ref.currentInfo = initCollection.data[0]
|
||||
|
||||
const folders = await api.getCollectionsByParent('folder', initCollection.data[0].id)
|
||||
const files = await api.getFolderMetaFileByParent('folder', initCollection.data[0].id)
|
||||
const folders = await api.collection.getByParent('folder', initCollection.data[0].id)
|
||||
const files = await api.meta.getCollectionByParent('folder', initCollection.data[0].id)
|
||||
file.updateFileList(folders)
|
||||
file.updateFileList(files)
|
||||
|
||||
@@ -91,7 +91,7 @@ export default {
|
||||
},
|
||||
async mounted () {
|
||||
await this.getControllerList()
|
||||
await api.getJwtData()
|
||||
await api.auth.getJwtData()
|
||||
this.pageMqttSub()
|
||||
this.pageInitPub()
|
||||
},
|
||||
|
||||
@@ -368,8 +368,8 @@ export default {
|
||||
this.currentPathIndex = file.getPathMaxIndex()
|
||||
|
||||
// call getfolder api and update
|
||||
const folders = await api.getCollectionsByParent('folder', info.id)
|
||||
const files = await api.getFolderMetaFileByParent('folder', info.id)
|
||||
const folders = await api.collection.getByParent('folder', info.id)
|
||||
const files = await api.meta.getCollectionByParent('folder', info.id)
|
||||
file.updateFileList(folders)
|
||||
file.updateFileList(files)
|
||||
|
||||
@@ -388,8 +388,8 @@ export default {
|
||||
this.currentPathIndex = file.getPathMaxIndex()
|
||||
this.currentInfo = item
|
||||
// call getfolder api and update
|
||||
const folders = await api.getCollectionsByParent('folder', item.id)
|
||||
const files = await api.getFolderMetaFileByParent('folder', item.id)
|
||||
const folders = await api.collection.getByParent('folder', item.id)
|
||||
const files = await api.meta.getCollectionByParent('folder', item.id)
|
||||
file.updateFileList(folders)
|
||||
file.updateFileList(files)
|
||||
|
||||
@@ -405,12 +405,12 @@ export default {
|
||||
this.currentPathIndex = -1
|
||||
|
||||
// call getfolder api and update
|
||||
const initCollection = await api.getCollectionsByParentName('folder', 0, 'root')
|
||||
const initCollection = await api.collection.getByParentName('folder', 0, 'root')
|
||||
|
||||
if (initCollection.data.length === 1) {
|
||||
this.currentInfo = initCollection.data[0]
|
||||
const folders = await api.getCollectionsByParent('folder', initCollection.data[0].id)
|
||||
const files = await api.getFolderMetaFileByParent('folder', initCollection.data[0].id)
|
||||
const folders = await api.collection.getByParent('folder', initCollection.data[0].id)
|
||||
const files = await api.meta.getCollectionByParent('folder', initCollection.data[0].id)
|
||||
file.updateFileList(folders)
|
||||
file.updateFileList(files)
|
||||
this.fileLists = file.getFileList()
|
||||
@@ -428,7 +428,7 @@ export default {
|
||||
this.setInputFieldError(this.createInfo.errorMessagesAll[0] + ' ' + illegalChar[0], this.createInfo)
|
||||
} else {
|
||||
// folder name existed
|
||||
const existedFolder = await api.getCollectionsByParentName(this.currentInfo.type, this.currentInfo.id, term)
|
||||
const existedFolder = await api.collection.getByParentName(this.currentInfo.type, this.currentInfo.id, term)
|
||||
if (existedFolder.data.length === 0) {
|
||||
this.setInputFieldSuccess(this.createInfo)
|
||||
} else {
|
||||
@@ -444,7 +444,7 @@ export default {
|
||||
createFolder: async function () {
|
||||
const parent = [].concat((this.pathLists.length === 0) ? this.currentInfo.id : this.pathLists[this.pathLists.length - 1].id)
|
||||
const type = 'folder'
|
||||
await api.createCollection({
|
||||
await api.collection.create({
|
||||
name: this.createInfo.changedName,
|
||||
parent: { [type]: parent },
|
||||
type: type,
|
||||
@@ -469,7 +469,7 @@ export default {
|
||||
editFile: async function () {
|
||||
// TODO editFile
|
||||
if (this.editInfo.type !== 'folder') {
|
||||
await api.updateMetaFile(this.editInfo.info.id, { name: this.editInfo.changedName })
|
||||
await api.meta.update(this.editInfo.info.id, { name: this.editInfo.changedName })
|
||||
} else {
|
||||
}
|
||||
await this.editFileDone()
|
||||
@@ -546,17 +546,17 @@ export default {
|
||||
for (const item of this.deleteInfo.rawChannelAndIDArrays) {
|
||||
const channel = item[0]
|
||||
const id = item[1]
|
||||
await api.updateRawFile(channel, id, { deleted: true })
|
||||
await api.clearDeleteRawFile(channel, id)
|
||||
await api.raw.update(channel, id, { deleted: true })
|
||||
await api.raw.clearDel(channel, id)
|
||||
}
|
||||
for (const item of this.deleteInfo.miniChannelAndIDArrays) {
|
||||
const channel = item[0]
|
||||
const id = item[1]
|
||||
await api.updateMiniFile(channel, id, { deleted: true })
|
||||
await api.clearDeleteMiniFile(channel, id)
|
||||
await api.mini.update(channel, id, { deleted: true })
|
||||
await api.mini.clearDel(channel, id)
|
||||
}
|
||||
await api.updateMetaFile(this.deleteInfo.metaID, { deleted: true })
|
||||
await api.clearDeleteMetaFile(this.deleteInfo.metaID)
|
||||
await api.meta.update(this.deleteInfo.metaID, { deleted: true })
|
||||
await api.meta.clearDel(this.deleteInfo.metaID)
|
||||
},
|
||||
deleteFileConfirm: function (info) {
|
||||
this.fillDeleteInfo(info)
|
||||
@@ -603,8 +603,8 @@ export default {
|
||||
file.clearFileList()
|
||||
|
||||
// call getfolder api and update
|
||||
const folders = await api.getCollectionsByParent('folder', this.currentInfo.id)
|
||||
const files = await api.getFolderMetaFileByParent('folder', this.currentInfo.id)
|
||||
const folders = await api.collection.getByParent('folder', this.currentInfo.id)
|
||||
const files = await api.meta.getCollectionByParent('folder', this.currentInfo.id)
|
||||
file.updateFileList(folders)
|
||||
file.updateFileList(files)
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ import { chartData } from '../../../data/task/ChartsManagement'
|
||||
import { taskInfo } from '../../../data/task/TaskInfo'
|
||||
import CanvasChart from './chart/CanvasChart'
|
||||
import TaskDevices from './controller/TaskDevices'
|
||||
// import api from '../../../data/api'
|
||||
// import TaskFormula from './formula/TaskFormula'
|
||||
|
||||
// TODO change chart data tag format
|
||||
@@ -110,9 +111,9 @@ export default {
|
||||
TaskDevices,
|
||||
// TaskFormula,
|
||||
},
|
||||
async created () {
|
||||
await taskInfo.updateTaskInfo(this.$route.params.taskID)
|
||||
},
|
||||
// async created () {
|
||||
// await taskInfo.updateTaskInfo(this.$route.params.taskID)
|
||||
// },
|
||||
data () {
|
||||
return {
|
||||
// modal
|
||||
@@ -128,6 +129,8 @@ export default {
|
||||
selectChartID: null,
|
||||
showDeviceSetting: true,
|
||||
chartAreaClass: ['flex', 'xs12', 'sm12', 'md12', 'xl8', 'pa-0'],
|
||||
|
||||
deviceList: {},
|
||||
}
|
||||
},
|
||||
mqtt: {
|
||||
@@ -149,6 +152,47 @@ export default {
|
||||
},
|
||||
async '+/hardware_device/+' (data, topic) {
|
||||
await taskInfo.deviceInfo(String.fromCharCode.apply(null, data))
|
||||
console.log(this.deviceList)
|
||||
for (const d1 in taskInfo.getTaskInfo().deviceList) {
|
||||
if (taskInfo.getTaskInfo().deviceList[d1].info.device_address.length > 0) {
|
||||
const addr1 = taskInfo.getTaskInfo().deviceList[d1].info.device_address.join()
|
||||
let parameter, content
|
||||
for (const d2 in this.deviceList) {
|
||||
const addr2 = this.deviceList[d2].info.device_address.join()
|
||||
if (addr1 === addr2) {
|
||||
console.log(this.deviceList[d2].parameterSet)
|
||||
for (const p in this.deviceList[d2].parameterSet) {
|
||||
if (p !== 'STIMULATING') {
|
||||
if (parameter == null) {
|
||||
parameter = p
|
||||
} else {
|
||||
parameter = parameter + '|' + p
|
||||
}
|
||||
let c
|
||||
if (Array.isArray(this.deviceList[d2].parameterSet[p])) {
|
||||
c = '0:' + this.deviceList[d2].parameterSet[p].length + '=' + this.deviceList[d2].parameterSet[p]
|
||||
} else {
|
||||
c = this.deviceList[d2].parameterSet[p]
|
||||
}
|
||||
|
||||
if (content == null) {
|
||||
content = c
|
||||
} else {
|
||||
content = content + '|' + c
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('****', parameter, content)
|
||||
this.mqttPub(taskInfo.getTaskInfo().controllerID + '_user', JSON.stringify({
|
||||
header: 'device_parameter/0',
|
||||
device: parseInt(d1),
|
||||
parameter: parameter,
|
||||
content: content,
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.$refs.devices_ref != null) {
|
||||
await this.$refs.devices_ref.loadingDone()
|
||||
}
|
||||
@@ -157,8 +201,9 @@ export default {
|
||||
async '+/data_server/device_data_stream/+/+' (data, topic) {
|
||||
const topicSplit = topic.split('/')
|
||||
if (!taskInfo.getDeviceInfoByRawID(parseInt(topicSplit[3])).info.isSync) {
|
||||
taskInfo.deviceStart(parseInt(topicSplit[3]))
|
||||
chartData.defaultChartGenerator(taskInfo.getDeviceIDByRaw(parseInt(topicSplit[3])), null, 'device')
|
||||
if (chartData.defaultChartGenerator(taskInfo.getDeviceIDByRaw(parseInt(topicSplit[3])), null, 'device')) {
|
||||
taskInfo.deviceStart(parseInt(topicSplit[3]))
|
||||
}
|
||||
}
|
||||
dataStreamBuffer.into(String.fromCharCode.apply(null, data), parseInt(topicSplit[3]), (parseInt(topicSplit[4]) + 1))
|
||||
},
|
||||
@@ -256,6 +301,14 @@ export default {
|
||||
if (await this.$refs.devices_ref != null) {
|
||||
await this.$refs.devices_ref.loadingStart()
|
||||
}
|
||||
// let _parameter, _content
|
||||
|
||||
// this.mqttPub(taskInfo.getTaskInfo().controllerID + '_user', JSON.stringify({
|
||||
// header: 'device_parameter/0',
|
||||
// device: 7,
|
||||
// parameter: 'RECORDING_CH|AXIS_CH',
|
||||
// content: '7|1',
|
||||
// }))
|
||||
this.mqttPub(taskInfo.getTaskInfo().controllerID + '_user', JSON.stringify({
|
||||
header: 'hardware_device/0',
|
||||
}))
|
||||
@@ -279,9 +332,13 @@ export default {
|
||||
}
|
||||
},
|
||||
refreshDevicesWindow: function () {
|
||||
// console.log(taskInfo.getTaskInfo())
|
||||
if (this.$refs.devices_ref != null) {
|
||||
this.$refs.devices_ref.refresh()
|
||||
}
|
||||
// api.task.update({
|
||||
// device_config: taskInfo.getTaskInfo().deviceList,
|
||||
// })
|
||||
},
|
||||
addChart: async function () {
|
||||
const defaultID = {}
|
||||
@@ -377,8 +434,7 @@ export default {
|
||||
this.chartAreaClass[3] = 'md12'
|
||||
this.chartAreaClass[4] = 'xl12'
|
||||
},
|
||||
addDevice: async function (deviceID) {
|
||||
this.mqttSub(taskInfo.getTaskInfo().controllerID + '/data_server/device_data_stream/' + taskInfo.getRawDeviceID(deviceID) + '/+')
|
||||
addMappingChart: async function (deviceID) {
|
||||
const chart = await this.addChart()
|
||||
await this.$nextTick(async () => {
|
||||
chartData.getAllChartsData()[chart].mappingID = deviceID
|
||||
@@ -388,9 +444,19 @@ export default {
|
||||
})
|
||||
}
|
||||
})
|
||||
return chart
|
||||
},
|
||||
addDevice: async function (deviceID) {
|
||||
this.mqttSub(taskInfo.getTaskInfo().controllerID + '/data_server/device_data_stream/' + taskInfo.getRawDeviceID(deviceID) + '/+')
|
||||
const chart = this.addMappingChart(deviceID)
|
||||
if (taskInfo.getDeviceInfo(deviceID).info.isSync) {
|
||||
chartData.defaultChartGenerator(deviceID, chart, 'device')
|
||||
}
|
||||
// console.log(chartData.getAllChartsData())
|
||||
// console.log(taskInfo.getTaskInfo())
|
||||
// await api.task.update({
|
||||
// device_config: taskInfo.getTaskInfo().deviceList,
|
||||
// })
|
||||
this.pageToast('The device [' + deviceID + '] has been registered.')
|
||||
},
|
||||
removeDevice: function (deviceID) {
|
||||
@@ -497,11 +563,11 @@ export default {
|
||||
watch: {
|
||||
},
|
||||
async mounted () {
|
||||
// await taskInfo.updateTaskInfo(this.$route.params.taskID)
|
||||
this.deviceList = await taskInfo.updateTaskInfo(this.$route.params.taskID)
|
||||
console.log(taskInfo.getTaskInfo())
|
||||
// this.screenHeight = document.documentElement.clientHeight
|
||||
|
||||
this.pageMqttSub(taskInfo.getTaskInfo().controllerID)
|
||||
console.log(taskInfo.getTaskInfo().controllerID)
|
||||
await this.pageInit()
|
||||
|
||||
// this.chartNumber = taskInfo.getTaskInfo().chartNumber
|
||||
|
||||
@@ -30,44 +30,62 @@
|
||||
<div v-else :style="'width: '+ cardwidth + '; height: ' + cardheight + ';'" >
|
||||
<canvas-chart-setting></canvas-chart-setting>
|
||||
</div>
|
||||
<div class="flex row xs12 md12 xl12 sm12" style="text-align: center;" >
|
||||
<div>
|
||||
<va-select
|
||||
class="xs4 md4 xl4 sm4"
|
||||
<div class="flex row">
|
||||
<div class="flex row xs12 md12 xl12 sm12" style="text-align: center;" >
|
||||
<!-- <va-select
|
||||
class="ma-1"
|
||||
:on-change="mappingSelectChange()"
|
||||
small
|
||||
:label="'MAPPING'"
|
||||
v-model="mappingSelect"
|
||||
textBy="name"
|
||||
:options="mappingOptions"
|
||||
/>
|
||||
</div>
|
||||
<div class="mx-1">
|
||||
/> -->
|
||||
<va-input
|
||||
@keyup.enter="xIntervalChange(xIntervalInput)"
|
||||
@blur="xIntervalChange(xIntervalInput)"
|
||||
v-model="xIntervalInput"
|
||||
:label="'x-interval'"
|
||||
v-if="data.chartXMode === 'time'"
|
||||
class="ma-1"
|
||||
@keyup.enter="timeIntervalChange(timeIntervalInput)"
|
||||
@blur="timeIntervalChange(timeIntervalInput)"
|
||||
v-model="timeIntervalInput"
|
||||
:label="'time-interval'"
|
||||
>
|
||||
<p slot="append" style="margin-right: 0;" small>
|
||||
ms
|
||||
</p>
|
||||
</va-input>
|
||||
</div>
|
||||
<div class="mx-1">
|
||||
<va-input
|
||||
v-if="data.chartXMode === 'value'"
|
||||
class="ma-1"
|
||||
@keyup.enter="xIntervalChange(xIntervalInput)"
|
||||
@blur="xIntervalChange(xIntervalInput)"
|
||||
v-model="xIntervalInput"
|
||||
:label="'x-interval'"
|
||||
>
|
||||
</va-input>
|
||||
<va-input
|
||||
class="ma-1"
|
||||
@keyup.enter="yIntervalChange(yIntervalInput)"
|
||||
@blur="yIntervalChange(yIntervalInput)"
|
||||
v-model="yIntervalInput"
|
||||
:label="'y-interval'"
|
||||
>
|
||||
</va-input>
|
||||
</div>
|
||||
<div>
|
||||
<va-input
|
||||
v-if="data.chartDevice === 'neulive'"
|
||||
class="ma-1"
|
||||
@keyup.enter="threeAxisIntervalChange(threeAxisIntervalInput)"
|
||||
@blur="threeAxisIntervalChange(threeAxisIntervalInput)"
|
||||
v-model="threeAxisIntervalInput"
|
||||
:label="'3axis-interval'"
|
||||
>
|
||||
</va-input>
|
||||
<va-button class="no-dark-style-va-button" small @click="init()">INIT</va-button>
|
||||
<va-button small color="dark" @click="remove()">REMOVE</va-button>
|
||||
</div>
|
||||
|
||||
<!-- <div class="xs2 md2 xl2 sm2" style="text-align: center;" >
|
||||
<va-button class="no-dark-style-va-button" small @click="init()">INIT</va-button>
|
||||
<va-button small color="dark" @click="remove()">REMOVE</va-button>
|
||||
</div> -->
|
||||
</div>
|
||||
</va-card>
|
||||
</div>
|
||||
@@ -119,8 +137,10 @@ export default {
|
||||
mappingOptions: taskInfo.getMappingList(),
|
||||
nameCard: chartData.getAllChartsData()[this.chartID].cardName,
|
||||
initDone: false,
|
||||
xIntervalInput: 500,
|
||||
yIntervalInput: 1000,
|
||||
timeIntervalInput: '',
|
||||
threeAxisIntervalInput: '',
|
||||
xIntervalInput: '',
|
||||
yIntervalInput: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -128,19 +148,32 @@ export default {
|
||||
watch: {
|
||||
},
|
||||
methods: {
|
||||
timeIntervalChange: function (val) {
|
||||
chartData.getAllChartsData()[this.chartID].xAxis.forEach(x => {
|
||||
if (x.type === 'time') {
|
||||
x.interval = val * 1000
|
||||
}
|
||||
})
|
||||
},
|
||||
xIntervalChange: function (val) {
|
||||
chartData.getAllChartsData()[this.chartID].xAxis.forEach(x => {
|
||||
x.interval = val * 1000
|
||||
if (val < 500) {
|
||||
x.axisLabel.show = false
|
||||
} else {
|
||||
x.axisLabel.show = true
|
||||
if (x.type === 'value') {
|
||||
x.interval = val * 1
|
||||
}
|
||||
})
|
||||
},
|
||||
yIntervalChange: function (val) {
|
||||
chartData.getAllChartsData()[this.chartID].yAxis.forEach(y => {
|
||||
y.interval = val * 1
|
||||
if (parseInt(y.channel) <= 255) {
|
||||
y.interval = val * 1
|
||||
}
|
||||
})
|
||||
},
|
||||
threeAxisIntervalChange: function (val) {
|
||||
chartData.getAllChartsData()[this.chartID].yAxis.forEach(y => {
|
||||
if (parseInt(y.channel) >= 255) {
|
||||
y.interval = val * 1
|
||||
}
|
||||
})
|
||||
},
|
||||
init: function () {
|
||||
|
||||
@@ -56,6 +56,7 @@ import TaskDeviceList from './TaskDeviceList'
|
||||
import { taskInfo } from '../../../../data/task/TaskInfo'
|
||||
import { chartData } from '../../../../data/task/ChartsManagement'
|
||||
import { dataStreamBuffer } from '../../../../data/task/DataStreamBuffer'
|
||||
import api from '@/data/api'
|
||||
|
||||
export default {
|
||||
name: 'TaskDevices',
|
||||
@@ -97,14 +98,26 @@ export default {
|
||||
},
|
||||
loadingDone: async function () {
|
||||
this.state.LOADING = false
|
||||
// const ret = await api.task.getAll()
|
||||
// if (ret.data.length > 0) {
|
||||
// for (const device in ret.data[0].device_config) {
|
||||
// if (ret.data[0].device_config[device].device_address) {
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
this.clearDevice()
|
||||
console.log(this.deviceOptions)
|
||||
for (let i = this.deviceOptions.length - 1; i >= 0; i--) {
|
||||
this.deviceSelect = this.deviceOptions[i]
|
||||
await this.addDevice(this.deviceOptions[i].id)
|
||||
// this.sleep(500).then(() => {
|
||||
// this.addDevice(this.deviceOptions[i].id)
|
||||
// })
|
||||
for (let i = 4; i <= 7; i++) {
|
||||
await this.addDevice(i)
|
||||
}
|
||||
// for (let i = this.deviceOptions.length - 1; i >= 0; i--) {
|
||||
// this.deviceSelect = this.deviceOptions[i]
|
||||
// await this.addDevice(this.deviceOptions[i].id)
|
||||
// // this.sleep(500).then(() => {
|
||||
// // this.addDevice(this.deviceOptions[i].id)
|
||||
// // })
|
||||
// }
|
||||
},
|
||||
startDevice: async function (device) {
|
||||
await chartData.defaultChartGenerator(device.id, null, 'device')
|
||||
@@ -126,6 +139,8 @@ export default {
|
||||
parameter: 'STIMULATING',
|
||||
content: 1,
|
||||
}))
|
||||
taskInfo.getTaskInfo().deviceList[(taskInfo.getRawDeviceID(device.id)).toString()].parameterSet.STIMULATING = 1
|
||||
|
||||
device.isStimulate = true
|
||||
} else if (taskInfo.getDeviceInfo(device.id).info.library_name.startsWith('Elite')) {
|
||||
this.mqttPub(taskInfo.getTaskInfo().controllerID + '_user', JSON.stringify({
|
||||
@@ -138,6 +153,9 @@ export default {
|
||||
device.isSync = true
|
||||
this.$emit('refreshSetting')
|
||||
// ### show device info
|
||||
api.task.update({
|
||||
device_config: taskInfo.getTaskInfo().deviceList,
|
||||
})
|
||||
console.log(taskInfo.getDeviceInfo(device.id))
|
||||
}
|
||||
},
|
||||
@@ -198,6 +216,9 @@ export default {
|
||||
device.isSync = true
|
||||
device.stopping = false
|
||||
this.$emit('refreshSetting')
|
||||
api.task.update({
|
||||
device_config: taskInfo.getTaskInfo().deviceList,
|
||||
})
|
||||
|
||||
// ### show device info
|
||||
console.log(taskInfo.getDeviceInfo(device.id))
|
||||
@@ -227,6 +248,11 @@ export default {
|
||||
parameter: 'STIMULATING',
|
||||
content: 1,
|
||||
}))
|
||||
taskInfo.getTaskInfo().deviceList[(taskInfo.getRawDeviceID(device.id)).toString()].parameterSet.STIMULATING = 1
|
||||
|
||||
api.task.update({
|
||||
device_config: taskInfo.getTaskInfo().deviceList,
|
||||
})
|
||||
device.isStimulate = true
|
||||
},
|
||||
stiStop: function (device) {
|
||||
@@ -285,7 +311,10 @@ export default {
|
||||
if (selectID == null) {
|
||||
return false
|
||||
}
|
||||
|
||||
const addr = taskInfo.getDeviceInfoByRawID(selectID).info.device_address
|
||||
if (addr.length === 0) {
|
||||
return false
|
||||
}
|
||||
await taskInfo.getTaskInfo().deviceAddrList.push(taskInfo.getDeviceInfoByRawID(selectID).info.device_address)
|
||||
await taskInfo.getTaskInfo().taskDeviceID.push(selectID)
|
||||
const _address = this.GLOBAL.transMac(taskInfo.getDeviceInfoByRawID(selectID).info.device_address)
|
||||
@@ -330,6 +359,12 @@ export default {
|
||||
taskInfo.updateAllList()
|
||||
this.$emit('remove', device.id)
|
||||
},
|
||||
clearDevice: async function () {
|
||||
taskInfo.getTaskInfo().deviceAddrList.length = 0
|
||||
taskInfo.getTaskInfo().taskDeviceID.length = 0
|
||||
this.deviceList.length = 0
|
||||
taskInfo.updateAllList()
|
||||
},
|
||||
generateChart: function (device) {
|
||||
this.$emit('add', device.id)
|
||||
},
|
||||
|
||||
@@ -76,14 +76,14 @@ export default {
|
||||
fileNameChange: async function (name) {
|
||||
if (this.enableSetting) {
|
||||
if (this.deviceInfo.info.isSync === false) {
|
||||
let fileNameCount = await api.getMetaFilesByName(name)
|
||||
let fileNameCount = await api.meta.getByName(name)
|
||||
if (fileNameCount.data != null) {
|
||||
let duplicateCount = 1
|
||||
let fileName = name
|
||||
while (fileNameCount.data.length !== 0) {
|
||||
const res = name.split('(')[0]
|
||||
fileName = `${res}(${duplicateCount})`
|
||||
fileNameCount = await api.getMetaFilesByName(fileName)
|
||||
fileNameCount = await api.meta.getByName(fileName)
|
||||
duplicateCount += 1
|
||||
}
|
||||
this.fileNameInput = fileName
|
||||
@@ -143,7 +143,7 @@ export default {
|
||||
this.fileNameChange(this.fileNameInput)
|
||||
|
||||
// directory init
|
||||
const collection = await api.getCollectionsAll()
|
||||
const collection = await api.collection.getAll()
|
||||
this.directoryOptions = collection.data.filter(el => el.name !== 'root')
|
||||
|
||||
if (Object.keys(this.deviceInfo.info.parent).length === 0) {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import api from './index'
|
||||
|
||||
const _header = {}
|
||||
|
||||
function setHeader (header) {
|
||||
_header.Authorization = 'Bearer ' + header
|
||||
}
|
||||
|
||||
function getHeader () {
|
||||
if (Object.keys(_header).length === 0) {
|
||||
getJwtData()
|
||||
}
|
||||
return _header
|
||||
}
|
||||
|
||||
async function getJwtData () {
|
||||
const _jwt = await api.axios.get('/public/auth/get_cookie')
|
||||
|
||||
setHeader(_jwt.data)
|
||||
}
|
||||
|
||||
const auth = {
|
||||
getHeader,
|
||||
getJwtData,
|
||||
}
|
||||
|
||||
export default auth
|
||||
@@ -0,0 +1,81 @@
|
||||
import api from './index'
|
||||
import auth from './auth'
|
||||
|
||||
async function create (attrs) {
|
||||
const _header = auth.getHeader()
|
||||
const _data = {
|
||||
name: attrs.name,
|
||||
parent: attrs.parent,
|
||||
type: attrs.type,
|
||||
size: attrs.size,
|
||||
}
|
||||
|
||||
try {
|
||||
return await api.axios.post('/api/collection/create', _data, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByID (id) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/collection/get_by_id/${id}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByName (name) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/collection/get_by_name/${name}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByParent (type, parent) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/collection/get_by_parent/${type}/${parent}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getAll () {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get('/api/collection/get/all', { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByParentName (collectionType, parent, name) {
|
||||
console.log(collectionType, parent, name)
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/collection/get_by_parent_name/${collectionType}/${parent}/${name}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const collection = {
|
||||
create,
|
||||
getByID,
|
||||
getByName,
|
||||
getByParent,
|
||||
getByParentName,
|
||||
getAll,
|
||||
}
|
||||
|
||||
export default collection
|
||||
@@ -0,0 +1,52 @@
|
||||
import api from './index'
|
||||
import auth from './auth'
|
||||
|
||||
async function create (_data) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.post('/api/controller/create/', _data, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getAll () {
|
||||
const _header = auth.getHeader()
|
||||
console.log(_header)
|
||||
try {
|
||||
return await api.axios.get('/api/controller/get/all', { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByMac (mac) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/controller/get_by_mac/${mac}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function update (attrs) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.post('/api/controller/update', attrs, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const controller = {
|
||||
create,
|
||||
getAll,
|
||||
getByMac,
|
||||
update,
|
||||
}
|
||||
|
||||
export default controller
|
||||
@@ -0,0 +1,73 @@
|
||||
import api from './index'
|
||||
import auth from './auth'
|
||||
|
||||
async function create (attrs) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.post('/api/device/create', attrs, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function updateByID (id, attrs) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.post(`/api/device/update_by_id/${id}`, attrs, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function del (id) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/device/clear_deleted/${id}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByID (id) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/device/get_by_id/${id}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByName (name) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/device/get_by_name/${name}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getAll () {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get('/api/device/get/all', { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const device = {
|
||||
create,
|
||||
updateByID,
|
||||
del,
|
||||
getByID,
|
||||
getByName,
|
||||
getAll,
|
||||
}
|
||||
|
||||
export default device
|
||||
+17
-399
@@ -1,408 +1,26 @@
|
||||
import axios from 'axios'
|
||||
import auth from './auth'
|
||||
import collection from './collection'
|
||||
import controller from './controller'
|
||||
import task from './task'
|
||||
import device from './device'
|
||||
import meta from './meta'
|
||||
import raw from './raw'
|
||||
import mini from './mini'
|
||||
|
||||
// axios.defaults.baseURL = 'http://192.168.3.53:3000'
|
||||
axios.defaults.baseURL = 'http://' + location.href.split('/')[2].split(':')[0] + ':3000'
|
||||
|
||||
const _header = {}
|
||||
|
||||
function setHeader (header) {
|
||||
_header.Authorization = 'Bearer ' + header
|
||||
}
|
||||
|
||||
function getHeader () {
|
||||
return _header
|
||||
}
|
||||
|
||||
async function getJwtData () {
|
||||
const _jwt = await axios.get('/public/auth/get_cookie')
|
||||
|
||||
setHeader(_jwt.data)
|
||||
}
|
||||
|
||||
async function createCollection (attrs) {
|
||||
const _header = getHeader()
|
||||
const _data = {
|
||||
name: attrs.name,
|
||||
parent: attrs.parent,
|
||||
type: attrs.type,
|
||||
size: attrs.size,
|
||||
}
|
||||
|
||||
try {
|
||||
return await axios.post('/api/collection/create', _data, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getCollectionsByID (id) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/collection/get_by_id/' + id, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getCollectionsByName (name) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/collection/get_by_name/' + name, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getCollectionsByParent (type, parent) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/collection/get_by_parent/' + type + '/' + parent, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getCollectionsAll () {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/collection/get/all', { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getControllersAll () {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/controller/get/all', { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getCollectionsByParentName (collectionType, parent, name) {
|
||||
console.log(collectionType, parent, name)
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/collection/get_by_parent_name/' + collectionType + '/' + parent + '/' + name, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function createDevice (attrs) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.post('/api/device/create', attrs, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function updateDeviceByID (id, attrs) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.post(`/api/device/update_by_id/${id}`, attrs, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteDevice (id) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get(`/api/device/clear_deleted/${id}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getDeviceByID (id) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/device/get_by_id/' + id, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getDeviceByName (name) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/device/get_by_name/' + name, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getDevicesAll () {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/device/get/all', { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function createMetaFile () {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.post('/api/file/meta/create', { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function updateMetaFile (id, attrs) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.post(`/api/file/meta/update/${id}`, attrs, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function updateRawFile (channel, id, attrs) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.post(`/api/file/raw/update/${channel}/${id}`, attrs, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function updateMiniFile (channel, id, attrs) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.post(`/api/file/mini/update/${channel}/${id}`, attrs, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
async function clearDeleteMetaFile (id) {
|
||||
console.log('clearDeleteMetaFile')
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get(`/api/file/meta/clear_deleted/${id}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function clearDeleteRawFile (channel, id) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get(`/api/file/raw/clear_deleted/${channel}/${id}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function clearDeleteMiniFile (channel, id) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get(`/api/file/mini/clear_deleted/${channel}/${id}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getFolderMetaFileByParent (type, parent) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/meta/get_by_parent/' + type + '/' + parent, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getRawFilesByID (channel, id) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/raw/get_by_id/' + channel + '/' + id, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getRawFilesByIDs (channel, id) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/raw/get_by_ids/' + channel + '/' + id, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getRawFilesAttrByIDs (channel, id, attr) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/raw/get_attr_by_ids/' + channel + '/' + id + '/' + attr, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getMetaFilesByID (id) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/meta/get_by_id/' + id, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getMetaFilesByName (name) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/meta/get_by_name/' + name, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getRawFilesByParent (channel, parent) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/raw/get_by_parent/' + channel + '/' + parent, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getRawFilesAttrByParent (channel, parent, attr) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/raw/get_attr_by_parent/' + channel + '/' + parent + '/' + attr, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getMiniFilesByID (channel, id) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/mini/get_by_id/' + channel + '/' + id, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getMiniFilesByParent (channel, parent) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/mini/get_by_parent/' + channel + '/' + parent, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getMiniFilesAttrByParent (channel, parent, attr) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/mini/get_attr_by_parent/' + channel + '/' + parent + '/' + attr, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getMiniFilesAttrByID (channel, id, attr) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/mini/get_attr_by_id/' + channel + '/' + id + '/' + attr, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getMiniFilesMeanDataByID (channel, id) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/mini/mean/get_by_id/' + channel + '/' + id, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getMiniFilesRandomDataByID (channel, id) {
|
||||
const _header = getHeader()
|
||||
try {
|
||||
return await axios.get('/api/file/mini/random/get_by_id/' + channel + '/' + id, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const api = {
|
||||
getJwtData,
|
||||
createCollection,
|
||||
getCollectionsByID,
|
||||
getCollectionsByName,
|
||||
getCollectionsByParent,
|
||||
getCollectionsByParentName,
|
||||
getCollectionsAll,
|
||||
getControllersAll,
|
||||
createDevice,
|
||||
updateDeviceByID,
|
||||
deleteDevice,
|
||||
getDeviceByID,
|
||||
getDeviceByName,
|
||||
getDevicesAll,
|
||||
createMetaFile,
|
||||
updateMetaFile,
|
||||
updateRawFile,
|
||||
updateMiniFile,
|
||||
clearDeleteMetaFile,
|
||||
clearDeleteRawFile,
|
||||
clearDeleteMiniFile,
|
||||
getFolderMetaFileByParent,
|
||||
getRawFilesByParent,
|
||||
getRawFilesByID,
|
||||
getRawFilesByIDs,
|
||||
getRawFilesAttrByIDs,
|
||||
getMiniFilesByID,
|
||||
getMiniFilesByParent,
|
||||
getMiniFilesMeanDataByID,
|
||||
getMiniFilesRandomDataByID,
|
||||
getMetaFilesByID,
|
||||
getMetaFilesByName,
|
||||
getRawFilesAttrByParent,
|
||||
getMiniFilesAttrByID,
|
||||
getMiniFilesAttrByParent,
|
||||
axios,
|
||||
auth,
|
||||
collection,
|
||||
controller,
|
||||
task,
|
||||
device,
|
||||
meta,
|
||||
raw,
|
||||
mini,
|
||||
}
|
||||
|
||||
export default api
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import api from './index'
|
||||
import auth from './auth'
|
||||
|
||||
async function create () {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.post('/api/file/meta/create', { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function update (id, attrs) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.post(`/api/file/meta/update/${id}`, attrs, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function clearDel (id) {
|
||||
console.log('clearDelete')
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/meta/clear_deleted/${id}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getCollectionByParent (type, parent) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/meta/get_by_parent/${type}/${parent}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByID (id) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/meta/get_by_id/${id}`, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByName (name) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get('/api/file/meta/get_by_name/' + name, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const meta = {
|
||||
create,
|
||||
update,
|
||||
clearDel,
|
||||
getCollectionByParent,
|
||||
getByID,
|
||||
getByName,
|
||||
}
|
||||
|
||||
export default meta
|
||||
@@ -0,0 +1,95 @@
|
||||
import api from './index'
|
||||
import auth from './auth'
|
||||
|
||||
async function update (channel, id, attrs) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.post(`/api/file/mini/update/${channel}/${id}`, attrs, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function clearDel (channel, id) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/mini/clear_deleted/${channel}/${id}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByID (channel, id) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/mini/get_by_id/${channel}/${id}`, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByParent (channel, parent) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/mini/get_by_parent/${channel}/${parent}`, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getAttrByParent (channel, parent, attr) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/mini/get_attr_by_parent/${channel}/${parent}/${attr}`, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getAttrByID (channel, id, attr) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/mini/get_attr_by_id/${channel}/${id}/${attr}`, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getMeanDataByID (channel, id) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/mini/mean/get_by_id/${channel}/${id}`, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getRandomDataByID (channel, id) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/mini/random/get_by_id/${channel}/${id}`, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const mini = {
|
||||
update,
|
||||
clearDel,
|
||||
getByID,
|
||||
getByParent,
|
||||
getAttrByParent,
|
||||
getAttrByID,
|
||||
getMeanDataByID,
|
||||
getRandomDataByID,
|
||||
}
|
||||
|
||||
export default mini
|
||||
@@ -0,0 +1,84 @@
|
||||
import api from './index'
|
||||
import auth from './auth'
|
||||
|
||||
async function update (channel, id, attrs) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.post(`/api/file/raw/update/${channel}/${id}`, attrs, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function clearDel (channel, id) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/raw/clear_deleted/${channel}/${id}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByID (channel, id) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/raw/get_by_id/${channel}/${id}`, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByIDs (channel, ids) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/raw/get_by_ids/${channel}/${ids}`, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getAttrByIDs (channel, ids, attr) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/raw/get_attr_by_ids/${channel}/${ids}/${attr}`, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByParent (channel, parent) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/raw/get_by_parent/${channel}/${parent}`, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getAttrByParent (channel, parent, attr) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/file/raw/get_attr_by_parent/${channel}/${parent}/${attr}`, { responseType: 'json', headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const raw = {
|
||||
update,
|
||||
clearDel,
|
||||
getByID,
|
||||
getByIDs,
|
||||
getAttrByIDs,
|
||||
getByParent,
|
||||
getAttrByParent,
|
||||
}
|
||||
|
||||
export default raw
|
||||
@@ -0,0 +1,52 @@
|
||||
import api from './index'
|
||||
import auth from './auth'
|
||||
|
||||
async function create (_data) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.post('/api/task/create/', _data, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getAll () {
|
||||
const _header = auth.getHeader()
|
||||
console.log(_header)
|
||||
try {
|
||||
return await api.axios.get('/api/task/get/all', { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function getByID (id) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.get(`/api/task/get_by_id/${id}`, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function update (attrs) {
|
||||
const _header = auth.getHeader()
|
||||
try {
|
||||
return await api.axios.post('/api/task/update', attrs, { headers: _header })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const task = {
|
||||
create,
|
||||
getAll,
|
||||
getByID,
|
||||
update,
|
||||
}
|
||||
|
||||
export default task
|
||||
@@ -48,10 +48,10 @@ export const download = {
|
||||
|
||||
while (rawDataIDList.length >= 1000) {
|
||||
const _rawDataIDList = rawDataIDList.splice(0, 1000)
|
||||
const _data = await api.getRawFilesAttrByIDs(channelID, _rawDataIDList, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
const _data = await api.raw.getAttrByIDs(channelID, _rawDataIDList, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
prevLastTime = await this.parseRawData(_data.data, prevLastTime, meta, result[channelID])
|
||||
}
|
||||
const _data = await api.getRawFilesAttrByIDs(channelID, rawDataIDList, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
const _data = await api.raw.getAttrByIDs(channelID, rawDataIDList, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
prevLastTime = await this.parseRawData(_data.data, prevLastTime, meta, result[channelID])
|
||||
}
|
||||
return result
|
||||
@@ -62,22 +62,22 @@ export const download = {
|
||||
result[channelID] = []
|
||||
|
||||
const prevLastTime = 0
|
||||
const _data = await api.getRawFilesAttrByIDs(channelID, list, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
const _data = await api.raw.getAttrByIDs(channelID, list, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
await this.parseRawData(_data.data, prevLastTime, meta, result[channelID])
|
||||
return result
|
||||
},
|
||||
rawByIDChannels: async function (id, channel, meta) {
|
||||
const data = []
|
||||
const rawData = await api.getRawFilesByID(channel, id)
|
||||
const rawData = await api.raw.getByID(channel, id)
|
||||
await this.parseRawData(rawData.data, null, meta, data)
|
||||
return data
|
||||
},
|
||||
miniMeanByIDChannel: async function (id, channel, meta) {
|
||||
const miniData = await api.getMiniFilesByID(channel, id)
|
||||
const miniData = await api.mini.getByID(channel, id)
|
||||
return await this.parseMiniData(miniData, 'data_mean', meta)
|
||||
},
|
||||
miniRandomByIDChannel: async function (id, channel, meta) {
|
||||
const rawData = await api.getMiniFilesByID(channel, id)
|
||||
const rawData = await api.mini.getByID(channel, id)
|
||||
return await this.parseMiniData(rawData, 'data_random', meta)
|
||||
},
|
||||
parseRawData: async function (rawData, prevLastTime, meta, dataArray) {
|
||||
|
||||
@@ -23,9 +23,10 @@ function getIndexArrayForBalenceSampleRate (indexArray, dis, l) {
|
||||
}
|
||||
|
||||
// generate x axis format
|
||||
function makeXAxis (gridIndex, type) {
|
||||
function makeXAxis (gridIndex, type, channel) {
|
||||
return {
|
||||
type: type,
|
||||
name: '',
|
||||
gridIndex: gridIndex,
|
||||
axisLine: { onZero: false, lineStyle: { color: '#aaa' } },
|
||||
axisTick: { show: false },
|
||||
@@ -44,17 +45,24 @@ function makeXAxis (gridIndex, type) {
|
||||
// lineStyle: { color: '#eee' },
|
||||
// },
|
||||
// splitNumber: 20,
|
||||
interval: 500000,
|
||||
interval: 'auto',
|
||||
scale: true,
|
||||
min: 'dataMin',
|
||||
max: 'dataMax',
|
||||
channel: channel,
|
||||
}
|
||||
}
|
||||
|
||||
// generate y axis format
|
||||
function makeYAxis (gridIndex, type) {
|
||||
function makeYAxis (gridIndex, type, channel) {
|
||||
return {
|
||||
type: type,
|
||||
// name: 'none',
|
||||
// nameLocation: 'center',
|
||||
// nameTextStyle: {
|
||||
// // align: 'left',
|
||||
// // verticalAlign: 'bottom',
|
||||
// },
|
||||
gridIndex: gridIndex,
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false }, // color: '#ccc' } },
|
||||
@@ -76,7 +84,8 @@ function makeYAxis (gridIndex, type) {
|
||||
max: 'dataMax',
|
||||
// splitNumber: 3,
|
||||
// minInterval: 1,
|
||||
interval: 100,
|
||||
interval: 'auto',
|
||||
channel: channel,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -681,6 +690,7 @@ export const chartData = {
|
||||
const yType = setting[2]
|
||||
const yValue = setting[3]
|
||||
chartRegister(chartID, 0, xType, device.id, xValue, yType, device.id, yValue, null)
|
||||
_chartData[chartID].chartDevice = 'elite'
|
||||
} else if (taskInfo.getDeviceInfo(device.id).info.library_name.indexOf('Neulive') >= 0) {
|
||||
const channelSet = taskInfo.getDeviceInfo(device.id).parameterSet.RECORDING_CH.toString(2).split('').reverse()
|
||||
const axisChannelSet = taskInfo.getDeviceInfo(device.id).parameterSet.AXIS_CH.toString(2).split('').reverse()
|
||||
@@ -720,6 +730,10 @@ export const chartData = {
|
||||
}
|
||||
}
|
||||
})
|
||||
for (let i = 0; i < _chartData[chartID].series.length - 1; i++) {
|
||||
_chartData[chartID].xAxis[_chartData[chartID].series[i].xAxisIndex].axisLabel.show = false
|
||||
}
|
||||
_chartData[chartID].chartDevice = 'neulive'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -746,8 +760,10 @@ export const chartData = {
|
||||
}
|
||||
} else {
|
||||
// update all
|
||||
let isSetting = false
|
||||
for (const chartID in _chartData) {
|
||||
if (parseInt(_chartData[chartID].mappingID) === parseInt(item.id)) {
|
||||
isSetting = true
|
||||
console.log(_chartData[chartID])
|
||||
chartData.reset(chartID, _chartData[chartID].mappingID, _chartData[chartID].cardName)
|
||||
console.log(_chartData[chartID])
|
||||
@@ -762,7 +778,11 @@ export const chartData = {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isSetting === false) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
},
|
||||
|
||||
// get chart data by chart ID
|
||||
@@ -864,14 +884,17 @@ const chartRegister = (chartID, gridIndex, deviceNameX, deviceIDX, channelX, dev
|
||||
}
|
||||
// create new axis
|
||||
if (_xAxisIndex === -1) {
|
||||
_chartData[chartID].xAxis.push(makeXAxis(gridIndex, xAxisType))
|
||||
_chartData[chartID].xAxis.push(makeXAxis(gridIndex, xAxisType, channelX))
|
||||
_xAxisIndex = _chartData[chartID].xAxis.length - 1
|
||||
}
|
||||
if (_yAxisIndex === -1) {
|
||||
_chartData[chartID].yAxis.push(makeYAxis(gridIndex, yAxisType))
|
||||
_chartData[chartID].yAxis.push(makeYAxis(gridIndex, yAxisType, channelY))
|
||||
_yAxisIndex = _chartData[chartID].yAxis.length - 1
|
||||
}
|
||||
|
||||
_chartData[chartID].chartXMode = _chartData[chartID].xAxis[_xAxisIndex].type
|
||||
_chartData[chartID].chartYMode = _chartData[chartID].yAxis[_yAxisIndex].type
|
||||
|
||||
// update dataZoom AxisIndex list
|
||||
const dataZoomXAxisIndex = Array.apply(null, { length: _chartData[chartID].xAxis.length }).map(Number.call, Number)
|
||||
const dataZoomYAxisIndex = Array.apply(null, { length: _chartData[chartID].yAxis.length }).map(Number.call, Number)
|
||||
@@ -910,6 +933,26 @@ const chartRegister = (chartID, gridIndex, deviceNameX, deviceIDX, channelX, dev
|
||||
// const label = parseInt(parseInt(val / 1000000) / 60) + ' m ' + parseInt((val % 60000000) / 1000000) + ' s'
|
||||
return label
|
||||
}
|
||||
} else if (sourceList[0].name === 'Elite') {
|
||||
switch (sourceList[0].channel) {
|
||||
case 1:
|
||||
_chartData[chartID].xAxis[_xAxisIndex].axisLabel.formatter = function (val) {
|
||||
return val + 'nA'
|
||||
}
|
||||
break
|
||||
case 2:
|
||||
_chartData[chartID].xAxis[_xAxisIndex].axisLabel.formatter = function (val) {
|
||||
return val + 'uV'
|
||||
}
|
||||
break
|
||||
case 3:
|
||||
_chartData[chartID].xAxis[_xAxisIndex].axisLabel.formatter = function (val) {
|
||||
return val + 'mΩ'
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// set yAxis format
|
||||
@@ -937,6 +980,29 @@ const chartRegister = (chartID, gridIndex, deviceNameX, deviceIDX, channelX, dev
|
||||
_chartData[chartID].yAxis[_yAxisIndex].min = -scaleRange
|
||||
_chartData[chartID].yAxis[_yAxisIndex].max = scaleRange
|
||||
}
|
||||
_chartData[chartID].yAxis[_yAxisIndex].axisLabel.formatter = function (val) {
|
||||
return val + 'uV'
|
||||
}
|
||||
} else if (sourceList[1].name === 'Elite') {
|
||||
switch (sourceList[1].channel) {
|
||||
case 1:
|
||||
_chartData[chartID].yAxis[_yAxisIndex].axisLabel.formatter = function (val) {
|
||||
return val + 'nA'
|
||||
}
|
||||
break
|
||||
case 2:
|
||||
_chartData[chartID].yAxis[_yAxisIndex].axisLabel.formatter = function (val) {
|
||||
return val + 'uV'
|
||||
}
|
||||
break
|
||||
case 3:
|
||||
_chartData[chartID].yAxis[_yAxisIndex].axisLabel.formatter = function (val) {
|
||||
return val + 'mΩ'
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// register series into grid
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import newTask from '@/factories/task/taskFactory'
|
||||
import { dataStreamBuffer } from './DataStreamBuffer'
|
||||
import api from '@/data/api'
|
||||
|
||||
const eliteImgUrl = require('@/assets/img/elite_img.png')
|
||||
const neuliveImgUrl = require('@/assets/img/neulive_img.png')
|
||||
@@ -81,13 +82,28 @@ const updateAllList = async () => {
|
||||
export const taskInfo = {
|
||||
|
||||
updateTaskInfo: async (taskID) => {
|
||||
let deviceList
|
||||
const update = async () => {
|
||||
_taskInfo.controllerID = 'tommy_test'
|
||||
let contID = 0
|
||||
const cont = await api.controller.getAll()
|
||||
if (cont.data.length > 0) {
|
||||
_taskInfo.controllerID = cont.data[0].mqtt_id
|
||||
contID = cont.data[0].id
|
||||
}
|
||||
|
||||
const task = await api.task.getAll()
|
||||
if (task.data.length === 0) {
|
||||
await api.task.create({
|
||||
controller_id: contID,
|
||||
})
|
||||
} else {
|
||||
deviceList = task.data[0].device_config
|
||||
}
|
||||
}
|
||||
// _taskInfo.deviceAddrList = [[128, 111, 176, 237, 124, 140], [164, 218, 50, 212, 231, 58], [24, 4, 237, 55, 198, 53]]
|
||||
// _taskInfo.chartNumber = _taskInfo.deviceAddrList.length
|
||||
await update()
|
||||
return _taskInfo
|
||||
return deviceList
|
||||
},
|
||||
|
||||
destroyed: () => {
|
||||
|
||||
@@ -4,6 +4,8 @@ function newChart (chartID) {
|
||||
chartType: 'detail',
|
||||
chartDevice: 'neulive',
|
||||
chartMode: 0,
|
||||
chartXMode: 'value', // value or time
|
||||
chartYMode: 'value', // value or time
|
||||
cardName: 'chart' + String(chartID),
|
||||
cardHeight: '500px',
|
||||
cardWidth: 'auto',
|
||||
|
||||
@@ -36,6 +36,13 @@ function newSeries (type, legendName, xAxisIndex, yAxisIndex, xAxisSource, yAxis
|
||||
lineStyle: {
|
||||
width: 1.5,
|
||||
},
|
||||
markArea: {
|
||||
data: [[{
|
||||
xAxis: 0,
|
||||
}, {
|
||||
xAxis: 0,
|
||||
}]],
|
||||
},
|
||||
data: [],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ const controllerActs = {
|
||||
* @return {object} : controller data
|
||||
*/
|
||||
[typePath.init]: async ({ state, getters, commit, dispatch }, payload) => {
|
||||
const controllers = await payload.api.getControllersAll()
|
||||
const controllers = await payload.api.controller.getAll()
|
||||
commit(typePath.set, { list: controllers.data })
|
||||
},
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ const deviceActs = {
|
||||
* @param {object} api
|
||||
*/
|
||||
[typePath.init]: async ({ state, getters, commit, dispatch }, payload) => {
|
||||
const devices = await payload.api.getDevicesAll()
|
||||
const devices = await payload.api.device.getAll()
|
||||
commit(typePath.set, { deviceList: devices.data })
|
||||
},
|
||||
|
||||
@@ -41,7 +41,7 @@ const deviceActs = {
|
||||
* @param {object} api
|
||||
*/
|
||||
[typePath.updateDatabaseByID]: async ({ state, getters, commit, dispatch }, payload) => {
|
||||
await payload.api.updateDeviceByID(payload.id, payload.request)
|
||||
await payload.api.device.updateByID(payload.id, payload.request)
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ const deviceActs = {
|
||||
dispatch(typePath.reorder, { deviceList: payload.deviceList, api: payload.api })
|
||||
|
||||
await dispatch(typePath.updateDatabaseByID, { id: payload.id, request: { deleted: true }, api: payload.api })
|
||||
await payload.api.deleteDevice(payload.id)
|
||||
await payload.api.device.del(payload.id)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ const metaActs = {
|
||||
*/
|
||||
[typePath.init]: async ({ state, getters, commit }, payload) => {
|
||||
const promises = payload.metaIDList.map(async id => {
|
||||
const metaRes = await payload.api.getMetaFilesByID(id)
|
||||
const metaRes = await payload.api.meta.getByID(id)
|
||||
return metaRes.data[0]
|
||||
})
|
||||
const list = await Promise.all(promises)
|
||||
|
||||
@@ -26,7 +26,7 @@ const recActs = {
|
||||
|
||||
const getRawInfo = metaList.map(async meta => {
|
||||
const getData = JSON.parse(meta.channels).map(async ch => {
|
||||
const res = await payload.api.getRawFilesAttrByParent(ch, meta.id, 'id-start_time-end_time')
|
||||
const res = await payload.api.raw.getAttrByParent(ch, meta.id, 'id-start_time-end_time')
|
||||
res.data.forEach(_data => {
|
||||
_data.load = false
|
||||
_data.data = []
|
||||
@@ -49,7 +49,7 @@ const recActs = {
|
||||
const combineMiniIDs = [].concat.apply([], miniIDs)
|
||||
|
||||
for (const id of combineMiniIDs) {
|
||||
const res = await payload.api.getMiniFilesAttrByID(ch, id, 'id-start_time-end_time-scale')
|
||||
const res = await payload.api.mini.getAttrByID(ch, id, 'id-start_time-end_time-scale')
|
||||
res.data.forEach(_data => {
|
||||
_data.load = false
|
||||
_data.data = []
|
||||
@@ -62,7 +62,7 @@ const recActs = {
|
||||
})
|
||||
}
|
||||
|
||||
// const res = await payload.api.getMiniFilesAttrByParent(ch, meta.id, 'id-start_time-end_time-scale')
|
||||
// const res = await payload.api.mini.getAttrByParent(ch, meta.id, 'id-start_time-end_time-scale')
|
||||
// res.data.forEach(_data => {
|
||||
// _data.load = false
|
||||
// _data.data = []
|
||||
|
||||
@@ -81,15 +81,11 @@ const chartMutations = {
|
||||
label += millisecond + ' ms '
|
||||
}
|
||||
} else { // not time, e.g. I, V, R
|
||||
if ((payload.axis === 'x' && state.axisXLabelScale.description === 'Log') || (payload.axis === 'y' && state.axisYLabelScale.description === 'Log')) { // default: 'Linear'
|
||||
label = Math.log10(Math.abs(val / unitScale)).toFixed(2) + unit
|
||||
const num = val / unitScale
|
||||
if (Math.abs(num) >= 1e+6) {
|
||||
label = num.toExponential(3) + unit
|
||||
} else {
|
||||
const num = val / unitScale
|
||||
if (Math.abs(num) >= 1e+6) {
|
||||
label = num.toExponential(3) + unit
|
||||
} else {
|
||||
label = num.toFixed(1) + unit
|
||||
}
|
||||
label = num.toFixed(1) + unit
|
||||
}
|
||||
}
|
||||
return label
|
||||
|
||||
@@ -17,6 +17,8 @@ function newState () {
|
||||
chartData: {},
|
||||
chartOverviewData: {},
|
||||
chartDetailData: {},
|
||||
startTimeCurrent: 0,
|
||||
endTimeCurrent: 0,
|
||||
currentScale: '0',
|
||||
axisXLabelScale: {}, // Linear or Log
|
||||
axisYLabelScale: {}, // Linear or Log
|
||||
|
||||
@@ -40,7 +40,7 @@ const downloadActs = {
|
||||
*/
|
||||
[typePath.init]: async ({ state, getters, commit }, payload) => {
|
||||
const promises = payload.metaIDList.map(async id => {
|
||||
const metaRes = await payload.api.getMetaFilesByID(String(id))
|
||||
const metaRes = await payload.api.meta.getByID(String(id))
|
||||
const downloadInfo = Object.assign(newDownload(), metaRes.data[0])
|
||||
for (const channel of JSON.parse(downloadInfo.channels)) {
|
||||
downloadInfo.downloadBuffer[channel] = []
|
||||
@@ -68,7 +68,7 @@ const downloadActs = {
|
||||
*/
|
||||
[typePath.rawDataByIDs]: async ({ state, getters, commit, dispatch }, payload) => {
|
||||
const { channel, rawDataIDList, api } = payload
|
||||
const rawDataRes = await api.getRawFilesAttrByIDs(channel, rawDataIDList, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
const rawDataRes = await api.raw.getAttrByIDs(channel, rawDataIDList, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
dispatch(typePath.parseRawData, { rawData: rawDataRes, channel: channel })
|
||||
},
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ const exportActs = {
|
||||
*/
|
||||
[typePath.init]: async ({ state, getters, commit }, payload) => {
|
||||
const promises = payload.metaIDList.map(async id => {
|
||||
const metaRes = await payload.api.getMetaFilesByID(id)
|
||||
const metaRes = await payload.api.meta.getByID(id)
|
||||
return metaRes.data[0]
|
||||
})
|
||||
const list = await Promise.all(promises)
|
||||
|
||||
@@ -67,7 +67,7 @@ const downloadActs = {
|
||||
*/
|
||||
[typePath.init]: async ({ state, getters, commit }, payload) => {
|
||||
const promises = payload.metaIDList.map(async id => {
|
||||
const metaRes = await payload.api.getMetaFilesByID(String(id))
|
||||
const metaRes = await payload.api.meta.getByID(String(id))
|
||||
const downloadInfo = Object.assign(newDownload(), metaRes.data[0])
|
||||
// for (const channel of JSON.parse(downloadInfo.channels)) {
|
||||
// downloadInfo._downloadBuffer[channel] = []
|
||||
@@ -96,7 +96,7 @@ const downloadActs = {
|
||||
[typePath.rawDataByIDs]: async ({ state, getters, commit, dispatch }, payload) => {
|
||||
const { channel, rawDataIDList, api } = payload
|
||||
const channelNums = JSON.parse(state.downloadingFile.channels).length
|
||||
const rawDataRes = await api.getRawFilesAttrByIDs(channel % channelNums, rawDataIDList, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
const rawDataRes = await api.raw.getAttrByIDs(channel % channelNums, rawDataIDList, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
dispatch(typePath.parseRawData, { rawData: rawDataRes, channel: channel })
|
||||
},
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ const exportActs = {
|
||||
*/
|
||||
[typePath.init]: async ({ state, getters, commit }, payload) => {
|
||||
const promises = payload.metaIDList.map(async id => {
|
||||
const metaRes = await payload.api.getMetaFilesByID(id)
|
||||
const metaRes = await payload.api.meta.getByID(id)
|
||||
return metaRes.data[0]
|
||||
})
|
||||
const list = await Promise.all(promises)
|
||||
|
||||
@@ -40,7 +40,7 @@ const downloadActs = {
|
||||
*/
|
||||
[typePath.init]: async ({ state, getters, commit }, payload) => {
|
||||
const promises = payload.metaIDList.map(async id => {
|
||||
const metaRes = await payload.api.getMetaFilesByID(String(id))
|
||||
const metaRes = await payload.api.meta.getByID(String(id))
|
||||
const downloadInfo = Object.assign(newDownload(), metaRes.data[0])
|
||||
for (const channel of JSON.parse(downloadInfo.channels)) {
|
||||
downloadInfo.downloadBuffer[channel] = []
|
||||
@@ -68,7 +68,7 @@ const downloadActs = {
|
||||
*/
|
||||
[typePath.rawDataByIDs]: async ({ state, getters, commit, dispatch }, payload) => {
|
||||
const { channel, rawDataIDList, api } = payload
|
||||
const rawDataRes = await api.getRawFilesAttrByIDs(channel, rawDataIDList, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
const rawDataRes = await api.raw.getAttrByIDs(channel, rawDataIDList, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
dispatch(typePath.parseRawData, { rawData: rawDataRes, channel: channel })
|
||||
},
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ const exportActs = {
|
||||
*/
|
||||
[typePath.init]: async ({ state, getters, commit }, payload) => {
|
||||
const promises = payload.metaIDList.map(async id => {
|
||||
const metaRes = await payload.api.getMetaFilesByID(id)
|
||||
const metaRes = await payload.api.meta.getByID(id)
|
||||
return metaRes.data[0]
|
||||
})
|
||||
const list = await Promise.all(promises)
|
||||
|
||||
@@ -56,7 +56,7 @@ const downloadActs = {
|
||||
*/
|
||||
[typePath.init]: async ({ state, getters, commit }, payload) => {
|
||||
const promises = payload.metaIDList.map(async id => {
|
||||
const metaRes = await payload.api.getMetaFilesByID(String(id))
|
||||
const metaRes = await payload.api.meta.getByID(String(id))
|
||||
const downloadInfo = Object.assign(newDownload(), metaRes.data[0])
|
||||
// for (const channel of JSON.parse(downloadInfo.channels)) {
|
||||
// downloadInfo._downloadBuffer[channel] = []
|
||||
@@ -85,7 +85,7 @@ const downloadActs = {
|
||||
[typePath.rawDataByIDs]: async ({ state, getters, commit, dispatch }, payload) => {
|
||||
const { channel, rawDataIDList, api } = payload
|
||||
const channelNums = JSON.parse(state.downloadingFile.channels).length
|
||||
const rawDataRes = await api.getRawFilesAttrByIDs(channel % channelNums, rawDataIDList, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
const rawDataRes = await api.raw.getAttrByIDs(channel % channelNums, rawDataIDList, 'id-channel-size-serial_number-start_time-end_time-data')
|
||||
dispatch(typePath.parseRawData, { rawData: rawDataRes, channel: channel })
|
||||
},
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ const exportActs = {
|
||||
*/
|
||||
[typePath.init]: async ({ state, getters, commit }, payload) => {
|
||||
const promises = payload.metaIDList.map(async id => {
|
||||
const metaRes = await payload.api.getMetaFilesByID(id)
|
||||
const metaRes = await payload.api.meta.getByID(id)
|
||||
return metaRes.data[0]
|
||||
})
|
||||
const list = await Promise.all(promises)
|
||||
|
||||
Reference in New Issue
Block a user