mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-08-01 04:01:01 +00:00
refactor: remove google sheets stuff
This commit is contained in:
parent
87882a07ef
commit
97d7ceb4e7
3 changed files with 4 additions and 50 deletions
|
|
@ -8,9 +8,9 @@ const A = {
|
|||
API_KEY: 'AIzaSyBqr3r5B5QGb_drLTK8_q9HW7YUez83Bik',
|
||||
EL_CLIENT_ID: '37646582031-qo0kc0p6amaukfd5ub16hhp6f8smrk1n.apps.googleusercontent.com',
|
||||
EL_API_KEY: 'Er6sAwgXCDKPgw7y8jSuQQTv',
|
||||
DISCOVERY_DOCS: ['https://sheets.googleapis.com/$discovery/rest?version=v4'],
|
||||
SCOPES: 'https://www.googleapis.com/auth/spreadsheets.readonly' +
|
||||
' https://www.googleapis.com/auth/drive'
|
||||
DISCOVERY_DOCS: [],
|
||||
// NOTE: separate by space if multiple
|
||||
SCOPES: 'https://www.googleapis.com/auth/drive'
|
||||
};
|
||||
|
||||
const CLIENT_ID = A.EL_CLIENT_ID;
|
||||
|
|
@ -18,7 +18,6 @@ const CLIENT_SECRET = A.EL_API_KEY;
|
|||
const SCOPES = [
|
||||
'https://www.googleapis.com/auth/drive',
|
||||
'https://www.googleapis.com/auth/drive.install',
|
||||
'https://www.googleapis.com/auth/spreadsheets.readonly'
|
||||
];
|
||||
|
||||
const POPUP_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36';
|
||||
|
|
|
|||
|
|
@ -152,50 +152,6 @@ export class GoogleApiService {
|
|||
}
|
||||
}
|
||||
|
||||
// -----------------
|
||||
appendRow$(spreadsheetId, row): Observable<any> {
|
||||
// @see: https://developers.google.com/sheets/api/reference/rest/
|
||||
const range = 'A1:Z99';
|
||||
return this._mapHttp$({
|
||||
method: 'POST',
|
||||
url: `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${range}:append`,
|
||||
params: {
|
||||
key: GOOGLE_SETTINGS.API_KEY,
|
||||
insertDataOption: 'INSERT_ROWS',
|
||||
valueInputOption: 'USER_ENTERED'
|
||||
},
|
||||
data: {values: [row]}
|
||||
});
|
||||
}
|
||||
|
||||
getSpreadsheetData$(spreadsheetId, range): Observable<any> {
|
||||
// @see: https://developers.google.com/sheets/api/reference/rest/
|
||||
return this._mapHttp$({
|
||||
method: 'GET',
|
||||
url: `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${range}`,
|
||||
params: {
|
||||
key: GOOGLE_SETTINGS.API_KEY,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
getSpreadsheetHeadingsAndLastRow$(spreadsheetId): Observable<{ headings: any, lastRow: any } | Observable<never>> {
|
||||
return this.getSpreadsheetData$(spreadsheetId, 'A1:Z99')
|
||||
.pipe(map((response: any) => {
|
||||
const range = response.body || response;
|
||||
|
||||
if (range && range.values && range.values[0]) {
|
||||
return {
|
||||
headings: range.values[0],
|
||||
lastRow: range.values[range.values.length - 1],
|
||||
};
|
||||
} else {
|
||||
this._handleError('No data found');
|
||||
return throwError({[HANDLED_ERROR_PROP_STR]: 'No data found'});
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
getFileInfo$(fileId): Observable<any> {
|
||||
if (!fileId) {
|
||||
this._snackIt('ERROR', T.F.GOOGLE.S_API.ERR_NO_FILE_ID);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,8 @@ export const GOOGLE_SETTINGS = {
|
|||
API_KEY: 'AIzaSyBqr3r5B5QGb_drLTK8_q9HW7YUez83Bik',
|
||||
};
|
||||
|
||||
export const GOOGLE_DISCOVERY_DOCS = ['https://sheets.googleapis.com/$discovery/rest?version=v4'];
|
||||
export const GOOGLE_DISCOVERY_DOCS = [];
|
||||
export const GOOGLE_SCOPES = '' +
|
||||
'https://www.googleapis.com/auth/spreadsheets.readonly' +
|
||||
' https://www.googleapis.com/auth/drive.install' +
|
||||
' https://www.googleapis.com/auth/drive';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue