Nesta Bentum před 4 roky
rodič
revize
57e7a013e6
1 změnil soubory, kde provedl 93 přidání a 59 odebrání
  1. 93 59
      report-viewer/src/store/store.ts

+ 93 - 59
report-viewer/src/store/store.ts

@@ -1,65 +1,99 @@
-import {createStore} from "vuex";
+import { createStore } from "vuex";
 
 /**
  * Local store. Stores the state of the application.
  */
-const store = createStore({
-    state() {
-        return {
-            /**
-             * The set of ids to be hidden.
-             */
-            anonymous: new Set(),
-            /**
-             * Stored files if zip mode is used. Stores the files as key - file name, value - file string
-             */
-            files: Object,
-            /**
-             * Indicates whether local mode is used.
-             */
-            local: Boolean,
-            /**
-             * Indicates whether zip mode is used.
-             */
-            zip: Boolean,
-            /**
-             * Indicates whether single file mode is used.
-             */
-            single: Boolean,
-            /**
-             * Files string if single mode is used.
-             */
-            fileString: {
-                type: String,
-                required: false
-            }
-        }
-    },
-    mutations: {
-        addAnonymous(state: any, id) {
-            for (let i = 0; i < id.length; i++) {
-                state.anonymous.add(id[i])
-            }
-        },
-        removeAnonymous(state, id) {
-            for (let i = 0; i < id.length; i++) {
-                state.anonymous.delete(id[i])
-            }
-        },
-        resetAnonymous(state) {
-            state.anonymous = new Set()
-        },
-        saveFile(state, file: Record<string, any>) {
-            state.files[file.fileName] = file.data
-        },
-        setLoadingType(state, payload: Record<string, any>) {
-            state.local = payload.local
-            state.zip = payload.zip
-            state.single = payload.single
-            state.fileString = payload.fileString
-        }
 
-    }
-})
+interface State {
+  /**
+   * The set of ids to be hidden.
+   */
+  anonymous: Set<string>;
+  /**
+   * Stored files if zip mode is used. Stores the files as key - file name, value - file string
+   */
+  files: Record<string, string>;
+  /**
+   * Indicates whether local mode is used.
+   */
+  local: boolean;
+  /**
+   * Indicates whether zip mode is used.
+   */
+  zip: boolean;
+  /**
+   * Indicates whether single file mode is used.
+   */
+  single: boolean;
+  /**
+   * Files string if single mode is used.
+   */
+  fileString: string;
+}
+
+interface File {
+  fileName: string;
+  data: string;
+}
+
+interface LoadConfiguration {
+  local: boolean;
+  zip: boolean;
+  single: boolean;
+  fileString: string;
+}
+
+const store = createStore<State>({
+  state: {
+    /**
+     * The set of ids to be hidden.
+     */
+    anonymous: new Set(),
+    /**
+     * Stored files if zip mode is used. Stores the files as key - file name, value - file string
+     */
+    files: {},
+    /**
+     * Indicates whether local mode is used.
+     */
+    local: false,
+    /**
+     * Indicates whether zip mode is used.
+     */
+    zip: false,
+    /**
+     * Indicates whether single file mode is used.
+     */
+    single: false,
+    /**
+     * Files string if single mode is used.
+     */
+    fileString: "",
+  },
+  mutations: {
+    addAnonymous(state: State, id) {
+      for (let i = 0; i < id.length; i++) {
+        state.anonymous.add(id[i]);
+      }
+    },
+    removeAnonymous(state, id) {
+      for (let i = 0; i < id.length; i++) {
+        state.anonymous.delete(id[i]);
+      }
+    },
+    resetAnonymous(state) {
+      state.anonymous = new Set();
+    },
+    saveFile(state, file: File) {
+      state.files[file.fileName] = file.data;
+    },
+    setLoadingType(state, payload: LoadConfiguration) {
+      state.local = payload.local;
+      state.zip = payload.zip;
+      state.single = payload.single;
+      state.fileString = payload.fileString;
+    },
+  },
+});
 
-export default store
+export default store;