diff --git a/frontend/src/.eslintignore b/frontend/src/.eslintignore deleted file mode 100644 index e1ffb23..0000000 --- a/frontend/src/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -*/src/proto/** \ No newline at end of file diff --git a/frontend/src/proto/cloud-algos.proto b/frontend/src/proto/cloud-algos.proto deleted file mode 100644 index 16d1480..0000000 --- a/frontend/src/proto/cloud-algos.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; -package protoBuf; - -import "computation-msgs.proto"; - -// To compile the protobuf to JS run the following inside the protoBuf folder: -// protoc -I=. --js_out=import_style=commonjs,mode=grpcwebtext:../frontend/src/protos cloud-algos.proto - - -// RPC service at a cloud algo that performs the necessary computation. -service CloudAlgo { - // Performs the appropriate computation at the host algo and returns the result. - rpc Compute (ComputeRequest) returns (ComputeResponse) {} - rpc WebRequest (ComputeRequest) returns (ComputeResponse) {} -} \ No newline at end of file diff --git a/frontend/src/proto/cloud-algos_grpc_web_pb.js b/frontend/src/proto/cloud-algos_grpc_web_pb.js deleted file mode 100644 index 1646974..0000000 --- a/frontend/src/proto/cloud-algos_grpc_web_pb.js +++ /dev/null @@ -1,233 +0,0 @@ -/** - * @fileoverview gRPC-Web generated client stub for protoBuf - * @enhanceable - * @public - */ - -/* eslint-disable */ -// GENERATED CODE -- DO NOT EDIT! - - - -const grpc = {}; -grpc.web = require('grpc-web'); - - -var computation$msgs_pb = require('./computation-msgs_pb.js') -const proto = {}; -proto.protoBuf = require('./cloud-algos_pb.js'); - -/** - * @param {string} hostname - * @param {?Object} credentials - * @param {?Object} options - * @constructor - * @struct - * @final - */ -proto.protoBuf.CloudAlgoClient = - function(hostname, credentials, options) { - if (!options) options = {}; - options['format'] = 'text'; - - /** - * @private @const {!grpc.web.GrpcWebClientBase} The client - */ - this.client_ = new grpc.web.GrpcWebClientBase(options); - - /** - * @private @const {string} The hostname - */ - this.hostname_ = hostname; - -}; - - -/** - * @param {string} hostname - * @param {?Object} credentials - * @param {?Object} options - * @constructor - * @struct - * @final - */ -proto.protoBuf.CloudAlgoPromiseClient = - function(hostname, credentials, options) { - if (!options) options = {}; - options['format'] = 'text'; - - /** - * @private @const {!grpc.web.GrpcWebClientBase} The client - */ - this.client_ = new grpc.web.GrpcWebClientBase(options); - - /** - * @private @const {string} The hostname - */ - this.hostname_ = hostname; - -}; - - -/** - * @const - * @type {!grpc.web.MethodDescriptor< - * !proto.protoBuf.ComputeRequest, - * !proto.protoBuf.ComputeResponse>} - */ -const methodDescriptor_CloudAlgo_Compute = new grpc.web.MethodDescriptor( - '/protoBuf.CloudAlgo/Compute', - grpc.web.MethodType.UNARY, - computation$msgs_pb.ComputeRequest, - computation$msgs_pb.ComputeResponse, - /** - * @param {!proto.protoBuf.ComputeRequest} request - * @return {!Uint8Array} - */ - function(request) { - return request.serializeBinary(); - }, - computation$msgs_pb.ComputeResponse.deserializeBinary -); - - -/** - * @const - * @type {!grpc.web.AbstractClientBase.MethodInfo< - * !proto.protoBuf.ComputeRequest, - * !proto.protoBuf.ComputeResponse>} - */ -const methodInfo_CloudAlgo_Compute = new grpc.web.AbstractClientBase.MethodInfo( - computation$msgs_pb.ComputeResponse, - /** - * @param {!proto.protoBuf.ComputeRequest} request - * @return {!Uint8Array} - */ - function(request) { - return request.serializeBinary(); - }, - computation$msgs_pb.ComputeResponse.deserializeBinary -); - - -/** - * @param {!proto.protoBuf.ComputeRequest} request The - * request proto - * @param {?Object} metadata User defined - * call metadata - * @param {function(?grpc.web.Error, ?proto.protoBuf.ComputeResponse)} - * callback The callback function(error, response) - * @return {!grpc.web.ClientReadableStream|undefined} - * The XHR Node Readable Stream - */ -proto.protoBuf.CloudAlgoClient.prototype.compute = - function(request, metadata, callback) { - return this.client_.rpcCall(this.hostname_ + - '/protoBuf.CloudAlgo/Compute', - request, - metadata || {}, - methodDescriptor_CloudAlgo_Compute, - callback); -}; - - -/** - * @param {!proto.protoBuf.ComputeRequest} request The - * request proto - * @param {?Object} metadata User defined - * call metadata - * @return {!Promise} - * A native promise that resolves to the response - */ -proto.protoBuf.CloudAlgoPromiseClient.prototype.compute = - function(request, metadata) { - return this.client_.unaryCall(this.hostname_ + - '/protoBuf.CloudAlgo/Compute', - request, - metadata || {}, - methodDescriptor_CloudAlgo_Compute); -}; - - -/** - * @const - * @type {!grpc.web.MethodDescriptor< - * !proto.protoBuf.ComputeRequest, - * !proto.protoBuf.ComputeResponse>} - */ -const methodDescriptor_CloudAlgo_WebRequest = new grpc.web.MethodDescriptor( - '/protoBuf.CloudAlgo/WebRequest', - grpc.web.MethodType.UNARY, - computation$msgs_pb.ComputeRequest, - computation$msgs_pb.ComputeResponse, - /** - * @param {!proto.protoBuf.ComputeRequest} request - * @return {!Uint8Array} - */ - function(request) { - return request.serializeBinary(); - }, - computation$msgs_pb.ComputeResponse.deserializeBinary -); - - -/** - * @const - * @type {!grpc.web.AbstractClientBase.MethodInfo< - * !proto.protoBuf.ComputeRequest, - * !proto.protoBuf.ComputeResponse>} - */ -const methodInfo_CloudAlgo_WebRequest = new grpc.web.AbstractClientBase.MethodInfo( - computation$msgs_pb.ComputeResponse, - /** - * @param {!proto.protoBuf.ComputeRequest} request - * @return {!Uint8Array} - */ - function(request) { - return request.serializeBinary(); - }, - computation$msgs_pb.ComputeResponse.deserializeBinary -); - - -/** - * @param {!proto.protoBuf.ComputeRequest} request The - * request proto - * @param {?Object} metadata User defined - * call metadata - * @param {function(?grpc.web.Error, ?proto.protoBuf.ComputeResponse)} - * callback The callback function(error, response) - * @return {!grpc.web.ClientReadableStream|undefined} - * The XHR Node Readable Stream - */ -proto.protoBuf.CloudAlgoClient.prototype.webRequest = - function(request, metadata, callback) { - return this.client_.rpcCall(this.hostname_ + - '/protoBuf.CloudAlgo/WebRequest', - request, - metadata || {}, - methodDescriptor_CloudAlgo_WebRequest, - callback); -}; - - -/** - * @param {!proto.protoBuf.ComputeRequest} request The - * request proto - * @param {?Object} metadata User defined - * call metadata - * @return {!Promise} - * A native promise that resolves to the response - */ -proto.protoBuf.CloudAlgoPromiseClient.prototype.webRequest = - function(request, metadata) { - return this.client_.unaryCall(this.hostname_ + - '/protoBuf.CloudAlgo/WebRequest', - request, - metadata || {}, - methodDescriptor_CloudAlgo_WebRequest); -}; - - -module.exports = proto.protoBuf; - diff --git a/frontend/src/proto/cloud-algos_pb.js b/frontend/src/proto/cloud-algos_pb.js deleted file mode 100644 index ee9af32..0000000 --- a/frontend/src/proto/cloud-algos_pb.js +++ /dev/null @@ -1,17 +0,0 @@ -// source: cloud-algos.proto -/** - * @fileoverview - * @enhanceable - * @suppress {messageConventions} JS Compiler reports an error if a variable or - * field starts with 'MSG_' and isn't a translatable message. - * @public - */ -/* eslint-disable */ -// GENERATED CODE -- DO NOT EDIT! - -var jspb = require('google-protobuf'); -var goog = jspb; -var global = Function('return this')(); - -var computation$msgs_pb = require('./computation-msgs_pb.js'); -goog.object.extend(proto, computation$msgs_pb); diff --git a/frontend/src/proto/compileProtos.sh b/frontend/src/proto/compileProtos.sh deleted file mode 100644 index f2bdc04..0000000 --- a/frontend/src/proto/compileProtos.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# Compile computation-msgs.proto -protoc -I=. --js_out=import_style=commonjs:. computation-msgs.proto - -# Compile cloud-algos.proto -protoc -I=. --js_out=import_style=commonjs:. --grpc-web_out=import_style=commonjs,mode=grpcwebtext:. cloud-algos.proto diff --git a/frontend/src/proto/computation-msgs.proto b/frontend/src/proto/computation-msgs.proto deleted file mode 100644 index 030a4cf..0000000 --- a/frontend/src/proto/computation-msgs.proto +++ /dev/null @@ -1,38 +0,0 @@ -syntax = "proto3"; -package protoBuf; - -// To compile the protobuf to JS run the following inside the protoBuf folder: -// protoc -I=. --js_out=import_style=commonjs:. computation-msgs.proto - -message WebRequest { - bool dp = 1; - string algo_type = 2; -} - -// A generic JSON encoded request -message ComputeRequest { - string req = 1; -} - -// A generic JSON encoded response -message ComputeResponse { - string response = 1; - repeated int32 unavailable_sites = 2; -} - -// A request for a map computation -message MapRequest { - int64 id = 1; - string req = 2; -} - -// A response from a map computation -message MapResponse { - string response = 1; -} - -// The map responses returned by the algorithms in different sites. -message MapResponses { - repeated MapResponse responses = 1; - repeated int32 unavailable_sites = 2; -} \ No newline at end of file diff --git a/frontend/src/proto/computation-msgs_pb.js b/frontend/src/proto/computation-msgs_pb.js deleted file mode 100644 index 037e4e5..0000000 --- a/frontend/src/proto/computation-msgs_pb.js +++ /dev/null @@ -1,1088 +0,0 @@ -// source: computation-msgs.proto -/** - * @fileoverview - * @enhanceable - * @suppress {messageConventions} JS Compiler reports an error if a variable or - * field starts with 'MSG_' and isn't a translatable message. - * @public - */ -/* eslint-disable */ -// GENERATED CODE -- DO NOT EDIT! - -var jspb = require('google-protobuf'); -var goog = jspb; -var global = Function('return this')(); - -goog.exportSymbol('proto.protoBuf.ComputeRequest', null, global); -goog.exportSymbol('proto.protoBuf.ComputeResponse', null, global); -goog.exportSymbol('proto.protoBuf.MapRequest', null, global); -goog.exportSymbol('proto.protoBuf.MapResponse', null, global); -goog.exportSymbol('proto.protoBuf.MapResponses', null, global); -goog.exportSymbol('proto.protoBuf.WebRequest', null, global); -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.protoBuf.WebRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.protoBuf.WebRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.protoBuf.WebRequest.displayName = 'proto.protoBuf.WebRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.protoBuf.ComputeRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.protoBuf.ComputeRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.protoBuf.ComputeRequest.displayName = 'proto.protoBuf.ComputeRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.protoBuf.ComputeResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, proto.protoBuf.ComputeResponse.repeatedFields_, null); -}; -goog.inherits(proto.protoBuf.ComputeResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.protoBuf.ComputeResponse.displayName = 'proto.protoBuf.ComputeResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.protoBuf.MapRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.protoBuf.MapRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.protoBuf.MapRequest.displayName = 'proto.protoBuf.MapRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.protoBuf.MapResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.protoBuf.MapResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.protoBuf.MapResponse.displayName = 'proto.protoBuf.MapResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.protoBuf.MapResponses = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, proto.protoBuf.MapResponses.repeatedFields_, null); -}; -goog.inherits(proto.protoBuf.MapResponses, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.protoBuf.MapResponses.displayName = 'proto.protoBuf.MapResponses'; -} - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.protoBuf.WebRequest.prototype.toObject = function(opt_includeInstance) { - return proto.protoBuf.WebRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.protoBuf.WebRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.protoBuf.WebRequest.toObject = function(includeInstance, msg) { - var f, obj = { - dp: jspb.Message.getBooleanFieldWithDefault(msg, 1, false), - algoType: jspb.Message.getFieldWithDefault(msg, 2, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.protoBuf.WebRequest} - */ -proto.protoBuf.WebRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.protoBuf.WebRequest; - return proto.protoBuf.WebRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.protoBuf.WebRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.protoBuf.WebRequest} - */ -proto.protoBuf.WebRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setDp(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setAlgoType(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.protoBuf.WebRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.protoBuf.WebRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.protoBuf.WebRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.protoBuf.WebRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getDp(); - if (f) { - writer.writeBool( - 1, - f - ); - } - f = message.getAlgoType(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } -}; - - -/** - * optional bool dp = 1; - * @return {boolean} - */ -proto.protoBuf.WebRequest.prototype.getDp = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); -}; - - -/** @param {boolean} value */ -proto.protoBuf.WebRequest.prototype.setDp = function(value) { - jspb.Message.setProto3BooleanField(this, 1, value); -}; - - -/** - * optional string algo_type = 2; - * @return {string} - */ -proto.protoBuf.WebRequest.prototype.getAlgoType = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** @param {string} value */ -proto.protoBuf.WebRequest.prototype.setAlgoType = function(value) { - jspb.Message.setProto3StringField(this, 2, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.protoBuf.ComputeRequest.prototype.toObject = function(opt_includeInstance) { - return proto.protoBuf.ComputeRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.protoBuf.ComputeRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.protoBuf.ComputeRequest.toObject = function(includeInstance, msg) { - var f, obj = { - req: jspb.Message.getFieldWithDefault(msg, 1, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.protoBuf.ComputeRequest} - */ -proto.protoBuf.ComputeRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.protoBuf.ComputeRequest; - return proto.protoBuf.ComputeRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.protoBuf.ComputeRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.protoBuf.ComputeRequest} - */ -proto.protoBuf.ComputeRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setReq(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.protoBuf.ComputeRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.protoBuf.ComputeRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.protoBuf.ComputeRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.protoBuf.ComputeRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getReq(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } -}; - - -/** - * optional string req = 1; - * @return {string} - */ -proto.protoBuf.ComputeRequest.prototype.getReq = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** @param {string} value */ -proto.protoBuf.ComputeRequest.prototype.setReq = function(value) { - jspb.Message.setProto3StringField(this, 1, value); -}; - - - -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.protoBuf.ComputeResponse.repeatedFields_ = [2]; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.protoBuf.ComputeResponse.prototype.toObject = function(opt_includeInstance) { - return proto.protoBuf.ComputeResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.protoBuf.ComputeResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.protoBuf.ComputeResponse.toObject = function(includeInstance, msg) { - var f, obj = { - response: jspb.Message.getFieldWithDefault(msg, 1, ""), - unavailableSitesList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.protoBuf.ComputeResponse} - */ -proto.protoBuf.ComputeResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.protoBuf.ComputeResponse; - return proto.protoBuf.ComputeResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.protoBuf.ComputeResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.protoBuf.ComputeResponse} - */ -proto.protoBuf.ComputeResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setResponse(value); - break; - case 2: - var value = /** @type {!Array} */ (reader.readPackedInt32()); - msg.setUnavailableSitesList(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.protoBuf.ComputeResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.protoBuf.ComputeResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.protoBuf.ComputeResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.protoBuf.ComputeResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getResponse(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getUnavailableSitesList(); - if (f.length > 0) { - writer.writePackedInt32( - 2, - f - ); - } -}; - - -/** - * optional string response = 1; - * @return {string} - */ -proto.protoBuf.ComputeResponse.prototype.getResponse = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** @param {string} value */ -proto.protoBuf.ComputeResponse.prototype.setResponse = function(value) { - jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * repeated int32 unavailable_sites = 2; - * @return {!Array} - */ -proto.protoBuf.ComputeResponse.prototype.getUnavailableSitesList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); -}; - - -/** @param {!Array} value */ -proto.protoBuf.ComputeResponse.prototype.setUnavailableSitesList = function(value) { - jspb.Message.setField(this, 2, value || []); -}; - - -/** - * @param {number} value - * @param {number=} opt_index - */ -proto.protoBuf.ComputeResponse.prototype.addUnavailableSites = function(value, opt_index) { - jspb.Message.addToRepeatedField(this, 2, value, opt_index); -}; - - -/** - * Clears the list making it empty but non-null. - */ -proto.protoBuf.ComputeResponse.prototype.clearUnavailableSitesList = function() { - this.setUnavailableSitesList([]); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.protoBuf.MapRequest.prototype.toObject = function(opt_includeInstance) { - return proto.protoBuf.MapRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.protoBuf.MapRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.protoBuf.MapRequest.toObject = function(includeInstance, msg) { - var f, obj = { - id: jspb.Message.getFieldWithDefault(msg, 1, 0), - req: jspb.Message.getFieldWithDefault(msg, 2, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.protoBuf.MapRequest} - */ -proto.protoBuf.MapRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.protoBuf.MapRequest; - return proto.protoBuf.MapRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.protoBuf.MapRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.protoBuf.MapRequest} - */ -proto.protoBuf.MapRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {number} */ (reader.readInt64()); - msg.setId(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setReq(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.protoBuf.MapRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.protoBuf.MapRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.protoBuf.MapRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.protoBuf.MapRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getId(); - if (f !== 0) { - writer.writeInt64( - 1, - f - ); - } - f = message.getReq(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } -}; - - -/** - * optional int64 id = 1; - * @return {number} - */ -proto.protoBuf.MapRequest.prototype.getId = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** @param {number} value */ -proto.protoBuf.MapRequest.prototype.setId = function(value) { - jspb.Message.setProto3IntField(this, 1, value); -}; - - -/** - * optional string req = 2; - * @return {string} - */ -proto.protoBuf.MapRequest.prototype.getReq = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** @param {string} value */ -proto.protoBuf.MapRequest.prototype.setReq = function(value) { - jspb.Message.setProto3StringField(this, 2, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.protoBuf.MapResponse.prototype.toObject = function(opt_includeInstance) { - return proto.protoBuf.MapResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.protoBuf.MapResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.protoBuf.MapResponse.toObject = function(includeInstance, msg) { - var f, obj = { - response: jspb.Message.getFieldWithDefault(msg, 1, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.protoBuf.MapResponse} - */ -proto.protoBuf.MapResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.protoBuf.MapResponse; - return proto.protoBuf.MapResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.protoBuf.MapResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.protoBuf.MapResponse} - */ -proto.protoBuf.MapResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setResponse(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.protoBuf.MapResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.protoBuf.MapResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.protoBuf.MapResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.protoBuf.MapResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getResponse(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } -}; - - -/** - * optional string response = 1; - * @return {string} - */ -proto.protoBuf.MapResponse.prototype.getResponse = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** @param {string} value */ -proto.protoBuf.MapResponse.prototype.setResponse = function(value) { - jspb.Message.setProto3StringField(this, 1, value); -}; - - - -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.protoBuf.MapResponses.repeatedFields_ = [1,2]; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.protoBuf.MapResponses.prototype.toObject = function(opt_includeInstance) { - return proto.protoBuf.MapResponses.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.protoBuf.MapResponses} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.protoBuf.MapResponses.toObject = function(includeInstance, msg) { - var f, obj = { - responsesList: jspb.Message.toObjectList(msg.getResponsesList(), - proto.protoBuf.MapResponse.toObject, includeInstance), - unavailableSitesList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.protoBuf.MapResponses} - */ -proto.protoBuf.MapResponses.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.protoBuf.MapResponses; - return proto.protoBuf.MapResponses.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.protoBuf.MapResponses} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.protoBuf.MapResponses} - */ -proto.protoBuf.MapResponses.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.protoBuf.MapResponse; - reader.readMessage(value,proto.protoBuf.MapResponse.deserializeBinaryFromReader); - msg.addResponses(value); - break; - case 2: - var value = /** @type {!Array} */ (reader.readPackedInt32()); - msg.setUnavailableSitesList(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.protoBuf.MapResponses.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.protoBuf.MapResponses.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.protoBuf.MapResponses} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.protoBuf.MapResponses.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getResponsesList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 1, - f, - proto.protoBuf.MapResponse.serializeBinaryToWriter - ); - } - f = message.getUnavailableSitesList(); - if (f.length > 0) { - writer.writePackedInt32( - 2, - f - ); - } -}; - - -/** - * repeated MapResponse responses = 1; - * @return {!Array} - */ -proto.protoBuf.MapResponses.prototype.getResponsesList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.protoBuf.MapResponse, 1)); -}; - - -/** @param {!Array} value */ -proto.protoBuf.MapResponses.prototype.setResponsesList = function(value) { - jspb.Message.setRepeatedWrapperField(this, 1, value); -}; - - -/** - * @param {!proto.protoBuf.MapResponse=} opt_value - * @param {number=} opt_index - * @return {!proto.protoBuf.MapResponse} - */ -proto.protoBuf.MapResponses.prototype.addResponses = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.protoBuf.MapResponse, opt_index); -}; - - -/** - * Clears the list making it empty but non-null. - */ -proto.protoBuf.MapResponses.prototype.clearResponsesList = function() { - this.setResponsesList([]); -}; - - -/** - * repeated int32 unavailable_sites = 2; - * @return {!Array} - */ -proto.protoBuf.MapResponses.prototype.getUnavailableSitesList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); -}; - - -/** @param {!Array} value */ -proto.protoBuf.MapResponses.prototype.setUnavailableSitesList = function(value) { - jspb.Message.setField(this, 2, value || []); -}; - - -/** - * @param {number} value - * @param {number=} opt_index - */ -proto.protoBuf.MapResponses.prototype.addUnavailableSites = function(value, opt_index) { - jspb.Message.addToRepeatedField(this, 2, value, opt_index); -}; - - -/** - * Clears the list making it empty but non-null. - */ -proto.protoBuf.MapResponses.prototype.clearUnavailableSitesList = function() { - this.setUnavailableSitesList([]); -}; - - -goog.object.extend(exports, proto.protoBuf); diff --git a/webapp/backend/restserver/views.py b/webapp/backend/restserver/views.py index 71a2a75..fab6ca1 100644 --- a/webapp/backend/restserver/views.py +++ b/webapp/backend/restserver/views.py @@ -1,15 +1,36 @@ +import sys +sys.path.append("/home/stolet/gopath/src/leap") + from django.http import Http404 + +# from django.conf import settings +# import os from rest_framework.views import APIView from rest_framework.response import Response from rest_framework import status +import api.leap as leap +import api.leap_fn as leap_fn +import api.codes as codes +import cloudalgo.functions as cloud_functions + class ComputeView(APIView): """ API endpoint that sends requests from the web portal to the LEAP infrastructure. """ def post(self, request, format=None): - print("Got POST for compute") + leap_predef = None + if request.dp: + leap_predef = leap_fn.PrivatePredefinedFunction(codes.PRIVATE_SITE_COUNT_ALGO, epsilon=1, delta=0) + else: + leap_predef = leap_fn.PredefinedFunction(codes.COUNT_ALGO) + + selector = "[age] > 50 and [bmi] < 25" + leap_predef.selector = selector + dist_leap = leap.DistributedLeap(leap_predef) + print(dist_leap.get_result()) + return Response(status=status.HTTP_200_OK) class SitesView(APIView): @@ -19,5 +40,4 @@ class SitesView(APIView): """ def get(self, request, format=None): - print("Got GET for sites") return Response(status=status.HTTP_200_OK) diff --git a/webapp/backend/webbackend/settings.py b/webapp/backend/webbackend/settings.py index 37e0c98..9ed4a3c 100644 --- a/webapp/backend/webbackend/settings.py +++ b/webapp/backend/webbackend/settings.py @@ -16,6 +16,7 @@ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +# FILES_DIR = os.path.abspath(os.path.join(BASE_DIR, '../../../')) # Quick-start development settings - unsuitable for production diff --git a/webapp/frontend/package.json b/webapp/frontend/package.json index e46c42e..d53a3e1 100644 --- a/webapp/frontend/package.json +++ b/webapp/frontend/package.json @@ -3,18 +3,22 @@ "version": "0.1.0", "private": true, "dependencies": { + "@material-ui/core": "^4.9.2", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", "axios": "^0.19.2", + "flexbox-react": "^4.4.0", "google-protobuf": "^3.11.3", "grpc-web": "^1.0.7", "protoc-gen-grpc": "^1.4.0", "react": "^16.12.0", "react-dom": "^16.12.0", + "react-icons": "^3.9.0", "react-progress-button": "^5.1.0", "react-router-dom": "^5.1.2", "react-scripts": "3.3.0", + "react-table": "^7.0.0-rc.15", "serialize-javascript": "^2.1.2" }, "scripts": { diff --git a/webapp/frontend/src/components/QuestionTable/QuestionTable.js b/webapp/frontend/src/components/QuestionTable/QuestionTable.js new file mode 100644 index 0000000..4e4f0ba --- /dev/null +++ b/webapp/frontend/src/components/QuestionTable/QuestionTable.js @@ -0,0 +1,114 @@ +import React from 'react'; +import Table from '@material-ui/core/Table'; +import TableBody from '@material-ui/core/TableBody'; +import TableCell from '@material-ui/core/TableCell'; +import TableContainer from '@material-ui/core/TableContainer'; +import TableHead from '@material-ui/core/TableHead'; +import TableRow from '@material-ui/core/TableRow'; +import Paper from '@material-ui/core/Paper'; +import Button from "../Button/Button"; + +class QuestionTable extends React.Component { + constructor(props) { + super(props); + this.state = {buttonState: "", queryResult: []}; + this.useStyles = { + table: { + minWidth: 650, + }, + } + this.classes = this.useStyles; + this.rows = [] + if (this.state.queryResult.length === 0) { + this.rows = [ + this.createData(1, + 'How many women in our database have been previously pregnant?', + true, + ''), + this.createData(1, + 'What is the median age of first pregnancy?', + true, + ''), + this.createData(1, + 'What is the median pain level of pregnancies?', + false, + ''), + this.createData(1, + 'Is age at first pregnancy associated with pain level?', + true, + ''), + ]; + } else { + this.rows = [ + this.createData(1, + 'How many women in our database have been previously pregnant?', + true, + ''), + this.createData(1, + 'What is the median age of first pregnancy?', + true, + ''), + this.createData(1, + 'What is the median pain level of pregnancies?', + false, + ''), + this.createData(1, + 'Is age at first pregnancy associated with pain level?', + true, + ''), + ]; + } + + } + + returnDp(dp) { + if (dp) { + return "On" + } else { + return "Off" + } + } + + createData(id, question, dp, result) { + return {id, question, dp, result}; + } + + render() { + return ( + + + + + + DP + Question + Result + Get Result + + + + {this.rows.map(row => { + + return ( + + {this.returnDp(row.dp)} + {row.question} + {row.result} + + {
+
+ ) + } +} + +export default QuestionTable \ No newline at end of file diff --git a/webapp/frontend/src/components/SimpleTable/SimpleTable.js b/webapp/frontend/src/components/SimpleTable/SimpleTable.js new file mode 100644 index 0000000..39fa077 --- /dev/null +++ b/webapp/frontend/src/components/SimpleTable/SimpleTable.js @@ -0,0 +1,89 @@ +import React from 'react'; +import {makeStyles} from '@material-ui/core/styles'; +import Table from '@material-ui/core/Table'; +import TableBody from '@material-ui/core/TableBody'; +import TableCell from '@material-ui/core/TableCell'; +import TableContainer from '@material-ui/core/TableContainer'; +import TableHead from '@material-ui/core/TableHead'; +import TableRow from '@material-ui/core/TableRow'; +import Paper from '@material-ui/core/Paper'; +import {MdSignalCellular4Bar, MdSignalCellularOff} from 'react-icons/md' + +const useStyles = makeStyles({ + table: { + minWidth: 650, + }, +}); + +function createData(id, available) { + return {id, available}; +} + +const rows = [ + createData('Site 1', true), + createData('Site 2', true), + createData('Site 3', false), + createData('Site 4', true), + createData('Site 5', false), +]; + +function returnAvailableIcon(available) { + if (available) { + return + } else { + return + } +} + +export default function SimpleTable() { + const classes = useStyles(); + const [selected, setSelected] = React.useState([]); + + const handleClick = (event, id) => { + const selectedIndex = selected.indexOf(id); + let newSelected = []; + if (selectedIndex === -1) { + newSelected = newSelected.concat(selected, id); + } else if (selectedIndex === 0) { + newSelected = newSelected.concat(selected.slice(1)); + } else if (selectedIndex === selected.length - 1) { + newSelected = newSelected.concat(selected.slice(0, -1)); + } else if (selectedIndex > 0) { + newSelected = newSelected.concat( + selected.slice(0, selectedIndex), + selected.slice(selectedIndex + 1), + ); + } + setSelected(newSelected); + }; + + const isSelected = name => selected.indexOf(name) !== -1; + + return ( + + + + + Site ID + Available + + + + {rows.map(row => { + const isItemSelected = isSelected(row.id); + return ( + handleClick(event, row.id)}> + + {row.id} + + {returnAvailableIcon(row.available)} + ) + })} + +
+
+ ); +} \ No newline at end of file diff --git a/webapp/frontend/src/pages/Home/Home.css b/webapp/frontend/src/pages/Home/Home.css index 6e8ae9e..e69de29 100644 --- a/webapp/frontend/src/pages/Home/Home.css +++ b/webapp/frontend/src/pages/Home/Home.css @@ -1,3 +0,0 @@ -.ComputeButton { - background: aqua; -} \ No newline at end of file diff --git a/webapp/frontend/src/pages/Home/Home.js b/webapp/frontend/src/pages/Home/Home.js index 4151c44..68d3b93 100644 --- a/webapp/frontend/src/pages/Home/Home.js +++ b/webapp/frontend/src/pages/Home/Home.js @@ -1,13 +1,17 @@ import React from "react"; +import Flexbox from "flexbox-react" + import "./Home.css" -import Button from "../../components/Button/Button" import ComputeService from "../../services/ComputeService" +import SimpleTable from "../../components/SimpleTable/SimpleTable"; +import QuestionTable from "../../components/QuestionTable/QuestionTable"; +import Divider from '@material-ui/core/Divider'; class Home extends React.Component { constructor(props) { super(props); - this.state = { queryResult: null}; + this.state = {queryResult: []}; this.computeService = new ComputeService(); this.handleComputeClick = this.handleComputeClick.bind(this); this.ButtonElement = React.createRef(); @@ -15,40 +19,52 @@ class Home extends React.Component { handleComputeClick() { this.computeService.compute({dp: false, algo: "count"}).then(res => { - console.log("Something is working"); - this.setState({queryResult: res.computationResult}); + this.setState({queryResult: [128]}); this.ButtonElement.current.changeState('success'); }).catch(err => { this.ButtonElement.current.changeState('error'); }) - - // , res => { - // console.log("Something is working"); - // this.setState({queryResult: res.computationResult}); - // this.ButtonElement.current.changeState('success'); - // }).catch(err => { - // console.log("Is this the error?"); - // console.log(err); - // console.log("Yes sir!"); - // this.ButtonElement.current.changeState('error'); - // }); } render() { return ( -
- How many women in our database have been previously pregnant? -
-
-
+ + + + + + + + + + + + + + + + + + + + + + + + ); } } -export default Home \ No newline at end of file +export default Home + +// +//
How many women in our database have been previously pregnant?
+//