From 8df7f2301d7f29be4597d0dd71bb60b8c9f5f028 Mon Sep 17 00:00:00 2001 From: msramalho <19508417+msramalho@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:15:18 +0100 Subject: [PATCH] new feature ready --- src/store/index.js | 47 +++++++++++++- src/views/HomeView.vue | 139 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 168 insertions(+), 18 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 85f9a5f..736e59e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -14,6 +14,7 @@ import { addDoc, query, where, + limit, getDocs, doc, deleteDoc, @@ -29,6 +30,7 @@ export default new Vuex.Store({ access_token: null, docs: [], loading: false, + errorMessage: "", }, mutations: { setUser(state, user) { @@ -43,6 +45,9 @@ export default new Vuex.Store({ setAccessToken(state, access_token) { state.access_token = access_token; }, + setErrorMessage(state, errorMessage) { + state.errorMessage = errorMessage; + }, }, actions: { async signin({ commit, dispatch }) { @@ -282,7 +287,7 @@ export default new Vuex.Store({ endColumnIndex: 11, }, description: - "Protecting header row (needed for auto-archiver)", + "Protecting header row (needed for auto-archiver), do not modify archiving column names, you can add and move columns around when no 'Archive in Progress' is present in the 'Archive status' column.", warningOnly: true, }, }, @@ -317,5 +322,45 @@ export default new Vuex.Store({ console.error("add (firebase.js): ", error); } }, + + async enable({ state, dispatch, commit }, { spreadsheetId }) { + commit("setLoading", true); + commit("setErrorMessage", ""); + + try { + // fetch existing sheet + const sheetToEnable = await gapi.client.sheets.spreadsheets.get({ + spreadsheetId: spreadsheetId, + }); + + const q = query( + collection(firebaseFirestore, "sheets"), + where("uid", "==", state.user.uid), + where("sheetId", "==", spreadsheetId), + limit(1) + ); + + const response = await getDocs(q); + if(response.docs.length > 0) { + throw "Sheet already enabled"; + } + + const col = await collection(firebaseFirestore, "sheets"); + await addDoc(col, { + sheetId: spreadsheetId, + url: sheetToEnable.result.spreadsheetUrl, + timestamp: Date.now(), + uid: state.user.uid, + lastArchived: null, + name: sheetToEnable.result.properties.title, + }); + + dispatch("getDocs"); + } catch (error) { + commit("setErrorMessage", `Unable to add sheet: ${JSON.stringify(error)}`); + commit("setLoading", false); + console.error("add (firebase.js): ", error); + } + }, }, }); diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 967e5b9..ae49cca 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -25,27 +25,38 @@ >associated article.
+Link columnbellingcat-auto-archiver-api@bellingcat-auto-archiver-b85db.iam.gserviceaccount.com
+ into your spreadsheet
+ Link where you will put the URLs.Archive Status to monitor progress and success
+ of archiver
+ Archive location where the link to the archived
+ content is added
+ Archive date info on when archiving occurred
+ Thumbnail an image preview from archived media
+ Upload timestamp online content creation date
+ Upload title titleTextual content text contentScreenshot link to page screenshotHash content hash (for integrity purposes)
+