aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-07-23 01:33:14 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-07-23 01:33:14 -0400
commit010c7978ce19392b4f02bdea29e734ac2abac01f (patch)
tree4b2d8e15842164aededfff48556253a00b217484 /src
parent6248a0a4afd154b84ebea1202a48bec0fd4b87de (diff)
further non-breaking cognitive services
Diffstat (limited to 'src')
-rw-r--r--src/client/cognitive_services/CognitiveServices.ts8
-rw-r--r--src/client/views/nodes/ImageBox.tsx18
-rw-r--r--src/server/index.ts5
3 files changed, 19 insertions, 12 deletions
diff --git a/src/client/cognitive_services/CognitiveServices.ts b/src/client/cognitive_services/CognitiveServices.ts
index 2a3fe1d26..d525455cb 100644
--- a/src/client/cognitive_services/CognitiveServices.ts
+++ b/src/client/cognitive_services/CognitiveServices.ts
@@ -8,8 +8,8 @@ import { RouteStore } from "../../server/RouteStore";
import { Utils } from "../../Utils";
export enum Services {
- ComputerVision,
- Face
+ ComputerVision = "vision",
+ Face = "face"
}
export enum Confidence {
@@ -38,8 +38,8 @@ export namespace CognitiveServices {
export const analyze = async (imageUrl: string, service: Services) => {
return fetch(Utils.prepend(`${RouteStore.cognitiveServices}/${service}`)).then(async response => {
let apiKey = await response.text();
- if (apiKey) {
- return;
+ if (!apiKey) {
+ return undefined;
}
let uriBase;
let parameters;
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index c3ee1e823..f88150d66 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -25,6 +25,7 @@ import { Docs } from '../../documents/Documents';
import { DocServer } from '../../DocServer';
import { Font } from '@react-pdf/renderer';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { CognitiveServices } from '../../cognitive_services/CognitiveServices';
var requestImageSize = require('../../util/request-image-size');
var path = require('path');
const { Howl, Howler } = require('howler');
@@ -195,10 +196,10 @@ export class ImageBox extends DocComponent<FieldViewProps, ImageDocument>(ImageD
let field = Cast(this.Document[this.props.fieldKey], ImageField);
if (field) {
let url = field.url.href;
- let subitems: ContextMenuProps[] = [];
- subitems.push({ description: "Copy path", event: () => Utils.CopyText(url), icon: "expand-arrows-alt" });
- subitems.push({ description: "Record 1sec audio", event: this.recordAudioAnnotation, icon: "expand-arrows-alt" });
- subitems.push({
+ let funcs: ContextMenuProps[] = [];
+ funcs.push({ description: "Copy path", event: () => Utils.CopyText(url), icon: "expand-arrows-alt" });
+ funcs.push({ description: "Record 1sec audio", event: this.recordAudioAnnotation, icon: "expand-arrows-alt" });
+ funcs.push({
description: "Rotate", event: action(() => {
let proto = Doc.GetProto(this.props.Document);
let nw = this.props.Document.nativeWidth;
@@ -212,7 +213,14 @@ export class ImageBox extends DocComponent<FieldViewProps, ImageDocument>(ImageD
this.props.Document.height = w;
}), icon: "expand-arrows-alt"
});
- ContextMenu.Instance.addItem({ description: "Image Funcs...", subitems: subitems });
+
+ let modes: ContextMenuProps[] = [];
+ let dataDoc = Doc.GetProto(this.Document);
+ modes.push({ description: "Generate Tags", event: () => CognitiveServices.Image.generateMetadata(dataDoc), icon: "tag" });
+ modes.push({ description: "Find Faces", event: () => CognitiveServices.Image.extractFaces(dataDoc), icon: "camera" });
+
+ ContextMenu.Instance.addItem({ description: "Image Funcs...", subitems: funcs });
+ ContextMenu.Instance.addItem({ description: "Analyze...", subitems: modes });
}
}
diff --git a/src/server/index.ts b/src/server/index.ts
index d808e8158..5b086a2cf 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -286,12 +286,11 @@ addSecureRoute(
addSecureRoute(Method.GET, (user, res, req) => {
let requested = req.params.requestedservice;
- console.log(requested);
switch (requested) {
- case "Face":
+ case "face":
res.send(process.env.FACE);
break;
- case "ComputerVision":
+ case "vision":
res.send(process.env.VISION);
break;
default: