├── .circleci └── config.yml ├── .editorconfig ├── .gitignore ├── .jshintrc ├── .vscode └── settings.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── assets ├── deploy-to-aws.png └── high-level-architecture.png ├── deployment ├── build.sh ├── scripts │ ├── 00-cleanup.sh │ ├── 01-prepare-cf.sh │ ├── 02-cf-custom-resource-lambda.sh │ ├── 03-website.sh │ ├── 04-services-lambda.sh │ ├── 05-greengrass-lambdas.sh │ └── 06-models.sh └── utils │ ├── getLicenses.js │ └── package.json ├── docs ├── blueprint-views.md ├── deployment-meta-language.md ├── developers.md ├── device-blueprints.md ├── device-types.md └── system-blueprints.md └── source ├── cf ├── defaults │ ├── device-blueprints │ │ ├── empty-gg-blueprint-v1.0.json │ │ ├── rpi-ml-demo-squeezenet-v1.0.json │ │ └── rpi-sense-hat-demo-v1.0.json │ ├── device-types │ │ ├── deeplens-aws-v1.0.json │ │ ├── deeplens-sputnik-v1.0.json │ │ ├── esp32-devkitc-v1.0.json │ │ ├── intel-up2-v1.0.json │ │ ├── intel-up2-webcam-v1.0.json │ │ ├── jetson-nano-webcam-v1.0.json │ │ ├── rpi-picamera-v1.0.json │ │ ├── rpi-sense-hat-picamera-v1.0.json │ │ ├── rpi-sense-hat-v1.0.json │ │ ├── rpi-webcam-v1.0.json │ │ └── simple-greengrass-device-v1.0.json │ ├── lambdas │ │ ├── libs │ │ │ ├── camera │ │ │ │ ├── camera │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── darwincamera.py │ │ │ │ │ ├── deeplenscamera.py │ │ │ │ │ ├── jetsontx2cameracamera.py │ │ │ │ │ ├── raspberrypicamera.py │ │ │ │ │ ├── test.py │ │ │ │ │ └── video0camera.py │ │ │ │ └── setup.py │ │ │ ├── file_output │ │ │ │ ├── file_output │ │ │ │ │ └── __init__.py │ │ │ │ └── setup.py │ │ │ ├── ggiot │ │ │ │ ├── ggiot │ │ │ │ │ └── __init__.py │ │ │ │ └── setup.py │ │ │ └── videostream │ │ │ │ ├── setup.py │ │ │ │ └── videostream │ │ │ │ └── __init__.py │ │ ├── sputnik-gg-ml-inference-squeezenet-demo-python │ │ │ ├── .gitignore │ │ │ ├── lambda_function.py │ │ │ ├── load_model.py │ │ │ ├── requirements.txt │ │ │ └── setup.cfg │ │ ├── sputnik-hello-world-python │ │ │ ├── .gitignore │ │ │ ├── lambda_function.py │ │ │ ├── requirements.txt │ │ │ └── setup.cfg │ │ ├── sputnik-rpi-sense-hat-demo-python │ │ │ ├── .gitignore │ │ │ ├── RTIMULib.ini │ │ │ ├── lambda_function.py │ │ │ ├── requirements.txt │ │ │ ├── sense_hat │ │ │ │ ├── __init__.py │ │ │ │ ├── sense_hat.py │ │ │ │ ├── sense_hat_text.png │ │ │ │ ├── sense_hat_text.txt │ │ │ │ └── stick.py │ │ │ └── setup.cfg │ │ ├── sputnik-simple-greengrass-device-demo-python │ │ │ ├── .gitignore │ │ │ ├── lambda_function.py │ │ │ ├── requirements.txt │ │ │ └── setup.cfg │ │ └── sputnik-simple-greengrass-gateway-demo-python │ │ │ ├── .gitignore │ │ │ ├── lambda_function.py │ │ │ ├── requirements.txt │ │ │ └── setup.cfg │ ├── sputnik-defaults.yml │ └── system-blueprints │ │ └── sample-system-v1.0.json ├── sputnik-appsync-schema.gql ├── sputnik-appsync.yml ├── sputnik-cloudtrail.yml ├── sputnik-cognito.yml ├── sputnik-ddb-tables.yml ├── sputnik-lambda-helpers.yml ├── sputnik-lambda-services.yml ├── sputnik-s3bucket-data.yml ├── sputnik-s3bucket-website.yml └── sputnik.yml ├── console ├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── package.json ├── src │ ├── app │ │ ├── app.component.css │ │ ├── app.component.html │ │ ├── app.component.ts │ │ ├── app.module.ts │ │ ├── app.routes.ts │ │ ├── common │ │ │ └── modules │ │ │ │ ├── card │ │ │ │ ├── card.component.ts │ │ │ │ └── card.module.ts │ │ │ │ ├── gauge │ │ │ │ ├── gauge.component.ts │ │ │ │ └── gauge.module.ts │ │ │ │ ├── graph-line │ │ │ │ ├── graph-line.component.ts │ │ │ │ └── graph-line.module.ts │ │ │ │ ├── pretty-json │ │ │ │ ├── pretty-json.component.html │ │ │ │ ├── pretty-json.component.ts │ │ │ │ └── pretty-json.module.ts │ │ │ │ └── table │ │ │ │ ├── table.component.html │ │ │ │ ├── table.component.ts │ │ │ │ └── table.module.ts │ │ ├── graphql │ │ │ ├── mutations │ │ │ │ ├── attach-principal-policy.ts │ │ │ │ ├── deployment.add.ts │ │ │ │ ├── device-blueprint.add.ts │ │ │ │ ├── device-blueprint.delete.ts │ │ │ │ ├── device-blueprint.update.ts │ │ │ │ ├── device-type.add.ts │ │ │ │ ├── device-type.delete.ts │ │ │ │ ├── device-type.update.ts │ │ │ │ ├── device.add.ts │ │ │ │ ├── device.create-certificate.ts │ │ │ │ ├── device.delete.ts │ │ │ │ ├── device.update.ts │ │ │ │ ├── iotdata-thing-shadow.update.ts │ │ │ │ ├── just-in-time-on-boarding-state.set.ts │ │ │ │ ├── setting.update.ts │ │ │ │ ├── system-blueprint.add.ts │ │ │ │ ├── system-blueprint.delete.ts │ │ │ │ ├── system-blueprint.update.ts │ │ │ │ ├── system.add.ts │ │ │ │ ├── system.delete.ts │ │ │ │ ├── system.refresh.ts │ │ │ │ ├── system.update.ts │ │ │ │ ├── user.delete.ts │ │ │ │ ├── user.disable.ts │ │ │ │ ├── user.enable.ts │ │ │ │ ├── user.invite.ts │ │ │ │ └── user.update.ts │ │ │ ├── queries │ │ │ │ ├── data.get.ts │ │ │ │ ├── deployments.list.ts │ │ │ │ ├── describe-endpoint.get.ts │ │ │ │ ├── device-blueprint.get.ts │ │ │ │ ├── device-blueprints.list.ts │ │ │ │ ├── device-type.get.ts │ │ │ │ ├── device-types.list.ts │ │ │ │ ├── device.get.ts │ │ │ │ ├── device.getStats.ts │ │ │ │ ├── devices-of-device-type.list.ts │ │ │ │ ├── devices-with-device-blueprint.list.ts │ │ │ │ ├── devices.list.ts │ │ │ │ ├── groups.list.ts │ │ │ │ ├── iotdata-thing-shadow.get.ts │ │ │ │ ├── just-in-time-on-boarding-state.get.ts │ │ │ │ ├── s3.list-objects-v2.ts │ │ │ │ ├── setting.get.ts │ │ │ │ ├── system-blueprint.get.ts │ │ │ │ ├── system-blueprints.list.ts │ │ │ │ ├── system.get.ts │ │ │ │ ├── system.getStats.ts │ │ │ │ ├── systems.list.ts │ │ │ │ ├── user.get.ts │ │ │ │ └── users.list.ts │ │ │ └── subscriptions │ │ │ │ ├── device-blueprint.added.ts │ │ │ │ ├── device-blueprint.deleted.ts │ │ │ │ ├── device-blueprint.updated.ts │ │ │ │ ├── device-type.added.ts │ │ │ │ ├── device-type.deleted.ts │ │ │ │ ├── device-type.updated.ts │ │ │ │ ├── device.added.ts │ │ │ │ ├── device.deleted.ts │ │ │ │ ├── device.updated.ts │ │ │ │ ├── system-blueprint.added.ts │ │ │ │ ├── system-blueprint.deleted.ts │ │ │ │ ├── system-blueprint.updated.ts │ │ │ │ ├── system.added.ts │ │ │ │ ├── system.deleted.ts │ │ │ │ └── system.updated.ts │ │ ├── models │ │ │ ├── addon.model.ts │ │ │ ├── data.model.ts │ │ │ ├── deployment.model.ts │ │ │ ├── device-blueprint.model.ts │ │ │ ├── device-type.model.ts │ │ │ ├── device.model.ts │ │ │ ├── group.model.ts │ │ │ ├── invitation-model.ts │ │ │ ├── invitation.model.ts │ │ │ ├── message.model.ts │ │ │ ├── new-password-user.model.ts │ │ │ ├── profile-info.model.ts │ │ │ ├── registration-user.model.ts │ │ │ ├── setting.model.ts │ │ │ ├── stats.model.ts │ │ │ ├── system-blueprint.model.ts │ │ │ ├── system.model.ts │ │ │ └── user.model.ts │ │ ├── pipes │ │ │ ├── cert-id-from-arn.pipe.ts │ │ │ ├── device-blueprint-name-from-id.pipe.ts │ │ │ ├── device-type-name-from-id.pipe.ts │ │ │ ├── moment.pipe.ts │ │ │ ├── pipes.module.ts │ │ │ ├── stringify.pipe.ts │ │ │ └── system-blueprint-from-system-blueprint-id.pipe.ts │ │ ├── public │ │ │ ├── auth │ │ │ │ ├── confirm │ │ │ │ │ ├── confirm-registration.component.html │ │ │ │ │ └── confirm-registration.component.ts │ │ │ │ ├── forgot │ │ │ │ │ ├── forgot-password-step-2.component.html │ │ │ │ │ ├── forgot-password.component.html │ │ │ │ │ └── forgot-password.component.ts │ │ │ │ ├── login │ │ │ │ │ ├── login.component.css │ │ │ │ │ ├── login.component.html │ │ │ │ │ └── login.component.ts │ │ │ │ ├── newpassword │ │ │ │ │ ├── new-password.component.html │ │ │ │ │ └── new-password.component.ts │ │ │ │ ├── register │ │ │ │ │ ├── registration.component.html │ │ │ │ │ └── registration.component.ts │ │ │ │ └── resend │ │ │ │ │ ├── resend-code.component.html │ │ │ │ │ └── resend-code.component.ts │ │ │ ├── home │ │ │ │ ├── home.component.html │ │ │ │ └── home.component.ts │ │ │ └── tests │ │ │ │ ├── tests.component.html │ │ │ │ ├── tests.component.ts │ │ │ │ └── tests.module.ts │ │ ├── secure │ │ │ ├── child-views │ │ │ │ ├── child-views.module.ts │ │ │ │ ├── devices │ │ │ │ │ ├── default-device │ │ │ │ │ │ ├── default-device.component.ts │ │ │ │ │ │ └── default-device.module.ts │ │ │ │ │ ├── device-child-views.module.ts │ │ │ │ │ └── ml-demo-squeezenet-v1.0 │ │ │ │ │ │ ├── ml-demo-squeezenet-v1.0.component.html │ │ │ │ │ │ ├── ml-demo-squeezenet-v1.0.component.ts │ │ │ │ │ │ └── ml-demo-squeezenet-v1.0.module.ts │ │ │ │ └── systems │ │ │ │ │ ├── default-system │ │ │ │ │ ├── default-system.component.ts │ │ │ │ │ └── default-system.module.ts │ │ │ │ │ └── system-child-views.module.ts │ │ │ ├── common │ │ │ │ ├── iot-pubsuber.component.ts │ │ │ │ └── prettifier.component.ts │ │ │ ├── deployments │ │ │ │ ├── deployments.component.html │ │ │ │ └── deployments.component.ts │ │ │ ├── device-blueprints │ │ │ │ ├── device-blueprint.component.html │ │ │ │ ├── device-blueprint.component.ts │ │ │ │ ├── device-blueprints.component.html │ │ │ │ ├── device-blueprints.component.ts │ │ │ │ └── device-blueprints.module.ts │ │ │ ├── device-types │ │ │ │ ├── device-type.component.html │ │ │ │ ├── device-type.component.ts │ │ │ │ ├── device-types.component.html │ │ │ │ ├── device-types.component.ts │ │ │ │ └── device-types.module.ts │ │ │ ├── devices │ │ │ │ ├── device.component.html │ │ │ │ ├── device.component.ts │ │ │ │ ├── devices.component.html │ │ │ │ └── devices.component.ts │ │ │ ├── home │ │ │ │ ├── secure-home.component.html │ │ │ │ └── secure-home.component.ts │ │ │ ├── maps │ │ │ │ ├── maps.component.html │ │ │ │ └── maps.component.ts │ │ │ ├── profile │ │ │ │ ├── profile.component.html │ │ │ │ └── profile.component.ts │ │ │ ├── secure-home-layout.component.html │ │ │ ├── secure-home-layout.component.ts │ │ │ ├── settings │ │ │ │ ├── settings.component.html │ │ │ │ └── settings.component.ts │ │ │ ├── system-blueprints │ │ │ │ ├── system-blueprint.component.html │ │ │ │ ├── system-blueprint.component.ts │ │ │ │ ├── system-blueprints.component.html │ │ │ │ ├── system-blueprints.component.ts │ │ │ │ └── system-blueprints.module.ts │ │ │ ├── systems │ │ │ │ ├── system.component.html │ │ │ │ ├── system.component.ts │ │ │ │ ├── system.edit.modal.component.html │ │ │ │ ├── system.edit.modal.component.ts │ │ │ │ ├── systems.component.html │ │ │ │ ├── systems.component.ts │ │ │ │ ├── systems.modal.component.html │ │ │ │ ├── systems.modal.component.ts │ │ │ │ └── systems.module.ts │ │ │ └── users │ │ │ │ ├── user.component.html │ │ │ │ ├── user.component.ts │ │ │ │ ├── users.component.html │ │ │ │ └── users.component.ts │ │ ├── services │ │ │ ├── admin.service.ts │ │ │ ├── appsync.service.ts │ │ │ ├── bread-crumb.service.ts │ │ │ ├── deployment.service.ts │ │ │ ├── device-blueprint.service.ts │ │ │ ├── device-type.service.ts │ │ │ ├── device.service.ts │ │ │ ├── iot.service.ts │ │ │ ├── logger.service.ts │ │ │ ├── s3 │ │ │ │ ├── s3-image.component.ts │ │ │ │ ├── s3.module.ts │ │ │ │ └── s3.service.ts │ │ │ ├── services.module.ts │ │ │ ├── setting.service.ts │ │ │ ├── stat.service.ts │ │ │ ├── system-blueprint.service.ts │ │ │ ├── system.service.ts │ │ │ ├── user-login.service.ts │ │ │ └── user-registration.service.ts │ │ └── widgets │ │ │ ├── button-widget.component.ts │ │ │ ├── card-widget.component.ts │ │ │ ├── checkbox-widget.component.ts │ │ │ ├── color-picker-widget.component.ts │ │ │ ├── gauge-widget.component.ts │ │ │ ├── graph-realtime-widget.component.ts │ │ │ ├── input-text-widget.component.ts │ │ │ ├── text-widget.component.ts │ │ │ ├── widget.component.ts │ │ │ ├── widgets.component.ts │ │ │ ├── widgets.module.ts │ │ │ └── widgets.service.ts │ ├── assets │ │ ├── .gitignore │ │ ├── .gitkeep │ │ ├── appVariables.js │ │ ├── css │ │ │ ├── colors │ │ │ │ └── default.css │ │ │ ├── login.css │ │ │ └── ratchet.css │ │ └── img │ │ │ ├── aws_smile.png │ │ │ ├── background │ │ │ ├── error-bg.jpg │ │ │ └── login-register.jpg │ │ │ ├── custom-select.png │ │ │ ├── icon │ │ │ ├── danger.svg │ │ │ ├── success.svg │ │ │ └── warning.svg │ │ │ ├── iot-ds.png │ │ │ ├── lightbulb.png │ │ │ ├── simengine.png │ │ │ ├── simulation.png │ │ │ └── tooltip │ │ │ ├── Euclid.png │ │ │ ├── shape1.svg │ │ │ ├── shape2.svg │ │ │ ├── shape3.svg │ │ │ ├── tooltip1.svg │ │ │ ├── tooltip2.svg │ │ │ └── tooltip3.svg │ ├── browserslist │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── favicon.ico │ ├── index.html │ ├── karma.conf.js │ ├── main.ts │ ├── polyfills.ts │ ├── styles.css │ ├── tsconfig.app.json │ └── tslint.json ├── tools │ └── postinstall │ │ ├── create-assets.sh │ │ └── patch-ngcli-webpack.ts ├── tsconfig.json └── tslint.json ├── resources ├── cf-helper-s3 │ ├── index.js │ ├── lib │ │ └── s3-helper.js │ └── package.json ├── usage-metrics │ ├── metrics.common.js │ └── package.json └── utils │ ├── index.js │ ├── lib │ ├── blueprint-parser.js │ ├── dynamodb-helper.js │ ├── greengrass-helper.js │ ├── iot-helper.js │ ├── list-greengrass-group-ids-for-thingarn.js │ └── s3-helper.js │ ├── libs.js │ ├── package.json │ └── test.js └── services ├── admin ├── index.js ├── lib │ ├── deleteUser.js │ ├── disableUser.js │ ├── enableUser.js │ ├── generatePassword.js │ ├── getUser.js │ ├── inviteUser.js │ ├── listGroups.js │ ├── listUsers.js │ ├── setUserGroups.js │ └── updateUser.js ├── libs.js ├── package.json └── test.js ├── deployments ├── index.js ├── lib │ ├── addDeployment.js │ ├── createGreengrassXDefinitionVersion.js │ ├── merge-sputnik-shadows.js │ └── merge-sputnik-specs.js ├── libs.js └── package.json ├── devices ├── index.js ├── lib │ ├── addDevice.js │ ├── createCertificate.js │ ├── deleteDevice.js │ ├── getDeviceStats.js │ ├── test.js │ └── updateDevice.js ├── libs.js └── package.json ├── just-in-time-on-boarding ├── index.js └── package.json ├── settings ├── index.js └── package.json └── systems ├── index.js ├── lib ├── delete-system.js ├── get-system-stats.js └── refresh-system.js ├── libs.js └── package.json /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | jobs: 3 | # placeholder for circleci, currently bypass checks for master until beta release 4 | # beta release has a full config that onces merged will replace this. 5 | # we need this for dependabot and other automation to occur in master 6 | bypass: 7 | description: > 8 | Skipping checks for master until beta release 9 | docker: 10 | - image: >- 11 | circleci/node:12.16.2 12 | steps: 13 | - run: echo "Skipping for master until beta release" 14 | 15 | workflows: 16 | version: 2 17 | verify: 18 | jobs: 19 | - bypass 20 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 4 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | 15 | [*.yml] 16 | max_line_length = off 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | **/dist 3 | **/open-source 4 | **/.zip 5 | **/tmp 6 | **/out-tsc 7 | 8 | # dependencies 9 | **/node_modules 10 | 11 | # e2e 12 | **/e2e/*.js 13 | **/e2e/*.map 14 | 15 | # misc 16 | **/npm-debug.log 17 | **/testem.log 18 | **/package-lock.json 19 | **/yarn.lock 20 | 21 | # System Files 22 | **/.DS_Store 23 | **/.sonarlint 24 | 25 | # Custom for ease of deployments 26 | deployment/deploy.sh 27 | 28 | # Python lambdas 29 | *.egg-info 30 | *.dist-info 31 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "esversion": 6, 3 | "node": true 4 | } 5 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.pythonPath": "/usr/local/bin/python3", 3 | "javascript.preferences.quoteStyle": "single", 4 | "typescript.preferences.quoteStyle": "single", 5 | "prettier.singleQuote": true, 6 | "editor.defaultFormatter": "esbenp.prettier-vscode" 7 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | IoT Kickstart (Sputnik) 2 | Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | ********************** 5 | THIRD PARTY COMPONENTS 6 | ********************** 7 | This software includes third party software subject to the following copyrights: 8 | 9 | @sweetalert2/ngx-sweetalert2@5.1.0 under the MIT license 10 | aws-amplify-angular@3.0.11 under the Apache-2.0 license 11 | aws-amplify@1.1.36 under the Apache-2.0 license 12 | bootstrap@4.3.1 under the MIT license 13 | chart.js@2.8.0 under the MIT license 14 | chartjs-plugin-annotation@0.5.7 under the MIT license 15 | chartjs-plugin-draggable@0.1.6 under the MIT license 16 | chartjs-plugin-streaming@1.8.0 under the MIT license 17 | core-js@2.6.9 under the MIT license 18 | file-saver@2.0.2 under the MIT license 19 | font-awesome@4.7.0 under the (OFL-1.1 AND MIT) license 20 | fs-extra@7.0.1 under the MIT license 21 | gauge.js@0.2.1 under the MIT license 22 | graphql-tag@2.10.0 under the MIT license 23 | graphql@14.0.2 under the MIT license 24 | jquery-blockui@2.7.0 under the MIT license 25 | jquery-slimscroll@1.3.8 under the [ 'MIT', 'GPL' ] license 26 | jquery@3.4.1 under the MIT license 27 | jszip@3.2.2 under the (MIT OR GPL-3.0) license 28 | moment@2.24.0 under the MIT license 29 | ng-block-ui@2.1.7 under the MIT license 30 | ng2-charts@2.2.0 under the ISC license 31 | ngx-color-picker@7.5.0 under the MIT license 32 | node-forge@0.8.5 under the (BSD-3-Clause OR GPL-2.0) license 33 | node-waves@0.7.6 under the MIT license 34 | owl.carousel@2.3.4 under the MIT* license 35 | popper.js@1.15.0 under the MIT license 36 | shortid@2.2.14 under the MIT license 37 | sticky-kit@1.1.3 under the WTFPL license 38 | stream@0.0.2 under the MIT license 39 | sweetalert2@8.17.1 under the MIT license 40 | systemjs@0.21.5 under the MIT license 41 | underscore-deep-extend@1.1.5 under the MIT license 42 | underscore@1.9.1 under the MIT license 43 | uuid@3.3.2 under the MIT license 44 | -------------------------------------------------------------------------------- /assets/deploy-to-aws.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/assets/deploy-to-aws.png -------------------------------------------------------------------------------- /assets/high-level-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/assets/high-level-architecture.png -------------------------------------------------------------------------------- /deployment/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This assumes all of the OS-level configuration has been completed and git repo has already been cloned 4 | # 5 | # This script should be run from the repo's deployment directory 6 | # cd deployment 7 | # ./build-s3-dist.sh source-bucket-base-name version-code 8 | # 9 | # Paramenters: 10 | # - source-bucket-base-name: Name for the S3 bucket location where the script will deploy the code to. The template will append '-[region_name]' to this bucket name. 11 | # For example: ./build-s3-dist.sh my-super-bucket v1.0.0 12 | # The template will then expect the source code to be located in the my-super-bucket-[region_name] bucket 13 | # 14 | # - version-code: version of the package 15 | 16 | # Check to see if input has been provided: 17 | if [ -z "$1" ] || [ -z "$2" ]; then 18 | echo "Please provide the base source bucket name and version where the code will eventually reside." 19 | echo "For example: ./build-s3-dist.sh my-super-bucket v1.0.0" 20 | exit 1 21 | fi 22 | 23 | set -e 24 | 25 | echo "------------------------------------------------------------------------------" 26 | echo "[Dependencies]" 27 | echo "jq version: `jq --version`" 28 | echo "yarn version: `yarn --version`" 29 | echo "------------------------------------------------------------------------------" 30 | echo 31 | 32 | # Get reference for all important folders 33 | template_dir="$PWD" 34 | dist_dir="$template_dir/dist" 35 | source_dir="$template_dir/../source" 36 | 37 | $template_dir/scripts/00-cleanup.sh $dist_dir 38 | $template_dir/scripts/01-prepare-cf.sh $source_dir $dist_dir $1 $2 39 | $template_dir/scripts/02-cf-custom-resource-lambda.sh $source_dir $dist_dir 40 | $template_dir/scripts/03-website.sh $source_dir $dist_dir 41 | $template_dir/scripts/04-services-lambda.sh $source_dir $dist_dir 42 | $template_dir/scripts/05-greengrass-lambdas.sh $source_dir $dist_dir 43 | $template_dir/scripts/06-models.sh $dist_dir 44 | -------------------------------------------------------------------------------- /deployment/scripts/00-cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check to see if input has been provided: 4 | if [ -z "$1" ]; then 5 | echo "Please provide the dist dir" 6 | echo "For example: ./00-cleanup.sh ./dist" 7 | exit 1 8 | fi 9 | 10 | set -e 11 | 12 | echo "00-cleanup.sh-----------------------------------------------------------------" 13 | echo "[Init] Clean old dist and old website dir" 14 | echo "rm -rf $1" 15 | rm -rf $1 16 | echo "mkdir -p $1" 17 | mkdir -p $1 18 | echo "------------------------------------------------------------------------------" 19 | echo 20 | exit 0 21 | -------------------------------------------------------------------------------- /deployment/scripts/01-prepare-cf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check to see if input has been provided: 4 | if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]; then 5 | echo "Please provide the source dir, dist dir, bucket name, version" 6 | echo "For example: ./00-prepare-cf.sh ../source ./dist sputnik.yml BUCKET v0.1" 7 | exit 1 8 | fi 9 | 10 | set -e 11 | 12 | function sed_file() { 13 | echo "sed -i '' -e $1 $2" 14 | sed -i '' -e $1 $2 15 | } 16 | 17 | echo "01-prepare-cf.sh--------------------------------------------------------------" 18 | echo "[Packing] Cloud formation template" 19 | echo 20 | echo "Removing old $2/cf dir (rm -rf $2/cf)" 21 | rm -rf $2/cf 22 | 23 | echo "Copying CF folder accross (cp -R $1/cf $2)" 24 | cp -R $1/cf $2 25 | 26 | echo "Updating code source bucket in templates with $3 and code source version in template with $4" 27 | replace="s/%%BUCKET_NAME%%/$3/g" 28 | sed_file $replace "${2}/cf/*.yml" 29 | sed_file $replace "${2}/cf/defaults/*.yml" 30 | 31 | replace="s/%%VERSION%%/$4/g" 32 | sed_file $replace "${2}/cf/*.yml" 33 | sed_file $replace "${2}/cf/defaults/*.yml" 34 | 35 | echo 36 | echo "------------------------------------------------------------------------------" 37 | echo "Remove defaults lambda source code" 38 | rm -rf $2/cf/defaults/lambdas 39 | echo "------------------------------------------------------------------------------" 40 | echo 41 | exit 0 42 | -------------------------------------------------------------------------------- /deployment/scripts/02-cf-custom-resource-lambda.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check to see if input has been provided: 4 | if [ -z "$1" ] || [ -z "$2" ]; then 5 | echo "Please provide the source dir, dist dir" 6 | echo "For example: ./00-cleanup.sh ../source ./dist" 7 | exit 1 8 | fi 9 | 10 | set -e 11 | 12 | echo "02-cf-custom-resource-lambda.sh-----------------------------------------------" 13 | echo "mkdir -p $2/lambda" 14 | mkdir -p $2/lambda 15 | echo 16 | echo "[Rebuild] Cloudformation custom resource - S3 Helper" 17 | cd $1/resources/cf-helper-s3 18 | yarn run build 19 | cp $1/resources/cf-helper-s3/dist/`jq -cr '.name' package.json`.zip $2/lambda/`jq -cr '.name' package.json`.zip 20 | 21 | echo 22 | echo "[Rebuild] Cloudformation custom resource - Utils" 23 | echo 24 | cd $1/resources/utils 25 | yarn run build 26 | cp ./dist/`jq -cr '.name' package.json`.zip $2/lambda/`jq -cr '.name' package.json`.zip 27 | 28 | echo 29 | echo "------------------------------------------------------------------------------" 30 | echo 31 | 32 | exit 0 33 | -------------------------------------------------------------------------------- /deployment/scripts/03-website.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check to see if input has been provided: 4 | if [ -z "$1" ] || [ -z "$2" ]; then 5 | echo "Please provide the source dir, dist dir, the website dir name and the manifest generator path" 6 | echo "For example: ./00-cleanup.sh ../source ./dist console" 7 | exit 1 8 | fi 9 | 10 | set -e 11 | 12 | echo "03-website.sh-----------------------------------------------------------------" 13 | echo 14 | echo "Removing old $2/console dir (rm -rf $2/console)" 15 | rm -rf $2/console 16 | echo "mkdir -p $2/console" 17 | mkdir -p $2/console 18 | echo 19 | echo "[Rebuild] console" 20 | # build and copy console distribution files 21 | cd $1/console 22 | rm -rf ./dist 23 | yarn install 24 | yarn run build 25 | cp -r ./dist/** $2/console 26 | echo "[Custom building] Deleting appVariables.js" 27 | rm $2/console/assets/appVariables*.* 28 | 29 | echo 30 | echo "------------------------------------------------------------------------------" 31 | echo 32 | exit 0 33 | -------------------------------------------------------------------------------- /deployment/scripts/04-services-lambda.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check to see if input has been provided: 4 | if [ -z "$1" ] || [ -z "$2" ]; then 5 | echo "Please provide the source dir, dist dir" 6 | echo "For example: ./04-services-lambda.sh ../source ./dist" 7 | exit 1 8 | fi 9 | 10 | set -e 11 | 12 | echo "04-services-lambda.sh---------------------------------------------------------" 13 | echo "mkdir -p $2/lambda" 14 | mkdir -p $2/lambda 15 | 16 | echo 17 | echo "[Build] Services - Admin" 18 | echo 19 | cd $1/services/admin 20 | yarn run build 21 | cp ./dist/`jq -cr '.name' package.json`.zip $2/lambda/`jq -cr '.name' package.json`.zip 22 | 23 | echo 24 | echo "[Build] Services - Devices" 25 | echo 26 | cd $1/services/devices 27 | yarn run build 28 | cp ./dist/`jq -cr '.name' package.json`.zip $2/lambda/`jq -cr '.name' package.json`.zip 29 | 30 | echo 31 | echo "[Build] Services - Just In Time On Boarding" 32 | echo 33 | cd $1/services/just-in-time-on-boarding 34 | yarn run build 35 | cp ./dist/`jq -cr '.name' package.json`.zip $2/lambda/`jq -cr '.name' package.json`.zip 36 | 37 | echo 38 | echo "[Build] Services - Settings" 39 | echo 40 | cd $1/services/settings 41 | yarn run build 42 | cp ./dist/`jq -cr '.name' package.json`.zip $2/lambda/`jq -cr '.name' package.json`.zip 43 | 44 | echo 45 | echo "[Build] Services - Deployments" 46 | echo 47 | cd $1/services/deployments 48 | yarn run build 49 | cp ./dist/`jq -cr '.name' package.json`.zip $2/lambda/`jq -cr '.name' package.json`.zip 50 | 51 | echo 52 | echo "[Build] Services - Systems" 53 | echo 54 | cd $1/services/systems 55 | yarn run build 56 | cp ./dist/`jq -cr '.name' package.json`.zip $2/lambda/`jq -cr '.name' package.json`.zip 57 | 58 | 59 | echo 60 | echo "------------------------------------------------------------------------------" 61 | echo 62 | exit 0 63 | -------------------------------------------------------------------------------- /deployment/scripts/05-greengrass-lambdas.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check to see if input has been provided: 4 | if [ -z "$1" ] || [ -z "$2" ]; then 5 | echo "Please provide the source dir, dist dir" 6 | echo "For example: ./05-greengrass-lambdas.sh ../source ./dist" 7 | exit 1 8 | fi 9 | 10 | set -e 11 | 12 | rm -rf $2/cf/defaults/lambdas 13 | echo "mkdir -p $2/lambda" 14 | mkdir -p $2/greengrasslambda 15 | 16 | echo "05-greengrass-lambdas.sh--------------------------------------------------------------------------------" 17 | echo 18 | echo 19 | 20 | cd $1/cf/defaults/lambdas/ 21 | 22 | for PYTHON_LAMBDA in *-python/ ; do 23 | echo "***" 24 | echo $PYTHON_LAMBDA 25 | cd $1/cf/defaults/lambdas/$PYTHON_LAMBDA 26 | pip install -r requirements.txt -t . --upgrade 27 | zip -rq $2/greengrasslambda/`echo ${PWD##*/}`.zip . 28 | echo "Done with $PYTHON_LAMBDA" 29 | done 30 | 31 | echo 32 | echo "--------------------------------------------------------------------------------------------------------" 33 | echo 34 | exit 0 35 | -------------------------------------------------------------------------------- /deployment/scripts/06-models.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check to see if input has been provided: 4 | if [ -z "$1" ] ; then 5 | echo "Please provide the source dir, dist dir" 6 | echo "For example: ./06-models.sh ./dist" 7 | exit 1 8 | fi 9 | 10 | set -e 11 | 12 | rm -rf $1/assets 13 | echo "mkdir -p $1/assets" 14 | mkdir -p $1/assets 15 | echo "mkdir -p $1/assets/models" 16 | mkdir -p $1/assets/models 17 | 18 | echo "06-models.sh--------------------------------------------------------------------------------" 19 | echo 20 | echo 21 | 22 | mkdir -p /tmp/squeezenet_v1.1 23 | curl -o /tmp/squeezenet_v1.1/squeezenet_v1.1-0000.params https://s3.amazonaws.com/model-server/model_archive_1.0/examples/squeezenet_v1.1/squeezenet_v1.1-0000.params 24 | curl -o /tmp/squeezenet_v1.1/squeezenet_v1.1-symbol.json https://s3.amazonaws.com/model-server/model_archive_1.0/examples/squeezenet_v1.1/squeezenet_v1.1-symbol.json 25 | curl -o /tmp/squeezenet_v1.1/synset.txt https://s3.amazonaws.com/model-server/model_archive_1.0/examples/squeezenet_v1.1/synset.txt 26 | zip -r -j $1/assets/models/squeezenet_v1.1.zip /tmp/squeezenet_v1.1/* 27 | 28 | echo 29 | echo "--------------------------------------------------------------------------------------------------------" 30 | echo 31 | exit 0 32 | -------------------------------------------------------------------------------- /deployment/utils/getLicenses.js: -------------------------------------------------------------------------------- 1 | const checker = require('license-checker'); 2 | 3 | const packageJSON = require('../../source/console/package.json').dependencies; 4 | const packages = Object.keys(packageJSON).reduce((total, value) => { 5 | return `${total};${value}@${packageJSON[value].replace('~', '').replace('^', '')}`; 6 | }, ''); 7 | 8 | // console.log(packages); 9 | 10 | checker.init( 11 | { 12 | start: '../../source/console', 13 | direct: true, 14 | production: true, 15 | packages: packages 16 | }, 17 | (err, packages) => { 18 | if (err) { 19 | console.error('ERROR', err); 20 | } else { 21 | Object.keys(packages).forEach(key => { 22 | console.log(key, 'under the', packages[key].licenses, 'license'); 23 | }); 24 | // console.log(packages); 25 | } 26 | } 27 | ); 28 | -------------------------------------------------------------------------------- /deployment/utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-samples/aws-iot-kickstart-utils", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "getLicenses.js", 6 | "dependencies": { 7 | "license-checker": "^25.0.1" 8 | }, 9 | "devDependencies": {}, 10 | "scripts": { 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "author": "", 14 | "license": "ISC" 15 | } 16 | -------------------------------------------------------------------------------- /source/cf/defaults/device-blueprints/empty-gg-blueprint-v1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "empty-gg-blueprint-v1.0", 3 | "name": "Empty Greengrass Blueprint v1.0", 4 | "type": "GREENGRASS", 5 | "compatibility": ["all"], 6 | "deviceTypeMappings": [], 7 | "spec": {} 8 | } 9 | -------------------------------------------------------------------------------- /source/cf/defaults/device-types/esp32-devkitc-v1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "esp32-devkitc-v1.0", 3 | "name": "ESP32 DevKitC v1.0", 4 | "type": "A:FreeRTOS", 5 | "spec": {} 6 | } 7 | -------------------------------------------------------------------------------- /source/cf/defaults/device-types/simple-greengrass-device-v1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "simple-greengrass-device-v1.0", 3 | "name": "Simple Greengrass Device v1.0", 4 | "type": "GREENGRASS", 5 | "spec": { 6 | "CoreDefinitionVersion": { 7 | "Cores": [{ 8 | "CertificateArn": "[CORE_CERTIFICATE_ARN]", 9 | "SyncShadow": true, 10 | "ThingArn": "[CORE_ARN]" 11 | }] 12 | }, 13 | "FunctionDefinitionVersion": { 14 | "Functions": [{ 15 | "FunctionArn": "arn:aws:lambda:::function:GGIPDetector:1", 16 | "FunctionConfiguration": { 17 | "Environment": { 18 | "AccessSysfs": true, 19 | "Variables": {} 20 | }, 21 | "MemorySize": 32768, 22 | "Pinned": true, 23 | "Timeout": 3 24 | } 25 | }] 26 | }, 27 | "LoggerDefinitionVersion": { 28 | "Loggers": [{ 29 | "Component": "GreengrassSystem", 30 | "Level": "INFO", 31 | "Type": "AWSCloudWatch" 32 | }, 33 | { 34 | "Component": "Lambda", 35 | "Level": "INFO", 36 | "Type": "AWSCloudWatch" 37 | }, 38 | { 39 | "Component": "GreengrassSystem", 40 | "Level": "INFO", 41 | "Space": 300000, 42 | "Type": "FileSystem" 43 | }, 44 | { 45 | "Component": "Lambda", 46 | "Level": "INFO", 47 | "Space": 300000, 48 | "Type": "FileSystem" 49 | } 50 | ] 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/libs/camera/camera/darwincamera.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import logging 5 | import cv2 6 | 7 | class DarwinCamera: 8 | 9 | def __init__(self, width=1920, height=1080): 10 | logging.info("Initializing the Darwin Camera") 11 | self.stream = cv2.VideoCapture(0) 12 | self.stream.set(3, width) 13 | self.stream.set(4, height) 14 | 15 | def read(self): 16 | return self.stream.read() 17 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/libs/camera/camera/deeplenscamera.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import awscam # pylint: disable=import-error 5 | import logging 6 | 7 | class DeeplensCamera: 8 | 9 | def __init__(self): 10 | logging.info("Initializing the Deeplens Camera: awscam") 11 | 12 | def read(self): 13 | return awscam.getLastFrame() 14 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/libs/camera/camera/jetsontx2cameracamera.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import logging 5 | import cv2 6 | 7 | class JetsonTX2Camera: 8 | 9 | def __init__(self): 10 | logging.info("Initializing the Jetson TX2 camera") 11 | HD_2K = False 12 | if HD_2K: 13 | self.width = 2592 # 648 14 | self.height = 1944 # 486 15 | else: 16 | self.width = 1296 # 324 17 | self.height = 972 # 243 18 | 19 | gst_str = ("nvcamerasrc ! " 20 | "video/x-raw(memory:NVMM), width=(int)2592, height=(int)1944," 21 | "format=(string)I420, framerate=(fraction)30/1 ! " 22 | "nvvidconv ! video/x-raw, width=(int){}, height=(int){}, " 23 | "format=(string)BGRx ! videoconvert ! appsink").format(self.width, self.height) 24 | self.stream = cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER) 25 | 26 | def read(self): 27 | return self.stream.read() 28 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/libs/camera/camera/raspberrypicamera.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import logging 5 | import picamera # pylint: disable=import-error 6 | import io 7 | import cv2 8 | import numpy as np 9 | 10 | class RaspberryPiCamera: 11 | 12 | def __init__(self, width=1920, height=1080): 13 | logging.info("Initializing the picamera") 14 | 15 | def piCameraCapture(self): 16 | _stream = io.BytesIO() 17 | self.picam.capture(_stream, format='jpeg') 18 | # Construct a numpy array from the _stream 19 | data = np.fromstring(_stream.getvalue(), dtype=np.uint8) 20 | # "Decode" the image from the array, preserving colour 21 | return True, cv2.imdecode(data, 1) 22 | 23 | picamera.PiCamera.read = piCameraCapture 24 | PICAMERA = self.stream = picamera.PiCamera() 25 | self.stream.resolution = (self.width, self.height) 26 | self.stream.start_preview() 27 | 28 | def read(self): 29 | return self.stream.read() 30 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/libs/camera/camera/test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import logging 5 | from camera import Camera 6 | 7 | logging.info('Start of the test code.') 8 | 9 | CAMERA = Camera(camera_type="Darwin") 10 | 11 | print(CAMERA.read()) 12 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/libs/camera/camera/video0camera.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import logging 5 | import cv2 6 | 7 | class Video0Camera: 8 | 9 | def __init__(self, width=1920, height=1080): 10 | logging.info("Initializing the video0 Camera") 11 | self.stream = cv2.VideoCapture(0) 12 | self.stream.set(3, width) 13 | self.stream.set(4, height) 14 | 15 | def read(self): 16 | return self.stream.read() 17 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/libs/camera/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | setup(name='camera', 4 | version='0.1', 5 | description='camera code', 6 | author='teuteuguy', 7 | license='MIT', 8 | packages = find_packages(), 9 | zip_safe=False) 10 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/libs/file_output/file_output/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | from threading import Thread 5 | import os 6 | 7 | 8 | class FileOutput(Thread): 9 | ''' 10 | File output manage an opencv frame output 11 | saving it to disque in mjpeg format. 12 | ''' 13 | 14 | def __init__(self, path, frame): 15 | ''' Constructor. ''' 16 | Thread.__init__(self) 17 | 18 | self.stopped = False 19 | self.path = path 20 | self.write(frame) 21 | 22 | def stop(self): 23 | '''stop() set a flag to stop the run loop''' 24 | self.stopped = True 25 | 26 | def write(self, jpeg): 27 | '''write() refresh the last opencv frame''' 28 | self.jpeg = jpeg 29 | 30 | def run(self): 31 | '''run() constantly write the file on drive''' 32 | if not os.path.exists(self.path): 33 | os.mkfifo(self.path) 34 | file = open(self.path, 'w') 35 | while not self.stopped: 36 | try: 37 | file.write(self.jpeg.tobytes()) 38 | except IOError as err: 39 | file = open(self.path, 'w') 40 | continue 41 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/libs/file_output/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup(name='file_output', 4 | version='0.1', 5 | description='file_output code', 6 | author='teuteuguy', 7 | license='MIT', 8 | packages=['file_output'], 9 | zip_safe=False) 10 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/libs/ggiot/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | setup(name='ggiot', 4 | version='0.1', 5 | description='ggiot code', 6 | author='teuteuguy', 7 | license='MIT', 8 | packages=find_packages(), 9 | install_requires=[ 10 | 'greengrasssdk', 11 | ], 12 | zip_safe=False) 13 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/libs/videostream/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup(name='videostream', 4 | version='0.1', 5 | description='camera code', 6 | author='teuteuguy', 7 | license='MIT', 8 | packages=['videostream'], 9 | zip_safe=False) 10 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-gg-ml-inference-squeezenet-demo-python/.gitignore: -------------------------------------------------------------------------------- 1 | *.egg-info 2 | camera 3 | videostream 4 | ggiot 5 | file_output 6 | greengrass_common 7 | greengrass_ipc_python_sdk 8 | greengrasssdk 9 | cbor2 10 | __pycache__ 11 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-gg-ml-inference-squeezenet-demo-python/requirements.txt: -------------------------------------------------------------------------------- 1 | ../libs/camera 2 | ../libs/ggiot 3 | ../libs/file_output 4 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-gg-ml-inference-squeezenet-demo-python/setup.cfg: -------------------------------------------------------------------------------- 1 | [install] 2 | prefix= 3 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-hello-world-python/.gitignore: -------------------------------------------------------------------------------- 1 | greengrasssdk 2 | greengrasssdk* 3 | cbor2 4 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-hello-world-python/lambda_function.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | 5 | # greengrassHelloWorld.py 6 | # Demonstrates a simple publish to a topic using Greengrass core sdk 7 | # This lambda function will retrieve underlying platform information and send 8 | # a hello world message along with the platform information to the topic 'hello/world' 9 | # The function will sleep for five seconds, then repeat. Since the function is 10 | # long-lived it will run forever when deployed to a Greengrass core. The handler 11 | # will NOT be invoked in our example since the we are executing an infinite loop. 12 | # 13 | # This can be found on the AWS IoT Console. 14 | 15 | import greengrasssdk 16 | import platform 17 | from threading import Timer 18 | import time 19 | 20 | # Creating a greengrass core sdk client 21 | client = greengrasssdk.client('iot-data') 22 | 23 | # Retrieving platform information to send from Greengrass Core 24 | my_platform = platform.platform() 25 | 26 | 27 | # When deployed to a Greengrass core, this code will be executed immediately 28 | # as a long-lived lambda function. The code will enter the infinite while loop 29 | # below. 30 | # If you execute a 'test' on the Lambda Console, this test will fail by hitting the 31 | # execution timeout of three seconds. This is expected as this function never returns 32 | # a result. 33 | 34 | def greengrass_hello_world_run(): 35 | if not my_platform: 36 | client.publish(topic='hello/world', payload='Hello world! Sent from Greengrass Core.') 37 | else: 38 | client.publish(topic='hello/world', 39 | payload='Hello world! Sent from Greengrass Core running on platform: {}'.format(my_platform)) 40 | 41 | # Asynchronously schedule this function to be run again in 5 seconds 42 | Timer(5, greengrass_hello_world_run).start() 43 | 44 | 45 | # Execute the function above 46 | greengrass_hello_world_run() 47 | 48 | # This is a dummy handler and will not be invoked 49 | # Instead the code above will be executed in an infinite loop for our example 50 | def function_handler(event, context): 51 | return 52 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-hello-world-python/requirements.txt: -------------------------------------------------------------------------------- 1 | greengrasssdk 2 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-hello-world-python/setup.cfg: -------------------------------------------------------------------------------- 1 | [install] 2 | prefix= 3 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-rpi-sense-hat-demo-python/.gitignore: -------------------------------------------------------------------------------- 1 | camera 2 | ggiot 3 | file_output 4 | greengrass_common 5 | greengrass_ipc_python_sdk 6 | greengrasssdk 7 | cbor2 8 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-rpi-sense-hat-demo-python/requirements.txt: -------------------------------------------------------------------------------- 1 | ../libs/ggiot 2 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-rpi-sense-hat-demo-python/sense_hat/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from .sense_hat import SenseHat, SenseHat as AstroPi 3 | from .stick import ( 4 | SenseStick, 5 | InputEvent, 6 | DIRECTION_UP, 7 | DIRECTION_DOWN, 8 | DIRECTION_LEFT, 9 | DIRECTION_RIGHT, 10 | DIRECTION_MIDDLE, 11 | ACTION_PRESSED, 12 | ACTION_RELEASED, 13 | ACTION_HELD, 14 | ) 15 | 16 | __version__ = '2.2.0' 17 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-rpi-sense-hat-demo-python/sense_hat/sense_hat_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/cf/defaults/lambdas/sputnik-rpi-sense-hat-demo-python/sense_hat/sense_hat_text.png -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-rpi-sense-hat-demo-python/sense_hat/sense_hat_text.txt: -------------------------------------------------------------------------------- 1 | +-*/!"#$><0123456789.=)(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz?,;:|@%[&_']\~ 2 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-rpi-sense-hat-demo-python/setup.cfg: -------------------------------------------------------------------------------- 1 | [install] 2 | prefix= 3 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-simple-greengrass-device-demo-python/.gitignore: -------------------------------------------------------------------------------- 1 | AWSIoTPythonSDK 2 | bin 3 | boto3 4 | botocore 5 | dateutil 6 | docutils 7 | jmespath 8 | s3transfer 9 | urllib3 10 | __pycache__ 11 | six.py 12 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-simple-greengrass-device-demo-python/requirements.txt: -------------------------------------------------------------------------------- 1 | boto3 2 | AWSIoTPythonSDK 3 | 4 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-simple-greengrass-device-demo-python/setup.cfg: -------------------------------------------------------------------------------- 1 | [install] 2 | prefix= 3 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-simple-greengrass-gateway-demo-python/.gitignore: -------------------------------------------------------------------------------- 1 | camera 2 | ggiot 3 | file_output 4 | greengrass_common 5 | greengrass_ipc_python_sdk 6 | greengrasssdk 7 | cbor2 8 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-simple-greengrass-gateway-demo-python/lambda_function.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | from ggiot import GGIoT 5 | import json 6 | import os 7 | import socket 8 | import sys 9 | from threading import Event, Thread, Timer 10 | import time 11 | import datetime 12 | import math 13 | 14 | ############################################# 15 | ## CONSTANT and variables declaration 16 | ############################################# 17 | #Change it with your configuration 18 | 19 | def get_parameter(name, default): 20 | if name in os.environ and os.environ[name] != "": 21 | return os.environ[name] 22 | return default 23 | 24 | 25 | THING_NAME = get_parameter("THING_NAME", get_parameter("AWS_IOT_THING_NAME", "UNKNOWN")) 26 | PREFIX = "sputnik" 27 | 28 | ############################################# 29 | ## INIT 30 | ############################################# 31 | 32 | # Greengrass 33 | GGIOT = GGIoT(thing=THING_NAME, prefix=PREFIX) 34 | 35 | 36 | ############################################# 37 | ## MAIN CODE 38 | ############################################# 39 | 40 | def lambda_handler(event, context): 41 | try: 42 | topic = context.client_context.custom["subject"] 43 | payload = event 44 | print('Received message on topic %s: %s\n' % (topic, json.dumps(payload))) 45 | 46 | payload['sputnikGatewayMessage'] = "Hello from gateway!" 47 | 48 | GGIOT.publish(PREFIX + "/" + THING_NAME + "/" + topic, payload) 49 | 50 | except Exception as e: 51 | print(e) 52 | 53 | return 54 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-simple-greengrass-gateway-demo-python/requirements.txt: -------------------------------------------------------------------------------- 1 | ../libs/ggiot 2 | -------------------------------------------------------------------------------- /source/cf/defaults/lambdas/sputnik-simple-greengrass-gateway-demo-python/setup.cfg: -------------------------------------------------------------------------------- 1 | [install] 2 | prefix= 3 | -------------------------------------------------------------------------------- /source/cf/sputnik-cloudtrail.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | AWSTemplateFormatVersion: '2010-09-09' 5 | Description: 'sputnik - CloudTrail - Version %%VERSION%%' 6 | 7 | Resources: 8 | 9 | cloudtrailBucket: 10 | DeletionPolicy: Retain 11 | Type: AWS::S3::Bucket 12 | Properties: {} 13 | 14 | cloudtrailBucketPolicy: 15 | Type: AWS::S3::BucketPolicy 16 | Properties: 17 | Bucket: !Ref cloudtrailBucket 18 | PolicyDocument: 19 | Version: "2012-10-17" 20 | Statement: 21 | - 22 | Sid: "AWSCloudTrailAclCheck" 23 | Effect: "Allow" 24 | Principal: 25 | Service: "cloudtrail.amazonaws.com" 26 | Action: "s3:GetBucketAcl" 27 | Resource: !Join ['', ['arn:aws:s3:::', !Ref cloudtrailBucket]] 28 | - 29 | Sid: "AWSCloudTrailWrite" 30 | Effect: "Allow" 31 | Principal: 32 | Service: "cloudtrail.amazonaws.com" 33 | Action: "s3:PutObject" 34 | Resource: !Join ['', ['arn:aws:s3:::', !Ref cloudtrailBucket, '/*']] 35 | Condition: 36 | StringEquals: 37 | s3:x-amz-acl: "bucket-owner-full-control" 38 | 39 | cloudTrail: 40 | DependsOn: 41 | - cloudtrailBucketPolicy 42 | Type: AWS::CloudTrail::Trail 43 | Properties: 44 | S3BucketName: !Ref cloudtrailBucket 45 | IsLogging: true 46 | 47 | Outputs: 48 | cloudtrailBucket: 49 | Description: 'sputnik CloudTrail Bucket' 50 | Value: !Ref cloudtrailBucket 51 | -------------------------------------------------------------------------------- /source/cf/sputnik-s3bucket-data.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | AWSTemplateFormatVersion: '2010-09-09' 5 | Description: 'sputnik - Data Bucket - Version %%VERSION%%' 6 | 7 | Resources: 8 | dataBucketAccessPolicy: 9 | Type: "AWS::IAM::ManagedPolicy" 10 | DeletionPolicy: Retain 11 | Properties: 12 | Description: "sputnik policy to access the Data Bucket." 13 | PolicyDocument: 14 | Version: "2012-10-17" 15 | Statement: 16 | - 17 | Effect: "Allow" 18 | Action: 19 | # TODO BE MORE RESTRICTIVE 20 | - "s3:ListBucket" 21 | - "s3:GetObject" 22 | - "s3:ListObjects" 23 | Resource: 24 | - !Join ["*", [!GetAtt dataBucket.Arn, "/*"]] 25 | - !Join ["", [!GetAtt dataBucket.Arn, "*"]] 26 | 27 | dataBucket: 28 | Type: AWS::S3::Bucket 29 | DeletionPolicy: Retain 30 | Properties: 31 | CorsConfiguration: 32 | CorsRules: 33 | - 34 | AllowedOrigins: 35 | - "*" 36 | AllowedMethods: 37 | - "HEAD" 38 | - "GET" 39 | AllowedHeaders: 40 | - "*" 41 | Outputs: 42 | dataBucket: 43 | Description: 'sputnik Data Bucket' 44 | Value: !Ref dataBucket 45 | dataBucketArn: 46 | Description: 'sputnik Data Bucket ARN' 47 | Value: !GetAtt dataBucket.Arn 48 | dataBucketAccessPolicyArn: 49 | Description: 'sputnik Data Bucket Access Policy ARN' 50 | Value: !Ref dataBucketAccessPolicy 51 | -------------------------------------------------------------------------------- /source/cf/sputnik-s3bucket-website.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | AWSTemplateFormatVersion: '2010-09-09' 5 | Description: 'sputnik - Website Bucket - Version %%VERSION%%' 6 | 7 | Parameters: 8 | IsWebsitePublic: 9 | Type: String 10 | Description: Do you want to make the public S3 website public ? 11 | Default: false 12 | AllowedValues: 13 | - true 14 | - false 15 | 16 | Conditions: 17 | MakeS3WebsiteBucketPublic: !Equals [ !Ref IsWebsitePublic, true ] 18 | 19 | 20 | Resources: 21 | websiteBucket: 22 | Type: AWS::S3::Bucket 23 | DeletionPolicy: Retain 24 | Properties: 25 | WebsiteConfiguration: 26 | IndexDocument: 'index.html' 27 | ErrorDocument: 'index.html' 28 | 29 | websiteBucketPolicy: 30 | Type: 'AWS::S3::BucketPolicy' 31 | Condition: MakeS3WebsiteBucketPublic 32 | Properties: 33 | Bucket: 34 | !Ref 'websiteBucket' 35 | PolicyDocument: 36 | Statement: 37 | Action: 's3:GetObject' 38 | Effect: 'Allow' 39 | Resource: !Join ['', ['arn:aws:s3:::', !Ref websiteBucket, '/*']] 40 | Principal: '*' 41 | 42 | Outputs: 43 | websiteBucket: 44 | Description: 'sputnik Website Bucket' 45 | Value: !Ref websiteBucket 46 | websiteBucketArn: 47 | Description: 'sputnik Website Bucket ARN' 48 | Value: !GetAtt websiteBucket.Arn 49 | websiteUrl: 50 | Description: 'sputnik Website URL' 51 | Value: !GetAtt websiteBucket.WebsiteURL 52 | -------------------------------------------------------------------------------- /source/console/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 4 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /source/console/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | yarn-error.log 34 | testem.log 35 | /typings 36 | /package-lock.json 37 | 38 | # System Files 39 | .DS_Store 40 | Thumbs.db 41 | -------------------------------------------------------------------------------- /source/console/README.md: -------------------------------------------------------------------------------- 1 | # sputnik website 2 | -------------------------------------------------------------------------------- /source/console/src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/console/src/app/app.component.css -------------------------------------------------------------------------------- /source/console/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /source/console/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { Router } from '@angular/router'; 3 | import { LoggerService } from './services/logger.service'; 4 | import { BlockUI, NgBlockUI } from 'ng-block-ui'; 5 | 6 | @Component({ 7 | selector: 'app-root', 8 | templateUrl: './app.component.html', 9 | styleUrls: ['./app.component.css'] 10 | }) 11 | export class AppComponent implements OnInit { 12 | @BlockUI() blockUI: NgBlockUI; 13 | 14 | constructor(public router: Router, private logger: LoggerService) { 15 | this.blockUI.start('Loading...'); 16 | } 17 | 18 | ngOnInit() { 19 | this.logger.info('AppComponent: Checking if the user is already authenticated'); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /source/console/src/app/common/modules/card/card.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, ContentChild, ElementRef } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-card', 5 | template: ` 6 |
7 |
8 | 9 |
10 |
11 |
12 | 13 |
14 |
15 | 16 |
17 |
18 | 19 |
20 |
21 | 24 |
25 | ` 26 | }) 27 | export class CardComponent { 28 | @ContentChild('header') header: ElementRef; 29 | @ContentChild('footer') footer: ElementRef; 30 | @ContentChild('title') title: ElementRef; 31 | @ContentChild('subtitle') subtitle: ElementRef; 32 | @ContentChild('text') text: ElementRef; 33 | 34 | constructor() {} 35 | } 36 | -------------------------------------------------------------------------------- /source/console/src/app/common/modules/card/card.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | // Components 5 | import { CardComponent } from './card.component'; 6 | 7 | @NgModule({ 8 | declarations: [CardComponent], 9 | exports: [CardComponent], 10 | imports: [CommonModule], 11 | providers: [] 12 | }) 13 | export class CardModule {} 14 | -------------------------------------------------------------------------------- /source/console/src/app/common/modules/gauge/gauge.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | // Components 5 | import { GaugeComponent } from './gauge.component'; 6 | 7 | @NgModule({ 8 | declarations: [GaugeComponent], 9 | exports: [GaugeComponent], 10 | imports: [CommonModule], 11 | providers: [] 12 | }) 13 | export class GaugeModule {} 14 | -------------------------------------------------------------------------------- /source/console/src/app/common/modules/graph-line/graph-line.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { ChartsModule } from 'ng2-charts'; 4 | 5 | // Components 6 | import { GraphLineComponent } from './graph-line.component'; 7 | 8 | @NgModule({ 9 | declarations: [GraphLineComponent], 10 | exports: [GraphLineComponent], 11 | imports: [CommonModule, ChartsModule], 12 | providers: [ChartsModule] 13 | }) 14 | export class GraphLineModule {} 15 | -------------------------------------------------------------------------------- /source/console/src/app/common/modules/pretty-json/pretty-json.component.html: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /source/console/src/app/common/modules/pretty-json/pretty-json.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule } from '@angular/forms'; 4 | 5 | // Components 6 | import { PrettyJsonComponent } from './pretty-json.component'; 7 | 8 | // Pipes 9 | import { PipesModule } from '@pipes/pipes.module'; 10 | 11 | @NgModule({ 12 | declarations: [PrettyJsonComponent], 13 | exports: [PrettyJsonComponent], 14 | imports: [ 15 | CommonModule, 16 | FormsModule, 17 | 18 | // Pipes 19 | PipesModule 20 | ] 21 | }) 22 | export class PrettyJsonModule {} 23 | -------------------------------------------------------------------------------- /source/console/src/app/common/modules/table/table.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit } from '@angular/core'; 2 | import { Router } from '@angular/router'; 3 | 4 | // Services 5 | import { LoggerService } from '@services/logger.service'; 6 | 7 | export class TableHeader { 8 | attr: string; 9 | name: string; 10 | class: string; 11 | pipe: string; 12 | pipeValue: string; 13 | } 14 | 15 | export class Pages { 16 | current: Number; 17 | total: Number; 18 | pageSize: Number; 19 | } 20 | 21 | @Component({ 22 | selector: 'app-table', 23 | templateUrl: './table.component.html' 24 | }) 25 | export class TableComponent implements OnInit { 26 | @Input() 27 | dataPagingLimit: Number = 10; 28 | @Input() 29 | data: any; 30 | @Input() 31 | tableData: any[]; 32 | @Input() 33 | tableHeaders: TableHeader[]; 34 | @Input() 35 | pages: Pages; 36 | @Input() 37 | openAttribute: string; 38 | @Input() 39 | openPath: string; 40 | 41 | constructor(private logger: LoggerService, private router: Router) { 42 | this.logger.info('constructor'); 43 | this.data = []; 44 | this.tableData = []; 45 | this.tableHeaders = []; 46 | this.pages = null; 47 | this.openAttribute = null; 48 | this.openPath = null; 49 | } 50 | 51 | ngOnInit() { 52 | this.logger.info('onInit'); 53 | } 54 | 55 | click(elem) { 56 | if (this.openAttribute !== null && this.openPath !== null) { 57 | this.router.navigate([this.openPath + elem[this.openAttribute]]); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /source/console/src/app/common/modules/table/table.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | // Components 5 | import { TableComponent } from './table.component'; 6 | 7 | // Pipes 8 | import { PipesModule } from '@pipes/pipes.module'; 9 | 10 | @NgModule({ 11 | declarations: [TableComponent], 12 | exports: [TableComponent], 13 | imports: [ 14 | CommonModule, 15 | 16 | // Pipes 17 | PipesModule 18 | ] 19 | }) 20 | export class TableModule {} 21 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/attach-principal-policy.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation AttachPrincipalPolicy($policyName: String!, $principal: String!) { 5 | attachPrincipalPolicy(policyName: $policyName, principal: $principal) 6 | } 7 | `; 8 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/deployment.add.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation AddDeployment($thingId: String!) { 5 | addDeployment(thingId: $thingId) { 6 | thingId 7 | deploymentId 8 | type 9 | spec 10 | greengrassGroup 11 | createdAt 12 | updatedAt 13 | } 14 | } 15 | `; 16 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/device-blueprint.add.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation AddDeviceAlueprint( 5 | $name: String! 6 | $type: String! 7 | $compatibility: [String]! 8 | $deviceTypeMappings: AWSJSON! 9 | $spec: AWSJSON! 10 | ) { 11 | addDeviceBlueprint( 12 | name: $name 13 | type: $type 14 | compatibility: $compatibility 15 | deviceTypeMappings: $deviceTypeMappings 16 | spec: $spec 17 | ) { 18 | id 19 | name 20 | type 21 | compatibility 22 | deviceTypeMappings 23 | spec 24 | createdAt 25 | updatedAt 26 | } 27 | } 28 | `; 29 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/device-blueprint.delete.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation DeleteDeviceBlueprint($id: String!) { 5 | deleteDeviceBlueprint(id: $id) { 6 | id 7 | name 8 | type 9 | compatibility 10 | deviceTypeMappings 11 | spec 12 | createdAt 13 | updatedAt 14 | } 15 | } 16 | `; 17 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/device-blueprint.update.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation UpdateDeviceBlueprint( 5 | $id: String! 6 | $name: String! 7 | $type: String! 8 | $compatibility: [String]! 9 | $deviceTypeMappings: AWSJSON! 10 | $spec: AWSJSON! 11 | ) { 12 | updateDeviceBlueprint( 13 | id: $id 14 | name: $name 15 | type: $type 16 | compatibility: $compatibility 17 | deviceTypeMappings: $deviceTypeMappings 18 | spec: $spec 19 | ) { 20 | id 21 | name 22 | type 23 | compatibility 24 | deviceTypeMappings 25 | spec 26 | createdAt 27 | updatedAt 28 | } 29 | } 30 | `; 31 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/device-type.add.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation AddDeviceType( 5 | $name: String! 6 | $type: String! 7 | $spec: AWSJSON 8 | ) { 9 | addDeviceType( 10 | name: $name 11 | type: $type 12 | spec: $spec 13 | ) { 14 | id 15 | name 16 | type 17 | spec 18 | createdAt 19 | updatedAt 20 | } 21 | } 22 | `; 23 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/device-type.delete.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation DeleteDeviceType( 5 | $id: String! 6 | ) { 7 | deleteDeviceType( 8 | id: $id 9 | ) { 10 | id 11 | name 12 | type 13 | spec 14 | createdAt 15 | updatedAt 16 | } 17 | } 18 | `; 19 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/device-type.update.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation UpdateDeviceType( 5 | $id: String! 6 | $name: String! 7 | $type: String! 8 | $spec: AWSJSON 9 | ) { 10 | updateDeviceType( 11 | id: $id 12 | name: $name 13 | type: $type 14 | spec: $spec 15 | ) { 16 | id 17 | name 18 | type 19 | spec 20 | createdAt 21 | updatedAt 22 | } 23 | } 24 | `; 25 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/device.add.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation AddDevice( 5 | $name: String! 6 | $deviceTypeId: String! 7 | $deviceBlueprintId: String! 8 | ) { 9 | addDevice( 10 | name: $name 11 | deviceTypeId: $deviceTypeId 12 | deviceBlueprintId: $deviceBlueprintId 13 | ) { 14 | thingId 15 | thingName 16 | thingArn 17 | name 18 | deviceTypeId 19 | deviceBlueprintId 20 | greengrassGroupId 21 | spec 22 | lastDeploymentId 23 | createdAt 24 | updatedAt 25 | } 26 | } 27 | `; 28 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/device.create-certificate.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation CreateCertificate($thingId: String!, $csr: String!) { 5 | createCertificate(thingId: $thingId, csr: $csr) { 6 | certificateArn 7 | certificateId 8 | certificatePem 9 | } 10 | } 11 | `; 12 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/device.delete.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation DeleteDevice($thingId: String!) { 5 | deleteDevice(thingId: $thingId) { 6 | thingId 7 | thingName 8 | thingArn 9 | name 10 | deviceTypeId 11 | deviceBlueprintId 12 | greengrassGroupId 13 | spec 14 | lastDeploymentId 15 | createdAt 16 | updatedAt 17 | } 18 | } 19 | `; 20 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/device.update.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation UpdateDevice( 5 | $thingId: String! 6 | $name: String! 7 | $deviceTypeId: String! 8 | $deviceBlueprintId: String! 9 | $spec: AWSJSON! 10 | ) { 11 | updateDevice( 12 | thingId: $thingId 13 | name: $name 14 | deviceTypeId: $deviceTypeId 15 | deviceBlueprintId: $deviceBlueprintId 16 | spec: $spec 17 | ) { 18 | thingId 19 | thingName 20 | thingArn 21 | name 22 | deviceTypeId 23 | deviceBlueprintId 24 | greengrassGroupId 25 | spec 26 | lastDeploymentId 27 | createdAt 28 | updatedAt 29 | } 30 | } 31 | `; 32 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/iotdata-thing-shadow.update.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation UpdateThingShadow($params: AWSJSON!) { 5 | updateThingShadow(params: $params) { 6 | payload 7 | } 8 | } 9 | `; 10 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/just-in-time-on-boarding-state.set.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation SetJustInTimeOnBoardingState($enabled: Boolean!) { 5 | setJustInTimeOnBoardingState(enabled: $enabled) 6 | } 7 | `; 8 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/setting.update.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation UpdateSetting($id: String!, $type: String!, $setting: AWSJSON!) { 5 | updateSetting(id: $id, type: $type, setting: $setting) { 6 | id 7 | type 8 | setting 9 | createdAt 10 | updatedAt 11 | } 12 | } 13 | `; 14 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/system-blueprint.add.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation AddSystemBlueprint($name: String!, $description: String, $prefix: String!, $spec: AWSJSON!) { 5 | addSystemBlueprint( 6 | name: $name 7 | description: $description 8 | prefix: $prefix 9 | spec: $spec 10 | ) { 11 | id 12 | name 13 | description 14 | prefix 15 | spec 16 | createdAt 17 | updatedAt 18 | } 19 | } 20 | `; 21 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/system-blueprint.delete.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation DeleteSystemBlueprint($id: String!) { 5 | deleteSystemBlueprint(id: $id) { 6 | id 7 | name 8 | description 9 | prefix 10 | spec 11 | createdAt 12 | updatedAt 13 | } 14 | } 15 | `; 16 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/system-blueprint.update.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation UpdateSystemBlueprint($id: String!, $name: String!, $description: String, $prefix: String!, $spec: AWSJSON!) { 5 | updateSystemBlueprint(id: $id, name: $name, description: $description, prefix: $prefix, spec: $spec) { 6 | id 7 | name 8 | description 9 | prefix 10 | spec 11 | createdAt 12 | updatedAt 13 | } 14 | } 15 | `; 16 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/system.add.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation AddSystem($name: String!, $description: String, $deviceIds: [String]!, $systemBlueprintId: String!) { 5 | addSystem( 6 | name: $name 7 | description: $description 8 | deviceIds: $deviceIds 9 | systemBlueprintId: $systemBlueprintId 10 | ) { 11 | id 12 | name 13 | description 14 | deviceIds 15 | systemBlueprintId 16 | createdAt 17 | updatedAt 18 | } 19 | } 20 | `; 21 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/system.delete.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation DeleteSystem($id: String!) { 5 | deleteSystem(id: $id) { 6 | id 7 | name 8 | description 9 | deviceIds 10 | systemBlueprintId 11 | createdAt 12 | updatedAt 13 | } 14 | } 15 | `; 16 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/system.refresh.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation RefreshSystem($id: String!) { 5 | refreshSystem(id: $id) 6 | } 7 | `; 8 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/system.update.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation UpdateSystem($id: String!, $name: String!, $description: String, $deviceIds: [String]!) { 5 | updateSystem(id: $id, name: $name, description: $description, deviceIds: $deviceIds) { 6 | id 7 | name 8 | description 9 | deviceIds 10 | systemBlueprintId 11 | createdAt 12 | updatedAt 13 | } 14 | } 15 | `; 16 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/user.delete.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation DeleteUser($username: String!) { 5 | deleteUser(username: $username) { 6 | user_id 7 | name 8 | email 9 | enabled 10 | groups { 11 | name 12 | _state 13 | } 14 | status 15 | created_at 16 | updated_at 17 | } 18 | } 19 | `; 20 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/user.disable.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation DisableUser($username: String!) { 5 | disableUser(username: $username) { 6 | user_id 7 | name 8 | email 9 | enabled 10 | groups { 11 | name 12 | _state 13 | } 14 | status 15 | created_at 16 | updated_at 17 | } 18 | } 19 | `; 20 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/user.enable.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation EnableUser($username: String!) { 5 | enableUser(username: $username) { 6 | user_id 7 | name 8 | email 9 | enabled 10 | groups { 11 | name 12 | _state 13 | } 14 | status 15 | created_at 16 | updated_at 17 | } 18 | } 19 | `; 20 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/user.invite.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation InviteUser($name: String!, $email: String!, $groups: AWSJSON!) { 5 | inviteUser(name: $name, email: $email, groups: $groups) 6 | } 7 | `; 8 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/mutations/user.update.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | mutation UpdateUser($username: String!, $groups: AWSJSON!) { 5 | updateUser(username: $username, groups: $groups) { 6 | user_id 7 | name 8 | email 9 | enabled 10 | groups { 11 | name 12 | _state 13 | } 14 | status 15 | created_at 16 | updated_at 17 | } 18 | } 19 | `; 20 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/data.get.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query GetData($thingName: String!, $metricName: String!, $timeAgoInSecs: Int!) { 5 | getData(thingName: $thingName, metricName: $metricName, timeAgoInSecs: $timeAgoInSecs) { 6 | Data { 7 | ThingNameAndMetric 8 | Timestamp 9 | Data 10 | } 11 | } 12 | } 13 | `; 14 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/deployments.list.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query ListDeployments($limit: Int, $nextToken: String) { 5 | listDeployments(limit: $limit, nextToken: $nextToken) { 6 | deployments { 7 | thingId 8 | deploymentId 9 | type 10 | createdAt 11 | updatedAt 12 | } 13 | nextToken 14 | } 15 | } 16 | `; 17 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/describe-endpoint.get.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query DescribeEndpoint($endpointType: String) { 5 | describeEndpoint(endpointType: $endpointType) 6 | } 7 | `; 8 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/device-blueprint.get.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query GetDeviceBlueprint($id: String!) { 5 | getDeviceBlueprint(id: $id) { 6 | id 7 | name 8 | type 9 | compatibility 10 | deviceTypeMappings 11 | spec 12 | createdAt 13 | updatedAt 14 | } 15 | } 16 | `; 17 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/device-blueprints.list.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query ListDeviceBlueprints($limit: Int, $nextToken: String) { 5 | listDeviceBlueprints(limit: $limit, nextToken: $nextToken) { 6 | deviceBlueprints { 7 | id 8 | name 9 | type 10 | compatibility 11 | deviceTypeMappings 12 | spec 13 | createdAt 14 | updatedAt 15 | } 16 | nextToken 17 | } 18 | } 19 | `; 20 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/device-type.get.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query GetDeviceType($id: String!) { 5 | getDeviceType(id: $id) { 6 | id 7 | name 8 | type 9 | spec 10 | createdAt 11 | updatedAt 12 | } 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/device-types.list.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query ListDeviceTypes($limit: Int, $nextToken: String) { 5 | listDeviceTypes(limit: $limit, nextToken: $nextToken) { 6 | deviceTypes { 7 | id 8 | name 9 | type 10 | spec 11 | createdAt 12 | updatedAt 13 | } 14 | nextToken 15 | } 16 | } 17 | `; 18 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/device.get.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query GetDevice($thingId: String!) { 5 | getDevice(thingId: $thingId) { 6 | thingId 7 | thingName 8 | thingArn 9 | name 10 | deviceTypeId 11 | deviceBlueprintId 12 | certificateArn 13 | connectionState { 14 | state 15 | at 16 | } 17 | spec 18 | greengrassGroupId 19 | lastDeploymentId 20 | createdAt 21 | updatedAt 22 | } 23 | } 24 | `; 25 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/device.getStats.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query GetDeviceStats { 5 | getDeviceStats { 6 | total 7 | connected 8 | disconnected 9 | } 10 | } 11 | `; 12 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/devices-of-device-type.list.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query ListDevicesOfDeviceType($deviceTypeId: String!, $limit: Int, $nextToken: String) { 5 | listDevicesOfDeviceType(deviceTypeId: $deviceTypeId, limit: $limit, nextToken: $nextToken) { 6 | devices { 7 | thingId 8 | thingName 9 | thingArn 10 | name 11 | deviceTypeId 12 | deviceBlueprintId 13 | connectionState { 14 | state 15 | at 16 | } 17 | spec 18 | greengrassGroupId 19 | createdAt 20 | updatedAt 21 | } 22 | nextToken 23 | } 24 | } 25 | `; 26 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/devices-with-device-blueprint.list.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query ListDevicesWithDeviceBlueprint($deviceBlueprintId: String!, $limit: Int, $nextToken: String) { 5 | listDevicesWithDeviceBlueprint(deviceBlueprintId: $deviceBlueprintId, limit: $limit, nextToken: $nextToken) { 6 | devices { 7 | thingId 8 | thingName 9 | thingArn 10 | name 11 | deviceTypeId 12 | deviceBlueprintId 13 | } 14 | nextToken 15 | } 16 | } 17 | `; 18 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/devices.list.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query ListDevices($limit: Int, $nextToken: String) { 5 | listDevices(limit: $limit, nextToken: $nextToken) { 6 | devices { 7 | thingId 8 | thingName 9 | name 10 | deviceTypeId 11 | deviceBlueprintId 12 | connectionState { 13 | state 14 | at 15 | } 16 | lastDeploymentId 17 | createdAt 18 | updatedAt 19 | } 20 | nextToken 21 | } 22 | } 23 | `; 24 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/groups.list.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query ListGroups($limit: Int, $nextToken: String) { 5 | listGroups(limit: $limit, nextToken: $nextToken) { 6 | Groups { 7 | GroupName 8 | UserPoolId 9 | Description 10 | RoleArn 11 | Precedence 12 | LastModifiedDate 13 | CreationDate 14 | } 15 | NextToken 16 | } 17 | } 18 | `; 19 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/iotdata-thing-shadow.get.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query GetThingShadow($params: AWSJSON!) { 5 | getThingShadow(params: $params) { 6 | payload 7 | } 8 | } 9 | `; 10 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/just-in-time-on-boarding-state.get.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query GetJustInTimeOnBoardingState { 5 | getJustInTimeOnBoardingState 6 | } 7 | `; 8 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/s3.list-objects-v2.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query S3ListObjectsV2($params: AWSJSON!) { 5 | s3ListObjectsV2(params: $params) { 6 | Contents { 7 | Key 8 | } 9 | KeyCount 10 | NextContinuationToken 11 | IsTruncated 12 | } 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/setting.get.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query GetSetting($id: String!) { 5 | getSetting(id: $id) { 6 | id 7 | type 8 | setting 9 | createdAt 10 | updatedAt 11 | } 12 | } 13 | `; 14 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/system-blueprint.get.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query GetSystemBlueprint($id: String!) { 5 | getSystemBlueprint(id: $id) { 6 | id 7 | name 8 | description 9 | prefix 10 | spec 11 | createdAt 12 | updatedAt 13 | } 14 | } 15 | `; 16 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/system-blueprints.list.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query ListSystemBlueprints($limit: Int, $nextToken: String) { 5 | listSystemBlueprints(limit: $limit, nextToken: $nextToken) { 6 | systemBlueprints { 7 | id 8 | name 9 | description 10 | prefix 11 | spec 12 | createdAt 13 | updatedAt 14 | } 15 | nextToken 16 | } 17 | } 18 | `; 19 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/system.get.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query GetSystem($id: String!) { 5 | getSystem(id: $id) { 6 | id 7 | name 8 | description 9 | deviceIds 10 | systemBlueprintId 11 | createdAt 12 | updatedAt 13 | } 14 | } 15 | `; 16 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/system.getStats.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query GetSystemStats { 5 | getSystemStats { 6 | total 7 | } 8 | } 9 | `; 10 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/systems.list.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query ListSystems($limit: Int, $nextToken: String) { 5 | listSystems(limit: $limit, nextToken: $nextToken) { 6 | systems { 7 | id 8 | name 9 | description 10 | deviceIds 11 | systemBlueprintId 12 | createdAt 13 | updatedAt 14 | } 15 | nextToken 16 | } 17 | } 18 | `; 19 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/user.get.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query GetUser($username: String!) { 5 | getUser(username: $username) { 6 | user_id 7 | name 8 | email 9 | enabled 10 | groups { 11 | name 12 | _state 13 | } 14 | status 15 | created_at 16 | updated_at 17 | } 18 | } 19 | `; 20 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/queries/users.list.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | query ListUsers($limit: Int, $paginationToken: String) { 5 | listUsers(limit: $limit, paginationToken: $paginationToken) { 6 | Users { 7 | user_id 8 | name 9 | email 10 | enabled 11 | groups { 12 | name 13 | _state 14 | } 15 | status 16 | created_at 17 | updated_at 18 | } 19 | PaginationToken 20 | } 21 | } 22 | `; 23 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/device-blueprint.added.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription AddedDeviceBlueprint { 5 | addedDeviceBlueprint { 6 | id 7 | name 8 | type 9 | compatibility 10 | deviceTypeMappings 11 | spec 12 | createdAt 13 | updatedAt 14 | } 15 | } 16 | `; 17 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/device-blueprint.deleted.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription DeletedDeviceBlueprint { 5 | deletedDeviceBlueprint { 6 | id 7 | name 8 | type 9 | compatibility 10 | deviceTypeMappings 11 | spec 12 | createdAt 13 | updatedAt 14 | } 15 | } 16 | `; 17 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/device-blueprint.updated.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription UpdatedDeviceBlueprint { 5 | updatedDeviceBlueprint { 6 | id 7 | name 8 | type 9 | compatibility 10 | deviceTypeMappings 11 | spec 12 | createdAt 13 | updatedAt 14 | } 15 | } 16 | `; 17 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/device-type.added.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription AddedDeviceType { 5 | addedDeviceType { 6 | id 7 | name 8 | type 9 | spec 10 | createdAt 11 | updatedAt 12 | } 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/device-type.deleted.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription DeletedDeviceType { 5 | deletedDeviceType { 6 | id 7 | name 8 | type 9 | spec 10 | createdAt 11 | updatedAt 12 | } 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/device-type.updated.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription UpdatedDeviceType { 5 | updatedDeviceType { 6 | id 7 | name 8 | type 9 | spec 10 | createdAt 11 | updatedAt 12 | } 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/device.added.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription AddedDevice { 5 | addedDevice { 6 | thingId 7 | thingName 8 | deviceTypeId 9 | deviceBlueprintId 10 | connectionState { 11 | state 12 | at 13 | } 14 | greengrassGroupId 15 | lastDeploymentId 16 | createdAt 17 | updatedAt 18 | } 19 | } 20 | `; 21 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/device.deleted.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription DeletedDevice { 5 | deletedDevice { 6 | thingId 7 | thingName 8 | deviceTypeId 9 | deviceBlueprintId 10 | connectionState { 11 | state 12 | at 13 | } 14 | greengrassGroupId 15 | lastDeploymentId 16 | createdAt 17 | updatedAt 18 | } 19 | } 20 | `; 21 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/device.updated.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription UpdatedDevice { 5 | updatedDevice { 6 | thingId 7 | thingName 8 | deviceTypeId 9 | deviceBlueprintId 10 | connectionState { 11 | state 12 | at 13 | } 14 | greengrassGroupId 15 | lastDeploymentId 16 | createdAt 17 | updatedAt 18 | } 19 | } 20 | `; 21 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/system-blueprint.added.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription AddedSystemBlueprint { 5 | addedSystemBlueprint { 6 | id 7 | name 8 | description 9 | spec 10 | createdAt 11 | updatedAt 12 | } 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/system-blueprint.deleted.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription DeletedSystemBlueprint { 5 | deletedSystemBlueprint { 6 | id 7 | name 8 | description 9 | spec 10 | createdAt 11 | updatedAt 12 | } 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/system-blueprint.updated.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription UpdatedSystemBlueprint { 5 | updatedSystemBlueprint { 6 | id 7 | name 8 | description 9 | spec 10 | createdAt 11 | updatedAt 12 | } 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/system.added.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription AddedSystem { 5 | addedSystem { 6 | id 7 | deviceIds 8 | name 9 | systemBlueprintId 10 | createdAt 11 | updatedAt 12 | } 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/system.deleted.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription DeletedSystem { 5 | deletedSystem { 6 | id 7 | deviceIds 8 | name 9 | systemBlueprintId 10 | createdAt 11 | updatedAt 12 | } 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /source/console/src/app/graphql/subscriptions/system.updated.ts: -------------------------------------------------------------------------------- 1 | import gql from 'graphql-tag'; 2 | 3 | export default gql` 4 | subscription UpdatedSystem { 5 | updatedSystem { 6 | id 7 | deviceIds 8 | name 9 | systemBlueprintId 10 | createdAt 11 | updatedAt 12 | } 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /source/console/src/app/models/addon.model.ts: -------------------------------------------------------------------------------- 1 | 2 | export class AddOn { 3 | id: string; 4 | name: string; 5 | img: string; 6 | version: string; 7 | description: string; 8 | 9 | constructor(values: Object = {}) { 10 | Object.assign(this, values); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /source/console/src/app/models/data.model.ts: -------------------------------------------------------------------------------- 1 | 2 | export class Data { 3 | thingNameAndMetric: string; 4 | timestamp: number; 5 | data: any; 6 | 7 | constructor(values: Object = {}) { 8 | Object.assign(this, values); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /source/console/src/app/models/deployment.model.ts: -------------------------------------------------------------------------------- 1 | export class Deployment { 2 | thingId: string; 3 | deploymentId: string; 4 | spec = '{}'; 5 | createdAt: string; 6 | updatedAt: string; 7 | 8 | constructor(values: Object = {}) { 9 | Object.assign(this, values); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /source/console/src/app/models/device-blueprint.model.ts: -------------------------------------------------------------------------------- 1 | export class DeviceBlueprint { 2 | id: string; 3 | name = 'new'; 4 | type = 'UNKNOWN'; 5 | compatibility: string[] = []; 6 | deviceTypeMappings: any = []; 7 | spec: any = {}; 8 | createdAt: string; 9 | updatedAt: string; 10 | 11 | constructor(values: Object = {}) { 12 | Object.assign(this, values); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /source/console/src/app/models/device-type.model.ts: -------------------------------------------------------------------------------- 1 | export class DeviceType { 2 | id: string; 3 | name = 'new'; 4 | type = 'UNKNOWN'; 5 | spec: any = {}; 6 | createdAt: string; 7 | updatedAt: string; 8 | 9 | constructor(values: Object = {}) { 10 | Object.assign(this, values); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /source/console/src/app/models/device.model.ts: -------------------------------------------------------------------------------- 1 | export class ConnectionState { 2 | state: string; 3 | at: string; 4 | constructor(values: Object = {}) { 5 | Object.assign(this, values); 6 | } 7 | } 8 | 9 | export class Device { 10 | thingId: string; 11 | thingName: string; 12 | thingArn: string; 13 | name: string; 14 | deviceTypeId: string; 15 | deviceBlueprintId: string; 16 | greengrassGroupId: string; 17 | spec: any = {}; 18 | connectionState: ConnectionState = new ConnectionState(); 19 | lastDeploymentId: string; 20 | createdAt: string; 21 | updatedAt: string; 22 | certificateArn: string; 23 | 24 | constructor(values: Object = {}) { 25 | Object.assign(this, values); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /source/console/src/app/models/group.model.ts: -------------------------------------------------------------------------------- 1 | export class Group { 2 | GroupName: string; 3 | UserPoolId: string; 4 | Description: string; 5 | LastModifiedDate: string; 6 | CreationDate: string; 7 | 8 | constructor(values: Object = {}) { 9 | Object.assign(this, values); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /source/console/src/app/models/invitation-model.ts: -------------------------------------------------------------------------------- 1 | export class Invitation { 2 | name: string; 3 | email: string; 4 | groups: any[]; 5 | } 6 | -------------------------------------------------------------------------------- /source/console/src/app/models/invitation.model.ts: -------------------------------------------------------------------------------- 1 | export class Invitation { 2 | name: string; 3 | email: string; 4 | groups: any[]; 5 | } 6 | -------------------------------------------------------------------------------- /source/console/src/app/models/message.model.ts: -------------------------------------------------------------------------------- 1 | export class Message { 2 | topic: string; 3 | content: any = {}; 4 | timestamp: string; 5 | 6 | constructor(values: Object = {}) { 7 | Object.assign(this, values); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /source/console/src/app/models/new-password-user.model.ts: -------------------------------------------------------------------------------- 1 | export class NewPasswordUser { 2 | email: string; 3 | existingPassword: string; 4 | password: string; 5 | } 6 | -------------------------------------------------------------------------------- /source/console/src/app/models/profile-info.model.ts: -------------------------------------------------------------------------------- 1 | // declare let _: any; 2 | import * as _ from 'underscore'; 3 | 4 | export class ProfileInfo { 5 | user_id: string; 6 | name: string; 7 | email: string; 8 | enabled: boolean; 9 | groups: any[]; 10 | mapboxToken: string; 11 | 12 | constructor(values: Object = {}) { 13 | Object.assign(this, values); 14 | } 15 | 16 | isAdmin(): boolean { 17 | return _.contains(this.groups, 'Administrators'); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /source/console/src/app/models/registration-user.model.ts: -------------------------------------------------------------------------------- 1 | export class RegistrationUser { 2 | name: string; 3 | email: string; 4 | password: string; 5 | } 6 | -------------------------------------------------------------------------------- /source/console/src/app/models/setting.model.ts: -------------------------------------------------------------------------------- 1 | export class Setting { 2 | id: string = ''; 3 | type: string = ''; 4 | setting: any = {}; 5 | createdAt: string = ''; 6 | updatedAt: string = ''; 7 | 8 | constructor(values: Object = {}) { 9 | Object.assign(this, values); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /source/console/src/app/models/stats.model.ts: -------------------------------------------------------------------------------- 1 | export class DeviceStats { 2 | total = 0; 3 | connected = 0; 4 | disconnected = 0; 5 | constructor(values: Object = {}) { 6 | Object.assign(this, values); 7 | } 8 | } 9 | 10 | export class SystemStats { 11 | total = 0; 12 | constructor(values: Object = {}) { 13 | Object.assign(this, values); 14 | } 15 | } 16 | 17 | export class SystemBlueprintStats { 18 | total = 0; 19 | constructor(values: Object = {}) { 20 | Object.assign(this, values); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /source/console/src/app/models/system-blueprint.model.ts: -------------------------------------------------------------------------------- 1 | export class SystemBlueprint { 2 | id: string; 3 | name = 'new'; 4 | description = 'UNKNOWN'; 5 | prefix = 'Sputnik_'; 6 | spec: any = {}; 7 | createdAt: string; 8 | updatedAt: string; 9 | 10 | constructor(values: Object = {}) { 11 | Object.assign(this, values); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /source/console/src/app/models/system.model.ts: -------------------------------------------------------------------------------- 1 | export class System { 2 | id: string; 3 | name = 'new'; 4 | description = 'UNKNOWN'; 5 | deviceIds: string[] = []; 6 | systemBlueprintId: string; // = 'UNKNOWN'; 7 | createdAt: string; 8 | updatedAt: string; 9 | 10 | constructor(values: Object = {}) { 11 | Object.assign(this, values); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /source/console/src/app/models/user.model.ts: -------------------------------------------------------------------------------- 1 | export class User { 2 | user_id: string; 3 | name: string; 4 | email: string; 5 | enabled: string; 6 | groups: any[]; 7 | status: string; 8 | created_at: string; 9 | updated_at: string; 10 | 11 | constructor(values: Object = {}) { 12 | Object.assign(this, values); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /source/console/src/app/pipes/cert-id-from-arn.pipe.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | @Pipe({ name: 'certIdFromArn', pure: true }) 4 | export class CertIdFromArnPipe implements PipeTransform { 5 | 6 | constructor() {} 7 | 8 | transform(arn: string): string { 9 | if (arn === undefined || arn === 'NOTSET') { 10 | return 'Certificate Not Defined!'; 11 | } else { 12 | return arn.split('cert/')[1]; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /source/console/src/app/pipes/device-blueprint-name-from-id.pipe.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | import { DeviceBlueprint } from '@models/device-blueprint.model'; 4 | 5 | import { DeviceBlueprintService } from '@services/device-blueprint.service'; 6 | 7 | @Pipe({ name: 'deviceBlueprintNameFromId', pure: true }) 8 | export class DeviceBlueprintNameFromIdPipe implements PipeTransform { 9 | 10 | constructor(private deviceBlueprintService: DeviceBlueprintService) {} 11 | 12 | transform(id: string): string { 13 | const index = this.deviceBlueprintService.deviceBlueprints.findIndex((db: DeviceBlueprint) => { 14 | return db.id === id; 15 | }); 16 | if (index !== -1) { 17 | return this.deviceBlueprintService.deviceBlueprints[index].name; 18 | } else { 19 | return ''; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /source/console/src/app/pipes/device-type-name-from-id.pipe.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | import { DeviceType } from '@models/device-type.model'; 4 | 5 | import { DeviceTypeService } from '@services/device-type.service'; 6 | 7 | @Pipe({ name: 'deviceTypeNameFromId', pure: true }) 8 | // export class DeviceTypeNameFromIdPipe implements PipeTransform { 9 | // transform(id: string, deviceTypes: DeviceType[]): string { 10 | // const index = deviceTypes.findIndex((dt: DeviceType) => { 11 | // return dt.id === id; 12 | // }); 13 | // if (index !== -1) { 14 | // return deviceTypes[index].name; 15 | // } else { 16 | // return ''; 17 | // } 18 | // } 19 | // } 20 | export class DeviceTypeNameFromIdPipe implements PipeTransform { 21 | 22 | constructor(private deviceTypeService: DeviceTypeService) {} 23 | 24 | transform(id: string): string { 25 | const index = this.deviceTypeService.deviceTypes.findIndex((dt: DeviceType) => { 26 | return dt.id === id; 27 | }); 28 | if (index !== -1) { 29 | return this.deviceTypeService.deviceTypes[index].name; 30 | } else { 31 | return ''; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /source/console/src/app/pipes/moment.pipe.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | import * as moment from 'moment'; 4 | 5 | @Pipe({ name: 'moment' }) 6 | export class MomentPipe implements PipeTransform { 7 | transform(value: any, format: string): any { 8 | return moment(value).format(format); 9 | } 10 | } 11 | 12 | @Pipe({ name: 'fromNow' }) 13 | export class FromNowPipe implements PipeTransform { 14 | transform(value: any): any { 15 | return moment(value).fromNow(); 16 | } 17 | } 18 | 19 | @Pipe({ name: 'fromNowValue' }) 20 | export class FromNowValuePipe implements PipeTransform { 21 | transform(value: any): any { 22 | return moment().diff(moment(value), 'seconds'); 23 | } 24 | } 25 | 26 | @Pipe({ name: 'momentTo' }) 27 | export class MomentToPipe implements PipeTransform { 28 | transform(value: any, offsetSeconds: number = 0): any { 29 | return moment().to(moment(value).add(offsetSeconds, 'seconds')); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /source/console/src/app/pipes/pipes.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | // Pipes 5 | import { CertIdFromArnPipe } from '../pipes/cert-id-from-arn.pipe'; 6 | import { DeviceBlueprintNameFromIdPipe } from '../pipes/device-blueprint-name-from-id.pipe'; 7 | import { DeviceTypeNameFromIdPipe } from '../pipes/device-type-name-from-id.pipe'; 8 | import { FromNowPipe, FromNowValuePipe, MomentPipe, MomentToPipe } from '../pipes/moment.pipe'; 9 | import { SystemBlueprintFromSystemBlueprintIdPipe } from '../pipes/system-blueprint-from-system-blueprint-id.pipe'; 10 | import { StringifyPipe } from '../pipes/stringify.pipe'; 11 | 12 | @NgModule({ 13 | declarations: [ 14 | CertIdFromArnPipe, 15 | DeviceBlueprintNameFromIdPipe, 16 | DeviceTypeNameFromIdPipe, 17 | MomentPipe, 18 | SystemBlueprintFromSystemBlueprintIdPipe, 19 | FromNowPipe, 20 | FromNowValuePipe, 21 | MomentToPipe, 22 | StringifyPipe 23 | ], 24 | exports: [ 25 | CertIdFromArnPipe, 26 | DeviceBlueprintNameFromIdPipe, 27 | DeviceTypeNameFromIdPipe, 28 | MomentPipe, 29 | SystemBlueprintFromSystemBlueprintIdPipe, 30 | FromNowPipe, 31 | FromNowValuePipe, 32 | MomentToPipe, 33 | StringifyPipe 34 | ] 35 | }) 36 | export class PipesModule {} 37 | -------------------------------------------------------------------------------- /source/console/src/app/pipes/stringify.pipe.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | // @Pipe({ name: 'stringify' }) 3 | @Pipe({ name: 'stringify', pure: true }) 4 | // @Pipe({ name: 'stringify', pure: false }) 5 | export class StringifyPipe implements PipeTransform { 6 | transform(value: any, width: number): any { 7 | return JSON.stringify(value, null, width); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /source/console/src/app/pipes/system-blueprint-from-system-blueprint-id.pipe.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | import { SystemBlueprint } from '@models/system-blueprint.model'; 4 | 5 | import { SystemBlueprintService } from '@services/system-blueprint.service'; 6 | 7 | @Pipe({ name: 'systemBlueprintFromSystemBlueprintId', pure: true }) 8 | export class SystemBlueprintFromSystemBlueprintIdPipe implements PipeTransform { 9 | constructor(private systemBlueprintService: SystemBlueprintService) {} 10 | 11 | transform(id: string): SystemBlueprint { 12 | const index = this.systemBlueprintService.systemBlueprints.findIndex((r: SystemBlueprint) => { 13 | return r.id === id; 14 | }); 15 | if (index !== -1) { 16 | return this.systemBlueprintService.systemBlueprints[index]; 17 | } else { 18 | return null; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /source/console/src/app/public/auth/newpassword/new-password.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { Router } from '@angular/router'; 3 | 4 | // Models 5 | import { NewPasswordUser } from '@models/new-password-user.model'; 6 | 7 | // Services 8 | import { UserRegistrationService } from '@services/user-registration.service'; 9 | import { UserLoginService, CognitoCallback } from '@services/user-login.service'; 10 | import { LoggerService } from '@services/logger.service'; 11 | 12 | /** 13 | * This component is responsible for displaying and controlling 14 | * the registration of the user. 15 | */ 16 | @Component({ 17 | selector: 'app-root-newpassword', 18 | templateUrl: './new-password.component.html' 19 | }) 20 | export class NewPasswordComponent implements CognitoCallback { 21 | registrationUser: NewPasswordUser; 22 | router: Router; 23 | errorMessage: string; 24 | 25 | constructor( 26 | public userRegistration: UserRegistrationService, 27 | public userService: UserLoginService, 28 | router: Router, 29 | private logger: LoggerService 30 | ) { 31 | this.router = router; 32 | this.onInit(); 33 | } 34 | 35 | onInit() { 36 | this.registrationUser = new NewPasswordUser(); 37 | this.errorMessage = null; 38 | this.logger.info('Checking if the user is already authenticated. If so, then redirect to the secure site'); 39 | } 40 | 41 | setPassword() { 42 | this.errorMessage = null; 43 | this.userRegistration.newPassword(this.registrationUser, this); 44 | } 45 | 46 | cognitoCallback(error: Error, result: any) { 47 | if (error != null) { 48 | // error 49 | console.error(error); 50 | this.errorMessage = error.message; 51 | this.logger.error('result: ' + this.errorMessage); 52 | } else { 53 | // success move to the next step 54 | this.logger.info('redirecting'); 55 | this.router.navigate(['/securehome']); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /source/console/src/app/public/auth/register/registration.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { Router } from '@angular/router'; 3 | 4 | // Services 5 | import { CognitoCallback, CognitoCallbackError } from '../../../services/user-login.service'; 6 | import { UserRegistrationService } from '../../../services/user-registration.service'; 7 | import { LoggerService } from '../../../services/logger.service'; 8 | 9 | // Helpers 10 | declare var jquery: any; 11 | declare var $: any; 12 | 13 | export class RegistrationUser { 14 | name: string; 15 | email: string; 16 | password: string; 17 | } 18 | /** 19 | * This component is responsible for displaying and controlling 20 | * the registration of the user. 21 | */ 22 | @Component({ 23 | selector: 'app-root', 24 | templateUrl: './registration.component.html' 25 | }) 26 | export class RegisterComponent implements OnInit, CognitoCallback { 27 | registrationUser: RegistrationUser; 28 | errorMessage: string; 29 | 30 | constructor(public router: Router, 31 | public userRegistration: UserRegistrationService, 32 | private logger: LoggerService) { 33 | } 34 | 35 | ngOnInit() { 36 | this.registrationUser = new RegistrationUser(); 37 | this.errorMessage = null; 38 | 39 | $('.owl-carousel').owlCarousel({ 40 | slideSpeed: 300, 41 | paginationSpeed: 400, 42 | singleItem: !0, 43 | autoPlay: !0 44 | }); 45 | } 46 | 47 | onRegister() { 48 | this.errorMessage = null; 49 | this.userRegistration.register(this.registrationUser, this); 50 | } 51 | 52 | cognitoCallback(error: CognitoCallbackError, result: any) { 53 | if (error != null) { 54 | // error 55 | this.errorMessage = error.message; 56 | this.logger.error('result: ' + this.errorMessage); 57 | } else { 58 | // success, move to the next step 59 | this.logger.info('redirecting'); 60 | this.router.navigate(['/home/confirmRegistration', result.user.username]); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /source/console/src/app/public/auth/resend/resend-code.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { Router } from '@angular/router'; 3 | 4 | // Services 5 | import { CognitoCallback } from '../../../services/user-login.service'; 6 | import { UserRegistrationService } from '../../../services/user-registration.service'; 7 | import { LoggerService } from '../../../services/logger.service'; 8 | 9 | // Helpers 10 | declare var jquery: any; 11 | declare var $: any; 12 | 13 | @Component({ 14 | selector: 'app-root', 15 | templateUrl: './resend-code.component.html' 16 | }) 17 | export class ResendCodeComponent implements OnInit, CognitoCallback { 18 | 19 | email: string; 20 | username: string; 21 | errorMessage: string; 22 | 23 | constructor( 24 | public registrationService: UserRegistrationService, 25 | public router: Router, 26 | private logger: LoggerService 27 | ) {} 28 | 29 | ngOnInit() { 30 | $('.owl-carousel').owlCarousel({ 31 | slideSpeed: 300, 32 | paginationSpeed: 400, 33 | singleItem: !0, 34 | autoPlay: !0 35 | }); 36 | } 37 | 38 | resendCode() { 39 | this.username = this.email.replace('@', '_').replace('.', '_'); 40 | this.registrationService.resendCode(this.username, this); 41 | } 42 | 43 | cognitoCallback(error: any, result: any) { 44 | if (error != null) { 45 | this.errorMessage = 'Something went wrong...please try again'; 46 | } else { 47 | this.router.navigate(['/home/confirmRegistration', this.username]); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /source/console/src/app/public/home/home.component.html: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /source/console/src/app/public/home/home.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { LoggerService } from '../../services/logger.service'; 3 | 4 | import { BlockUI, NgBlockUI } from 'ng-block-ui'; 5 | 6 | @Component({ 7 | selector: 'app-root-home', 8 | templateUrl: './home.component.html' 9 | }) 10 | export class HomeComponent implements OnInit { 11 | @BlockUI() blockUI: NgBlockUI; 12 | 13 | constructor(private logger: LoggerService) { 14 | // this.logger.info('HomeComponent.constructor'); 15 | } 16 | 17 | ngOnInit() { 18 | // this.logger.info('HomeComponent.ngOnInit'); 19 | this.blockUI.stop(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /source/console/src/app/public/tests/tests.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | Hello 5 |
6 |
7 |
8 |
9 |
10 | Yo 11 |
12 |
13 | 14 |
15 |
16 | 17 | -------------------------------------------------------------------------------- /source/console/src/app/public/tests/tests.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule } from '@angular/forms'; 4 | 5 | import { TestsComponent } from './tests.component'; 6 | 7 | import { CardModule } from '../../common/modules/card/card.module'; 8 | import { GaugeModule } from '../../common/modules/gauge/gauge.module'; 9 | import { WidgetsModule } from '@app/widgets/widgets.module'; 10 | 11 | // Pipes 12 | import { PipesModule } from '../../pipes/pipes.module'; 13 | 14 | @NgModule({ 15 | declarations: [TestsComponent], 16 | exports: [TestsComponent], 17 | imports: [PipesModule, CommonModule, FormsModule, WidgetsModule, GaugeModule, CardModule], 18 | providers: [], 19 | schemas: [NO_ERRORS_SCHEMA] 20 | }) 21 | export class TestsModule {} 22 | -------------------------------------------------------------------------------- /source/console/src/app/secure/child-views/child-views.module.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | // Systems 5 | import { DeviceChildViewsModule } from './devices/device-child-views.module'; 6 | import { SystemChildViewsModule } from './systems/system-child-views.module'; 7 | 8 | @Component({ 9 | selector: 'app-child-view', 10 | template: ` 11 | 12 | 13 | ` 14 | }) 15 | export class ChildViewComponent { 16 | @Input() data: any; 17 | @Input() type: string; 18 | } 19 | 20 | @NgModule({ 21 | declarations: [ChildViewComponent], 22 | exports: [ChildViewComponent], 23 | imports: [CommonModule, DeviceChildViewsModule, SystemChildViewsModule] 24 | }) 25 | export class ChildViewsModule {} 26 | -------------------------------------------------------------------------------- /source/console/src/app/secure/child-views/devices/default-device/default-device.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule } from '@angular/forms'; 4 | 5 | import { DefaultDeviceComponent } from './default-device.component'; 6 | 7 | import { WidgetsModule } from '@app/widgets/widgets.module'; 8 | 9 | // Pipes 10 | import { PipesModule } from '../../../../pipes/pipes.module'; 11 | 12 | @NgModule({ 13 | declarations: [DefaultDeviceComponent], 14 | exports: [DefaultDeviceComponent], 15 | imports: [PipesModule, CommonModule, FormsModule, WidgetsModule], 16 | providers: [], 17 | schemas: [] 18 | }) 19 | export class DefaultDeviceModule {} 20 | -------------------------------------------------------------------------------- /source/console/src/app/secure/child-views/devices/device-child-views.module.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | // Models 5 | import { Device } from '@models/device.model'; 6 | 7 | // Devices 8 | import { DefaultDeviceModule } from './default-device/default-device.module'; 9 | import { MLDemoSqueezenetV10Module } from './ml-demo-squeezenet-v1.0/ml-demo-squeezenet-v1.0.module'; 10 | 11 | @Component({ 12 | selector: 'app-device-child-view', 13 | template: ` 14 |
15 | 19 | 20 |
21 | ` 22 | }) 23 | export class DeviceChildViewComponent { 24 | @Input() device: Device; 25 | } 26 | 27 | @NgModule({ 28 | declarations: [DeviceChildViewComponent], 29 | exports: [DeviceChildViewComponent], 30 | imports: [CommonModule, DefaultDeviceModule, MLDemoSqueezenetV10Module] 31 | }) 32 | export class DeviceChildViewsModule {} 33 | -------------------------------------------------------------------------------- /source/console/src/app/secure/child-views/devices/ml-demo-squeezenet-v1.0/ml-demo-squeezenet-v1.0.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
Greengrass ML Squeezenet Demo
6 |
{{ device.name }} 7 | {{ latestData.fps }}fps 8 |
9 |
10 |
11 |
{{prediction.name}}
12 |
{{prediction.probability | percent}}
13 |
14 |
15 |
16 |
17 |
18 |
19 | -------------------------------------------------------------------------------- /source/console/src/app/secure/child-views/devices/ml-demo-squeezenet-v1.0/ml-demo-squeezenet-v1.0.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit } from '@angular/core'; 2 | 3 | // Components 4 | import { IoTPubSuberComponent } from '@common-secure/iot-pubsuber.component'; 5 | 6 | // Models 7 | import { Device } from '@models/device.model'; 8 | 9 | // Services 10 | import { IoTService } from '@services/iot.service'; 11 | 12 | @Component({ 13 | selector: 'app-ml-demo-squeezenet-v1-0', 14 | templateUrl: './ml-demo-squeezenet-v1.0.component.html' 15 | }) 16 | export class MLDemoSqueezenetV10Component extends IoTPubSuberComponent implements OnInit { 17 | @Input() device: Device = new Device(); 18 | latestData: any = null; 19 | 20 | constructor(private iotService: IoTService) { 21 | super(iotService); 22 | } 23 | 24 | ngOnInit() { 25 | this.subscribe([ 26 | { 27 | topic: 'sputnik/' + this.device.thingName + '/camera', 28 | onMessage: data => { 29 | // console.log('Data:', data.value); 30 | this.latestData = data.value; 31 | }, 32 | onError: err => { 33 | console.error('Error:', err); 34 | } 35 | }, 36 | { 37 | topic: 'sputnik/' + this.device.thingName + '/logger', 38 | onMessage: data => { 39 | // console.log('Logger:', data.value); 40 | if (data.value.hasOwnProperty('type') && data.value.type === 'info') { 41 | // console.log('INFO:', data.value.payload); 42 | } 43 | if (data.value.hasOwnProperty('type') && data.value.type === 'exception') { 44 | console.error('EXCEPTION:', data.value.payload); 45 | } 46 | }, 47 | onError: err => { 48 | console.error('Error:', err); 49 | } 50 | } 51 | ]); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /source/console/src/app/secure/child-views/devices/ml-demo-squeezenet-v1.0/ml-demo-squeezenet-v1.0.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | // Components 5 | import { MLDemoSqueezenetV10Component } from './ml-demo-squeezenet-v1.0.component'; 6 | 7 | // Pipes 8 | import { PipesModule } from '../../../../pipes/pipes.module'; 9 | 10 | @NgModule({ 11 | declarations: [MLDemoSqueezenetV10Component], 12 | exports: [MLDemoSqueezenetV10Component], 13 | imports: [PipesModule, CommonModule], 14 | providers: [] 15 | }) 16 | export class MLDemoSqueezenetV10Module {} 17 | -------------------------------------------------------------------------------- /source/console/src/app/secure/child-views/systems/default-system/default-system.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | // Components 5 | import { DefaultSystemComponent } from './default-system.component'; 6 | 7 | // Modules 8 | import { DeviceChildViewsModule } from '../../devices/device-child-views.module'; 9 | import { WidgetsModule } from '@app/widgets/widgets.module'; 10 | 11 | @NgModule({ 12 | declarations: [DefaultSystemComponent], 13 | exports: [DefaultSystemComponent], 14 | imports: [CommonModule, DeviceChildViewsModule, WidgetsModule], 15 | providers: [], 16 | schemas: [] 17 | }) 18 | export class DefaultSystemModule {} 19 | -------------------------------------------------------------------------------- /source/console/src/app/secure/child-views/systems/system-child-views.module.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | // Models 5 | import { Device } from '@models/device.model'; 6 | import { System } from '@models/system.model'; 7 | 8 | // Systems 9 | import { DefaultSystemModule } from './default-system/default-system.module'; 10 | 11 | @Component({ 12 | selector: 'app-system-child-view', 13 | template: ` 14 |
15 | 16 |
17 | ` 18 | }) 19 | export class SystemChildViewComponent { 20 | @Input() data: { 21 | system: System, 22 | devices: Device[] 23 | };// System = new System(); 24 | } 25 | 26 | @NgModule({ 27 | declarations: [SystemChildViewComponent], 28 | exports: [SystemChildViewComponent], 29 | imports: [CommonModule, DefaultSystemModule] 30 | }) 31 | export class SystemChildViewsModule {} 32 | -------------------------------------------------------------------------------- /source/console/src/app/secure/common/prettifier.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root-prettifier', 5 | template: '' 6 | }) 7 | export class PrettifierComponent { 8 | public prettifying = ''; 9 | 10 | private keyUpTimeOut1: any = null; 11 | private keyUpTimeOut2: any = null; 12 | 13 | constructor() {} 14 | 15 | editJsonOnKey(event: any, width: number, obj: any, attribute: string) { 16 | const _self = this; 17 | _self.prettifying = ''; 18 | clearTimeout(_self.keyUpTimeOut1); 19 | clearTimeout(_self.keyUpTimeOut2); 20 | _self.keyUpTimeOut1 = setTimeout(function() { 21 | _self.prettifying = '(formating json...)'; 22 | _self.keyUpTimeOut1 = setTimeout(function() { 23 | try { 24 | obj[attribute] = JSON.stringify(JSON.parse(event.target.value), null, width); 25 | event.target.value = obj[attribute]; 26 | _self.prettifying = ''; 27 | } catch (ex) { 28 | _self.prettifying = '(ERROR: JSON is incorrect!)'; 29 | } 30 | }, 100); 31 | }, 500); 32 | } 33 | 34 | manualPrettify(obj: any, attribute: string, width: number) { 35 | // obj[attribute] = JSON.stringify(JSON.parse(obj[attribute]), null, width); 36 | obj[attribute] = JSON.stringify(obj[attribute], null, width); 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /source/console/src/app/secure/device-blueprints/device-blueprints.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |
5 |
6 |
7 | 9 | 12 |

{{ pageTitle }} ({{totalDeviceBlueprints}})

13 | 14 |
15 | 17 |
18 |
19 |
20 |
21 | 22 |
23 | 24 | -------------------------------------------------------------------------------- /source/console/src/app/secure/device-blueprints/device-blueprints.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { RouterModule, Routes } from '@angular/router'; 5 | 6 | // Components 7 | import { SecureHomeLayoutComponent } from '@secure/secure-home-layout.component'; 8 | import { TableModule } from '@common-modules/table/table.module'; 9 | 10 | import { DeviceBlueprintComponent } from './device-blueprint.component'; 11 | import { DeviceBlueprintsComponent } from './device-blueprints.component'; 12 | 13 | // Pipes 14 | import { PipesModule } from '@pipes/pipes.module'; 15 | import { PrettyJsonModule } from '@common-modules/pretty-json/pretty-json.module'; 16 | 17 | const deviceBlueprintsRoutes: Routes = [ 18 | { 19 | path: 'securehome/device-blueprints', 20 | component: SecureHomeLayoutComponent, 21 | children: [{ path: ':id', component: DeviceBlueprintComponent }, { path: '', component: DeviceBlueprintsComponent }] 22 | } 23 | ]; 24 | 25 | @NgModule({ 26 | declarations: [DeviceBlueprintComponent, DeviceBlueprintsComponent], 27 | exports: [RouterModule, DeviceBlueprintComponent, DeviceBlueprintsComponent], 28 | imports: [ 29 | CommonModule, 30 | FormsModule, 31 | RouterModule.forChild(deviceBlueprintsRoutes), 32 | 33 | // Modules 34 | PrettyJsonModule, 35 | TableModule, 36 | 37 | // Pipes 38 | PipesModule 39 | ] 40 | }) 41 | export class DeviceBlueprintsModule {} 42 | -------------------------------------------------------------------------------- /source/console/src/app/secure/device-types/device-types.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |
5 |
6 |
7 | 9 | 12 |

{{ pageTitle }} ({{totalDeviceTypes}})

13 | 14 |
15 | 17 |
18 |
19 |
20 |
21 | 22 |
23 | 24 | -------------------------------------------------------------------------------- /source/console/src/app/secure/device-types/device-types.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { RouterModule, Routes } from '@angular/router'; 5 | 6 | // Components 7 | import { SecureHomeLayoutComponent } from '@secure/secure-home-layout.component'; 8 | import { TableModule } from '@common-modules/table/table.module'; 9 | 10 | import { DeviceTypeComponent } from './device-type.component'; 11 | import { DeviceTypesComponent } from './device-types.component'; 12 | 13 | // Pipes 14 | import { PipesModule } from '@pipes/pipes.module'; 15 | import { PrettyJsonModule } from '@common-modules/pretty-json/pretty-json.module'; 16 | 17 | const deviceTypesRoutes: Routes = [ 18 | { 19 | path: 'securehome/device-types', 20 | component: SecureHomeLayoutComponent, 21 | children: [{ path: ':id', component: DeviceTypeComponent }, { path: '', component: DeviceTypesComponent }] 22 | } 23 | ]; 24 | 25 | @NgModule({ 26 | declarations: [DeviceTypeComponent, DeviceTypesComponent], 27 | exports: [RouterModule, DeviceTypeComponent, DeviceTypesComponent], 28 | imports: [ 29 | CommonModule, 30 | FormsModule, 31 | RouterModule.forChild(deviceTypesRoutes), 32 | 33 | // Modules 34 | PrettyJsonModule, 35 | TableModule, 36 | 37 | // Pipes 38 | PipesModule 39 | ] 40 | }) 41 | export class DeviceTypesModule {} 42 | -------------------------------------------------------------------------------- /source/console/src/app/secure/home/secure-home.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, NgZone } from '@angular/core'; 2 | import { Router } from '@angular/router'; 3 | import { BlockUI, NgBlockUI } from 'ng-block-ui'; 4 | 5 | // Services 6 | import { BreadCrumbService, Crumb } from '../../services/bread-crumb.service'; 7 | 8 | @Component({ 9 | selector: 'app-root-home', 10 | templateUrl: './secure-home.component.html' 11 | }) 12 | export class SecureHomeComponent implements OnInit { 13 | public title = 'Home'; 14 | 15 | @BlockUI() 16 | blockUI: NgBlockUI; 17 | 18 | constructor(public router: Router, private breadCrumbService: BreadCrumbService) {} 19 | 20 | ngOnInit() { 21 | const _self = this; 22 | _self.breadCrumbService.setup(_self.title, []); 23 | _self.blockUI.stop(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /source/console/src/app/secure/maps/maps.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | -------------------------------------------------------------------------------- /source/console/src/app/secure/system-blueprints/system-blueprints.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |
5 |
6 |
7 | 9 | 12 |

{{ pageTitle }} ({{totalSystemBlueprints}})

13 | 14 |
15 | 17 |
18 |
19 |
20 |
21 | 22 |
23 | 24 | -------------------------------------------------------------------------------- /source/console/src/app/secure/system-blueprints/system-blueprints.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { RouterModule, Routes } from '@angular/router'; 5 | 6 | // Components 7 | import { SecureHomeLayoutComponent } from '@secure/secure-home-layout.component'; 8 | import { TableModule } from '@common-modules/table/table.module'; 9 | 10 | import { SystemBlueprintComponent } from './system-blueprint.component'; 11 | import { SystemBlueprintsComponent } from './system-blueprints.component'; 12 | 13 | // Pipes 14 | import { PipesModule } from '@pipes/pipes.module'; 15 | import { PrettyJsonModule } from '@common-modules/pretty-json/pretty-json.module'; 16 | 17 | const systemBlueprintsRoutes: Routes = [ 18 | { 19 | path: 'securehome/system-blueprints', 20 | component: SecureHomeLayoutComponent, 21 | children: [{ path: ':id', component: SystemBlueprintComponent }, { path: '', component: SystemBlueprintsComponent }] 22 | } 23 | ]; 24 | 25 | @NgModule({ 26 | declarations: [SystemBlueprintComponent, SystemBlueprintsComponent], 27 | exports: [RouterModule, SystemBlueprintComponent, SystemBlueprintsComponent], 28 | imports: [ 29 | CommonModule, 30 | FormsModule, 31 | RouterModule.forChild(systemBlueprintsRoutes), 32 | 33 | // Modules 34 | PrettyJsonModule, 35 | TableModule, 36 | 37 | // Pipes 38 | PipesModule 39 | ] 40 | }) 41 | export class SystemBlueprintsModule {} 42 | -------------------------------------------------------------------------------- /source/console/src/app/secure/systems/systems.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |
5 |
6 |
7 | 9 | 12 |

{{ pageTitle }} ({{totalSystems}})

13 | 14 |
15 | 17 |
18 |
19 |
20 |
21 | 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /source/console/src/app/secure/systems/systems.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { RouterModule, Routes } from '@angular/router'; 5 | 6 | // Components 7 | import { SecureHomeLayoutComponent } from '@secure/secure-home-layout.component'; 8 | 9 | import { SystemComponent } from './system.component'; 10 | import { SystemsComponent } from './systems.component'; 11 | import { SystemEditModalComponent } from './system.edit.modal.component'; 12 | import { SystemsModalComponent } from './systems.modal.component'; 13 | 14 | // Modules 15 | import { ChildViewsModule } from '../child-views/child-views.module'; 16 | import { TableModule } from '@common-modules/table/table.module'; 17 | import { PipesModule } from '@pipes/pipes.module'; 18 | import { PrettyJsonModule } from '@common-modules/pretty-json/pretty-json.module'; 19 | 20 | const systemsRoutes: Routes = [ 21 | { 22 | path: 'securehome/systems', 23 | component: SecureHomeLayoutComponent, 24 | children: [{ path: ':id', component: SystemComponent }, { path: '', component: SystemsComponent }] 25 | } 26 | ]; 27 | 28 | @NgModule({ 29 | declarations: [SystemComponent, SystemsComponent, SystemEditModalComponent, SystemsModalComponent], 30 | entryComponents: [SystemEditModalComponent, SystemsModalComponent], 31 | exports: [RouterModule, SystemComponent, SystemsComponent], 32 | imports: [ 33 | CommonModule, 34 | FormsModule, 35 | RouterModule.forChild(systemsRoutes), 36 | 37 | // Modules 38 | ChildViewsModule, 39 | PipesModule, 40 | PrettyJsonModule, 41 | TableModule 42 | 43 | ] 44 | }) 45 | export class SystemsModule {} 46 | -------------------------------------------------------------------------------- /source/console/src/app/services/bread-crumb.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Subject } from 'rxjs'; 3 | 4 | export class Crumb { 5 | title: string; 6 | link: string; 7 | active: boolean; 8 | constructor(values: Object = {}) { 9 | Object.assign(this, values); 10 | } 11 | } 12 | 13 | @Injectable() 14 | export class BreadCrumbService { 15 | constructor() {} 16 | 17 | private pageTitleSource = new Subject(); 18 | pageTitleObservable$ = this.pageTitleSource.asObservable(); 19 | 20 | private crumbSource = new Subject(); 21 | crumbObservable$ = this.crumbSource.asObservable(); 22 | 23 | // pageTitle(title: string) { 24 | // this.pageTitleSource.next(title); 25 | // } 26 | 27 | // crumbs(crumbs: Crumb[]) { 28 | // this.crumbSource.next(crumbs); 29 | // } 30 | 31 | setup(title: string, crumbs: Crumb[]) { 32 | this.pageTitleSource.next(title); 33 | this.crumbSource.next(crumbs); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /source/console/src/app/services/deployment.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Subject } from 'rxjs'; 3 | 4 | // Services 5 | import { LoggerService } from './logger.service'; 6 | import { AppSyncService } from './appsync.service'; 7 | 8 | // Helpers 9 | import * as _ from 'underscore'; 10 | 11 | @Injectable() 12 | export class DeploymentService { 13 | constructor(private logger: LoggerService, private appSyncService: AppSyncService) {} 14 | 15 | public listDeployments(limit: number, nextToken: string) { 16 | return this.appSyncService.listDeployments(limit, nextToken); 17 | } 18 | 19 | public addDeployment(thingId: string) { 20 | return this.appSyncService.addDeployment(thingId); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /source/console/src/app/services/logger.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { environment } from '../../environments/environment'; 3 | 4 | export abstract class Logger { 5 | info: any; 6 | warn: any; 7 | error: any; 8 | } 9 | 10 | @Injectable() 11 | export class LoggerService implements Logger { 12 | 13 | info: any; 14 | warn: any; 15 | error: any; 16 | 17 | invokeConsoleMethod(type: string, args?: any): void { } 18 | } 19 | 20 | export let isDebugMode = environment.isDebugMode; 21 | 22 | const noop = (): any => undefined; 23 | 24 | @Injectable() 25 | export class ConsoleLoggerService implements LoggerService { 26 | 27 | get info() { 28 | if (isDebugMode) { 29 | return console.log.bind(console); 30 | } else { 31 | return noop; 32 | } 33 | } 34 | 35 | get warn() { 36 | if (isDebugMode) { 37 | return console.warn.bind(console); 38 | } else { 39 | return noop; 40 | } 41 | } 42 | 43 | get error() { 44 | if (isDebugMode) { 45 | return console.error.bind(console); 46 | } else { 47 | return noop; 48 | } 49 | } 50 | 51 | invokeConsoleMethod(type: string, args?: any): void { 52 | const logFn: Function = (console)[type] || console.log || noop; 53 | logFn.apply(console, [args]); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /source/console/src/app/services/s3/s3-image.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnChanges } from '@angular/core'; 2 | 3 | // Services 4 | import { LoggerService } from '@services/logger.service'; 5 | import { S3Service } from '@services/s3/s3.service'; 6 | 7 | declare var appVariables: any; 8 | 9 | 10 | @Component({ 11 | selector: 'app-s3-image', 12 | template: '' 13 | }) 14 | export class S3ImageComponent implements OnChanges { 15 | 16 | @Input() 17 | s3Key: string; 18 | 19 | public signedUrl: string; 20 | 21 | constructor(private logger: LoggerService, private s3Service: S3Service) { 22 | this.signedUrl = ''; 23 | } 24 | 25 | ngOnChanges() { 26 | this.logger.info('ngOnChanges.s3Key:', this.s3Key); 27 | this.s3Service.getSignedUrlFor(this.s3Key).then((url: string) => { 28 | this.logger.info('ngOnChanges.signedUrl:', this.signedUrl); 29 | this.signedUrl = url; 30 | }).catch(err => { 31 | this.logger.error(err); 32 | }); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /source/console/src/app/services/s3/s3.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | // Components 5 | import { S3ImageComponent } from './s3-image.component'; 6 | 7 | // Services 8 | import { S3Service } from './s3.service'; 9 | 10 | @NgModule({ 11 | declarations: [S3ImageComponent], 12 | exports: [S3ImageComponent], 13 | imports: [CommonModule], 14 | providers: [S3Service] 15 | }) 16 | export class S3Module {} 17 | -------------------------------------------------------------------------------- /source/console/src/app/services/services.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | // AWS Specific 5 | import { AmplifyAngularModule, AmplifyService } from 'aws-amplify-angular'; 6 | 7 | // Modules 8 | import { S3Module } from './s3/s3.module'; 9 | 10 | // Services 11 | import { AdminService } from './admin.service'; 12 | import { AppSyncService } from './appsync.service'; 13 | import { BreadCrumbService } from './bread-crumb.service'; 14 | import { DeploymentService } from './deployment.service'; 15 | import { DeviceService } from './device.service'; 16 | import { DeviceBlueprintService } from './device-blueprint.service'; 17 | import { DeviceTypeService } from './device-type.service'; 18 | import { IoTService } from './iot.service'; 19 | import { SettingService } from './setting.service'; 20 | import { SystemService } from './system.service'; 21 | import { SystemBlueprintService } from './system-blueprint.service'; 22 | import { StatService } from './stat.service'; 23 | import { UserLoginService } from './user-login.service'; 24 | import { UserRegistrationService } from './user-registration.service'; 25 | // import { AdminService } from './admin.service'; 26 | // import { StatsService } from './stats.service'; 27 | // import { MQTTService } from './mqtt.service'; 28 | // import { DeviceSubViewComponentService } from './device-sub-view-component.service'; 29 | 30 | @NgModule({ 31 | imports: [AmplifyAngularModule, CommonModule, S3Module], 32 | providers: [ 33 | AdminService, 34 | AmplifyService, 35 | AppSyncService, 36 | BreadCrumbService, 37 | DeploymentService, 38 | DeviceService, 39 | DeviceBlueprintService, 40 | DeviceTypeService, 41 | IoTService, 42 | SettingService, 43 | SystemService, 44 | SystemBlueprintService, 45 | StatService, 46 | UserLoginService, 47 | UserRegistrationService 48 | ] 49 | }) 50 | export class AppServicesModule {} 51 | -------------------------------------------------------------------------------- /source/console/src/app/services/setting.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | // Models 4 | import { Setting } from '@models/setting.model'; 5 | 6 | // Services 7 | import { AppSyncService } from './appsync.service'; 8 | 9 | // Helpers 10 | import * as _ from 'underscore'; 11 | 12 | @Injectable() 13 | export class SettingService { 14 | constructor(private appSyncService: AppSyncService) {} 15 | 16 | public getSetting(id: string) { 17 | return this.appSyncService.getSetting(id); 18 | } 19 | public updateSetting(setting: Setting) { 20 | return this.appSyncService.updateSetting(setting); 21 | } 22 | public getJustInTimeOnBoardingState() { 23 | return this.appSyncService.getJustInTimeOnBoardingState(); 24 | } 25 | public setJustInTimeOnBoardingState(enabled: boolean) { 26 | return this.appSyncService.setJustInTimeOnBoardingState(enabled); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /source/console/src/app/services/stat.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Subject } from 'rxjs'; 3 | 4 | import { environment } from '@env/environment'; 5 | 6 | // Models 7 | import { DeviceStats, SystemStats } from '@models/stats.model'; 8 | 9 | // Services 10 | import { LoggerService } from './logger.service'; 11 | import { AppSyncService } from './appsync.service'; 12 | 13 | // Helpers 14 | import * as _ from 'underscore'; 15 | 16 | export class Stats { 17 | deviceStats: DeviceStats; 18 | systemStats: SystemStats; 19 | constructor(values: Object = {}) { 20 | Object.assign(this, values); 21 | } 22 | } 23 | 24 | @Injectable() 25 | export class StatService { 26 | private pollerInterval: any = null; 27 | 28 | private observer: any = new Subject(); 29 | statObservable$ = this.observer.asObservable(); 30 | 31 | constructor( 32 | private logger: LoggerService, 33 | private appSyncService: AppSyncService 34 | ) { 35 | const _self = this; 36 | _self.logger.info('StatService.constructor:'); 37 | _self.pollerInterval = setInterval(function() { 38 | _self.refresh(); 39 | }, environment.refreshInterval); 40 | _self.refresh(); 41 | } 42 | 43 | loadStats() { 44 | const _self = this; 45 | Promise.all([_self.appSyncService.getDeviceStats(), _self.appSyncService.getSystemStats()]) 46 | .then(results => { 47 | _self.observer.next(new Stats({ deviceStats: results[0], systemStats: results[1] })); 48 | }) 49 | .catch(err => { 50 | _self.logger.warn('error occurred calling getDeviceStats api, show message'); 51 | _self.logger.warn(err); 52 | }); 53 | } 54 | 55 | refresh() { 56 | this.loadStats(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /source/console/src/app/widgets/button-widget.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | import { WidgetComponent } from './widget.component'; 4 | 5 | @Component({ 6 | template: 7 | '' 8 | }) 9 | export class ButtonWidgetComponent extends WidgetComponent { 10 | public click() { 11 | this.setValue('click'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /source/console/src/app/widgets/card-widget.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input } from '@angular/core'; 2 | 3 | import { WidgetComponent } from './widget.component'; 4 | 5 | @Component({ 6 | template: ` 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | ` 25 | }) 26 | export class CardWidgetComponent extends WidgetComponent {} 27 | -------------------------------------------------------------------------------- /source/console/src/app/widgets/checkbox-widget.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit } from '@angular/core'; 2 | 3 | import { WidgetComponent } from './widget.component'; 4 | 5 | @Component({ 6 | template: ` 7 |
8 | 9 | 10 |
11 | ` 12 | }) 13 | 14 | export class CheckboxWidgetComponent extends WidgetComponent { 15 | 16 | public toggle(event) { 17 | let outputValue = false; 18 | if (this.data.hasOwnProperty('toggleTrue') && this.data.hasOwnProperty('toggleFalse')) { 19 | if (this.value === this.data.toggleTrue) { 20 | this.setValue(this.data.toggleFalse); 21 | } else if (this.value === this.data.toggleFalse) { 22 | this.setValue(this.data.toggleTrue); 23 | } 24 | } else { 25 | this.setValue(!this.value); // Assume direct boolean type value: true/false 26 | } 27 | event.stopPropagation(); 28 | event.preventDefault(); 29 | } 30 | 31 | get toggleValue() { 32 | if (this.data.hasOwnProperty('toggleTrue') && this.data.hasOwnProperty('toggleFalse')) { 33 | if (this.value === this.data.toggleTrue) { 34 | return true; 35 | } else if (this.value === this.data.toggleFalse) { 36 | return false; 37 | } else { 38 | return false; 39 | } 40 | } else { 41 | return this.value; 42 | } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /source/console/src/app/widgets/color-picker-widget.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | import { WidgetComponent } from './widget.component'; 4 | 5 | @Component({ 6 | template: ` 7 | 17 | ` 18 | }) 19 | 20 | export class ColorPickerWidgetComponent extends WidgetComponent { 21 | 22 | private rgbToHex(rgb) { 23 | let hex = Number(rgb).toString(16); 24 | if (hex.length < 2) { 25 | hex = '0' + hex; 26 | } 27 | return hex; 28 | } 29 | 30 | private fullColorHex(rgb) { 31 | return '#' + this.rgbToHex(rgb.r) + this.rgbToHex(rgb.g) + this.rgbToHex(rgb.b); 32 | } 33 | 34 | get htmlvalue() { 35 | if (this.value.hasOwnProperty('r') && this.value.hasOwnProperty('g') && this.value.hasOwnProperty('b')) { 36 | return this.fullColorHex(this.value); 37 | } else { 38 | return '#000000'; 39 | } 40 | } 41 | 42 | set htmlvalue(val: any) { 43 | this.value = { 44 | r: parseInt(val.substring(1, 3), 16), 45 | g: parseInt(val.substring(3, 5), 16), 46 | b: parseInt(val.substring(5, 7), 16) 47 | }; 48 | } 49 | 50 | public updateHtmlValue() { 51 | this.setValue(this.value); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /source/console/src/app/widgets/gauge-widget.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit } from '@angular/core'; 2 | import { Subject } from 'rxjs'; 3 | 4 | import { WidgetComponent } from './widget.component'; 5 | 6 | @Component({ 7 | template: '' 8 | }) 9 | 10 | export class GaugeWidgetComponent extends WidgetComponent { 11 | } 12 | -------------------------------------------------------------------------------- /source/console/src/app/widgets/graph-realtime-widget.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit } from '@angular/core'; 2 | import { Subject } from 'rxjs'; 3 | 4 | import { WidgetComponent } from './widget.component'; 5 | 6 | @Component({ 7 | template: ` 8 | 14 | ` 15 | }) 16 | export class GraphRealtimeWidgetComponent extends WidgetComponent { 17 | 18 | newvalue: Subject = new Subject(); 19 | 20 | // Override parent 21 | set value(val: any) { 22 | this.newvalue.next(val); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /source/console/src/app/widgets/input-text-widget.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit } from '@angular/core'; 2 | 3 | import { WidgetComponent } from './widget.component'; 4 | 5 | @Component({ 6 | template: ` 7 |
8 | 16 |
17 | 18 |
19 |
20 | ` 21 | }) 22 | export class InputTextWidgetComponent extends WidgetComponent { 23 | private _inputtext = ''; 24 | 25 | get inputText() { 26 | if (typeof this.value === 'string') { 27 | return this.value; 28 | } else { 29 | return ''; 30 | } 31 | } 32 | 33 | set inputText(value) { 34 | this._inputtext = value; 35 | } 36 | 37 | public submit() { 38 | if (this._inputtext !== '') { 39 | this.setValue(this._inputtext); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /source/console/src/app/widgets/text-widget.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit } from '@angular/core'; 2 | 3 | import { WidgetComponent } from './widget.component'; 4 | 5 | @Component({ 6 | template: '
{{ value }}{{ data.unit }}
' 7 | }) 8 | export class TextWidgetComponent extends WidgetComponent {} 9 | -------------------------------------------------------------------------------- /source/console/src/app/widgets/widgets.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Inject } from '@angular/core'; 2 | 3 | @Injectable() 4 | export class WidgetsService { 5 | 6 | public getObjectValueByString = function(obj, str) { 7 | str = str.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties 8 | str = str.replace(/^\./, ''); // strip a leading dot 9 | const ar = str.split('.'); 10 | for (let i = 0, n = ar.length; i < n; ++i) { 11 | const key = ar[i]; 12 | if (key in obj) { 13 | obj = obj[key]; 14 | } else { 15 | return; 16 | } 17 | } 18 | return obj; 19 | }; 20 | 21 | public setObjectValueByString = function(obj, str, value) { 22 | str = str.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties 23 | str = str.replace(/^\./, ''); // strip a leading dot 24 | const ar = str.split('.'); 25 | str = ar[0]; 26 | 27 | for (let i = 1, n = ar.length; i < n; ++i) { 28 | if (str in obj) { 29 | obj = obj[str]; 30 | } else { 31 | return; 32 | } 33 | 34 | str = ar[i]; 35 | } 36 | 37 | obj[str] = value; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /source/console/src/assets/.gitignore: -------------------------------------------------------------------------------- 1 | ui-js/underscore.min.js 2 | ui-js/jquery.min.js 3 | ui-js/jquery.slimscroll.min.js 4 | ui-js/jquery.blockUI.js 5 | ui-js/popper.min.js 6 | ui-js/bootstrap.min.js 7 | css/bootstrap.min.css 8 | ui-js/waves.min.js 9 | ui-js/gauge.min.js 10 | ui-js/sticky-kit.min.js 11 | 12 | ui-js/Chart.min.js 13 | ui-js/chartjs-plugin-annotation.min.js 14 | ui-js/chartjs-plugin-draggable.min.js 15 | 16 | ui-js/owl.carousel.min.js 17 | css/owl.carousel.min.css 18 | 19 | css/font-awesome.min.css 20 | css/materialdesignicons.min.css 21 | 22 | fonts 23 | fonts/* 24 | -------------------------------------------------------------------------------- /source/console/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/console/src/assets/.gitkeep -------------------------------------------------------------------------------- /source/console/src/assets/appVariables.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const appVariables = { 4 | IOT_ENDPOINT: '', 5 | S3_DATA_BUCKET: '', 6 | VERSION: '', 7 | IDENTITY_POOL_ID: '', 8 | USER_POOL_ID: '', 9 | USER_POOL_CLIENT_ID: '', 10 | IOT_COGNITO_POLICY: '', 11 | REGION: '', 12 | APP_SYNC_GRAPHQL_ENDPOINT: '' 13 | }; 14 | -------------------------------------------------------------------------------- /source/console/src/assets/img/aws_smile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/console/src/assets/img/aws_smile.png -------------------------------------------------------------------------------- /source/console/src/assets/img/background/error-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/console/src/assets/img/background/error-bg.jpg -------------------------------------------------------------------------------- /source/console/src/assets/img/background/login-register.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/console/src/assets/img/background/login-register.jpg -------------------------------------------------------------------------------- /source/console/src/assets/img/custom-select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/console/src/assets/img/custom-select.png -------------------------------------------------------------------------------- /source/console/src/assets/img/icon/danger.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /source/console/src/assets/img/icon/success.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /source/console/src/assets/img/icon/warning.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /source/console/src/assets/img/iot-ds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/console/src/assets/img/iot-ds.png -------------------------------------------------------------------------------- /source/console/src/assets/img/lightbulb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/console/src/assets/img/lightbulb.png -------------------------------------------------------------------------------- /source/console/src/assets/img/simengine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/console/src/assets/img/simengine.png -------------------------------------------------------------------------------- /source/console/src/assets/img/simulation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/console/src/assets/img/simulation.png -------------------------------------------------------------------------------- /source/console/src/assets/img/tooltip/Euclid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/console/src/assets/img/tooltip/Euclid.png -------------------------------------------------------------------------------- /source/console/src/assets/img/tooltip/shape1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /source/console/src/assets/img/tooltip/shape2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 9 | 11 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/console/src/assets/img/tooltip/shape3.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /source/console/src/assets/img/tooltip/tooltip1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /source/console/src/assets/img/tooltip/tooltip2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /source/console/src/assets/img/tooltip/tooltip3.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /source/console/src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # For IE 9-11 support, please uncomment the last line of the file and adjust as needed 5 | > 0.5% 6 | last 2 versions 7 | Firefox ESR 8 | not dead 9 | # IE 9-11 -------------------------------------------------------------------------------- /source/console/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true, 3 | appName: 'sputnik', 4 | appVersion: '0.0.1', 5 | isDebugMode: false, 6 | refreshInterval: 30000 7 | }; 8 | -------------------------------------------------------------------------------- /source/console/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false, 7 | appName: 'sputnik', 8 | appVersion: '0.0.1', 9 | isDebugMode: true, 10 | refreshInterval: 30000 11 | }; 12 | 13 | /* 14 | * In development mode, to ignore zone related error stack frames such as 15 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can 16 | * import the following file, but please comment it out in production mode 17 | * because it will have performance impact when throw error 18 | */ 19 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 20 | -------------------------------------------------------------------------------- /source/console/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-iot-kickstart/bde8dc9b1e41d582fdb4213a05bc50d4f0bb8f5c/source/console/src/favicon.ico -------------------------------------------------------------------------------- /source/console/src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; -------------------------------------------------------------------------------- /source/console/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | // AWS related 8 | import Amplify from '@aws-amplify/core'; 9 | 10 | declare var appVariables: any; 11 | 12 | Amplify.configure({ 13 | Auth: { 14 | identityPoolId: appVariables.IDENTITY_POOL_ID, // REQUIRED - Amazon Cognito Identity Pool ID 15 | region: appVariables.REGION, // REQUIRED - Amazon Cognito Region 16 | userPoolId: appVariables.USER_POOL_ID, // OPTIONAL - Amazon Cognito User Pool ID 17 | userPoolWebClientId: appVariables.USER_POOL_CLIENT_ID // OPTIONAL - Amazon Cognito Web Client ID, 18 | }, 19 | API: { 20 | aws_appsync_graphqlEndpoint: appVariables.APP_SYNC_GRAPHQL_ENDPOINT, 21 | aws_appsync_region: appVariables.REGION, 22 | aws_appsync_authenticationType: 'AMAZON_COGNITO_USER_POOLS' 23 | } 24 | }); 25 | 26 | 27 | if (environment.production) { 28 | enableProdMode(); 29 | } 30 | 31 | platformBrowserDynamic() 32 | .bootstrapModule(AppModule) 33 | .catch(err => console.log(err)); 34 | -------------------------------------------------------------------------------- /source/console/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | html { 3 | height: 100% 4 | } 5 | 6 | .mqttMessage { 7 | white-space: pre-wrap; 8 | /* Since CSS 2.1 */ 9 | white-space: -moz-pre-wrap; 10 | /* Mozilla, since 1999 */ 11 | white-space: -pre-wrap; 12 | /* Opera 4-6 */ 13 | white-space: -o-pre-wrap; 14 | /* Opera 7 */ 15 | word-wrap: break-word; 16 | /* Internet Explorer 5.5+ */ 17 | 18 | } 19 | 20 | .truncate { 21 | white-space: nowrap; 22 | overflow: hidden; 23 | text-overflow: ellipsis; 24 | } 25 | 26 | .text-overflow-center { 27 | margin-left: -100%; 28 | margin-right: -100%; 29 | text-align: center; 30 | } 31 | -------------------------------------------------------------------------------- /source/console/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "es2015", 6 | "types": ["node"] 7 | }, 8 | "exclude": [ 9 | "src/test.ts", 10 | "**/*.spec.ts" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /source/console/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /source/console/tools/postinstall/patch-ngcli-webpack.ts: -------------------------------------------------------------------------------- 1 | // #!/usr/bin/env ts-node 2 | 3 | // import * as fs from 'fs-extra'; 4 | 5 | // // tslint:disable-next-line:max-line-length 6 | // const configFile = `./node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js`; 7 | // const newConfig = `node: 8 | // { 9 | // fs: 'empty', 10 | // global: true, 11 | // crypto: 'empty', 12 | // tls: 'empty', 13 | // net: 'empty', 14 | // process: true, 15 | // module: false, 16 | // clearImmediate: false, 17 | // setImmediate: false 18 | // }`; 19 | 20 | // fs 21 | // .readFile(configFile) 22 | // .then((b: Buffer) => b.toString()) 23 | // .then((contents: string) => contents.replace(/node: false/g, newConfig)) 24 | // .then((config: string) => fs.writeFile(configFile, config).catch(console.log)) 25 | -------------------------------------------------------------------------------- /source/console/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./src/app/", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "moduleResolution": "node", 9 | "emitDecoratorMetadata": true, 10 | "experimentalDecorators": true, 11 | "target": "es6", 12 | "typeRoots": [ 13 | "node_modules/@types" 14 | ], 15 | "lib": [ 16 | "es2017", 17 | "dom" 18 | ], 19 | "paths": { 20 | "@app/*": ["./*"], 21 | "@assets/*": ["../assets/*"], 22 | "@common-components/*": ["common/components/*"], 23 | "@common-modules/*": ["common/modules/*"], 24 | "@common-secure/*": ["secure/common/*"], 25 | "@env/*": ["../environments/*"], 26 | "@graphql/*": ["graphql/*"], 27 | "@models/*": ["models/*"], 28 | "@pipes/*": ["pipes/*"], 29 | "@secure/*": ["secure/*"], 30 | "@services/*": ["services/*"], 31 | "@systems/*": ["secure/child-views/*"], 32 | "@widgets/*": ["widgets/*"] 33 | } 34 | }, 35 | } 36 | -------------------------------------------------------------------------------- /source/resources/cf-helper-s3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-samples/aws-iot-kickstart-custom-resource-helper-s3", 3 | "description": "Cloudformation Custom Resource Helper for S3", 4 | "main": "index.js", 5 | "author": { 6 | "name": "teuteuguy" 7 | }, 8 | "version": "0.0.1", 9 | "private": "true", 10 | "dependencies": {}, 11 | "devDependencies": {}, 12 | "scripts": { 13 | "build:init": "rm -rf dist && rm -rf node_modules", 14 | "build:zip": "zip -rq `jq -cr '.name' package.json`.zip .", 15 | "build:dist": "mkdir dist && mv `jq -cr '.name' package.json`.zip dist/", 16 | "build": "yarn run build:init && yarn install --production && yarn run build:zip && yarn run build:dist" 17 | }, 18 | "bundledDependencies": [] 19 | } 20 | -------------------------------------------------------------------------------- /source/resources/usage-metrics/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-samples/aws-iot-kickstart-usage-metrics", 3 | "version": "0.0.1", 4 | "description": "Usage metrics is an auxiliary class to capture metrics pertinent for feedback on the solution", 5 | "author": { 6 | "name": "aws-solutions-builder" 7 | }, 8 | "private": "true", 9 | "main": "metrics.common.js", 10 | "dependencies": { 11 | "moment": "*" 12 | }, 13 | "devDependencies": { 14 | "aws-sdk": "*", 15 | "chai": "*", 16 | "sinon": "*", 17 | "sinon-chai": "*", 18 | "mocha": "*", 19 | "aws-sdk-mock": "*", 20 | "npm-run-all": "*", 21 | "proxyquire": "*" 22 | }, 23 | "scripts": { 24 | "test": "mocha *.spec.js" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /source/resources/utils/lib/blueprint-parser.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const _ = require('underscore'); 4 | 5 | class ObjectToParse { 6 | constructor(object) { 7 | this.object = object; 8 | } 9 | 10 | setAtt(value) { 11 | 12 | } 13 | 14 | on(value) { 15 | 16 | } 17 | 18 | } 19 | 20 | /** 21 | * 22 | * @class BlueprintParser 23 | */ 24 | class BlueprintParser { 25 | 26 | /** 27 | * @class BlueprintParser 28 | * @constructor 29 | */ 30 | constructor() { 31 | } 32 | 33 | parse(what, message) { 34 | 35 | const tag = 'BlueprintParser.parse:'; 36 | console.log(tag, 'start', JSON.stringify(what), message); 37 | 38 | const objectToParse = new ObjectToParse(what); 39 | 40 | // For now only support !SetAtt 41 | if (!message.startsWith('!SetAtt[')) { 42 | return Promise.reject('Currently only supports actions that start with !SetAtt'); 43 | } else { 44 | 45 | // console.log(tag, JSON.stringify(message.split('!SetAtt['), null, 2)); 46 | // console.log(tag, JSON.stringify(message.split(']'), null, 2)); 47 | 48 | // console.log(tag, JSON.stringify(message.split('!'), null, 2)); 49 | 50 | let backwardBracketOccurences = message.split(']'); 51 | 52 | console.log(_.flatten(backwardBracketOccurences.map(backwardBracketContent => { 53 | return backwardBracketContent.split('['); 54 | }))); 55 | 56 | return Promise.resolve(''); 57 | } 58 | 59 | } 60 | 61 | 62 | } 63 | 64 | module.exports = BlueprintParser; 65 | -------------------------------------------------------------------------------- /source/resources/utils/lib/greengrass-helper.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let AWS = require('aws-sdk'); 4 | const fs = require('fs'); 5 | const moment = require('moment'); 6 | 7 | /** 8 | * 9 | * @class greengrassHelper 10 | */ 11 | class greengrassHelper { 12 | /** 13 | * @class greengrassHelper 14 | * @constructor 15 | */ 16 | constructor() { 17 | this.creds = new AWS.EnvironmentCredentials('AWS'); // Lambda provided credentials 18 | } 19 | 20 | associateServiceRoleToAccount() { 21 | const gg = new AWS.Greengrass(); 22 | return gg 23 | .associateServiceRoleToAccount({ 24 | RoleArn: process.env.GREENGRASS_SERVICE_ROLE_ARN 25 | }) 26 | .promise() 27 | .then(data => { 28 | return data; 29 | }); 30 | } 31 | 32 | } 33 | 34 | module.exports = greengrassHelper; 35 | -------------------------------------------------------------------------------- /source/resources/utils/lib/iot-helper.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let AWS = require('aws-sdk'); 4 | const fs = require('fs'); 5 | const moment = require('moment'); 6 | 7 | /** 8 | * 9 | * @class iotHelper 10 | */ 11 | class iotHelper { 12 | 13 | /** 14 | * @class iotHelper 15 | * @constructor 16 | */ 17 | constructor() { 18 | this.creds = new AWS.EnvironmentCredentials('AWS'); // Lambda provided credentials 19 | } 20 | 21 | describeEndpoint(endpointType = 'iot:Data') { 22 | const iot = new AWS.Iot(); 23 | console.log('describeEndpoint:', endpointType); 24 | return iot.describeEndpoint({ 25 | endpointType: endpointType 26 | }).promise().then(data => { 27 | console.log('Returned endpoint', data); 28 | return data; 29 | }); 30 | } 31 | 32 | attachPrincipalPolicy(policyName, principal) { 33 | const iot = new AWS.Iot(); 34 | return iot.attachPrincipalPolicy({ 35 | policyName: policyName, 36 | principal: principal 37 | }).promise().then(data => { 38 | console.log('attachPrincipalPolicy successful for', policyName, principal, data); 39 | return true; 40 | }).catch(err => { 41 | console.error(err); 42 | return false; 43 | }); 44 | } 45 | 46 | iotdata(cmd, params) { 47 | cmd = cmd.split('.')[1]; 48 | return this.describeEndpoint().then(endpoint => { 49 | const iotdata = new AWS.IotData({ 50 | endpoint: endpoint.endpointAddress 51 | }); 52 | return iotdata[cmd](params).promise(); 53 | }).then(result => { 54 | console.log('Result:', result); 55 | return result; 56 | }); 57 | } 58 | } 59 | 60 | module.exports = iotHelper; 61 | -------------------------------------------------------------------------------- /source/resources/utils/lib/s3-helper.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let AWS = require('aws-sdk'); 4 | const fs = require('fs'); 5 | 6 | /** 7 | * Helper function to interact with AWS S3 for cfn custom resource. 8 | * 9 | * @class s3Helper 10 | */ 11 | class s3Helper { 12 | 13 | /** 14 | * @class s3Helper 15 | * @constructor 16 | */ 17 | constructor() { 18 | this.creds = new AWS.EnvironmentCredentials('AWS'); // Lambda provided credentials 19 | } 20 | 21 | copyFileFromS3ToS3(sourceS3Bucket, sourceS3Key, destS3Bucket, destS3Key) { 22 | console.log(`source bucket: ${sourceS3Bucket}`); 23 | console.log(`source key: ${sourceS3Key}`); 24 | console.log(`dest bucket: ${destS3Bucket}`); 25 | console.log(`dest key: ${destS3Key}`); 26 | 27 | 28 | const params = { 29 | Bucket: destS3Bucket, 30 | Key: destS3Key, 31 | CopySource: [sourceS3Bucket, sourceS3Key].join('/'), 32 | MetadataDirective: 'REPLACE' 33 | }; 34 | 35 | // params.ContentType = this._setContentType(filelist[index]); 36 | // params.Metadata = { 37 | // 'Content-Type': params.ContentType 38 | // }; 39 | // console.log(params); 40 | const s3 = new AWS.S3(); 41 | 42 | return s3.copyObject(params).promise().then(data => { 43 | console.log(`${sourceS3Bucket}/${sourceS3Key} copied successfully`); 44 | return data; 45 | }).catch(err => { 46 | throw `error copying ${sourceS3Bucket}/${sourceS3Key}\n${err}`; 47 | }); 48 | } 49 | 50 | listObjectsV2(params) { 51 | const s3 = new AWS.S3({ region: 'us-east-1'}); 52 | 53 | console.log('listObjectsV2:', params); 54 | return s3.listObjectsV2(params).promise().then(data => { 55 | return data; 56 | }); 57 | } 58 | 59 | } 60 | 61 | module.exports = s3Helper; 62 | -------------------------------------------------------------------------------- /source/resources/utils/libs.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = { 3 | listGreengrassGroupIdsForThingArn: require('./lib/list-greengrass-group-ids-for-thingarn'), 4 | blueprintParser: require('./lib/blueprint-parser') 5 | }; 6 | -------------------------------------------------------------------------------- /source/resources/utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-samples/aws-iot-kickstart-custom-resource-helper-utils", 3 | "description": "Utils for the app", 4 | "main": "libs.js", 5 | "author": { 6 | "name": "teuteuguy" 7 | }, 8 | "version": "0.0.1", 9 | "private": "true", 10 | "dependencies": { 11 | "moment": "*", 12 | "underscore": "*", 13 | "uuid": "*", 14 | "usage-metrics": "file:../usage-metrics/" 15 | }, 16 | "scripts": { 17 | "build:init": "rm -rf dist && rm -rf node_modules", 18 | "build:zip": "zip -rq `jq -cr '.name' package.json`.zip .", 19 | "build:dist": "mkdir dist && mv `jq -cr '.name' package.json`.zip dist/", 20 | "build": "yarn run build:init && yarn install --production && yarn run build:zip && yarn run build:dist" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /source/resources/utils/test.js: -------------------------------------------------------------------------------- 1 | const BlueprintParser = require('./lib/blueprint-parser'); 2 | 3 | const blueprintParser = new BlueprintParser(); 4 | 5 | let spec = { 6 | FunctionDefinition: { 7 | Functions: [ 8 | { 9 | FunctionArn: 'Arn1', 10 | Variables: { 11 | Var1: 'Var11Value', 12 | Var2: 'Var12Value' 13 | } 14 | }, 15 | { 16 | FunctionArn: 'Arn2', 17 | Variables: { 18 | Var1: 'Var21Value', 19 | Var2: 'Var22Value' 20 | } 21 | } 22 | ] 23 | } 24 | } 25 | 26 | const action = '!SetAtt[toto,!On[Arn2,FunctionArn,FunctionDefinition.Functions]Variables.Titi]'; 27 | 28 | 29 | blueprintParser.parse(spec, action).then(result => console.log(result)).catch(err => console.error(err)); 30 | -------------------------------------------------------------------------------- /source/services/admin/index.js: -------------------------------------------------------------------------------- 1 | const libs = require('./libs'); 2 | 3 | function handler(event, context, callback) { 4 | console.log('Event:', JSON.stringify(event, null, 2)); 5 | 6 | let promise = null; 7 | 8 | switch (event.cmd) { 9 | case 'deleteUser': 10 | promise = libs.deleteUser; 11 | break; 12 | case 'disableUser': 13 | promise = libs.disableUser; 14 | break; 15 | case 'enableUser': 16 | promise = libs.enableUser; 17 | break; 18 | case 'getUser': 19 | promise = libs.getUser; 20 | break; 21 | case 'inviteUser': 22 | promise = libs.inviteUser; 23 | break; 24 | case 'listGroups': 25 | promise = libs.listGroups; 26 | break; 27 | case 'listUsers': 28 | promise = libs.listUsers; 29 | break; 30 | case 'updateUser': 31 | promise = libs.updateUser; 32 | break; 33 | default: 34 | callback('Unknown cmd, unable to resolve for arguments: ' + event, null); 35 | break; 36 | } 37 | 38 | if (promise) { 39 | promise(event, context).then(result => { 40 | callback(null, result); 41 | }).catch(err => { 42 | callback(err, null); 43 | }); 44 | } 45 | } 46 | 47 | exports.handler = handler; 48 | -------------------------------------------------------------------------------- /source/services/admin/lib/deleteUser.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const cognitoIdentityServiceProvider = new AWS.CognitoIdentityServiceProvider(); 3 | const _ = require('underscore'); 4 | 5 | const lib = 'deleteUser'; 6 | 7 | function deleteUser(username) { 8 | 9 | const params = { 10 | UserPoolId: process.env.USER_POOL_ID, 11 | Username: username 12 | }; 13 | 14 | return cognitoIdentityServiceProvider.adminDeleteUser(params).promise().then(data => { 15 | return data; 16 | }); 17 | } 18 | 19 | module.exports = function (event, context) { 20 | return deleteUser(event.username); 21 | }; 22 | -------------------------------------------------------------------------------- /source/services/admin/lib/disableUser.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const cognitoIdentityServiceProvider = new AWS.CognitoIdentityServiceProvider(); 3 | const _ = require('underscore'); 4 | 5 | const lib = 'disableUser'; 6 | 7 | function disableUser(username) { 8 | 9 | const params = { 10 | UserPoolId: process.env.USER_POOL_ID, 11 | Username: username 12 | }; 13 | 14 | return cognitoIdentityServiceProvider.adminDisableUser(params).promise().then(data => { 15 | return data; 16 | }); 17 | } 18 | 19 | module.exports = function (event, context) { 20 | return disableUser(event.username); 21 | }; 22 | -------------------------------------------------------------------------------- /source/services/admin/lib/enableUser.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const cognitoIdentityServiceProvider = new AWS.CognitoIdentityServiceProvider(); 3 | const _ = require('underscore'); 4 | 5 | const lib = 'enableUser'; 6 | 7 | function enableUser(username) { 8 | 9 | const params = { 10 | UserPoolId: process.env.USER_POOL_ID, 11 | Username: username 12 | }; 13 | 14 | return cognitoIdentityServiceProvider.adminEnableUser(params).promise().then(data => { 15 | return data; 16 | }); 17 | } 18 | 19 | module.exports = function (event, context) { 20 | return enableUser(event.username); 21 | }; 22 | -------------------------------------------------------------------------------- /source/services/admin/lib/generatePassword.js: -------------------------------------------------------------------------------- 1 | const generatePassword = require('password-generator'); 2 | const MAX_PASSWORD_LENGTH = 18; 3 | const MIN_PASSWORD_LENGTH = 12; 4 | 5 | /** 6 | * Helper function to validate that a generated password is strong. 7 | * @param {string} password - Password to validate. 8 | */ 9 | function _isStrongEnough(password) { 10 | const uppercaseMinCount = 1; 11 | const lowercaseMinCount = 1; 12 | const numberMinCount = 2; 13 | const UPPERCASE_RE = /([A-Z])/g; 14 | const LOWERCASE_RE = /([a-z])/g; 15 | const NUMBER_RE = /([\d])/g; 16 | const NON_REPEATING_CHAR_RE = /([\w\d\?\-])\1{2,}/g; 17 | 18 | let uc = password.match(UPPERCASE_RE); 19 | let lc = password.match(LOWERCASE_RE); 20 | let n = password.match(NUMBER_RE); 21 | let nr = password.match(NON_REPEATING_CHAR_RE); 22 | return password.length >= this.MIN_PASSWORD_LENGTH && 23 | !nr && 24 | uc && uc.length >= uppercaseMinCount && 25 | lc && lc.length >= lowercaseMinCount && 26 | n && n.length >= numberMinCount; 27 | } 28 | 29 | /** 30 | * Helper function to generated a strong password. 31 | */ 32 | function _generatedSecurePassword() { 33 | var password = ''; 34 | var randomLength = Math.floor(Math.random() * (MAX_PASSWORD_LENGTH - MIN_PASSWORD_LENGTH)) + 35 | MIN_PASSWORD_LENGTH; 36 | while (!_isStrongEnough(password)) { 37 | password = generatePassword(randomLength, false, /[\w\d\?\-]/); 38 | console.log(password, _isStrongEnough(password)); 39 | } 40 | 41 | return password; 42 | } 43 | 44 | module.exports = _generatedSecurePassword; 45 | -------------------------------------------------------------------------------- /source/services/admin/lib/getUser.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const cognitoIdentityServiceProvider = new AWS.CognitoIdentityServiceProvider(); 3 | const _ = require('underscore'); 4 | 5 | const lib = 'getUser'; 6 | 7 | function getUser(username) { 8 | 9 | const params = { 10 | UserPoolId: process.env.USER_POOL_ID, 11 | Username: username 12 | }; 13 | 14 | return cognitoIdentityServiceProvider.adminGetUser(params).promise().then(data => { 15 | let _user = { 16 | user_id: data.Username, 17 | name: '', 18 | email: '', 19 | groups: [], 20 | enabled: data.Enabled, 21 | created_at: data.UserCreateDate, 22 | updated_at: data.UserLastModifiedDate 23 | }; 24 | let _nm = _.where(data.UserAttributes, { 25 | Name: 'nickname' 26 | }); 27 | if (_nm.length > 0) { 28 | _user.name = _nm[0].Value; 29 | } 30 | 31 | let _em = _.where(data.UserAttributes, { 32 | Name: 'email' 33 | }); 34 | if (_em.length > 0) { 35 | _user.email = _em[0].Value; 36 | } 37 | 38 | return cognitoIdentityServiceProvider.adminListGroupsForUser(params).promise().then(grps => { 39 | 40 | grps.Groups.forEach(group => { 41 | _user.groups.push({ 42 | name: group.GroupName 43 | }); 44 | }); 45 | 46 | return _user; 47 | }); 48 | 49 | }); 50 | } 51 | 52 | 53 | module.exports = function (event, context) { 54 | return getUser(event.username); 55 | }; 56 | -------------------------------------------------------------------------------- /source/services/admin/lib/inviteUser.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const cognitoIdentityServiceProvider = new AWS.CognitoIdentityServiceProvider(); 3 | const _ = require('underscore'); 4 | const setUserGroups = require('./setUserGroups'); 5 | const generatePassword = require('./generatePassword'); 6 | 7 | const lib = 'inviteUser'; 8 | 9 | function inviteUser(name, email, groups) { 10 | 11 | console.log('inviteUser:', name, email, groups); 12 | const _username = email.replace('@', '_').replace(/\./g, '_'); 13 | 14 | const params = { 15 | UserPoolId: process.env.USER_POOL_ID, 16 | Username: _username, 17 | DesiredDeliveryMediums: ['EMAIL'], 18 | ForceAliasCreation: true, 19 | // TemporaryPassword: _password, 20 | UserAttributes: [{ 21 | Name: 'email', 22 | Value: email 23 | }, { 24 | Name: 'email_verified', 25 | Value: 'true' 26 | }, { 27 | Name: 'nickname', 28 | Value: name 29 | }] 30 | }; 31 | 32 | return cognitoIdentityServiceProvider.adminCreateUser(params).promise().then(data => { 33 | return setUserGroups(process.env.USER_POOL_ID, _username, groups).then(result => { 34 | // return data; 35 | return true; 36 | }); 37 | }); 38 | } 39 | 40 | module.exports = function (event, context) { 41 | return inviteUser(event.name, event.email, event.groups); 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /source/services/admin/lib/listGroups.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const cognitoIdentityServiceProvider = new AWS.CognitoIdentityServiceProvider(); 3 | const _ = require('underscore'); 4 | 5 | const lib = 'listGroups'; 6 | 7 | function listGroups(limit, nextToken) { 8 | let params = { 9 | UserPoolId: process.env.USER_POOL_ID 10 | }; 11 | if (limit) { 12 | params.Limit = limit; 13 | } 14 | if (nextToken) { 15 | params.NextToken = nextToken; 16 | } 17 | 18 | return cognitoIdentityServiceProvider.listGroups(params).promise().then(data => { 19 | return data; 20 | }); 21 | } 22 | 23 | 24 | module.exports = function (event, context) { 25 | return listGroups(event.limit, event.nextToken); 26 | }; 27 | -------------------------------------------------------------------------------- /source/services/admin/lib/listUsers.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const cognitoIdentityServiceProvider = new AWS.CognitoIdentityServiceProvider(); 3 | const _ = require('underscore'); 4 | 5 | const lib = 'listUsers'; 6 | 7 | function listUsers(limit, paginationToken) { 8 | let params = { 9 | UserPoolId: process.env.USER_POOL_ID, 10 | AttributesToGet: [ 11 | 'email', 12 | 'nickname' 13 | ], 14 | Filter: '' 15 | }; 16 | 17 | if (limit) { 18 | params.Limit = limit; 19 | } 20 | if (paginationToken) { 21 | params.PaginationToken = paginationToken; 22 | } 23 | 24 | console.log('listUsers: params:', params); 25 | 26 | return cognitoIdentityServiceProvider.listUsers(params).promise().then(data => { 27 | data.Users = data.Users.map(user => { 28 | let _user = { 29 | user_id: user.Username, 30 | name: '', 31 | email: '', 32 | enabled: user.Enabled, 33 | status: user.UserStatus 34 | }; 35 | 36 | const _nm = _.where(user.Attributes, { 37 | Name: 'nickname' 38 | }); 39 | 40 | const _em = _.where(user.Attributes, { 41 | Name: 'email' 42 | }); 43 | 44 | if (_nm.length > 0) { 45 | _user.name = _nm[0].Value; 46 | } 47 | 48 | if (_em.length > 0) { 49 | _user.email = _em[0].Value; 50 | } 51 | 52 | return _user; 53 | }); 54 | 55 | return data; 56 | }); 57 | } 58 | 59 | module.exports = function (event, context) { 60 | return listUsers(event.limit, event.paginationToken); 61 | }; 62 | -------------------------------------------------------------------------------- /source/services/admin/lib/setUserGroups.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const cognitoIdentityServiceProvider = new AWS.CognitoIdentityServiceProvider(); 3 | const _ = require('underscore'); 4 | 5 | const lib = 'setUserGroups'; 6 | 7 | function setUserGroups(poolinfo, username, groups) { 8 | const _self = this; 9 | 10 | return Promise.all(groups.map(group => { 11 | const params = { 12 | GroupName: group.name, 13 | UserPoolId: poolinfo, 14 | Username: username 15 | }; 16 | if (group._state === 'new') { 17 | return cognitoIdentityServiceProvider.adminAddUserToGroup(params).promise(); 18 | } else if (group._state === 'deleted') { 19 | return cognitoIdentityServiceProvider.adminRemoveUserFromGroup(params).promise(); 20 | } else { 21 | return null; 22 | } 23 | })).then(results => { 24 | return 'group modifications complete'; 25 | }); 26 | } 27 | 28 | module.exports = setUserGroups; 29 | -------------------------------------------------------------------------------- /source/services/admin/lib/updateUser.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const cognitoIdentityServiceProvider = new AWS.CognitoIdentityServiceProvider(); 3 | const _ = require('underscore'); 4 | 5 | const setUserGroups = require('./setUserGroups'); 6 | 7 | const lib = 'updateUser'; 8 | 9 | function updateUser(username, groups) { 10 | 11 | return setUserGroups(process.env.USER_POOL_ID, username, groups, 0).then(result => { 12 | return result; 13 | }); 14 | } 15 | 16 | module.exports = function (event, context) { 17 | return updateUser(event.username, event.groups); 18 | }; 19 | -------------------------------------------------------------------------------- /source/services/admin/libs.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | deleteUser: require('./lib/deleteUser'), 3 | disableUser: require('./lib/disableUser'), 4 | enableUser: require('./lib/enableUser'), 5 | getUser: require('./lib/getUser'), 6 | inviteUser: require('./lib/inviteUser'), 7 | listGroups: require('./lib/listGroups'), 8 | listUsers: require('./lib/listUsers'), 9 | updateUser: require('./lib/updateUser') 10 | }; 11 | -------------------------------------------------------------------------------- /source/services/admin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-samples/aws-iot-kickstart-admin-service", 3 | "description": "The admin microservice for the sputnik", 4 | "main": "libs.js", 5 | "license": "Amazon Software License (ASL)", 6 | "version": "0.0.1", 7 | "private": "true", 8 | "dependencies": { 9 | "moment": "*", 10 | "sputnik-custom-resource-helper-utils": "../../resources/utils/", 11 | "password-generator": "*", 12 | "underscore": "*" 13 | }, 14 | "devDependencies": {}, 15 | "scripts": { 16 | "prestart": "yarn install", 17 | "start": "node index.js", 18 | "build:init": "rm -rf dist && rm -rf node_modules", 19 | "build:zip": "zip -rq `jq -cr '.name' package.json`.zip .", 20 | "build:dist": "mkdir dist && mv `jq -cr '.name' package.json`.zip dist/", 21 | "fast-build": "rm -rf dist && yarn run build:zip && yarn run build:dist", 22 | "build": "yarn run build:init && yarn install --production && yarn run build:zip && yarn run build:dist" 23 | }, 24 | "bundledDependencies": [ 25 | "aws-sdk", 26 | "moment", 27 | "underscore" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /source/services/admin/test.js: -------------------------------------------------------------------------------- 1 | const generatePassword = require('./lib/generatePassword'); 2 | 3 | console.log(generatePassword()); 4 | -------------------------------------------------------------------------------- /source/services/deployments/index.js: -------------------------------------------------------------------------------- 1 | const libs = require('./libs'); 2 | 3 | 4 | function handler(event, context, callback) { 5 | console.log('Event:', JSON.stringify(event, null, 2)); 6 | 7 | let promise = null; 8 | 9 | switch (event.cmd) { 10 | case 'addDeployment': 11 | promise = libs.addDeployment; 12 | break; 13 | default: 14 | callback('Unknown cmd, unable to resolve for arguments: ' + event, null); 15 | break; 16 | } 17 | 18 | if (promise) { 19 | promise(event, context).then(result => { 20 | callback(null, result); 21 | }).catch(err => { 22 | callback(err, null); 23 | }); 24 | } 25 | 26 | } 27 | 28 | exports.handler = handler; 29 | -------------------------------------------------------------------------------- /source/services/deployments/lib/merge-sputnik-shadows.js: -------------------------------------------------------------------------------- 1 | 2 | const merge = require('deepmerge'); 3 | 4 | // TODO: check if we can use this for the greengrass stuff ? 5 | 6 | module.exports = function (parent, child) { 7 | 8 | if (parent === null || parent === undefined) { 9 | parent = {}; 10 | } 11 | if (child === null || child === undefined) { 12 | child = {}; 13 | } 14 | 15 | return merge(parent, child); 16 | }; 17 | -------------------------------------------------------------------------------- /source/services/deployments/libs.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | addDeployment: require('./lib/addDeployment') 3 | }; 4 | -------------------------------------------------------------------------------- /source/services/deployments/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-samples/aws-iot-kickstart-deployments-service", 3 | "description": "The deployments microservice for the sputnik", 4 | "main": "libs.js", 5 | "license": "Amazon Software License (ASL)", 6 | "version": "0.0.1", 7 | "private": "true", 8 | "dependencies": { 9 | "deep-diff": "^1.0.2", 10 | "deepmerge": "^2.2.1", 11 | "moment": "*", 12 | "underscore": "*", 13 | "uuid": "^3.3.2", 14 | "aws-sdk": "*" 15 | }, 16 | "devDependencies": {}, 17 | "scripts": { 18 | "prestart": "yarn install", 19 | "start": "node index.js", 20 | "build:init": "rm -rf dist && rm -rf node_modules", 21 | "build:zip": "zip -rq `jq -cr '.name' package.json`.zip .", 22 | "build:dist": "mkdir dist && mv `jq -cr '.name' package.json`.zip dist/", 23 | "fast-build": "rm -rf dist && yarn run build:zip && yarn run build:dist", 24 | "build": "yarn run build:init && yarn install --production && yarn run build:zip && yarn run build:dist" 25 | }, 26 | "bundledDependencies": [ 27 | "aws-sdk", 28 | "moment", 29 | "underscore" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /source/services/devices/index.js: -------------------------------------------------------------------------------- 1 | const libs = require('./libs'); 2 | 3 | function handler(event, context, callback) { 4 | console.log('Event:', JSON.stringify(event, null, 2)); 5 | 6 | let promise = null; 7 | 8 | switch (event.cmd) { 9 | case 'getDeviceStats': 10 | promise = libs.getDeviceStats; 11 | break; 12 | case 'addDevice': 13 | promise = libs.addDevice; 14 | break; 15 | case 'deleteDevice': 16 | promise = libs.deleteDevice; 17 | break; 18 | case 'updateDevice': 19 | promise = libs.updateDevice; 20 | break; 21 | case 'createCertificate': 22 | promise = libs.createCertificate; 23 | break; 24 | case 'test': 25 | promise = libs.test; 26 | break; 27 | default: 28 | callback('Unknown cmd, unable to resolve for arguments: ' + event, null); 29 | break; 30 | } 31 | 32 | if (promise) { 33 | promise(event, context).then(result => { 34 | callback(null, result); 35 | }).catch(err => { 36 | callback(err, null); 37 | }); 38 | } 39 | } 40 | 41 | exports.handler = handler; 42 | -------------------------------------------------------------------------------- /source/services/devices/lib/getDeviceStats.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const documentClient = new AWS.DynamoDB.DocumentClient(); 3 | const _ = require('underscore'); 4 | 5 | 6 | const lib = 'getDeviceStats'; 7 | 8 | function getDeviceStatsRecursive(lastEvalKey) { 9 | let params = { 10 | TableName: process.env.TABLE_DEVICES, 11 | Limit: 75 12 | }; 13 | 14 | if (lastEvalKey) { 15 | params.ExclusiveStartKey = lastEvalKey; 16 | } 17 | 18 | params.ProjectionExpression = 'thingId, userId, deviceTypeId, connectionState, deviceBlueprintId'; 19 | 20 | return documentClient.scan(params).promise().then(results => { 21 | let _stats = _.countBy(results.Items, (device) => { 22 | return device.connectionState.state; 23 | }); 24 | if (!_stats.hasOwnProperty('connected')) { 25 | _stats.connected = 0; 26 | } 27 | if (!_stats.hasOwnProperty('disconnected')) { 28 | _stats.disconnected = 0; 29 | } 30 | _stats.total = results.Items.length; 31 | 32 | if (results.LastEvaluatedKey) { 33 | return getDeviceStatsRecursive(result.LastEvaluatedKey).then(data => { 34 | _stats.connected += data.connected; 35 | _stats.disconnected += data.disconnected; 36 | _stats.total += data.total; 37 | return _stats; 38 | }); 39 | } else { 40 | return _stats; 41 | } 42 | }); 43 | } 44 | 45 | module.exports = function (event, context) { 46 | return getDeviceStatsRecursive(); 47 | }; 48 | -------------------------------------------------------------------------------- /source/services/devices/lib/test.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const documentClient = new AWS.DynamoDB.DocumentClient(); 3 | const dynamoDB = new AWS.DynamoDB(); 4 | const _ = require('underscore'); 5 | 6 | module.exports = function (event, context) { 7 | return documentClient.query({ 8 | TableName: process.env.TABLE_DEVICES, 9 | Index: 'deviceBlueprintId', 10 | KeyConditionExpression: 'deviceBlueprintId = :deviceBlueprintId', 11 | ExpressionAttributeValues: { 12 | ':deviceBlueprintId': 'aws-afr-3d-belt-mini-connected-factory-v1.0' 13 | } 14 | }).promise().then(data => { 15 | console.log(data); 16 | }); 17 | }; 18 | -------------------------------------------------------------------------------- /source/services/devices/libs.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | getDeviceStats: require('./lib/getDeviceStats'), 3 | addDevice: require('./lib/addDevice'), 4 | deleteDevice: require('./lib/deleteDevice'), 5 | updateDevice: require('./lib/updateDevice'), 6 | createCertificate: require('./lib/createCertificate'), 7 | test: require('./lib/test') 8 | }; 9 | -------------------------------------------------------------------------------- /source/services/devices/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-samples/aws-iot-kickstart-devices-service", 3 | "description": "The devices microservice for the sputnik", 4 | "main": "libs.js", 5 | "license": "Amazon Software License (ASL)", 6 | "version": "0.0.1", 7 | "private": "true", 8 | "dependencies": { 9 | "moment": "*", 10 | "sputnik-custom-resource-helper-utils": "../../resources/utils/", 11 | "underscore": "*", 12 | "usage-metrics": "file:../../resources/usage-metrics/", 13 | "aws-sdk": "*", 14 | "node-forge": "1.3.0", 15 | "shortid": "2.2.14" 16 | }, 17 | "devDependencies": {}, 18 | "scripts": { 19 | "prestart": "yarn install", 20 | "start": "node index.js", 21 | "build:init": "rm -rf dist && rm -rf node_modules", 22 | "build:zip": "zip -rq `jq -cr '.name' package.json`.zip .", 23 | "build:dist": "mkdir dist && mv `jq -cr '.name' package.json`.zip dist/", 24 | "fast-build": "rm -rf dist && yarn run build:zip && yarn run build:dist", 25 | "build": "yarn run build:init && yarn install --production && yarn run build:zip && yarn run build:dist" 26 | }, 27 | "bundledDependencies": [ 28 | "aws-sdk", 29 | "moment", 30 | "underscore" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /source/services/just-in-time-on-boarding/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-samples/aws-iot-kickstart-just-in-time-on-boarding-service", 3 | "description": "The Just In Time On Boarding microservice for sputnik", 4 | "main": "index.js", 5 | "license": "Amazon Software License (ASL)", 6 | "version": "0.0.1", 7 | "private": "true", 8 | "dependencies": { 9 | "moment": "*", 10 | "sputnik-custom-resource-helper-utils": "../../resources/utils/", 11 | "sputnik-devices-service": "../devices", 12 | "underscore": "*", 13 | "node-forge": "1.3.0", 14 | "shortid": "2.2.14" 15 | }, 16 | "devDependencies": {}, 17 | "scripts": { 18 | "prestart": "yarn install", 19 | "start": "node index.js", 20 | "build:init": "rm -rf dist && rm -rf node_modules", 21 | "build:zip": "zip -rq `jq -cr '.name' package.json`.zip .", 22 | "build:dist": "mkdir dist && mv `jq -cr '.name' package.json`.zip dist/", 23 | "fast-build": "rm -rf dist && yarn run build:zip && yarn run build:dist", 24 | "build": "yarn run build:init && yarn install --production && yarn run build:zip && yarn run build:dist" 25 | }, 26 | "bundledDependencies": [ 27 | "aws-sdk", 28 | "moment", 29 | "underscore" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /source/services/settings/index.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const iot = new AWS.Iot(); 3 | const dynamodb = new AWS.DynamoDB(); 4 | const documentClient = new AWS.DynamoDB.DocumentClient(); 5 | 6 | 7 | function handler(event, context, callback) { 8 | console.log('Event:', JSON.stringify(event, null, 2)); 9 | 10 | switch (event.cmd) { 11 | case 'getJustInTimeOnBoardingState': 12 | iot.getTopicRule({ 13 | ruleName: process.env.IOT_JUST_IN_TIME_ON_BOARDING_TOPIC_RULE 14 | }).promise().then(data => { 15 | console.log(data); 16 | callback(null, !data.rule.ruleDisabled); 17 | }).catch(err => { 18 | callback('Error getting the topic rule ' + process.env.IOT_JUST_IN_TIME_ON_BOARDING_TOPIC_RULE + ' : ' + err, null); 19 | }); 20 | break; 21 | case 'setJustInTimeOnBoardingState': 22 | console.log('setJustInTimeOnBoardingState called, with enabled =', event.enabled); 23 | const params = { 24 | ruleName: process.env.IOT_JUST_IN_TIME_ON_BOARDING_TOPIC_RULE 25 | }; 26 | let promise = null; 27 | if (event.enabled === false) { 28 | promise = iot.disableTopicRule(params).promise(); 29 | } else if (event.enabled === true) { 30 | promise = iot.enableTopicRule(params).promise(); 31 | } else { 32 | callback('wrong parameters ' + event, null); 33 | break; 34 | } 35 | promise.then(data => { 36 | event.cmd = 'getJustInTimeOnBoardingState'; 37 | return handler(event, context, callback); 38 | }).catch(err => { 39 | callback('Error enabling/disabling the topic rule ' + process.env.IOT_JUST_IN_TIME_ON_BOARDING_TOPIC_RULE + ' : ' + err, null); 40 | }); 41 | break; 42 | default: 43 | callback('Unknown cmd, unable to resolve for arguments: ' + event, null); 44 | break; 45 | } 46 | } 47 | 48 | exports.handler = handler; 49 | -------------------------------------------------------------------------------- /source/services/settings/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-samples/aws-iot-kickstart-settings-service", 3 | "description": "The settings microservice for the sputnik", 4 | "main": "index.js", 5 | "license": "Amazon Software License (ASL)", 6 | "version": "0.0.1", 7 | "private": "true", 8 | "dependencies": {}, 9 | "devDependencies": {}, 10 | "scripts": { 11 | "prestart": "yarn install", 12 | "start": "node index.js", 13 | "build:init": "rm -rf dist && rm -rf node_modules", 14 | "build:zip": "zip -rq `jq -cr '.name' package.json`.zip .", 15 | "build:dist": "mkdir dist && mv `jq -cr '.name' package.json`.zip dist/", 16 | "fast-build": "rm -rf dist && yarn run build:zip && yarn run build:dist", 17 | "build": "yarn run build:init && yarn install --production && yarn run build:zip && yarn run build:dist" 18 | }, 19 | "bundledDependencies": [ 20 | "aws-sdk" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /source/services/systems/index.js: -------------------------------------------------------------------------------- 1 | const libs = require('./libs'); 2 | 3 | function handler(event, context, callback) { 4 | console.log('Event:', JSON.stringify(event, null, 2)); 5 | 6 | let promise = null; 7 | 8 | switch (event.cmd) { 9 | case 'getSystemStats': 10 | promise = libs.getSystemStats(event, context); 11 | break; 12 | case 'deleteSystem': 13 | promise = libs.deleteSystem(event, context); 14 | break; 15 | case 'refreshSystem': 16 | promise = libs.refreshSystem(event, context).then(result => { return true; }); 17 | break; 18 | default: 19 | callback('Unknown cmd, unable to resolve for arguments: ' + JSON.stringify(event), null); 20 | break; 21 | } 22 | 23 | if (promise) { 24 | promise.then(result => { 25 | callback(null, result); 26 | }).catch(err => { 27 | callback(err, null); 28 | }); 29 | } 30 | } 31 | 32 | exports.handler = handler; 33 | -------------------------------------------------------------------------------- /source/services/systems/lib/delete-system.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const iot = new AWS.Iot(); 3 | const documentClient = new AWS.DynamoDB.DocumentClient(); 4 | const _ = require('underscore'); 5 | const moment = require('moment'); 6 | 7 | const lib = 'deleteSystem'; 8 | 9 | module.exports = function (event, context) { 10 | 11 | return documentClient.delete({ 12 | TableName: process.env.TABLE_SYSTEMS, 13 | Key: { 14 | id: event.id 15 | } 16 | }).promise(); 17 | 18 | }; 19 | -------------------------------------------------------------------------------- /source/services/systems/lib/get-system-stats.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const documentClient = new AWS.DynamoDB.DocumentClient(); 3 | const _ = require('underscore'); 4 | 5 | 6 | const lib = 'getSystemStats'; 7 | 8 | function getSystemStatsRecursive(lastEvalKey) { 9 | 10 | console.log(lib, lastEvalKey); 11 | 12 | let params = { 13 | TableName: process.env.TABLE_SYSTEMS, 14 | Limit: 75 15 | }; 16 | 17 | if (lastEvalKey) { 18 | params.ExclusiveStartKey = lastEvalKey; 19 | } 20 | 21 | params.ProjectionExpression = 'id, thingId, systemBlueprintId'; 22 | 23 | return documentClient.scan(params).promise().then(results => { 24 | console.log('scan', results.Items.length); 25 | let _stats = { 26 | total: results.Items.length 27 | }; 28 | 29 | if (results.LastEvaluatedKey) { 30 | return getSystemStatsRecursive(result.LastEvaluatedKey).then(data => { 31 | // _stats.connected += data.connected; 32 | // _stats.disconnected += data.disconnected; 33 | _stats.total += data.total; 34 | return _stats; 35 | }); 36 | } else { 37 | return _stats; 38 | } 39 | }); 40 | } 41 | 42 | module.exports = function (event, context, callback) { 43 | return getSystemStatsRecursive(); 44 | }; 45 | -------------------------------------------------------------------------------- /source/services/systems/libs.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | deleteSystem: require('./lib/delete-system'), 3 | getSystemStats: require('./lib/get-system-stats'), 4 | refreshSystem: require('./lib/refresh-system') 5 | }; 6 | -------------------------------------------------------------------------------- /source/services/systems/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@aws-samples/aws-iot-kickstart-systems-service", 3 | "description": "The systems microservice for the sputnik", 4 | "main": "libs.js", 5 | "license": "Amazon Software License (ASL)", 6 | "version": "0.0.1", 7 | "private": "true", 8 | "dependencies": { 9 | "moment": "*", 10 | "sputnik-devices-service": "../devices", 11 | "shortid": "^2.2.13", 12 | "underscore": "*", 13 | "uuid": "^3.3.2" 14 | }, 15 | "devDependencies": {}, 16 | "scripts": { 17 | "prestart": "yarn install", 18 | "start": "node index.js", 19 | "build:init": "rm -rf dist && rm -rf node_modules", 20 | "build:zip": "zip -rq `jq -cr '.name' package.json`.zip .", 21 | "build:dist": "mkdir dist && mv `jq -cr '.name' package.json`.zip dist/", 22 | "fast-build": "rm -rf dist && yarn run build:zip && yarn run build:dist", 23 | "build": "yarn run build:init && yarn install --production && yarn run build:zip && yarn run build:dist" 24 | }, 25 | "bundledDependencies": [ 26 | "aws-sdk", 27 | "moment", 28 | "underscore" 29 | ] 30 | } 31 | --------------------------------------------------------------------------------