diff --git a/src/data/index.ts b/src/data/index.ts new file mode 100644 index 0000000..3b002c2 --- /dev/null +++ b/src/data/index.ts @@ -0,0 +1,82 @@ +export default { + measurements: [ + { + assetId: 0, + measurements: { + '2020-01-01T00:00:00.000Z': 156, + '2020-02-01T00:00:00.000Z': 123, + '2020-03-01T00:00:00.000Z': 128, + '2020-04-01T00:00:00.000Z': 159, + '2020-05-01T00:00:00.000Z': 178, + '2020-06-01T00:00:00.000Z': 290, + '2020-07-01T00:00:00.000Z': 276, + '2020-08-01T00:00:00.000Z': 250, + '2020-09-01T00:00:00.000Z': 156, + '2020-10-01T00:00:00.000Z': 176, + '2020-11-01T00:00:00.000Z': 134, + '2020-12-01T00:00:00.000Z': 111 + } + }, + { + assetId: 2, + measurements: { + '2020-01-01T00:00:00.000Z': 141, + '2020-02-01T00:00:00.000Z': 125, + '2020-03-01T00:00:00.000Z': 113, + '2020-04-01T00:00:00.000Z': 151, + '2020-05-01T00:00:00.000Z': 107, + '2020-06-01T00:00:00.000Z': 116, + '2020-07-01T00:00:00.000Z': 125, + '2020-08-01T00:00:00.000Z': 146, + '2020-09-01T00:00:00.000Z': 101, + '2020-10-01T00:00:00.000Z': 126, + '2020-11-01T00:00:00.000Z': 151, + '2020-12-01T00:00:00.000Z': 148 + } + }, + { + assetId: 4, + measurements: { + '2020-01-01T00:00:00.000Z': 142, + '2020-02-01T00:00:00.000Z': 164, + '2020-03-01T00:00:00.000Z': 112, + '2020-04-01T00:00:00.000Z': 114, + '2020-05-01T00:00:00.000Z': 170, + '2020-06-01T00:00:00.000Z': 130, + '2020-07-01T00:00:00.000Z': 132, + '2020-08-01T00:00:00.000Z': 129, + '2020-09-01T00:00:00.000Z': 157, + '2020-10-01T00:00:00.000Z': 128, + '2020-11-01T00:00:00.000Z': 110, + '2020-12-01T00:00:00.000Z': 168 + } + } + ], + assets: [ + { + id: 0, + name: 'Asset 0', + parentId: undefined + }, + { + id: 1, + name: 'Asset 1', + parentId: undefined + }, + { + id: 2, + name: 'Asset 2', + parentId: 1 + }, + { + id: 3, + name: 'Asset 3', + parentId: 1 + }, + { + id: 4, + name: 'Asset 4', + parentId: 3 + } + ] +} \ No newline at end of file diff --git a/src/stores/assets.ts b/src/stores/assets.ts index d739ab1..17d355f 100644 --- a/src/stores/assets.ts +++ b/src/stores/assets.ts @@ -1,4 +1,5 @@ import { Api } from '@/api' +import data from '@/data' import type { AssetTreeMeasurements } from '@/helpers/aggregateMeasurements' import type { Assets } from '@/interfaces/asset.interface' import { defineStore } from 'pinia' @@ -17,36 +18,7 @@ export const useAssetsStore = defineStore('assets', () => { // we could use this to fetch from an API // assets.value = await Api.assets.getAll() - assets.value = [] - assets.value.push( - ...[ - { - id: 0, - name: 'Asset 0', - parentId: undefined - }, - { - id: 1, - name: 'Asset 1', - parentId: undefined - }, - { - id: 2, - name: 'Asset 2', - parentId: 1 - }, - { - id: 3, - name: 'Asset 3', - parentId: 1 - }, - { - id: 4, - name: 'Asset 4', - parentId: 3 - } - ] - ) + assets.value = [...data.assets] } onMounted(async () => await fetchAssets()) diff --git a/src/stores/measurements.ts b/src/stores/measurements.ts index 4dc46a9..7b4e49c 100644 --- a/src/stores/measurements.ts +++ b/src/stores/measurements.ts @@ -1,4 +1,5 @@ import { Api } from '@/api' +import data from '@/data' import type { Measurements } from '@/interfaces/measurements.interface' import { defineStore } from 'pinia' import { onMounted, ref } from 'vue' @@ -10,59 +11,7 @@ export const useMeasurementsStore = defineStore('measurements', () => { // we could use this to fetch from an API // measurements.value = await Api.measurements.getAll() - measurements.value = [ - { - assetId: 0, - measurements: { - '2020-01-01T00:00:00.000Z': 156, - '2020-02-01T00:00:00.000Z': 123, - '2020-03-01T00:00:00.000Z': 128, - '2020-04-01T00:00:00.000Z': 159, - '2020-05-01T00:00:00.000Z': 178, - '2020-06-01T00:00:00.000Z': 290, - '2020-07-01T00:00:00.000Z': 276, - '2020-08-01T00:00:00.000Z': 250, - '2020-09-01T00:00:00.000Z': 156, - '2020-10-01T00:00:00.000Z': 176, - '2020-11-01T00:00:00.000Z': 134, - '2020-12-01T00:00:00.000Z': 111 - } - }, - { - assetId: 2, - measurements: { - '2020-01-01T00:00:00.000Z': 141, - '2020-02-01T00:00:00.000Z': 125, - '2020-03-01T00:00:00.000Z': 113, - '2020-04-01T00:00:00.000Z': 151, - '2020-05-01T00:00:00.000Z': 107, - '2020-06-01T00:00:00.000Z': 116, - '2020-07-01T00:00:00.000Z': 125, - '2020-08-01T00:00:00.000Z': 146, - '2020-09-01T00:00:00.000Z': 101, - '2020-10-01T00:00:00.000Z': 126, - '2020-11-01T00:00:00.000Z': 151, - '2020-12-01T00:00:00.000Z': 148 - } - }, - { - assetId: 4, - measurements: { - '2020-01-01T00:00:00.000Z': 142, - '2020-02-01T00:00:00.000Z': 164, - '2020-03-01T00:00:00.000Z': 112, - '2020-04-01T00:00:00.000Z': 114, - '2020-05-01T00:00:00.000Z': 170, - '2020-06-01T00:00:00.000Z': 130, - '2020-07-01T00:00:00.000Z': 132, - '2020-08-01T00:00:00.000Z': 129, - '2020-09-01T00:00:00.000Z': 157, - '2020-10-01T00:00:00.000Z': 128, - '2020-11-01T00:00:00.000Z': 110, - '2020-12-01T00:00:00.000Z': 168 - } - } - ] + measurements.value = [...data.measurements] } onMounted(async () => await fetchMeasurements())