From ec969eed776302729c27af1886c526b730696e54 Mon Sep 17 00:00:00 2001 From: Nico Melone Date: Mon, 13 Apr 2020 16:01:17 -0500 Subject: [PATCH] initial add --- .gitignore | 14 - .../#current-cloud-backend/amplify-meta.json | 56 +++ ...treact8c9024fb-cloudformation-template.yml | 369 +++++++++++++++++ .../auth/hpiotreact8c9024fb/parameters.json | 53 +++ .../backend-config.json | 16 + .../hosting/S3AndCloudFront/parameters.json | 3 + .../hosting/S3AndCloudFront/template.json | 113 ++++++ amplify/.config/local-aws-info.json | 7 + amplify/.config/local-env-info.json | 5 + amplify/backend/amplify-meta.json | 56 +++ .../nested-cloudformation-stack.yml | 371 ++++++++++++++++++ package.json | 1 + public/favicon.ico | Bin 3150 -> 3230 bytes public/icon-512x512.png | Bin 0 -> 9498 bytes public/index.html | 2 +- src/App.css | 19 - src/App.js | 80 +--- src/aws-exports.js | 18 + src/charts/BarChart.js | 6 +- src/charts/LineChart.js | 28 +- yarn.lock | 269 ++++++++++++- 21 files changed, 1359 insertions(+), 127 deletions(-) create mode 100644 amplify/#current-cloud-backend/amplify-meta.json create mode 100644 amplify/#current-cloud-backend/auth/hpiotreact8c9024fb/hpiotreact8c9024fb-cloudformation-template.yml create mode 100644 amplify/#current-cloud-backend/auth/hpiotreact8c9024fb/parameters.json create mode 100644 amplify/#current-cloud-backend/backend-config.json create mode 100644 amplify/#current-cloud-backend/hosting/S3AndCloudFront/parameters.json create mode 100644 amplify/#current-cloud-backend/hosting/S3AndCloudFront/template.json create mode 100644 amplify/.config/local-aws-info.json create mode 100644 amplify/.config/local-env-info.json create mode 100644 amplify/backend/amplify-meta.json create mode 100644 amplify/backend/awscloudformation/nested-cloudformation-stack.yml create mode 100644 public/icon-512x512.png create mode 100644 src/aws-exports.js diff --git a/.gitignore b/.gitignore index 9674820..448863b 100644 --- a/.gitignore +++ b/.gitignore @@ -22,17 +22,3 @@ npm-debug.log* yarn-debug.log* yarn-error.log* -#amplify -amplify/\#current-cloud-backend -amplify/.config/local-* -amplify/mock-data -amplify/backend/amplify-meta.json -amplify/backend/awscloudformation -build/ -dist/ -node_modules/ -aws-exports.js -awsconfiguration.json -amplifyconfiguration.json -amplify-gradle-config.json -amplifyxc.config \ No newline at end of file diff --git a/amplify/#current-cloud-backend/amplify-meta.json b/amplify/#current-cloud-backend/amplify-meta.json new file mode 100644 index 0000000..cc42911 --- /dev/null +++ b/amplify/#current-cloud-backend/amplify-meta.json @@ -0,0 +1,56 @@ +{ + "providers": { + "awscloudformation": { + "AuthRoleName": "amplify-hpiot-react-hpiot-162610-authRole", + "UnauthRoleArn": "arn:aws:iam::860246592755:role/amplify-hpiot-react-hpiot-162610-unauthRole", + "AuthRoleArn": "arn:aws:iam::860246592755:role/amplify-hpiot-react-hpiot-162610-authRole", + "Region": "us-east-1", + "DeploymentBucketName": "amplify-hpiot-react-hpiot-162610-deployment", + "UnauthRoleName": "amplify-hpiot-react-hpiot-162610-unauthRole", + "StackName": "amplify-hpiot-react-hpiot-162610", + "StackId": "arn:aws:cloudformation:us-east-1:860246592755:stack/amplify-hpiot-react-hpiot-162610/1913c1f0-64a8-11ea-baa2-0ee5b74c6229", + "AmplifyAppId": "d3hyexpjn33q6q" + } + }, + "hosting": { + "S3AndCloudFront": { + "service": "S3AndCloudFront", + "providerPlugin": "awscloudformation", + "providerMetadata": { + "s3TemplateURL": "https://s3.amazonaws.com/amplify-hpiot-react-hpiot-162610-deployment/amplify-cfn-templates/hosting/template.json", + "logicalId": "hostingS3AndCloudFront" + }, + "lastPushTimeStamp": "2020-03-12T21:33:05.218Z", + "output": { + "S3BucketSecureURL": "https://hpiot-react-hpiot.s3.amazonaws.com", + "WebsiteURL": "http://hpiot-react-hpiot.s3-website-us-east-1.amazonaws.com", + "Region": "us-east-1", + "HostingBucketName": "hpiot-react-hpiot" + }, + "lastPushDirHash": "NulnbGKP8lFEe2FacQkja5CAJcc=" + } + }, + "auth": { + "hpiotreact8c9024fb": { + "service": "Cognito", + "providerPlugin": "awscloudformation", + "dependsOn": [], + "customAuth": false, + "providerMetadata": { + "s3TemplateURL": "https://s3.amazonaws.com/amplify-hpiot-react-hpiot-162610-deployment/amplify-cfn-templates/auth/hpiotreact8c9024fb-cloudformation-template.yml", + "logicalId": "authhpiotreact8c9024fb" + }, + "lastPushTimeStamp": "2020-03-12T21:33:05.218Z", + "output": { + "AppClientSecret": "msldgo1telohjsm20p8nn58f15iensrjup7cb1712tirkcrooou", + "UserPoolId": "us-east-1_L6XsGIASX", + "AppClientIDWeb": "63ieddff77nfc3i151m8l8k3ip", + "AppClientID": "3b1gubo57cng5p2avotsgr75ji", + "IdentityPoolId": "us-east-1:20972146-c6fe-4ada-a723-d1debcc7d074", + "IdentityPoolName": "hpiotreact8c9024fb_identitypool_8c9024fb__hpiot", + "UserPoolName": "hpiotreact8c9024fb_userpool_8c9024fb" + }, + "lastPushDirHash": "UsD33D5D2jMU3hAfHMEhFJOINGM=" + } + } +} \ No newline at end of file diff --git a/amplify/#current-cloud-backend/auth/hpiotreact8c9024fb/hpiotreact8c9024fb-cloudformation-template.yml b/amplify/#current-cloud-backend/auth/hpiotreact8c9024fb/hpiotreact8c9024fb-cloudformation-template.yml new file mode 100644 index 0000000..0159d22 --- /dev/null +++ b/amplify/#current-cloud-backend/auth/hpiotreact8c9024fb/hpiotreact8c9024fb-cloudformation-template.yml @@ -0,0 +1,369 @@ +AWSTemplateFormatVersion: 2010-09-09 + +Parameters: + env: + Type: String + authRoleArn: + Type: String + unauthRoleArn: + Type: String + + + + + identityPoolName: + Type: String + + allowUnauthenticatedIdentities: + Type: String + + resourceNameTruncated: + Type: String + + userPoolName: + Type: String + + autoVerifiedAttributes: + Type: CommaDelimitedList + + mfaConfiguration: + Type: String + + mfaTypes: + Type: CommaDelimitedList + + smsAuthenticationMessage: + Type: String + + smsVerificationMessage: + Type: String + + emailVerificationSubject: + Type: String + + emailVerificationMessage: + Type: String + + defaultPasswordPolicy: + Type: String + + passwordPolicyMinLength: + Type: Number + + passwordPolicyCharacters: + Type: CommaDelimitedList + + requiredAttributes: + Type: CommaDelimitedList + + userpoolClientGenerateSecret: + Type: String + + userpoolClientRefreshTokenValidity: + Type: Number + + userpoolClientWriteAttributes: + Type: CommaDelimitedList + + userpoolClientReadAttributes: + Type: CommaDelimitedList + + userpoolClientLambdaRole: + Type: String + + userpoolClientSetAttributes: + Type: String + + resourceName: + Type: String + + authSelections: + Type: String + + useDefault: + Type: String + + usernameAttributes: + Type: CommaDelimitedList + + userPoolGroupList: + Type: CommaDelimitedList + + dependsOn: + Type: CommaDelimitedList + +Conditions: + ShouldNotCreateEnvResources: !Equals [ !Ref env, NONE ] + +Resources: + + + # BEGIN SNS ROLE RESOURCE + SNSRole: + # Created to allow the UserPool SMS Config to publish via the Simple Notification Service during MFA Process + Type: AWS::IAM::Role + Properties: + RoleName: !If [ShouldNotCreateEnvResources, 'hpiotr8c9024fb_sns-role', !Join ['',[ 'sns', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]] + AssumeRolePolicyDocument: + Version: "2012-10-17" + Statement: + - Sid: "" + Effect: "Allow" + Principal: + Service: "cognito-idp.amazonaws.com" + Action: + - "sts:AssumeRole" + Condition: + StringEquals: + sts:ExternalId: hpiotr8c9024fb_role_external_id + Policies: + - + PolicyName: hpiotr8c9024fb-sns-policy + PolicyDocument: + Version: "2012-10-17" + Statement: + - + Effect: "Allow" + Action: + - "sns:Publish" + Resource: "*" + # BEGIN USER POOL RESOURCES + UserPool: + # Created upon user selection + # Depends on SNS Role for Arn if MFA is enabled + Type: AWS::Cognito::UserPool + UpdateReplacePolicy: Retain + Properties: + UserPoolName: !If [ShouldNotCreateEnvResources, !Ref userPoolName, !Join ['',[!Ref userPoolName, '-', !Ref env]]] + + Schema: + + - + Name: email + Required: true + Mutable: true + + + + + AutoVerifiedAttributes: !Ref autoVerifiedAttributes + + + EmailVerificationMessage: !Ref emailVerificationMessage + EmailVerificationSubject: !Ref emailVerificationSubject + + Policies: + PasswordPolicy: + MinimumLength: !Ref passwordPolicyMinLength + RequireLowercase: false + RequireNumbers: false + RequireSymbols: false + RequireUppercase: false + + UsernameAttributes: !Ref usernameAttributes + + MfaConfiguration: !Ref mfaConfiguration + SmsVerificationMessage: !Ref smsVerificationMessage + SmsConfiguration: + SnsCallerArn: !GetAtt SNSRole.Arn + ExternalId: hpiotr8c9024fb_role_external_id + + + UserPoolClientWeb: + # Created provide application access to user pool + # Depends on UserPool for ID reference + Type: "AWS::Cognito::UserPoolClient" + Properties: + ClientName: hpiotr8c9024fb_app_clientWeb + + RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity + UserPoolId: !Ref UserPool + DependsOn: UserPool + UserPoolClient: + # Created provide application access to user pool + # Depends on UserPool for ID reference + Type: "AWS::Cognito::UserPoolClient" + Properties: + ClientName: hpiotr8c9024fb_app_client + + GenerateSecret: !Ref userpoolClientGenerateSecret + RefreshTokenValidity: !Ref userpoolClientRefreshTokenValidity + UserPoolId: !Ref UserPool + DependsOn: UserPool + # BEGIN USER POOL LAMBDA RESOURCES + UserPoolClientRole: + # Created to execute Lambda which gets userpool app client config values + Type: 'AWS::IAM::Role' + Properties: + RoleName: !If [ShouldNotCreateEnvResources, !Ref userpoolClientLambdaRole, !Join ['',['upClientLambdaRole', !Select [3, !Split ['-', !Ref 'AWS::StackName']], '-', !Ref env]]] + AssumeRolePolicyDocument: + Version: '2012-10-17' + Statement: + - Effect: Allow + Principal: + Service: + - lambda.amazonaws.com + Action: + - 'sts:AssumeRole' + DependsOn: UserPoolClient + UserPoolClientLambda: + # Lambda which gets userpool app client config values + # Depends on UserPool for id + # Depends on UserPoolClientRole for role ARN + Type: 'AWS::Lambda::Function' + Properties: + Code: + ZipFile: !Join + - |+ + - - 'const response = require(''cfn-response'');' + - 'const aws = require(''aws-sdk'');' + - 'const identity = new aws.CognitoIdentityServiceProvider();' + - 'exports.handler = (event, context, callback) => {' + - ' if (event.RequestType == ''Delete'') { ' + - ' response.send(event, context, response.SUCCESS, {})' + - ' }' + - ' if (event.RequestType == ''Update'' || event.RequestType == ''Create'') {' + - ' const params = {' + - ' ClientId: event.ResourceProperties.clientId,' + - ' UserPoolId: event.ResourceProperties.userpoolId' + - ' };' + - ' identity.describeUserPoolClient(params).promise()' + - ' .then((res) => {' + - ' response.send(event, context, response.SUCCESS, {''appSecret'': res.UserPoolClient.ClientSecret});' + - ' })' + - ' .catch((err) => {' + - ' response.send(event, context, response.FAILED, {err});' + - ' });' + - ' }' + - '};' + Handler: index.handler + Runtime: nodejs10.x + Timeout: '300' + Role: !GetAtt + - UserPoolClientRole + - Arn + DependsOn: UserPoolClientRole + UserPoolClientLambdaPolicy: + # Sets userpool policy for the role that executes the Userpool Client Lambda + # Depends on UserPool for Arn + # Marked as depending on UserPoolClientRole for easier to understand CFN sequencing + Type: 'AWS::IAM::Policy' + Properties: + PolicyName: hpiotr8c9024fb_userpoolclient_lambda_iam_policy + Roles: + - !Ref UserPoolClientRole + PolicyDocument: + Version: '2012-10-17' + Statement: + - Effect: Allow + Action: + - 'cognito-idp:DescribeUserPoolClient' + Resource: !GetAtt UserPool.Arn + DependsOn: UserPoolClientLambda + UserPoolClientLogPolicy: + # Sets log policy for the role that executes the Userpool Client Lambda + # Depends on UserPool for Arn + # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing + Type: 'AWS::IAM::Policy' + Properties: + PolicyName: hpiotr8c9024fb_userpoolclient_lambda_log_policy + Roles: + - !Ref UserPoolClientRole + PolicyDocument: + Version: 2012-10-17 + Statement: + - Effect: Allow + Action: + - 'logs:CreateLogGroup' + - 'logs:CreateLogStream' + - 'logs:PutLogEvents' + Resource: !Sub + - arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:* + - { region: !Ref "AWS::Region", account: !Ref "AWS::AccountId", lambda: !Ref UserPoolClientLambda} + DependsOn: UserPoolClientLambdaPolicy + UserPoolClientInputs: + # Values passed to Userpool client Lambda + # Depends on UserPool for Id + # Depends on UserPoolClient for Id + # Marked as depending on UserPoolClientLambdaPolicy for easier to understand CFN sequencing + Type: 'Custom::LambdaCallout' + Properties: + ServiceToken: !GetAtt UserPoolClientLambda.Arn + clientId: !Ref UserPoolClient + userpoolId: !Ref UserPool + DependsOn: UserPoolClientLogPolicy + + + + + + + + # BEGIN IDENTITY POOL RESOURCES + + + IdentityPool: + # Always created + Type: AWS::Cognito::IdentityPool + Properties: + IdentityPoolName: !If [ShouldNotCreateEnvResources, 'hpiotreact8c9024fb_identitypool_8c9024fb', !Join ['',['hpiotreact8c9024fb_identitypool_8c9024fb', '__', !Ref env]]] + + CognitoIdentityProviders: + - ClientId: !Ref UserPoolClient + ProviderName: !Sub + - cognito-idp.${region}.amazonaws.com/${client} + - { region: !Ref "AWS::Region", client: !Ref UserPool} + - ClientId: !Ref UserPoolClientWeb + ProviderName: !Sub + - cognito-idp.${region}.amazonaws.com/${client} + - { region: !Ref "AWS::Region", client: !Ref UserPool} + + AllowUnauthenticatedIdentities: !Ref allowUnauthenticatedIdentities + + + DependsOn: UserPoolClientInputs + + + IdentityPoolRoleMap: + # Created to map Auth and Unauth roles to the identity pool + # Depends on Identity Pool for ID ref + Type: AWS::Cognito::IdentityPoolRoleAttachment + Properties: + IdentityPoolId: !Ref IdentityPool + Roles: + unauthenticated: !Ref unauthRoleArn + authenticated: !Ref authRoleArn + DependsOn: IdentityPool + + +Outputs : + + IdentityPoolId: + Value: !Ref 'IdentityPool' + Description: Id for the identity pool + IdentityPoolName: + Value: !GetAtt IdentityPool.Name + + + + + UserPoolId: + Value: !Ref 'UserPool' + Description: Id for the user pool + UserPoolName: + Value: !Ref userPoolName + AppClientIDWeb: + Value: !Ref 'UserPoolClientWeb' + Description: The user pool app client id for web + AppClientID: + Value: !Ref 'UserPoolClient' + Description: The user pool app client id + AppClientSecret: + Value: !GetAtt UserPoolClientInputs.appSecret + + + + + + + diff --git a/amplify/#current-cloud-backend/auth/hpiotreact8c9024fb/parameters.json b/amplify/#current-cloud-backend/auth/hpiotreact8c9024fb/parameters.json new file mode 100644 index 0000000..a7b85a9 --- /dev/null +++ b/amplify/#current-cloud-backend/auth/hpiotreact8c9024fb/parameters.json @@ -0,0 +1,53 @@ +{ + "identityPoolName": "hpiotreact8c9024fb_identitypool_8c9024fb", + "allowUnauthenticatedIdentities": false, + "resourceNameTruncated": "hpiotr8c9024fb", + "userPoolName": "hpiotreact8c9024fb_userpool_8c9024fb", + "autoVerifiedAttributes": [ + "email" + ], + "mfaConfiguration": "OFF", + "mfaTypes": [ + "SMS Text Message" + ], + "smsAuthenticationMessage": "Your authentication code is {####}", + "smsVerificationMessage": "Your verification code is {####}", + "emailVerificationSubject": "Your verification code", + "emailVerificationMessage": "Your verification code is {####}", + "defaultPasswordPolicy": false, + "passwordPolicyMinLength": 8, + "passwordPolicyCharacters": [], + "requiredAttributes": [ + "email" + ], + "userpoolClientGenerateSecret": true, + "userpoolClientRefreshTokenValidity": 30, + "userpoolClientWriteAttributes": [ + "email" + ], + "userpoolClientReadAttributes": [ + "email" + ], + "userpoolClientLambdaRole": "hpiotr8c9024fb_userpoolclient_lambda_role", + "userpoolClientSetAttributes": false, + "resourceName": "hpiotreact8c9024fb", + "authSelections": "identityPoolAndUserPool", + "authRoleArn": { + "Fn::GetAtt": [ + "AuthRole", + "Arn" + ] + }, + "unauthRoleArn": { + "Fn::GetAtt": [ + "UnauthRole", + "Arn" + ] + }, + "useDefault": "default", + "usernameAttributes": [ + "email" + ], + "userPoolGroupList": [], + "dependsOn": [] +} \ No newline at end of file diff --git a/amplify/#current-cloud-backend/backend-config.json b/amplify/#current-cloud-backend/backend-config.json new file mode 100644 index 0000000..2694335 --- /dev/null +++ b/amplify/#current-cloud-backend/backend-config.json @@ -0,0 +1,16 @@ +{ + "hosting": { + "S3AndCloudFront": { + "service": "S3AndCloudFront", + "providerPlugin": "awscloudformation" + } + }, + "auth": { + "hpiotreact8c9024fb": { + "service": "Cognito", + "providerPlugin": "awscloudformation", + "dependsOn": [], + "customAuth": false + } + } +} \ No newline at end of file diff --git a/amplify/#current-cloud-backend/hosting/S3AndCloudFront/parameters.json b/amplify/#current-cloud-backend/hosting/S3AndCloudFront/parameters.json new file mode 100644 index 0000000..629829f --- /dev/null +++ b/amplify/#current-cloud-backend/hosting/S3AndCloudFront/parameters.json @@ -0,0 +1,3 @@ +{ + "bucketName": "hpiot-react" +} \ No newline at end of file diff --git a/amplify/#current-cloud-backend/hosting/S3AndCloudFront/template.json b/amplify/#current-cloud-backend/hosting/S3AndCloudFront/template.json new file mode 100644 index 0000000..d98d689 --- /dev/null +++ b/amplify/#current-cloud-backend/hosting/S3AndCloudFront/template.json @@ -0,0 +1,113 @@ +{ + "AWSTemplateFormatVersion": "2010-09-09", + "Description": "Hosting resource stack creation using Amplify CLI", + "Parameters": { + "env": { + "Type": "String" + }, + "bucketName": { + "Type": "String" + } + }, + "Conditions": { + "ShouldNotCreateEnvResources": { + "Fn::Equals": [ + { + "Ref": "env" + }, + "NONE" + ] + } + }, + "Resources": { + "S3Bucket": { + "Type": "AWS::S3::Bucket", + "DeletionPolicy": "Retain", + "Properties": { + "BucketName": { + "Fn::If": [ + "ShouldNotCreateEnvResources", + { + "Ref": "bucketName" + }, + { + "Fn::Join": [ + "", + [ + { + "Ref": "bucketName" + }, + "-", + { + "Ref": "env" + } + ] + ] + } + ] + }, + "AccessControl": "Private", + "WebsiteConfiguration": { + "IndexDocument": "index.html", + "ErrorDocument": "index.html" + }, + "CorsConfiguration": { + "CorsRules": [ + { + "AllowedHeaders": [ + "Authorization", + "Content-Length" + ], + "AllowedMethods": [ + "GET" + ], + "AllowedOrigins": [ + "*" + ], + "MaxAge": 3000 + } + ] + } + } + } + }, + "Outputs": { + "Region": { + "Value": { + "Ref": "AWS::Region" + } + }, + "HostingBucketName": { + "Description": "Hosting bucket name", + "Value": { + "Ref": "S3Bucket" + } + }, + "WebsiteURL": { + "Value": { + "Fn::GetAtt": [ + "S3Bucket", + "WebsiteURL" + ] + }, + "Description": "URL for website hosted on S3" + }, + "S3BucketSecureURL": { + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Fn::GetAtt": [ + "S3Bucket", + "DomainName" + ] + } + ] + ] + }, + "Description": "Name of S3 bucket to hold website content" + } + } +} \ No newline at end of file diff --git a/amplify/.config/local-aws-info.json b/amplify/.config/local-aws-info.json new file mode 100644 index 0000000..0f870d7 --- /dev/null +++ b/amplify/.config/local-aws-info.json @@ -0,0 +1,7 @@ +{ + "hpiot": { + "configLevel": "project", + "useProfile": true, + "profileName": "default" + } +} \ No newline at end of file diff --git a/amplify/.config/local-env-info.json b/amplify/.config/local-env-info.json new file mode 100644 index 0000000..c959c3e --- /dev/null +++ b/amplify/.config/local-env-info.json @@ -0,0 +1,5 @@ +{ + "projectPath": "/mnt/c/Users/Nico Melone/Documents/React Website/hpiot-react", + "defaultEditor": "vscode", + "envName": "hpiot" +} \ No newline at end of file diff --git a/amplify/backend/amplify-meta.json b/amplify/backend/amplify-meta.json new file mode 100644 index 0000000..82968e7 --- /dev/null +++ b/amplify/backend/amplify-meta.json @@ -0,0 +1,56 @@ +{ + "providers": { + "awscloudformation": { + "AuthRoleName": "amplify-hpiot-react-hpiot-162610-authRole", + "UnauthRoleArn": "arn:aws:iam::860246592755:role/amplify-hpiot-react-hpiot-162610-unauthRole", + "AuthRoleArn": "arn:aws:iam::860246592755:role/amplify-hpiot-react-hpiot-162610-authRole", + "Region": "us-east-1", + "DeploymentBucketName": "amplify-hpiot-react-hpiot-162610-deployment", + "UnauthRoleName": "amplify-hpiot-react-hpiot-162610-unauthRole", + "StackName": "amplify-hpiot-react-hpiot-162610", + "StackId": "arn:aws:cloudformation:us-east-1:860246592755:stack/amplify-hpiot-react-hpiot-162610/1913c1f0-64a8-11ea-baa2-0ee5b74c6229", + "AmplifyAppId": "d3hyexpjn33q6q" + } + }, + "hosting": { + "S3AndCloudFront": { + "service": "S3AndCloudFront", + "providerPlugin": "awscloudformation", + "providerMetadata": { + "s3TemplateURL": "https://s3.amazonaws.com/amplify-hpiot-react-hpiot-162610-deployment/amplify-cfn-templates/hosting/template.json", + "logicalId": "hostingS3AndCloudFront" + }, + "lastPushTimeStamp": "2020-03-24T17:59:51.368Z", + "output": { + "S3BucketSecureURL": "https://hpiot-react-hpiot.s3.amazonaws.com", + "WebsiteURL": "http://hpiot-react-hpiot.s3-website-us-east-1.amazonaws.com", + "Region": "us-east-1", + "HostingBucketName": "hpiot-react-hpiot" + }, + "lastPushDirHash": "NulnbGKP8lFEe2FacQkja5CAJcc=" + } + }, + "auth": { + "hpiotreact8c9024fb": { + "service": "Cognito", + "providerPlugin": "awscloudformation", + "dependsOn": [], + "customAuth": false, + "providerMetadata": { + "s3TemplateURL": "https://s3.amazonaws.com/amplify-hpiot-react-hpiot-162610-deployment/amplify-cfn-templates/auth/hpiotreact8c9024fb-cloudformation-template.yml", + "logicalId": "authhpiotreact8c9024fb" + }, + "lastPushTimeStamp": "2020-03-24T17:59:51.373Z", + "output": { + "AppClientSecret": "msldgo1telohjsm20p8nn58f15iensrjup7cb1712tirkcrooou", + "UserPoolId": "us-east-1_L6XsGIASX", + "AppClientIDWeb": "63ieddff77nfc3i151m8l8k3ip", + "AppClientID": "3b1gubo57cng5p2avotsgr75ji", + "IdentityPoolId": "us-east-1:20972146-c6fe-4ada-a723-d1debcc7d074", + "IdentityPoolName": "hpiotreact8c9024fb_identitypool_8c9024fb__hpiot", + "UserPoolName": "hpiotreact8c9024fb_userpool_8c9024fb" + }, + "lastPushDirHash": "UsD33D5D2jMU3hAfHMEhFJOINGM=" + } + } +} \ No newline at end of file diff --git a/amplify/backend/awscloudformation/nested-cloudformation-stack.yml b/amplify/backend/awscloudformation/nested-cloudformation-stack.yml new file mode 100644 index 0000000..3ce7bfe --- /dev/null +++ b/amplify/backend/awscloudformation/nested-cloudformation-stack.yml @@ -0,0 +1,371 @@ +{ + "AWSTemplateFormatVersion": "2010-09-09", + "Description": "Root stack for the Amplify AWS CloudFormation provider", + "Parameters": { + "DeploymentBucketName": { + "Description": "Name of the common deployment bucket provided by the parent stack", + "Type": "String", + "Default": "DeploymentBucket" + }, + "AuthRoleName": { + "Type": "String", + "Default": "AuthRoleName" + }, + "UnauthRoleName": { + "Type": "String", + "Default": "UnauthRoleName" + } + }, + "Resources": { + "DeploymentBucket": { + "Type": "AWS::S3::Bucket", + "DeletionPolicy": "Retain", + "Properties": { + "BucketName": { + "Ref": "DeploymentBucketName" + } + } + }, + "AuthRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "RoleName": { + "Ref": "AuthRoleName" + }, + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "", + "Effect": "Deny", + "Principal": { + "Federated": "cognito-identity.amazonaws.com" + }, + "Action": "sts:AssumeRoleWithWebIdentity" + } + ] + } + } + }, + "UnauthRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "RoleName": { + "Ref": "UnauthRoleName" + }, + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "", + "Effect": "Deny", + "Principal": { + "Federated": "cognito-identity.amazonaws.com" + }, + "Action": "sts:AssumeRoleWithWebIdentity" + } + ] + } + } + }, + "hostingS3AndCloudFront": { + "Type": "AWS::CloudFormation::Stack", + "Properties": { + "TemplateURL": "https://s3.amazonaws.com/amplify-hpiot-react-hpiot-162610-deployment/amplify-cfn-templates/hosting/template.json", + "Parameters": { + "bucketName": "hpiot-react", + "env": "hpiot" + } + } + }, + "authhpiotreact8c9024fb": { + "Type": "AWS::CloudFormation::Stack", + "Properties": { + "TemplateURL": "https://s3.amazonaws.com/amplify-hpiot-react-hpiot-162610-deployment/amplify-cfn-templates/auth/hpiotreact8c9024fb-cloudformation-template.yml", + "Parameters": { + "identityPoolName": "hpiotwebapp78e5977f_identitypool_78e5977f", + "allowUnauthenticatedIdentities": false, + "resourceNameTruncated": "hpiotw78e5977f", + "userPoolName": "hpiotwebapp78e5977f_userpool_78e5977f", + "autoVerifiedAttributes": "email", + "mfaConfiguration": "OFF", + "mfaTypes": "SMS Text Message", + "smsAuthenticationMessage": "Your authentication code is {####}", + "smsVerificationMessage": "Your verification code is {####}", + "emailVerificationSubject": "Your verification code", + "emailVerificationMessage": "Your verification code is {####}", + "defaultPasswordPolicy": false, + "passwordPolicyMinLength": 8, + "passwordPolicyCharacters": "", + "requiredAttributes": "email", + "userpoolClientGenerateSecret": true, + "userpoolClientRefreshTokenValidity": 30, + "userpoolClientWriteAttributes": "email", + "userpoolClientReadAttributes": "email", + "userpoolClientLambdaRole": "hpiotw78e5977f_userpoolclient_lambda_role", + "userpoolClientSetAttributes": false, + "resourceName": "hpiotwebapp78e5977f", + "authSelections": "identityPoolAndUserPool", + "authRoleArn": { + "Fn::GetAtt": [ + "AuthRole", + "Arn" + ] + }, + "unauthRoleArn": { + "Fn::GetAtt": [ + "UnauthRole", + "Arn" + ] + }, + "useDefault": "default", + "usernameAttributes": "email, phone_number", + "dependsOn": "", + "env": "hpiot" + } + } + }, + "UpdateRolesWithIDPFunction": { + "DependsOn": [ + "AuthRole", + "UnauthRole", + "authhpiotreact8c9024fb" + ], + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": { + "Fn::Join": [ + "\n", + [ + "const response = require('cfn-response');", + "const aws = require('aws-sdk');", + "let responseData = {};", + "exports.handler = function(event, context) {", + " try {", + " let authRoleName = event.ResourceProperties.authRoleName;", + " let unauthRoleName = event.ResourceProperties.unauthRoleName;", + " let idpId = event.ResourceProperties.idpId;", + " let promises = [];", + " let authParamsJson = { 'Version': '2012-10-17','Statement': [{'Effect': 'Allow','Principal': {'Federated': 'cognito-identity.amazonaws.com'},'Action': 'sts:AssumeRoleWithWebIdentity','Condition': {'StringEquals': {'cognito-identity.amazonaws.com:aud': idpId},'ForAnyValue:StringLike': {'cognito-identity.amazonaws.com:amr': 'authenticated'}}}]};", + " let unauthParamsJson = { 'Version': '2012-10-17','Statement': [{'Effect': 'Allow','Principal': {'Federated': 'cognito-identity.amazonaws.com'},'Action': 'sts:AssumeRoleWithWebIdentity','Condition': {'StringEquals': {'cognito-identity.amazonaws.com:aud': idpId},'ForAnyValue:StringLike': {'cognito-identity.amazonaws.com:amr': 'unauthenticated'}}}]};", + " if (event.RequestType == 'Delete') {", + " delete authParamsJson.Statement.Condition;", + " delete unauthParamsJson.Statement.Condition;", + " let authParams = { PolicyDocument: JSON.stringify(authParamsJson),RoleName: authRoleName};", + " let unauthParams = {PolicyDocument: JSON.stringify(unauthParamsJson),RoleName: unauthRoleName};", + " const iam = new aws.IAM({ apiVersion: '2010-05-08', region: event.ResourceProperties.region});", + " promises.push(iam.updateAssumeRolePolicy(authParams).promise());", + " promises.push(iam.updateAssumeRolePolicy(unauthParams).promise());", + " Promise.all(promises)", + " .then((res) => {", + " console.log(\"delete response data\" + JSON.stringify(res));", + " response.send(event, context, response.SUCCESS, {});", + " });", + " }", + " if (event.RequestType == 'Update' || event.RequestType == 'Create') {", + " const iam = new aws.IAM({ apiVersion: '2010-05-08', region: event.ResourceProperties.region});", + " let authParams = { PolicyDocument: JSON.stringify(authParamsJson),RoleName: authRoleName};", + " let unauthParams = {PolicyDocument: JSON.stringify(unauthParamsJson),RoleName: unauthRoleName};", + " promises.push(iam.updateAssumeRolePolicy(authParams).promise());", + " promises.push(iam.updateAssumeRolePolicy(unauthParams).promise());", + " Promise.all(promises)", + " .then((res) => {", + " console.log(\"createORupdate\" + res);", + " console.log(\"response data\" + JSON.stringify(res));", + " response.send(event, context, response.SUCCESS, {});", + " });", + " }", + " } catch(err) {", + " console.log(err.stack);", + " responseData = {Error: err};", + " response.send(event, context, response.FAILED, responseData);", + " throw err;", + " }", + "};" + ] + ] + } + }, + "Handler": "index.handler", + "Runtime": "nodejs10.x", + "Timeout": "300", + "Role": { + "Fn::GetAtt": [ + "UpdateRolesWithIDPFunctionRole", + "Arn" + ] + } + } + }, + "UpdateRolesWithIDPFunctionOutputs": { + "Type": "Custom::LambdaCallout", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "UpdateRolesWithIDPFunction", + "Arn" + ] + }, + "region": { + "Ref": "AWS::Region" + }, + "idpId": { + "Fn::GetAtt": [ + "authhpiotreact8c9024fb", + "Outputs.IdentityPoolId" + ] + }, + "authRoleName": { + "Ref": "AuthRoleName" + }, + "unauthRoleName": { + "Ref": "UnauthRoleName" + } + } + }, + "UpdateRolesWithIDPFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "RoleName": { + "Fn::Join": [ + "", + [ + { + "Ref": "AuthRoleName" + }, + "-idp" + ] + ] + }, + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + }, + "Action": [ + "sts:AssumeRole" + ] + } + ] + }, + "Policies": [ + { + "PolicyName": "UpdateRolesWithIDPFunctionPolicy", + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Resource": "arn:aws:logs:*:*:*" + }, + { + "Effect": "Allow", + "Action": "iam:UpdateAssumeRolePolicy", + "Resource": { + "Fn::GetAtt": [ + "AuthRole", + "Arn" + ] + } + }, + { + "Effect": "Allow", + "Action": "iam:UpdateAssumeRolePolicy", + "Resource": { + "Fn::GetAtt": [ + "UnauthRole", + "Arn" + ] + } + } + ] + } + } + ] + } + } + }, + "Outputs": { + "Region": { + "Description": "CloudFormation provider root stack Region", + "Value": { + "Ref": "AWS::Region" + }, + "Export": { + "Name": { + "Fn::Sub": "${AWS::StackName}-Region" + } + } + }, + "StackName": { + "Description": "CloudFormation provider root stack ID", + "Value": { + "Ref": "AWS::StackName" + }, + "Export": { + "Name": { + "Fn::Sub": "${AWS::StackName}-StackName" + } + } + }, + "StackId": { + "Description": "CloudFormation provider root stack name", + "Value": { + "Ref": "AWS::StackId" + }, + "Export": { + "Name": { + "Fn::Sub": "${AWS::StackName}-StackId" + } + } + }, + "DeploymentBucketName": { + "Description": "CloudFormation provider root stack deployment bucket name", + "Value": { + "Ref": "DeploymentBucketName" + }, + "Export": { + "Name": { + "Fn::Sub": "${AWS::StackName}-DeploymentBucketName" + } + } + }, + "AuthRoleArn": { + "Value": { + "Fn::GetAtt": [ + "AuthRole", + "Arn" + ] + } + }, + "UnauthRoleArn": { + "Value": { + "Fn::GetAtt": [ + "UnauthRole", + "Arn" + ] + } + }, + "AuthRoleName": { + "Value": { + "Ref": "AuthRole" + } + }, + "UnauthRoleName": { + "Value": { + "Ref": "UnauthRole" + } + } + } +} \ No newline at end of file diff --git a/package.json b/package.json index 3d75096..e51ed0c 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "@testing-library/user-event": "^7.2.1", "aws-amplify": "^2.2.6", "aws-amplify-react": "^3.1.7", + "core-js": "^3.6.4", "npx": "^10.2.2", "react": "^16.13.1", "react-charts": "^2.0.0-beta.6", diff --git a/public/favicon.ico b/public/favicon.ico index bcd5dfd67cd0361b78123e95c2dd96031f27f743..ed5a0e9514521441aa290cbcdb0496ed5e26bdcd 100644 GIT binary patch literal 3230 zcmeH}KS*Oi5XQ%U2}Ffdhg#&tPCFru91^|GT2MK#Ix(nVG?;KjL?tE{34(=<33h^= zS6HRIq)r{M3s!;%7K&FKS-*Mg%4S1+Pq|BTN%-FGo1LBCWOg1eL|ym>hlsCqI6(A? zh{m8GGy$=_)kg?H9W~b=8DH~3VW_X2^#N}TI*0PJv-^SWKrUj6^D%92+>f};AIvNy zpi{{RA+9hb*P866pS+)O!{14)A4&EjMj!9#v2s4d;NP#amRjVNfuEUgswa>ebmD{8 z57i~Vs{146jKL4_I?)e413j;Z%uBZ|>#*AnIhaEZS2Bd;DlI{Q)!_DzZH(B zahPX6e;5mzz2b(ee6X*9kNfwWzv7>D_^;>xKi2>JBj=Aj8s(Jj@Z;#(wC-MsNXN9L(^N%%Bp7T4;J@?%2_x=5zbI<2~->=X60stMr0B~{wzpi9D0MG|# zyuANt7z6;uz%?PEfAnimLl^)6h5ARwGXemG2>?hqQv-I^Gpyh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N zF(7i$Jv(IM$8Akys9dhP^^~H2(7BfJp}yDW1#@!CL-!mGcSCnJ599WK9MV@yo_u$v MDeX2GIKR{Qf5okjU;qFB diff --git a/public/icon-512x512.png b/public/icon-512x512.png new file mode 100644 index 0000000000000000000000000000000000000000..ee16098a5a4cc218efd6f91d0b09ef439b9d2bb2 GIT binary patch literal 9498 zcmdsdcT|&E*Y5+UIEvzo3JM511aK5VrAY~4WDp||nh}wzRHc`I)S$k~03t)8ARQG& zLX##EO0WQi79l`@(3DUE1QO{f_hjC`zjg2W{=BeQ$#b54&iS3)_dX<8p-lJfk=X-5 z&_3klzic2#6nqthcJBfoKkxQ!L6FFQZW|k0A&rfX2L=at-uCr?pp&UFsqo96jpSNf zY+wI=c&GlMps!Xrs(&92dU{IgF?_VcB1|h~qqedFV{^R+q$ddxgzmt}V`qJVUi+g?|2h?0D`_b!hkYmlN004*dxE@yi3X z%iOP+p(&kirTCq>N6%NzMf^BWaee+)U6TEfRYGBcVj{u1>7Nk$?+q>Xr33ccx!i{z z@4v@=*Xy!|z55T$=D>+pPxcVr9e9maZ22p5ZBm~9Yg^v$>E>m7j_68RJ=jBDc_8@6 z^6$Fk+itO^_1>5?oqt43wBD%rCVjl^{ivP@m(u)fV1<_1yr43d{6tDubXV=YB<2%k zmPoq3(FQVIf}G0Le0b~EyNFi-?P8y6jRcu=hbV1a~mK?@t1;?7C%U`WGY+{^mCp;=#x-ftT$=AV^J7_$PArH6jcQiiaXC zOvD+YM}8GM@bEYE7cg`*)Z}`oae$wnhkqz!9PDv3)WiLF`0Y^d|9N$XusJ+i)Xzfa1{lS zZ~LTR5ka`U)T1P@U35BbPz*8(&^=BT0cSD79mM~5VCaJCf+D@jn=jj7!M@R{ z!MlO?NE5?H-zgw*J1=7+5K{-hMrYJ72a_*jH*H@3`xK?Lxp5g=cLM^*G&Fl%_?)jz zd!yb<0&nz_;8mFU!3eyOmk{nHy%S7_Q)K4UNq46or2XtW7z{=(=c2>4SNr-!fYUPH zj8Ek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84bm@8M|Bs( - React App + HP IoT diff --git a/src/App.css b/src/App.css index b53613e..3676185 100644 --- a/src/App.css +++ b/src/App.css @@ -2,17 +2,6 @@ text-align: center; } -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - .App-header { background-color: #282c34; min-height: 4vh; @@ -28,11 +17,3 @@ color: #61dafb; } -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/src/App.js b/src/App.js index d01b205..7d22398 100644 --- a/src/App.js +++ b/src/App.js @@ -20,62 +20,6 @@ Amplify.configure(awsconfig); let token = ""; - function connect() { - connectWS(token, currentRole); - subscribeWS(); - socket$.next({action: 'getDashboardData', policy: currentRole}); - } - - function connectWS(token, role) { - socket$ = new WebSocketSubject('wss://3fseaywb8b.execute-api.us-east-1.amazonaws.com/prototype?token=' + token + - '&role=' + role); - //console.log(socket$); - } - - function subscribeWS() { - socket$.subscribe((message) => { - console.log(message); - if (message instanceof Array) { - message.forEach(element => { - updateList(element); - }); - } else { - updateList(message); - } - serverMessages.sort((a, b) => a.location.localeCompare(b.location)); - console.log(serverMessages); - }, - (err) => console.error(err), - () => console.warn('Complete: Websocket closed') - ); - - - function updateList(obj) { - //console.log(serverMessages); - //console.log(obj); - const index = serverMessages.findIndex((e) => e.location === obj.location); - - if (index === -1) { - serverMessages.push(obj); - - } else { - Object.keys(obj).forEach(element => { - serverMessages[index][element] = obj[element]; - }); - } - } - - function setRole(index) { - currentRole = roles[index]; - roleSubject.next(currentRole); - socket$.complete(); - serverMessages = []; - connect(); - } - - } - - class Dashboard extends React.Component { constructor(props) { super(props); @@ -97,7 +41,14 @@ class Dashboard extends React.Component { serverMessages[index][element] = obj[element]; }); } -} + } + setRole(index) { + this.setState({promiseIsResolved: false}) + currentRole = roles[1]; + socket$.complete(); + serverMessages = []; + this.componentDidMount(); + } componentDidMount(){ Auth.currentAuthenticatedUser().then(data => { //console.log(data); @@ -106,7 +57,9 @@ class Dashboard extends React.Component { groups.forEach( (element, index, array) => { array[index] = element.replace(/_/g, ' '); }); - currentRole = data.signInUserSession.idToken.payload['cognito:roles'][0]; + if (! currentRole) { + currentRole = data.signInUserSession.idToken.payload['cognito:roles'][0]; + } token = data.signInUserSession.accessToken.jwtToken; roleSubject.subscribe({ next: r => r @@ -114,7 +67,6 @@ class Dashboard extends React.Component { socket$ = new WebSocketSubject('wss://3fseaywb8b.execute-api.us-east-1.amazonaws.com/prototype?token=' + token + '&role=' + currentRole); socket$.subscribe((message) => { - console.log(message); if (message instanceof Array) { message.forEach(element => { this.updateList(element); @@ -139,10 +91,15 @@ class Dashboard extends React.Component { if(!this.state.promiseIsResolved){return null} else{ return ( +
+
+
+
+
) } @@ -150,11 +107,10 @@ class Dashboard extends React.Component { } function App() { + return (
-
-

This is where the nav-bar will be

-
+
); diff --git a/src/aws-exports.js b/src/aws-exports.js new file mode 100644 index 0000000..240d354 --- /dev/null +++ b/src/aws-exports.js @@ -0,0 +1,18 @@ +// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten. + +const awsmobile = { + "aws_project_region": "us-east-1", + "aws_content_delivery_bucket": "hpiot-react-hpiot", + "aws_content_delivery_bucket_region": "us-east-1", + "aws_content_delivery_url": "http://hpiot-react-hpiot.s3-website-us-east-1.amazonaws.com", + "aws_cognito_identity_pool_id": "us-east-1:c018fdcf-3b1a-45db-a70e-daf34e217f8f", + "aws_cognito_region": "us-east-1", + "aws_user_pools_id": "us-east-1_XcUWWJXMT", + "aws_user_pools_web_client_id": "ms2jhuludm93g9qfpuio8m9k6", + "oauth": {}, + "aws_user_files_s3_bucket": "hpiotuserstorage-devs", + "aws_user_files_s3_bucket_region": "us-east-1" +}; + + +export default awsmobile; diff --git a/src/charts/BarChart.js b/src/charts/BarChart.js index 3aed72d..94517e0 100644 --- a/src/charts/BarChart.js +++ b/src/charts/BarChart.js @@ -1,6 +1,6 @@ import React, { PureComponent } from 'react'; import { - BarChart, Bar, Cell, XAxis, YAxis, CartesianGrid, Tooltip, Legend, + BarChart, Bar, Brush, ReferenceLine, XAxis, YAxis, CartesianGrid, Tooltip, Legend, } from 'recharts'; @@ -26,7 +26,9 @@ export default class Example extends PureComponent { - + + + diff --git a/src/charts/LineChart.js b/src/charts/LineChart.js index 4ea4272..4e5b435 100644 --- a/src/charts/LineChart.js +++ b/src/charts/LineChart.js @@ -1,6 +1,6 @@ import React, { PureComponent } from 'react'; import { - Label, LineChart, Line, CartesianGrid, XAxis, YAxis, Tooltip, ReferenceArea, + Label, LineChart, Line, CartesianGrid, XAxis, YAxis, Tooltip, ReferenceArea, Brush } from 'recharts'; @@ -37,7 +37,6 @@ export default class Example extends PureComponent { zoom() { let { refAreaLeft, refAreaRight, data } = this.state; - if (refAreaLeft === refAreaRight || refAreaRight === '') { this.setState(() => ({ refAreaLeft: '', @@ -50,8 +49,11 @@ export default class Example extends PureComponent { if (refAreaLeft > refAreaRight) [refAreaLeft, refAreaRight] = [refAreaRight, refAreaLeft]; // yAxis domain - const [bottom, top] = getAxisYDomain(refAreaLeft, refAreaRight, 'volumeflow', 5, this.state.data); - const [bottom2, top2] = getAxisYDomain(refAreaLeft, refAreaRight, 'depth', 50, this.state.data); + let refAreaLeftNum = data.findIndex((e) => e.location === refAreaLeft); + let refAreaRightNum = data.findIndex((e) => e.location === refAreaRight); + console.log(refAreaLeft,refAreaRight); + const [bottom, top] = getAxisYDomain(refAreaLeftNum, refAreaRightNum, 'volumeflow', 5, data); + const [bottom2, top2] = getAxisYDomain(refAreaLeftNum, refAreaRightNum, 'depth', 50, data); this.setState(() => ({ refAreaLeft: '', @@ -85,7 +87,6 @@ export default class Example extends PureComponent { const { data, barIndex, left, right, refAreaLeft, refAreaRight, top, bottom, top2, bottom2, } = this.state; - return (