aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/apis')
-rw-r--r--src/client/apis/GoogleAuthenticationManager.tsx46
-rw-r--r--src/client/apis/IBM_Recommender.ts66
-rw-r--r--src/client/apis/google_docs/GoogleApiClientUtils.ts2
-rw-r--r--src/client/apis/google_docs/GooglePhotosClientUtils.ts6
4 files changed, 54 insertions, 66 deletions
diff --git a/src/client/apis/GoogleAuthenticationManager.tsx b/src/client/apis/GoogleAuthenticationManager.tsx
index ce1277667..417dc3c3b 100644
--- a/src/client/apis/GoogleAuthenticationManager.tsx
+++ b/src/client/apis/GoogleAuthenticationManager.tsx
@@ -12,8 +12,8 @@ const prompt = "Paste authorization code here...";
@observer
export default class GoogleAuthenticationManager extends React.Component<{}> {
public static Instance: GoogleAuthenticationManager;
- @observable private openState = false;
private authenticationLink: Opt<string> = undefined;
+ @observable private openState = false;
@observable private authenticationCode: Opt<string> = undefined;
@observable private clickedState = false;
@observable private success: Opt<boolean> = undefined;
@@ -39,24 +39,18 @@ export default class GoogleAuthenticationManager extends React.Component<{}> {
const disposer = reaction(
() => this.authenticationCode,
async authenticationCode => {
- if (!authenticationCode) {
- return;
+ if (authenticationCode) {
+ disposer();
+ const { access_token, avatar, name } = await Networking.PostToServer("/writeGoogleAccessToken", { authenticationCode });
+ runInAction(() => {
+ this.avatar = avatar;
+ this.username = name;
+ this.hasBeenClicked = false;
+ this.success = false;
+ });
+ this.beginFadeout();
+ resolve(access_token);
}
- const { access_token, avatar, name } = await Networking.PostToServer(
- "/writeGoogleAccessToken",
- { authenticationCode }
- );
- runInAction(() => {
- this.avatar = avatar;
- this.username = name;
- });
- this.beginFadeout();
- disposer();
- resolve(access_token);
- action(() => {
- this.hasBeenClicked = false;
- this.success = false;
- });
}
);
});
@@ -86,26 +80,20 @@ export default class GoogleAuthenticationManager extends React.Component<{}> {
GoogleAuthenticationManager.Instance = this;
}
- private handleClick = () => {
- window.open(this.authenticationLink);
- setTimeout(() => this.hasBeenClicked = true, 500);
- }
-
- private handlePaste = action((e: React.ChangeEvent<HTMLInputElement>) => {
- this.authenticationCode = e.currentTarget.value;
- });
-
private get renderPrompt() {
return (
<div className={'authorize-container'}>
{this.displayLauncher ? <button
className={"dispatch"}
- onClick={this.handleClick}
+ onClick={() => {
+ window.open(this.authenticationLink);
+ setTimeout(() => this.hasBeenClicked = true, 500);
+ }}
style={{ marginBottom: this.clickedState ? 15 : 0 }}
>Authorize a Google account...</button> : (null)}
{this.clickedState ? <input
className={'paste-target'}
- onChange={this.handlePaste}
+ onChange={action(e => this.authenticationCode = e.currentTarget.value)}
placeholder={prompt}
/> : (null)}
{this.avatar ? <img
diff --git a/src/client/apis/IBM_Recommender.ts b/src/client/apis/IBM_Recommender.ts
index da6257f28..4e1c541c8 100644
--- a/src/client/apis/IBM_Recommender.ts
+++ b/src/client/apis/IBM_Recommender.ts
@@ -1,40 +1,40 @@
-import { Opt } from "../../new_fields/Doc";
+// import { Opt } from "../../new_fields/Doc";
-const NaturalLanguageUnderstandingV1 = require('ibm-watson/natural-language-understanding/v1');
-const { IamAuthenticator } = require('ibm-watson/auth');
+// const NaturalLanguageUnderstandingV1 = require('ibm-watson/natural-language-understanding/v1');
+// const { IamAuthenticator } = require('ibm-watson/auth');
-export namespace IBM_Recommender {
+// export namespace IBM_Recommender {
- // pass to IBM account is Browngfx1
+// // pass to IBM account is Browngfx1
- const naturalLanguageUnderstanding = new NaturalLanguageUnderstandingV1({
- version: '2019-07-12',
- authenticator: new IamAuthenticator({
- apikey: 'tLiYwbRim3CnBcCO4phubpf-zEiGcub1uh0V-sD9OKhw',
- }),
- url: 'https://gateway-wdc.watsonplatform.net/natural-language-understanding/api'
- });
+// const naturalLanguageUnderstanding = new NaturalLanguageUnderstandingV1({
+// version: '2019-07-12',
+// authenticator: new IamAuthenticator({
+// apikey: 'tLiYwbRim3CnBcCO4phubpf-zEiGcub1uh0V-sD9OKhw',
+// }),
+// url: 'https://gateway-wdc.watsonplatform.net/natural-language-understanding/api'
+// });
- const analyzeParams = {
- 'text': 'this is a test of the keyword extraction feature I am integrating into the program',
- 'features': {
- 'keywords': {
- 'sentiment': true,
- 'emotion': true,
- 'limit': 3
- },
- }
- };
+// const analyzeParams = {
+// 'text': 'this is a test of the keyword extraction feature I am integrating into the program',
+// 'features': {
+// 'keywords': {
+// 'sentiment': true,
+// 'emotion': true,
+// 'limit': 3
+// },
+// }
+// };
- export const analyze = async (_parameters: any): Promise<Opt<string>> => {
- try {
- const response = await naturalLanguageUnderstanding.analyze(_parameters);
- console.log(response);
- return (JSON.stringify(response, null, 2));
- } catch (err) {
- console.log('error: ', err);
- return undefined;
- }
- };
+// export const analyze = async (_parameters: any): Promise<Opt<string>> => {
+// try {
+// const response = await naturalLanguageUnderstanding.analyze(_parameters);
+// console.log(response);
+// return (JSON.stringify(response, null, 2));
+// } catch (err) {
+// console.log('error: ', err);
+// return undefined;
+// }
+// };
-} \ No newline at end of file
+// } \ No newline at end of file
diff --git a/src/client/apis/google_docs/GoogleApiClientUtils.ts b/src/client/apis/google_docs/GoogleApiClientUtils.ts
index d2a79f189..0d44ee8e0 100644
--- a/src/client/apis/google_docs/GoogleApiClientUtils.ts
+++ b/src/client/apis/google_docs/GoogleApiClientUtils.ts
@@ -248,7 +248,7 @@ export namespace GoogleApiClientUtils {
return undefined;
}
requests.push(...options.content.requests);
- const replies: any = await update({ documentId: documentId, requests });
+ const replies: any = await update({ documentId, requests });
if ("errors" in replies) {
console.log("Write operation failed:");
console.log(replies.errors.map((error: any) => error.message));
diff --git a/src/client/apis/google_docs/GooglePhotosClientUtils.ts b/src/client/apis/google_docs/GooglePhotosClientUtils.ts
index 7e5d5fe1b..7c4137f59 100644
--- a/src/client/apis/google_docs/GooglePhotosClientUtils.ts
+++ b/src/client/apis/google_docs/GooglePhotosClientUtils.ts
@@ -306,7 +306,7 @@ export namespace GooglePhotos {
};
export const WriteMediaItemsToServer = async (body: { mediaItems: any[] }): Promise<UploadInformation[]> => {
- const uploads = await Networking.PostToServer("/googlePhotosMediaDownload", body);
+ const uploads = await Networking.PostToServer("/googlePhotosMediaGet", body);
return uploads;
};
@@ -340,11 +340,11 @@ export namespace GooglePhotos {
const url = data.url.href;
const target = Doc.MakeAlias(source);
const description = parseDescription(target, descriptionKey);
- await DocumentView.makeCustomViewClicked(target, undefined, Docs.Create.FreeformDocument);
+ await DocumentView.makeCustomViewClicked(target, Docs.Create.FreeformDocument);
media.push({ url, description });
}
if (media.length) {
- const results = await Networking.PostToServer("/googlePhotosMediaUpload", { media, album });
+ const results = await Networking.PostToServer("/googlePhotosMediaPost", { media, album });
return results;
}
};