Skip to content

Commit

Permalink
Update uttlity method (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Futabay committed May 26, 2020
1 parent dd52c2a commit d8c568f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
6 changes: 3 additions & 3 deletions ait/gui/static/js/ait/gui/Plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import m from 'mithril'
import Dygraph from 'dygraphs';
import { getPacket } from '../util.js'
import { getFieldType } from '../util.js'

/*
* FIXME: The two Backend classes (Dygraphs and Highcharts) are not cleanly
Expand Down Expand Up @@ -82,7 +82,7 @@ class DygraphsBackend

plot (data, raw) {
const pname = data['packet']
let packet = getPacket(data['data'], raw)
let packet = getFieldType(data['data'], raw)
const names = this._plot._packets[pname]

if (!names) return
Expand Down Expand Up @@ -211,7 +211,7 @@ class HighchartsBackend

plot(data, raw) {
const pname = data['packet']
let packet = getPacket(data['data'], raw)
let packet = getFieldType(data['data'], raw)
const names = this._plot._packets[pname]
if (!names) return

Expand Down
4 changes: 2 additions & 2 deletions ait/gui/static/js/ait/gui/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import map from 'lodash/map'
import defaults from 'lodash/defaults'

import * as format from 'ait/format'
import { getPacket } from '../util.js'
import { getFieldType } from '../util.js'
import Field from './Field'
import Clock from './Clock'

Expand Down Expand Up @@ -143,7 +143,7 @@ const MnemonicSearch = {

if (curPacket !== null) {
dneu = this._selection in curPacket['dntoeu']
val = getPacket(curPacket, !dneu)
val = getFieldTyoe(curPacket, !dneu)
val = val[this._selection]
raw = curPacket['raw'][this._selection]
}
Expand Down
17 changes: 7 additions & 10 deletions ait/gui/static/js/ait/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,17 @@ function move (array, from, to) {
* Returns DN to EU value if it exists unless the `raw` parameter is true,
* otherwise return raw value.
*/
function getPacket (data, raw=false) {
let value = undefined
function getFieldType (data, raw=false) {

if (!data['dntoeu']){
value = data['raw']
}
else if (data['dntoeu'] && raw) {
value = data['raw']
}
else {
// Default to the raw value since it will always be avilable
let value = data['raw']

// If raw==false and a DN to EU value exists, grab that
if (!raw && data['dntoeu']) {
value = data['dntoeu']
}

return value
}

export { merge, move, getPacket }
export { merge, move, getFieldType }

0 comments on commit d8c568f

Please sign in to comment.