-
-
+
-
diff --git a/src/stores/counter.ts b/src/stores/counter.ts
new file mode 100644
index 0000000..4459247
--- /dev/null
+++ b/src/stores/counter.ts
@@ -0,0 +1,14 @@
+import { defineStore } from 'pinia'
+
+export const useCounterStore = defineStore('counter', {
+ state: () => {
+ return { count: 0 }
+ },
+ // could also be defined as
+ // state: () => ({ count: 0 })
+ actions: {
+ increment() {
+ this.count++
+ },
+ },
+})
diff --git a/src/stores/data-analysis/channel.ts b/src/stores/data-analysis/channel.ts
new file mode 100644
index 0000000..6622a4e
--- /dev/null
+++ b/src/stores/data-analysis/channel.ts
@@ -0,0 +1,10 @@
+import { defineStore } from 'pinia'
+
+export const useChannelStore = defineStore('data-analysis-channel', {
+ state: () => ({
+ xAxis: {},
+ yAxis: {},
+ }),
+ getters: {},
+ actions: {},
+})
diff --git a/src/stores/data-analysis/chart.ts b/src/stores/data-analysis/chart.ts
new file mode 100644
index 0000000..e69de29
diff --git a/src/stores/data-analysis/file-view.ts b/src/stores/data-analysis/file-view.ts
new file mode 100644
index 0000000..127d551
--- /dev/null
+++ b/src/stores/data-analysis/file-view.ts
@@ -0,0 +1,22 @@
+import { defineStore } from 'pinia'
+import { FileView } from '@/utils/file'
+
+interface FileViewState {
+ fileView: FileView
+ filesSelected: (string | never)[]
+}
+
+export const useFileViewStore = defineStore('data-analysis-file-view', {
+ state: (): FileViewState => ({
+ fileView: new FileView(),
+ filesSelected: [],
+ }),
+ // could also be defined as
+ // state: () => ({ count: 0 })
+ getters: {},
+ actions: {
+ setFilesSelect(fileSelect: string[]) {
+ this.filesSelected.push(...fileSelect)
+ },
+ },
+})
diff --git a/src/utils/collection.d.ts b/src/utils/collection.d.ts
new file mode 100644
index 0000000..43a1d9b
--- /dev/null
+++ b/src/utils/collection.d.ts
@@ -0,0 +1,12 @@
+interface collection {
+ id: number
+ name: string
+ parent: object
+ controller_id: number
+ size: number
+ type: string
+ description: string
+ deleted: bool
+}
+
+export { collection }
diff --git a/src/utils/file.ts b/src/utils/file.ts
new file mode 100644
index 0000000..c16c194
--- /dev/null
+++ b/src/utils/file.ts
@@ -0,0 +1,393 @@
+import api from '@/data/server-api'
+
+declare type FolderType = {
+ file: number
+ collection: number
+}
+
+class FileView {
+ children: Array
+ viewBy: string
+ offset: number
+ limit: number
+
+ constructor() {
+ this.children = []
+ this.viewBy = 'time'
+ this.offset = 0
+ this.limit = 20
+ }
+
+ init() {
+ this.children.length = 0
+ this.offset = 0
+ this.limit = 20
+ }
+
+ reset() {
+ this.children.length = 0
+ this.offset = 0
+ this.limit = 20
+ }
+
+ changeView(viewBy: string) {
+ this.reset()
+ this.viewBy = viewBy
+ }
+
+ async appendChildren(id: number) {
+ if (this.viewBy === 'folder') {
+ // append children folder
+ const folderResult = await this.getCollectionsFromServer(id)
+ for (const _data of folderResult.rows) {
+ const folder = new Folder(_data.id, _data.name)
+ // console.log('folder', folder)
+ await folder.init()
+ this.children.push(folder)
+ }
+ } else if (this.viewBy == 'time') {
+ const timeGroup = await this.getTimeGroupFromServer()
+ for (const time in timeGroup) {
+ const timeInstance = new Time(time, timeGroup[time]?.date)
+ await timeInstance.appendChildren()
+ this.children.push(timeInstance)
+ }
+ } else if (this.viewBy == 'project') {
+ const projectGroup = await this.getProjectGroupFromServer(['id', 'name', 'uuid', 'created_at'])
+ for (const project of projectGroup) {
+ const projectInstance = new Project(project.id, project.name, project.uuid, project.created_at)
+ await projectInstance.appendChildren()
+ this.children.push(projectInstance)
+ }
+ }
+ // console.log('children', this.children)
+ }
+
+ async getCollectionsFromServer(id: number, order: string[] = ['id', 'desc']) {
+ const result = await api.collection.getCollection(id, this.offset, this.limit, order)
+ return result.data
+ }
+
+ async getFilesByIdFromServer(id: number, order: string[] = ['id', 'desc']) {
+ const result = await api.meta.getMetaWithTypeFolder(id, this.offset, this.limit, order)
+ return result.data
+ }
+
+ async getTimeGroupFromServer() {
+ const result = await api.meta.getMetaGroupByTime()
+ return result.data
+ }
+
+ async getProjectGroupFromServer(attrs: string[]) {
+ const result = await api.project.getProjectGroup(attrs)
+ return result.data
+ }
+
+ getChildren() {
+ return this.children
+ }
+
+ getMetaFile(idType: string) {
+ for (const child of this.children) {
+ if (!(child instanceof MetaFile)) {
+ const result = child.getMetaFile(idType)
+ if (result) return result
+ }
+ }
+ }
+}
+
+class Time {
+ id: string
+ type: string
+ idType: string
+ name: string
+ children: Array