aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/MainView.tsx
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-09-06 06:29:26 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-09-06 06:29:26 -0400
commit5d59e9a379417140e10778cd43e8f87ecb816c37 (patch)
tree3470286463c83ecd30cb436f1a46a5aa5543667a /src/client/views/MainView.tsx
parent0404047f5e747608b33474fa1c883a489cd6b403 (diff)
lightly tested functional export of any image doc (web url or stored in server public folder) to google photos, optionally stored in a given target album
Diffstat (limited to 'src/client/views/MainView.tsx')
-rw-r--r--src/client/views/MainView.tsx17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index c1c95fc88..6d366216e 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -40,11 +40,10 @@ import { PreviewCursor } from './PreviewCursor';
import { FilterBox } from './search/FilterBox';
import PresModeMenu from './presentationview/PresentationModeMenu';
import { PresBox } from './nodes/PresBox';
-import { docs_v1 } from 'googleapis';
-import { Album } from '../../server/apis/google/typings/albums';
import { GooglePhotosClientUtils } from '../apis/google_docs/GooglePhotosClientUtils';
import { ImageField } from '../../new_fields/URLField';
import { LinkFollowBox } from './linking/LinkFollowBox';
+import { DocumentManager } from '../util/DocumentManager';
@observer
export class MainView extends React.Component {
@@ -131,10 +130,7 @@ export class MainView extends React.Component {
window.removeEventListener("keydown", KeyManager.Instance.handle);
window.addEventListener("keydown", KeyManager.Instance.handle);
- let imgurl = "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg";
- let image = Docs.Create.ImageDocument(imgurl, { width: 200, title: "an image of a cat" });
- let parameters = { title: StrCast(image.title), MEDIA_BINARY_DATA: GooglePhotosClientUtils.toDataURL(Cast(image.data, ImageField)) };
- // PostToServer(RouteStore.googlePhotosMediaUpload, parameters).then(console.log);
+ this.executeGooglePhotosRoutine();
reaction(() => {
let workspaces = CurrentUserUtils.UserDocument.workspaces;
@@ -153,6 +149,15 @@ export class MainView extends React.Component {
}, { fireImmediately: true });
}
+ executeGooglePhotosRoutine = async () => {
+ let imgurl = "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg";
+ let doc = Docs.Create.ImageDocument(imgurl, { width: 200, title: "an image of a cat" });
+ doc.caption = "Well isn't this a nice cat image!";
+ let photos = await GooglePhotosClientUtils.endpoint();
+ let albumId = (await photos.albums.list(50)).albums.filter((album: any) => album.title === "This is a generically created album!")[0].id;
+ console.log(await GooglePhotosClientUtils.UploadMedia([doc], { id: albumId }));
+ }
+
componentWillUnMount() {
window.removeEventListener("keydown", KeyManager.Instance.handle);
//close presentation