Compare commits

..

492 Commits

Author SHA1 Message Date
Sava 0fd0e6a13f Initial user, device, channel provisioning script used to speed up testing on a fresh Mainflux installation. Accepts email, password, device name, channel name as arguments. (#369)
Signed-off-by: Sava Radoš <sava.rados@mainflux.com>
2018-08-27 20:51:17 +02:00
Jovan Kostovski 8a86593dc3 NOISSUE - Makefile test target, CREATE TABLE and dev guide enhancements (#359)
* Fixes #337

Signed-off-by: Jovan Kostovski <chombium@gmail.com>

* added create table if not exists

Signed-off-by: Jovan Kostovski <chombium@gmail.com>

* added test target in sync with Semaphore CI

Signed-off-by: Jovan Kostovski <chombium@gmail.com>

* added warning about the possible data loss

Signed-off-by: Jovan Kostovski <chombium@gmail.com>
2018-08-27 12:17:41 +02:00
Ivan Milošević effade00aa MF-325 - Add SPDX license and copyright headers (#362)
* MF-325 - Add SPDX license and copyright headers

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* MF-325 - Add SPDX license and copyright headers

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* MF-325 - Add SPDX license and copyright headers

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* MF-325 - Add SPDX license and copyright headers

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* MF-325 - Change mainflux version from 0.4.0 to 0.5.0

Signed-off-by: Ivan Milošević <iva@blokovi.com>
2018-08-26 13:15:48 +02:00
Sava 8edf6907bc Change project retrieval procedure from git clone to go get (#366)
Signed-off-by: Sava Radoš <sava.rados@mainflux.com>
2018-08-25 14:39:30 +02:00
Dušan Borovčanin 507bd2ee84 MF-311 - Implement basic InfluxDB reader (#365)
* Add InfluxDB reader

Summary:
- Add basic reader features
- Update Makefile

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Raise test coverage

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Update README.md and docker composition

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Fix docker-compose.yml

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Remove exposed ports

Ports are already exposed by mapping, so no need to explicity expose them.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2018-08-25 12:48:03 +02:00
Sava 86f0d8e0d6 MF-363 - Add compiled .proto files (#364)
* Add compiled .proto files

Signed-off-by: Sava Radoš <sava.rados@mainflux.com>

* Remove proto as prerequisite for build services target

Signed-off-by: Sava Radoš <sava.rados@mainflux.com>
2018-08-24 15:33:40 +02:00
Aleksandar Novaković 6461761985 Add logging middleware to normalizer service (#360)
Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-08-21 10:15:50 +02:00
Paul RATHGEB ec03d877f0 Declare docker_mainflux-base-net as external and add it to all services (#361)
Signed-off-by: Paul RATHGEB <paul.rathgeb@skynet.be>
2018-08-20 22:00:45 +02:00
Ivan Milošević 4e137a3214 MF-343 - Thing Model: rename the Payload Field to Metadata (#358)
* Rename Payload field to Metadata

Rename Payload field of Thing to Metadata.

Signed-off-by: Ivan Milošević <iva@blokovi.com>

* Revert JSON payload rename in docs

Signed-off-by: Ivan Milošević <iva@blokovi.com>
2018-08-17 16:20:35 +02:00
Drasko DRASKOVIC af281da430 NOISSUE - Add insecure param to cli (#356)
Signed-off-by: drasko <drasko.draskovic@gmail.com>
2018-08-17 04:58:09 +02:00
Drasko DRASKOVIC 1683d17830 Add some make command info (#353)
Signed-off-by: drasko <drasko.draskovic@gmail.com>
2018-08-16 21:51:49 +02:00
Drasko DRASKOVIC 7e83b2d612 NOISSUE - Add system run script (#350)
* NOISSUE - Add system run script

Signed-off-by: drasko <drasko.draskovic@gmail.com>

* Add MQTT

Signed-off-by: drasko <drasko.draskovic@gmail.com>

* Add MQTT module install to Makefile. Fix warnings.

Signed-off-by: drasko <drasko.draskovic@gmail.com>
2018-08-16 19:52:43 +02:00
Drasko DRASKOVIC 312d30fd69 NOISSUE - Add Development Guide doc (#351)
* NOISSUE - Add Development Guide doc

Signed-off-by: drasko <drasko.draskovic@gmail.com>

* Add MQTT info

Signed-off-by: drasko <drasko.draskovic@gmail.com>

* Fix typos

Signed-off-by: drasko <drasko.draskovic@gmail.com>
2018-08-16 19:44:11 +02:00
Drasko DRASKOVIC 2c988c19b0 NOISSUE - Rename bashflux to cli and fix cert path (#349)
* NOISSUE - rename bashflux to cli and fix cert path

Signed-off-by: drasko <drasko.draskovic@gmail.com>

* Fix pkg name

Signed-off-by: drasko <drasko.draskovic@gmail.com>
2018-08-16 13:41:27 +02:00
Paul RATHGEB 455fedf075 Fix the influxdb hostname. Fix #346 (#348)
Signed-off-by: Paul RATHGEB <paul.rathgeb@skynet.be>
2018-08-16 04:06:25 +02:00
Aleksandar Novaković 58cdf2cddc MF-312 - Implement basic MongoDB reader (#344)
* Add mongodb reader service

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add tests for mongodb reader service

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add documentation for mongodb reader service

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Fix test function name

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Update comment in docker-compose for mongodb-reader service

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-08-08 13:38:34 +02:00
Aleksandar Novaković 6d48446c16 MF-313 - Implement basic Cassandra reader (#331)
* Fix logger message in http service

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Inline query and error handling in cassandra writer

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Fix comments and import statement in writer interface

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add reader common interface and shared HTTP API

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add Cassandra reader implementation

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add tests for cassandra reader

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add swagger doc and readme for readers

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Update make file

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add docker-compose configuration for cassandra reader

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add readme file to cassandra reader

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-08-06 17:06:55 +02:00
Ivan Milošević 29d146636a Change favicon on Dashflux (#341)
Signed-off-by: Ivan Milosevic <iva@blokovi.com>
2018-08-01 23:11:40 +02:00
Marco Ferragina f3f14e803d Improved getting started docs (#339)
* Improved getting started docs

Better explaination of how to send messages to a channel using websockets.
Added a basic nodejs example

Signed-off-by: Marco Ferragina <marco.ferragina@gmail.com>

* Added leading slash

Signed-off-by: Marco Ferragina <marco.ferragina@gmail.com>

* added some comments to example code in docs

Signed-off-by: Marco Ferragina <marco.ferragina@gmail.com>
2018-07-25 11:12:31 +02:00
Manuel Imperiale b090aa3e02 MF-216 - Integrate Bashflux into monorepo (#308)
* MF-216 - Integrate Bashflux into monorepo

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rename clients -> things

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix FormatResLog

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Initialize Channels commands in channels.go

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Mv bashflux to cmd/ repertory

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Mv API commands files to bashflux repertory

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Initialize Users commands in users.go

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Initialize Version command in version.go

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Initialize Messages command in messages.go

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rm bashflux .gitignore and mv commands to root .gitignore

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rename API commands vars

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix certificates paths

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rm test logs

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Remove get channels cmd without arguments

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix connect and disconnect commands

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix messages endpoint

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rm useless comments and dead code

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Use contentTypeSenml var

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rename cmdCobra -> cmd

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rm else statments

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rename SetServerAddr function vars

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rename conf parameters

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rename main with proper name

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix Update channel comment

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix README

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rm .DS_Store from .gitignore

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rename hhtp_client.go -> http.go

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rm DeleteAllChannels and DeleteAllThings funcs

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix BF users usage log

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Improve bashflux logs

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Share types in funcs

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Typo fix

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix BF version cmd

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Set certs paths via env variables

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix package

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rm not direct dependencies from Gopkg.toml

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix README

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Add def prefix to certificates paths

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* User thiings service for version cmd

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Rename GetReqResp -> SendRequest

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix version help

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Return directly the pointer in NewVersionCmd

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Define endpoints names as consts and be consistent with naming

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Use Spintf for string concatenation

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* typo fix

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix README

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix version endpoint

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Fix serverAddr

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2018-07-11 13:53:37 +02:00
Dušan Borovčanin 0b954847fd MF-334 - Correct normalizer k8 port (#335)
* Fix k8s normalizer deployment port

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Remove targert port

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2018-07-02 14:53:16 +02:00
Dušan Borovčanin 44f5a7241f NOISSUE - Expose SenML subject from Normalizer service (#330)
* Expose SenML subject from Normalizer service

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Export shared NATS subjects

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2018-06-19 00:37:04 +02:00
Dušan Borovčanin b694f08ea2 Inteface implementation files match interface name (#329)
Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2018-06-18 10:51:30 +02:00
Dušan Borovčanin f1537528f9 NOISSUE - Raise test coverage (#324)
* Update WS tests

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Use require in all writer tests

Refactor code.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Ignore Mainflux generated pb.go files

Ignore *.pb.go files generated by Mainflux, but don't ignore vendored generated code.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Return an exported ErrNotFound instead of the unexported one

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Update mocks to match the actual behaviour

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Update mocks error message

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Add auth service unavailable error test

Since this error is caused by gRPC server returning codes.Internal,
this behaviour is simulated using specific token. When that token is
passed as an auth header, the mock gRPC client returns aforementioned error.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Use require package for postgres tests

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Remove redundant error checks in tests

Refactor tests.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Rename error flag token

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2018-06-16 02:30:46 +02:00
Aleksandar Novaković 344eed7976 NOISSUE - Add exported metrics visualization for grafana (#326)
* Add exported metrics visualization in grafana

Add graphics for request count and request latency for users, things,
http adapter and ws adapter services.

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Rename grafana export file

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Move metrics configuration to metrics dir

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-06-15 17:08:49 +02:00
Aleksandar Novaković d8357b500c MF-328 - Add message persistence support for MQTT (#327)
* Add redis for message persistence

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add redis to docker composition

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Fix mqtt publish command in documentation

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Update documentation with new environment variables

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-06-15 07:27:23 -07:00
Dušan Borovčanin 993398b8ab NOISSUE - Update Kubernetes setup (#322)
* Add InfluxDB writer services setup to k8s

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Remove commented NginX config

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2018-06-15 13:04:52 +02:00
Aleksandar Novaković 426f59d392 MF-235 - Add support for storing messages in Cassandra (#321)
* Add Cassandra writer implementation

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add cassandra service with version and metrics endpoints

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add test for cassandra writer

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Exclude api.go files from code coverage

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add readme file for cassandra writer

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add docker compose configuration for cassandra writer

Add README file. Add docker compose configuration.

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add gocql as project dependency

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Fix init script for cassandra in docker-compose

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add testifies require subpackage

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-06-08 14:25:55 +02:00
Darko Draskovic 2b393ad50f MF-237 - Add support for storing messages in MongoDB (#307)
* Add mongodb-writer

Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>

* Add official mongodb driver

Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>

* Move Connect to main.go

Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>

* Remove bson.NewDoc and write msg directly in db

Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>

* Add MongoDB writer tests

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Update README.md

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Add mongodb services compose to addons dir

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Update docs

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Update docs and tests

Refactor code.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Expose MetricsMiddleware to align writers with other services

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Add logging middleware

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Update load tests version

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2018-06-01 15:50:23 +02:00
Dušan Borovčanin 9d7f4544c7 MF-296 - Create docker-compose with InfluxDB and Grafana (#306)
* Add docker-compose

Update README.md accordingly.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Move writer compose files to root docker dir

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Remove Point from InfluxDB writer config

Update docs.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2018-06-01 11:20:44 +02:00
Aleksandar Novaković 781d358f38 Add app prefix to dashflux (#320)
Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-05-31 17:24:23 +02:00
Dušan Borovčanin 7b6030d8ad NOISSUE - Rename path veriables in InfluxDB wirter (#315)
* Rename path variables

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Update README.md

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Fix README.md deployment env variables

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Rename InfluxDB point environment variable

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2018-05-31 12:28:00 +02:00
Aleksandar Novaković 89e69d132a Fix MQTT client id bug (#319)
Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-05-30 13:48:40 +02:00
Aleksandar Novaković 7590578745 Change clients to things in documentation (#318)
Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-05-29 16:00:18 +02:00
Aleksandar Novaković 97c2d9c30a NOISSUE - Update dashflux port on kubernetes configuration (#317)
* Update dashflux port on kubernetes configuration

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Remove target port from dashflux config

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-05-29 10:47:27 +02:00
Aleksandar Novaković c38a032fa5 Add version endpoint to nginx configuration (#316)
Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-05-28 19:20:17 +02:00
Aleksandar Novaković 1d75268ffa NOISSUE - Fix channel closing bug in WebSocket adapter (#309)
* Remove unnecessary error checks in ws adapter

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Fix WebSocket adapter channel closing bug

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-05-28 12:47:20 +02:00
Aleksandar Novaković ef3627f4ee NOISSUE - Add test suite for WebSocket adapter (#299)
* Add load test for WebSocket adapter

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add new test suite to README file

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-05-25 11:53:45 +02:00
Dušan Borovčanin 808ac50792 MF-282 - Rename clients to things in Dashflux (#305)
* Rename services, stores, environments and models

Rename services, stores and models to match naming change from `clients` to `things`.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Replace all occurrences of clients with things

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Update docker-compose and nginx.conf

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Rename `clients service` to `things service`

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Rename function and veriable names

Remove other occurences of `clients` word/prefix/sufix and replace it with `things`.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Fix error sending id

Id field must not be sent in POST request in order to create a new thing.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Disable thing type edit

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Export location header

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Update docker config to use port 3000

Update docker-compose.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Replace id check with bool variable

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Rename dialogs

Fix bug when creating channel with no connected things.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2018-05-24 15:26:03 +02:00
Aleksandar Novaković 4c8aeb395c Fix WebSocket mock (#300)
Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-05-23 23:33:15 +02:00
Aleksandar Novaković 64e71edf95 NOISSUE - Add mutex to WebSocket service mock (#294) 2018-05-21 23:12:21 +02:00
Dušan Borovčanin c5a40aeffa NOISSUE - Remove redundant error check (#292) 2018-05-21 20:11:04 +02:00
Aleksandar Novaković 3d134d52a6 NOISSUE - Add MQTT to kubernetes nginx (#293)
* Fix nginx configuration for kubernetes

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Add dashflux to nginx configuration

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Update kubernetes documentation

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>

* Update soft links paths to relative

Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
2018-05-21 18:18:13 +02:00
Dušan Borovčanin f0cbc47ee6 MF-236 - Add support for storing messages in InfluxDB (#283) 2018-05-21 16:28:52 +02:00
Dejan Mijić e0e2b2aad0 MF-269 - Replace UUID with BIGSERIAL as primary key (#291) 2018-05-21 12:51:46 +02:00
Aleksandar Novaković bbf2d5560c MF-165 - Add gRPC authorization calls to MQTT adapter (#285) 2018-05-20 09:29:19 +02:00
Dušan Borovčanin 69bfb8668e NOISSUE - Fix potential race in gRPC tests (#290) 2018-05-18 13:27:21 +02:00
Aleksandar Novaković 7043dea81a NOISSUE - Add Identify gRPC method (#288) 2018-05-17 20:17:02 +02:00
Govind KP e04d0aeaff NOISSUE - Drop $PWD from docker-compose (#286) 2018-05-17 14:38:16 +02:00
Dejan Mijić 9c6904d9b3 NOISSUE - Update load tests (#287) 2018-05-17 14:21:08 +02:00
Dejan Mijić 38a107919a MF-268 - Replace JWTs with UUIDs as thing's access keys (#284) 2018-05-16 14:28:41 +02:00
Dejan Mijić 48484210c2 NOISSUE - Rename clients to things (#281) 2018-05-15 17:13:09 +02:00
Aleksandar Novaković ceb630c782 NOISSUE - Emit non-SenML messages (#279) 2018-05-14 22:15:12 +02:00
Dušan Borovčanin 570ebc1c72 NOISSUE - Sync docker compose service ports with k8s settings (#278) 2018-05-14 17:21:06 +02:00
Dušan Borovčanin 50e14f0c65 NOISSUE - Add CoAP adapter version endpoint (#277) 2018-05-14 13:21:49 +02:00
Dušan Borovčanin d2bce84c06 NOISSUE - Update Docker compose (#274) 2018-05-14 13:11:29 +02:00
Aleksandar Novaković 89aa9603ec NOISSUE - Replace manager with users and clients services (#276) 2018-05-14 12:18:01 +02:00
Aleksandar Novaković 2ae581368f NOISSUE - Add WebSocket and CoAP services to kubernetes config (#275) 2018-05-14 12:13:04 +02:00
Aleksandar Novaković 99a3ec5d2d NOISSUE - Fix kubernetes configuration (#273) 2018-05-11 16:41:25 +02:00
Dušan Borovčanin 89a0fa3e9c NOISSUE - Handle authorization errors other than unauthorize (#264) 2018-05-11 16:37:32 +02:00
Dejan Mijić 1bc4dc9575 NOISSUE - Add MQTT build steps into Makefile (#267) 2018-05-11 01:13:33 +02:00
Dejan Mijić bca3d0774f MF-201 - Replace ORM with SQL (#265) 2018-05-11 01:00:10 +02:00
Aleksandar Novaković 816c172823 MF-164 - Split manager service (#266) 2018-05-10 23:53:25 +02:00
Dušan Borovčanin 6a361209c8 NOISSUE - Automate Dashflux container deployment (#261) 2018-05-10 10:39:48 +02:00
Dušan Borovčanin 27e1be23f5 NOISSUE - Integrate MQTT adapter to monorepo (#260) 2018-05-09 14:22:03 +02:00
Dušan Borovčanin c9bf245010 NOISSUE - Update CoAP docs (#257) 2018-05-09 12:56:20 +02:00
Dušan Borovčanin ff30957614 MF-244 - Integrate Dashflux (#258) 2018-05-09 12:32:49 +02:00
Dušan Borovčanin db6165aa6b MF-168 - Refactor CoAP adapter (#186) 2018-05-08 16:00:25 +02:00
Aleksandar Novaković c088e664c3 NOISSUE - Fix run and compile commands in README files (#249) 2018-05-02 09:41:21 +02:00
Dejan Mijić d499068e43 Update protobuf to 1.1.0 (#251) 2018-05-02 08:49:39 +02:00
Dušan Borovčanin 38d4c3fcea MF-136 - Setup staging and test environments (#226) 2018-04-30 13:32:38 +02:00
Aleksandar Novaković aea7db14b7 NOISSUE - Raise code coverage in ws adapter (#242)
* Fix failed subscription handling in ws adapter

Fix unsubscribing bug in ws adapter.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add subscription fail and publish fail test cases

Update mock implementation to receive publish error in order to
support these test cases.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Update mainflux version to 0.2.3

Update project version and load tests version to 0.2.3.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Update version endpoint response format

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
2018-04-24 13:56:13 +02:00
Aleksandar Novaković 58f3c735a0 NOISSUE - Fix Content-Type in examples (#243)
* Update content-type header in load tests

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Remove charset from content type header in documentation

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
2018-04-24 13:42:36 +02:00
Dušan Borovčanin 789963447a Add service name to version response (#241)
Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>
2018-04-24 13:39:15 +02:00
Dušan Borovčanin 2dc7f3eea1 NOISSUE - Raise endpoint test coverage (#240)
Ramove unnecessary checks from decodeList.
Cover some edge cases and fix decodeList to always return same error.

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>
2018-04-23 15:17:30 +02:00
Aleksandar Novaković 62297fedec MF-134 - Evaluate system's performance (#225)
* Add initial load tests

Add initial load tests for client creation and message publishing.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Make load tests executable as stand-alone application

Move code from test to main. Make code runnable with sbt run command.
Remove unnecessary config files.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add native packager support

Add native packager plugin. Update sbt config to support native
packager. Update paths in Engine.scala.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Move files back to test folder and remove native packager support

Remove nativa packager plugin. Add gatling plugin and move files to
test folder where they belong. Read vars from JAVA_OPTS instead of
environment variables.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add readme file for load tests

Add readme file for load tests with usage instructions.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add number of requests per second as test parameter

Add number of requests per second as parameter. Update read me according
to this addition.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add load test section in docs

Create documentation skeleton for load tests.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Reformat logger config file

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Update documentation skeleton

Move results section to scenarios. Move test environment to intro.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Align test version with mainflux version

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Update mainflux version to 0.2.2

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
2018-04-23 15:13:43 +02:00
Dejan Mijić f449f8b9c8 NOISSUE - Fix Content-Type header check (#238)
* Remove charset from required content type

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Bump version to 0.2.1

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Move constant to transport.go

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-04-22 16:48:06 +02:00
Dejan Mijić 544ba57850 NOISSUE - Ignore logging & metrics for code coverage (#233)
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-04-19 13:40:22 +02:00
Dejan Mijić e858e86ed9 NOISSUE - Fix paging (#232)
* Fix docs errors

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Fix edge case for limit check

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Explain limit value

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-04-18 23:06:11 +02:00
Dušan Borovčanin 84679ed42a MF-200 - Enable pagination of result sets (#227)
* Add pagination to clients and channels endpoints

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Refactor code

Change method signature and rename Bulk methods back to All.

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Rename transport_test.go to endpoint_test.go

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Fix manager tests to support pagination

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Add default offset and limit support

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Update docs

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Update tests to support pagination

- Move maxLimitSize checking to request validation.
- Add tests to support pagination.

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Fix handling query params for pagination

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Fix empty result set

Return empty results if invalid offset and limit is passed to channel and client repository.
Update tests accordingly.

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Update manager API docs

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Fix response to invalid limit query param

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Remove offset and limmit checks in repository methods

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>
2018-04-18 22:36:24 +02:00
Aleksandar Novaković b0610f034c Fix http publish example in docs (#231)
Fix http publish example in docs. Fix docker-compose example in docs
and README.md.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
2018-04-18 16:49:10 +02:00
Dejan Mijić cb9c0ee32a Specify targets for releasing docker containers (#230)
New targets will allow Makefile to be used as primary option for
releasing docker containers, both as 'latest' and versioned.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-04-18 14:13:38 +02:00
Aleksandar Novaković 3a5f4395e4 MF-171 - Extract websocket adapter as separate service (#188)
* Add websocket adapter

Add websocket adapter with basic logging and metrics middleware.
Add publish and subscribe to NATS subjects using websocket.
Add websocket handshake authorization over mainflux manager.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add test for websocket publish

Add test for websocket adapter's publish method. Add dependecy
injected logger to adapter. Remove unnecessary manager client
dependency from adapter.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add websocket library in dependencies

Add gorilla/websocket dependency in dep toml and lock file.
Add dependency in vendor dir.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add direct websocket connection

Add direct websocket connection. While messages are still beeing
published over NATS, they are not received over src.ws subject
in WebSocket adapter. Instead messages are sent directly over
websocket connection.

Add swagger file for WebSocket handshake endpoint. Update ReadMe
to reference new swagger file.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Refactore websocket adapter code

Extract listen part from handshake. Update WebSocket adapter code.
Fix subscribe to NATS subject, so that it is independent from other
adapters. Remove message base64 encoding from response..

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Remove connection management from websocket adapter

Align notion of channel with NATS topic. Remove connection
management from adapter logic. Add log messages to adapter's
transport layer.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Update NATS subjects and add subscriber interface

Update NATS subject name to channel.<channel_id>. Add and implement
subscriber interface. Implement subscriber interface in adapter.
Update readme to use new make <service_name> command. Refactor code.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add basic tests for broadcast and subscribe

Improve mock implementation of NATS pubsub. Add multiple basic test
cases for broadcast and subscribe methods. Add logging for subscribe.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add listen method test

Add listen method test and refactor existing tests. Refactor listen
method in adapter.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Move broadcast method to message broker interface

Refactor broadcast method to receive send message callback and message
that needs to be sent. Update tests accordingly.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Update pubsub API

Remove listen method from public API. Move listen call to subscribe
implementation. Update domain pubsub API in project root.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add connection error handlers to adapter API

Update publish and subscribe API to receive connection error handler.
Update tests accordingly. Handle NATS connection error.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Update logs

Replace go-kit logger with custom mainflux logger. Update log messages
where needed..

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Refactor web socket adapter

Remove MessagePubSub interface. Remove unnecessary callbacks. Add
channels to web socket adapter implementation.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add API layer tests

Update existing tests and add API layer tests.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Update docs with web socket related data

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Refactor web socket adapter

Update subscription struct, and refactor listen and broadcast methods.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add version and metrics endpoint to ws adapter

Update version to 0.2.0.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Fix race condition bug in ws adapter test

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Rename listen to broadcast and broadcast to listen

Switch names between listen and broadcast methods. Move channel
structure to service.go.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
2018-04-18 13:09:01 +02:00
Aleksandar Novaković 36a00f3464 Update project documentation with example requests and responses (#220)
Update documentation with example requests and responses in accordance
with new API changes. Add detailed flow explanation. Update readme with
valid snippet.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
2018-04-11 14:30:37 +02:00
Aleksandar Novaković 703d0543af Add HTTP adapter API test (#224)
Add HTTP adapter API tests. Fix Manager API tests.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
2018-04-11 14:29:04 +02:00
Aleksandar Novaković fb3619645d Add channel Id validation (#223)
Add channel id validation and remove unnecessary error. Update
swagger doc accordingly.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
2018-04-11 13:48:09 +02:00
Dejan Mijić 46a9cc086d Remove unhandled missing key error (#222)
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-04-11 11:44:15 +02:00
Dejan Mijić 367d3edbef Set JWT provider secret (#221)
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-04-10 17:30:13 +02:00
Dejan Mijić d5b913d432 MF-199 - Create documentation skeleton (#218)
* Copy basic docs contents to the main repo

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Include licensing and contributing info to docs

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Create documentation skeleton

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-04-08 23:03:12 +02:00
Aleksandar Novaković 2dace5564f MF-170 - Add manager API unit tests (#211)
* Fix connection request validation and EOF error handling

Fix validation of connection and client id in connection request.
Fix EOF error handling by returning HTTP status Bad Request.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add manager API tests and update swagger

Implement unit tests for every manager API endpoint. Update client
and connection mock implementations by switching to UUIDs. Update
swagger file with correct status codes.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Add content type check and update documentation

Add content type check in implementation and update documentation
accordingly. Refactor tests and add empty content type test cases.
Add code coverage badge to readme.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
2018-04-08 22:57:56 +02:00
Aleksandar Novaković 88b30626dd MF-174 - Add logger interface and go-kit logger implementation (#212)
* Add logger interface and go-kit logger implementation

Add wrapper logger interface and wrap go-kit logger in it. Add
tests for info, warn, error and log methods. Add log filtering by
level.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Refactor logger and replace go-kit logger with wrapper

Replace go-kit logger from services with logger wrapper. Refactor
code in logger wrapper. Remove unnecessary subpackage, methods and
log levels.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
2018-04-04 10:15:23 +02:00
Drasko DRASKOVIC 301d855015 Add CA cert (#215)
Signed-off-by: drasko <drasko.draskovic@gmail.com>
2018-04-04 02:29:29 +02:00
Dušan Borovčanin 7a193829f4 MF-139 - Expose metrics from all services (#213)
* Expose metrics from normalizer service

Add service interface in order to expose method to be monitored.

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Refactor normalizer

Add metrics to normalizer service without exporting its internals.

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>
2018-04-03 20:25:49 +02:00
Dejan Mijić 523716b090 Rename NATS subjects for HTTP & normalizer (#207)
* Change NATS subject name

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Change normalizer subscription name

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-03-22 23:59:15 +01:00
Dejan Mijić 36ca9015ff Handle wrong type unmarshalling (#206)
* Update the contributing guide

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Handle wrong type unmarshalling

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-03-22 23:53:43 +01:00
Drasko DRASKOVIC a6dfc26959 Simplify Makefile (#205)
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2018-03-22 13:10:11 +01:00
Dušan Borovčanin 924f6f120a Fix blinker tests (#193)
* Fix blinker tests

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>

* Add protobuf generated files to .gitignore

Signed-off-by: Dušan Borovčanin <borovcanindusan1@gmail.com>
2018-03-20 09:14:54 +01:00
Drasko DRASKOVIC 2c1c94af9b Fix #195 (#196)
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2018-03-20 00:09:44 +01:00
Dejan Mijić f5fbd6f22a Add protobuf (#192)
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2018-03-19 10:14:43 +01:00
Aleksandar Novaković 55bdc029c3 Add service startup message (#190)
* Add service startup message

Add startup message to manager, http, coap and normalizer services.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>

* Remove startup message from CoAP adapter

Remove startup message from CoAP adapter. Remove overhead startup
message variable.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
2018-03-18 13:54:54 +01:00
Dejan Mijić e42d422410 Fix golint warnings (#189)
* Fix goling warnings

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Bump version to 0.1.2

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-03-16 14:06:12 +01:00
Nikola Marčetić bf5d1544b6 Fixed docker composition (#187)
Signed-off-by: nmarcetic <n.marcetic86@gmail.com>
2018-03-16 13:52:51 +01:00
Max Peng 8876acbfec Fix docker compose failing start issue (#185)
* Fix docker compose failing start issue

* Delete unused code

* Fix nginx config issue
2018-03-16 09:59:13 +01:00
anovakovic01 250505700b Fix normalizer output queue (#184)
Fix normalizer output queue by changing subject to normalized.
Version updated from 0.1.0 to 0.1.1.

Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
2018-03-15 14:23:20 +01:00
Drasko DRASKOVIC 5cb169f7f8 Add Makefile and ARM support (#178)
* Add Makefile and ARM support

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>

* Add Docker build

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2018-03-13 09:26:59 +01:00
Dejan Mijić ccd8965d6f Use PostgreSQL as primary persistence solution (#175)
* Use normalizer as stream source

Renamed 'writer' service to 'normalizer' and dropped Cassandra
facilities from it. Extracted the common dependencies to 'mainflux'
package for easier sharing. Fixed the API docs and unified environment
variables.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Use docker build arguments to specify build

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Remove cassandra libraries

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Update go-kit version to 0.6.0

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Fix manager configuration

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Refactor docker-compose

Merged individual compose files and dropped external links. Remove CoAP
container since it is not referenced from NginX config at the moment.
Update port mapping in compose and nginx.conf. Dropped bin scripts.
Updated service documentation.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Drop content-type check

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Implement users data access layer in PostgreSQL

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Bump version to 0.1.0

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Use go-kit logger everywhere (except CoAP)

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Improve factory methods naming

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Implement clients data access layer on PostgreSQL

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Make tests stateless

All tests are refactored to use map-based table-driven tests. No
cross-tests dependencies is present anymore.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Remove gitignore

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Fix nginx proxying

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Mark client-user FK explicit

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Update API documentation

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Update channel model

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Add channel PostgreSQL repository tests

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Implement PostgreSQL channels DAO

Replaced update queries with raw SQL. Explicitly defined M2M table due
to difficulties of ensuring the referential integrity through GORM.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Expose connection endpoints

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Fix swagger docs and remove DB logging

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Fix nested query remarks

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Add unique indices

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-03-11 18:06:01 +01:00
Drasko DRASKOVIC b23ecb64e5 Merge pull request #167 from mainflux/coap
Update CoAP README
2018-02-17 16:15:26 +01:00
Drasko DRASKOVIC 03b020ae87 Update CoAP README
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2018-02-17 16:14:28 +01:00
Drasko DRASKOVIC 255d1c03b1 Merge pull request #162 from chombium/mainflux-161
replaced glide with dep dependency manager
2018-02-14 22:23:58 +01:00
Jovan Kostovski 7fe8100d6b replaced glide with dep dependency manager
Signed-off-by: Jovan Kostovski <chombium@gmail.com>
2018-02-14 18:28:42 +01:00
Drasko DRASKOVIC 6d9c92596c Merge pull request #158 from bblagojevic94/mainflux-157
Export normalize method from writer service inside cassandra package
2018-02-10 17:50:18 +01:00
Bojan Blagojevic 3ac88b05a8 Export normalize method from writer service inside cassandra package
Signed-off-by: Bojan Blagojevic <datiglavaradi@gmail.com>
2018-02-10 15:45:53 +01:00
Drasko DRASKOVIC f84958834e Merge pull request #148 from chombium/mainflux-147
Various bin script fixes
2018-02-06 10:44:02 +01:00
Jovan Kostovski 7723b92ba7 added the CoAP server
Signed-off-by: Jovan Kostovski <chombium@gmail.com>

Signed-off-by: Jovan Kostovski <chombium@gmail.com>
2018-02-06 02:14:22 +01:00
Jovan Kostovski 3072d054ee added back the coap service
Signed-off-by: Jovan Kostovski <chombium@gmail.com>

Signed-off-by: Jovan Kostovski <chombium@gmail.com>
2018-02-06 02:13:22 +01:00
Jovan Kostovski b4a51ae0a2 reverted the removal of the coap service
Signed-off-by: Jovan Kostovski <chombium@gmail.com>
2018-02-06 01:48:38 +01:00
Jovan Kostovski f277074d42 added desc. of the Cassandra create keyspaces cmd
Signed-off-by: Jovan Kostovski <chombium@gmail.com>
2018-02-06 01:48:38 +01:00
Jovan Kostovski 2f1b999727 removed the cleaning
Signed-off-by: Jovan Kostovski <chombium@gmail.com>
2018-02-06 01:48:38 +01:00
Jovan Kostovski ce86fbbe90 added desc. how to create the Cassandra keyspaces
Signed-off-by: Jovan Kostovski <chombium@gmail.com>

In the README.md it is written that the install script will guide the user how to setup the infrastructure
for running Mainflux, but there was a missing description on which Cassandra keyspacess are needed and how to create them.
2018-02-06 01:48:38 +01:00
Jovan Kostovski 615ba9267d clean up before/after compile and installation
Signed-off-by: Jovan Kostovski <chombium@gmail.com>
2018-02-06 01:48:38 +01:00
Jovan Kostovski 10113bd354 fixed the link to the contribution guide
Signed-off-by: Jovan Kostovski <chombium@gmail.com>
2018-02-06 01:48:38 +01:00
Jovan Kostovski c691ee06f0 show help and exit if no argument is provided
Signed-off-by: Jovan Kostovski <chombium@gmail.com>

bugfix for the case where the script was started without an argument.
The help was printed, but the _mainflux_docker was called as well, which
was causing the following error:
./mainflux-docker.sh: line 163: $1: unbound variable
2018-02-06 01:48:38 +01:00
Jovan Kostovski 23a3a5f194 added a .gitignore file
Signed-off-by: Jovan Kostovski <chombium@gmail.com>

Added a .gitignore file with the build folder in it, so that
if someone bulds Mainflux localy the build folder does not end
up in the repo.
2018-02-06 01:48:38 +01:00
Jovan Kostovski 6f202a9f83 #105 removed the Coap service from the build
Signed-off-by: Jovan Kostovski <chombium@gmail.com>
2018-02-06 01:48:38 +01:00
Jovan Kostovski 74f890128d fixed a typo
Signed-off-by: Jovan Kostovski <chombium@gmail.com>
2018-02-06 01:48:38 +01:00
Nikola Marčetić 6099da59e6 Merge pull request #154 from mainflux/docker-clean
Add `clean` function to docker-compose script
2018-02-05 10:47:31 +01:00
Drasko DRASKOVIC 0255a4cd61 Add clean function to docker-compose script
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2018-02-05 02:33:51 +01:00
Drasko DRASKOVIC 411cbf575a Merge pull request #146 from mainflux/issue-145
Fix 403 errors handling
2018-01-26 20:56:05 +01:00
Dejan Mijic 5d715aa984 Fix 403 errors handling
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-01-26 20:50:31 +01:00
Drasko DRASKOVIC 30f7dda491 Merge pull request #144 from kelvinji2009/master
fix external_link dependency for http adaptor service
2018-01-18 17:45:27 +01:00
kelvinji ff5d77722c fix external_link dependency for http adaptor service
Signed-off-by: kelvinji <kelvinji2009@gmail.com>
2018-01-14 18:40:20 +08:00
Dejan Mijic b6eac477b4 Fix code linting
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-01-13 18:25:58 +01:00
Dejan Mijić 7cc03be424 Close response body properly (#143) 2018-01-13 18:15:41 +01:00
Drasko DRASKOVIC 4f467dcdde Add HTTP auth check (#128)
* Add HTTP auth check

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>

* Add HTTP auth via Manager Client

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>

* Change the way manager client is injected

Instead of relying on modifying service structure, manager client is
injected through handler factory method, and store as a variable in that
module.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>

* Update dockerignore

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2018-01-07 14:42:38 +01:00
Drasko DRASKOVIC d413508b25 Fix #116: remove base values from C* tables (#140)
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2018-01-06 22:36:44 +01:00
Drasko DRASKOVIC 8036c74207 Merge pull request #138 from mainflux/mainflux-137
Remove redundant endpoints from manager
2018-01-05 09:11:10 +01:00
Dejan Mijic 3b57ebf532 Fix manager client implementation
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-12-29 11:10:31 +01:00
Dejan Mijic 15e9745517 Fix middleware method signature
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-12-29 10:56:59 +01:00
Dejan Mijic f30c9725aa Move contributing guide to .github folder
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-12-29 10:49:03 +01:00
Dejan Mijic 4c97094427 Update the API handlers
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-12-29 10:47:43 +01:00
Dejan Mijic 253a7afcf7 Implement access check based on the API spec
Instead of returning boolean value whether or not the access is granted,
an identifier bound to the provided access key is returned.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-12-29 10:40:44 +01:00
Dejan Mijic 52ab91c275 Update the API documentation of manager service
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-12-29 10:22:37 +01:00
oldmikeyang 5899177f57 change the order of message table and remove the time to live (#132) 2017-12-23 22:03:04 +01:00
Drasko DRASKOVIC 3e11147ab5 Merge pull request #131 from bzub/130-docker-script-fix
Search for "mainflux-nginx" instead of "nginx"
2017-12-18 14:49:53 +01:00
bzub c57c9f0a3c Search for "mainflux-nginx" instead of "nginx"
Fixes #130 where the script sees non mainflux-nginx container(s) and
assumes mainflux-nginx is already pulled/created.

Signed-off-by: bzub <bzubrod@gmail.com>
2017-12-16 17:02:10 -06:00
Drasko DRASKOVIC b6b997237e Merge pull request #129 from mainflux/feature-manager-client
Authentication client
2017-12-12 11:57:16 +01:00
Dejan Mijic c11cf5820c Add circuit breaker toward the manager service
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-12-12 11:20:57 +01:00
Dejan Mijic 28bff54ea6 Add authentication client
Implemented a HTTP client toward the manager service. The client is
intended to be used as a library that will generate requests to the
'/identity' endpoint of a manager service instance selected through
provided URL.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-12-11 15:22:42 +01:00
Dejan Mijic 00117519c4 Update HTTP adapter's configuration docs
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-12-11 14:18:42 +01:00
Drasko DRASKOVIC 238394e0a7 Merge pull request #125 from manuIO/master
Fix README
2017-11-23 18:03:56 +01:00
Manuel IMPERIALE 7eb12015c0 Fix README
Signed-off-by: Manuel IMPERIALE <manuel.imperiale@gmail.com>
2017-11-22 12:51:32 +01:00
Dejan Mijić 46a7341eba Merge pull request #121 from mainflux/revert-120-mainflux-83
Revert "Consul integration"
2017-10-16 11:28:12 +02:00
Dejan Mijić b651537ba9 Revert "Consul integration" 2017-10-16 11:27:11 +02:00
Drasko DRASKOVIC b9e1c0da81 Merge pull request #120 from mainflux/mainflux-83
Consul integration
2017-10-15 20:05:03 +02:00
Dejan Mijic 3466776152 Register CoAP adapter to Consul
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-10-15 18:19:23 +02:00
Dejan Mijic 3f9f56d0d4 Register http adapter to consul
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-10-15 18:08:01 +02:00
Dejan Mijic 2e5316e3fd Register writer to consul
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-10-15 18:07:52 +02:00
Dejan Mijic 9c429d142d Register manager to Consul
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-10-15 15:25:55 +02:00
Dejan Mijic 11eed2aa2c Format the startup logs
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-10-15 14:05:05 +02:00
Dejan Mijić 8019cd731e Merge pull request #101 from mainflux/coap
Add coap support
2017-10-08 10:37:01 +02:00
Drasko DRASKOVIC 923a5aefae Remove println
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-10-08 03:04:49 +02:00
Dejan Mijić 89015b0292 Merge pull request #112 from mainflux/readme
Add features
2017-10-07 22:39:05 +02:00
Drasko DRASKOVIC c7054a07f2 Remove comments, clean code
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-10-07 19:13:20 +02:00
Dejan Mijic c2d6cc511c Ensure codestyle adherence
Simplified code where possible. Fixed golint suggestions regarding the
missing godoc comments and unnecessary initialized variables.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-10-07 19:13:20 +02:00
Drasko DRASKOVIC 8d4543873f Add features
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-10-07 18:44:12 +02:00
Drasko DRASKOVIC 288f437b4d Merge pull request #114 from mainflux/godoc-fixes
Ensure codestyle adherence
2017-10-06 23:12:42 +02:00
Dejan Mijic 86f563ee10 Ensure codestyle adherence
Simplified code where possible. Fixed golint suggestions regarding the
missing godoc comments and unnecessary initialized variables.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-10-06 23:03:24 +02:00
Drasko DRASKOVIC dd874008b2 Initialize properly NATS in CoAP adapter
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-10-01 18:33:55 +02:00
Drasko DRASKOVIC 9cec19896e Simplify functions
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-10-01 17:01:50 +02:00
Drasko DRASKOVIC a79a9012e4 Add coap support
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-10-01 16:38:32 +02:00
Dejan Mijic 7c48c1cd78 Remove unused service references
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-10-01 02:18:03 +02:00
Drasko DRASKOVIC 13e9b440fe Merge pull request #111 from mainflux/mainflux-106
Improves API request validation
2017-10-01 01:48:22 +02:00
Dejan Mijic 481b5b230d Validate incoming requests
All validation has been moved to the API resources layer, i.e. the
domain objects provide validation method, but the service itself assumes
no corrupted values are passed to it.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-10-01 01:12:06 +02:00
Dejan Mijic da3089cf87 Ensure service interface is properly implemented
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-10-01 01:12:06 +02:00
Drasko DRASKOVIC eb99ef97e3 Merge pull request #110 from mainflux/compose-fix
Fixed compose file, added env var for mqtt-adapter
2017-09-30 22:38:45 +02:00
nmarcetic 1c664a002e Fixed compose file, added env var for mqtt-adapter
Signed-off-by: nmarcetic <n.marcetic86@gmail.com>
2017-09-30 19:44:11 +02:00
Dejan Mijić 23111608c8 Merge pull request #109 from mainflux/raw
Change writer message format - accept raw messages
2017-09-29 16:35:26 +02:00
Drasko DRASKOVIC 199a44b0a0 Change writer message format - accept raw messages
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-29 16:18:41 +02:00
Drasko DRASKOVIC ea3fb4b781 Merge pull request #107 from mainflux/launch
Fix mainflux-launch.sh script
2017-09-27 20:02:55 +02:00
Drasko DRASKOVIC 778685fca0 Fix mainflux-launch.sh script
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-27 19:03:32 +02:00
Dejan Mijić df61bdccad Merge pull request #99 from mainflux/identity
Add /identity
2017-09-27 15:07:22 +02:00
Drasko DRASKOVIC 82aa89397e Add /identity
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-27 14:31:57 +02:00
Drasko DRASKOVIC 0f2020aeee Merge pull request #105 from mainflux/install
Fix installation and remove coap from Makefile
2017-09-26 18:17:04 +02:00
Drasko DRASKOVIC 499b44fae2 Fix installation and remove coap from Makefile
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-26 16:58:36 +02:00
Dejan Mijić 7721b61fa2 Merge pull request #104 from mainflux/install
Add Makefile and fix installation from sources
2017-09-26 16:51:14 +02:00
Drasko DRASKOVIC f2aa007fab Add Makefile and fix installation from sources
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-26 16:50:14 +02:00
nmarcetic 3ecc79375d Fixed docker-compose.nginx, wrong path maping
Signed-off-by: nmarcetic <n.marcetic86@gmail.com>
2017-09-26 12:57:58 +02:00
Dejan Mijic f8c41caeb3 Fix documentation links
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-25 13:50:23 +02:00
Nikola Marčetić 0c92be51c8 Merge pull request #100 from mainflux/mainflux-98
Fixes the composition image names
2017-09-25 13:18:40 +02:00
Dejan Mijic 6347d6cbf3 Reorganize utility scripts
Moved docker composition management into 'bin' directory. Removed unused
monitoring composition and fixed versions of NATS, Cassandra and NGINX.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-25 12:29:48 +02:00
Dejan Mijić 0c629cce47 Merge pull request #95 from mainflux/normalizer
Add normalizer
2017-09-24 18:50:02 +02:00
Drasko DRASKOVIC 2554adcc1e Use interface
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-24 17:19:42 +02:00
Drasko DRASKOVIC 3494c7a5e1 Add normalizer
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-24 15:33:58 +02:00
Drasko DRASKOVIC 9afaea24c2 Merge pull request #97 from mainflux/mainflux-96
Fixes inconsisent label cardinality error
2017-09-24 13:41:49 +02:00
Dejan Mijic 7ea0d444bf Fix inconsisent label cardinality error
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-24 07:39:31 +02:00
Dejan Mijic 6dc67f66da Replace travis with semaphore
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-23 18:20:53 +02:00
Drasko DRASKOVIC c60b124ad2 Merge pull request #94 from mainflux/travis-ci-integration
Travis ci integration
2017-09-23 17:13:53 +02:00
Dejan Mijic 6f97c4588e Add CI script
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-23 17:10:31 +02:00
Dejan Mijic 75a8cdfe3f Unify service versioning
Services are versioned through top-level package. The package itself
contains an HTTP header that will be bound to the '/version' endpoint of
each of the available services.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-23 15:52:39 +02:00
Drasko DRASKOVIC bdf5001072 Merge pull request #93 from mainflux/feature-monorepo-migration
Monorepo migration
2017-09-23 14:18:30 +02:00
Dejan Mijic 40d4dd5f2d Fix contributing guide
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-23 13:44:25 +02:00
Dejan Mijic 4132a5c017 Update readme files for monorepo
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-23 02:27:49 +02:00
Dejan Mijic 26a2ea1ce1 Integrate http adapter service
Moved main method to top-level 'cmd' directory. Extracted the dockerfile
to the root as well.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-23 01:57:14 +02:00
Dejan Mijic bcc0bfdc3d Integrate message writer service
Moved main method to top-level cmd directory. Extracted its dockerfile
as well.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-23 01:22:21 +02:00
Dejan Mijic c966a7802d Integrate manager service
Setup top-level glide dependencies file. Migrated all of the manager
service code into this repository. Fixed docker build procedure.
Extracted executable to the top-level.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-23 01:03:27 +02:00
Dejan Mijic 311fe29dc4 Remove lora-related artifacts
Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-22 23:17:04 +02:00
nmarcetic 623f9b1951 Added db, persistence data from docker shared volume
Signed-off-by: nmarcetic <n.marcetic86@gmail.com>
2017-09-22 12:19:13 +02:00
Drasko DRASKOVIC e47e5ffc22 Merge pull request #92 from mainflux/docker-cassandra-persistency
Added volume to docker-compose-cassandra in order to support data per…
2017-09-22 12:16:09 +02:00
nmarcetic 3d7c341c5e Added volume to docker-compose-cassandra in order to support data persistency
Signed-off-by: nmarcetic <n.marcetic86@gmail.com>
2017-09-22 12:11:16 +02:00
Drasko DRASKOVIC 6fb3c3f594 Merge pull request #89 from mainflux/nginx-reverse-proxy
Added Nginx as revrse proxy, Traefik removed. CORS enabled
2017-09-21 23:49:38 +02:00
nmarcetic 79a6fc158b Added Nginx as revrse proxy, Traefik removed. CORS enabled
Signed-off-by: nmarcetic <n.marcetic86@gmail.com>
2017-09-21 18:50:00 +02:00
Drasko DRASKOVIC cc3283c32b Add NGINX Docker support
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-19 00:28:31 +02:00
Drasko DRASKOVIC fe3ecd5c78 Update README.md 2017-09-19 00:02:46 +02:00
Drasko DRASKOVIC 763f9aa0b7 Update README.md 2017-09-18 21:44:13 +02:00
Drasko DRASKOVIC 0e5f97a8a8 Update README.md 2017-09-18 21:41:57 +02:00
Drasko DRASKOVIC 3eeb2ef10e Add info about mainflux_docker.sh
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-18 21:38:06 +02:00
Drasko DRASKOVIC eff9f62b8b Add monitoring composition
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-18 21:28:21 +02:00
Drasko DRASKOVIC 5cebacdd35 Fix Traefik
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-18 16:33:27 +02:00
Drasko DRASKOVIC 0d3934e9a6 Fix manager bridge network
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-18 15:43:42 +02:00
Drasko DRASKOVIC 01bd08d5b8 Add traefik support
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-18 00:52:16 +02:00
Drasko DRASKOVIC 11f28ef754 Poll on Cassandra ready
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-17 17:23:35 +02:00
Drasko DRASKOVIC 717da672ac Add docker-compose helper script
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-17 03:35:06 +02:00
Drasko DRASKOVIC f21c36fcf6 Update CONTRIBUTING.md 2017-09-11 14:06:01 +02:00
Drasko DRASKOVIC b7863f171c Fix dead link 2017-09-11 14:04:40 +02:00
Drasko DRASKOVIC b7c5f14236 Update ISSUE_TEMPLATE.md 2017-09-11 11:55:32 +02:00
Drasko DRASKOVIC 25a8d94e8a Update ISSUE_TEMPLATE.md 2017-09-11 11:54:44 +02:00
Drasko DRASKOVIC d9ef550697 Update README.md 2017-09-11 11:41:43 +02:00
Drasko DRASKOVIC e967cfe5df Update ISSUE_TEMPLATE.md 2017-09-11 11:02:40 +02:00
Drasko DRASKOVIC 478d22a0d6 Update README.md 2017-09-11 10:37:32 +02:00
Drasko DRASKOVIC d1e450c752 Update README.md 2017-09-11 10:15:22 +02:00
Drasko DRASKOVIC 4a9f1b1414 Update README.md 2017-09-11 09:56:30 +02:00
Drasko DRASKOVIC 656add84f1 Remove depricated auth
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-05 01:40:31 +02:00
Drasko DRASKOVIC 90a141ea41 Fix scripts to use new service names
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-05 01:37:28 +02:00
Drasko DRASKOVIC e297ab4607 Change install script to use new repo names
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-05 01:34:25 +02:00
Drasko DRASKOVIC f8ee020c22 Update README.md 2017-09-04 16:40:14 +02:00
Drasko DRASKOVIC 67844820c3 Update README.md 2017-09-03 01:04:31 +02:00
Drasko DRASKOVIC a473d16cd3 Update README.md 2017-09-03 00:16:10 +02:00
Drasko DRASKOVIC 8c2726200f Update README.md 2017-09-02 23:33:58 +02:00
Drasko DRASKOVIC e93c447d0a Update README.md 2017-09-02 23:32:18 +02:00
Drasko DRASKOVIC 79a6683406 Update README.md 2017-09-02 22:29:46 +02:00
Drasko DRASKOVIC bc55890dc0 Update README.md 2017-09-02 22:28:23 +02:00
Drasko DRASKOVIC e44b035343 Move to new services
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-02 22:22:00 +02:00
Drasko DRASKOVIC 04586424b3 Add composition - towards 1.0.0
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-09-02 02:39:37 +02:00
Drasko DRASKOVIC 1ce3f72d87 Update README.md 2017-08-23 23:35:43 +02:00
Drasko DRASKOVIC 367871d268 Update README.md 2017-08-23 23:34:18 +02:00
Drasko DRASKOVIC b8a67898cc Update README.md 2017-07-08 17:04:35 +02:00
Drasko DRASKOVIC db361038af Update README.md 2017-07-08 17:04:01 +02:00
Drasko DRASKOVIC b71de906b3 Update CONTRIBUTING.md 2017-06-05 21:55:07 +02:00
Drasko DRASKOVIC 43f1f11964 Update README.md 2017-06-03 21:22:17 +02:00
Drasko DRASKOVIC 704b523a22 Update README.md 2017-06-03 21:09:26 +02:00
Drasko DRASKOVIC 890785baa1 Add script that stops system services
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-06-03 01:35:42 +02:00
Drasko DRASKOVIC d9cad2b4b3 Add comments
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-06-03 01:29:56 +02:00
Drasko DRASKOVIC c657eedb6c Add script to launch Go binaries
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-06-03 01:20:10 +02:00
Drasko DRASKOVIC 0a825bcce9 Update README.md 2017-06-02 12:01:18 +02:00
Drasko DRASKOVIC 5ac6ddb3e3 Update README.md 2017-06-02 11:35:41 +02:00
Drasko DRASKOVIC 4fa1f7c6a5 Update README.md 2017-05-24 19:25:14 +02:00
Drasko DRASKOVIC 85093c0b4b Update README.md 2017-05-24 14:56:56 +02:00
Drasko DRASKOVIC 80edbada70 Update README.md 2017-05-24 00:42:55 +02:00
Drasko DRASKOVIC f93c6a4249 Correct auth docker-compose
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-05-24 00:37:21 +02:00
Drasko DRASKOVIC 49249f08e2 Update README.md 2017-05-24 00:13:35 +02:00
Drasko DRASKOVIC 33ff1e7529 Update README.md 2017-05-24 00:12:12 +02:00
Drasko DRASKOVIC d9df54046c Update README.md 2017-05-24 00:10:56 +02:00
Drasko DRASKOVIC e73132e748 Switch to new architecture
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-05-24 00:02:53 +02:00
Darko Draskovic 23c8f1f53f Add mainflux-manager docker container
Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2017-05-23 20:01:10 +02:00
Drasko DRASKOVIC 811b5b787b Add coap server
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-05-01 02:36:25 +02:00
Drasko DRASKOVIC 4332a5ea4b Fix docker-compose
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-04-24 00:46:36 +02:00
Drasko DRASKOVIC 6e3b8407d9 Add support for new architecture
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-04-23 19:57:59 +02:00
Drasko DRASKOVIC 2f96df1c35 Use dockers from loraserver-docker
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-03-28 01:16:33 +02:00
Drasko DRASKOVIC 90cdfb300e Add LoRaWAN Server written in Erlang
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-03-20 01:21:40 +01:00
Drasko DRASKOVIC 318292703a Add port mapping
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-03-19 03:13:48 +01:00
Drasko DRASKOVIC ce40a0a7a5 Update README.md 2017-03-11 01:39:05 +01:00
Drasko DRASKOVIC 9f4acaf7a8 Update README.md 2017-03-01 23:58:00 +01:00
Drasko DRASKOVIC 068d3b6602 Add lora http certs, fix docekr-compose
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-02-11 18:53:30 +01:00
Drasko DRASKOVIC 09c063496b Add dockerize
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-02-10 01:42:43 +01:00
Drasko DRASKOVIC 56286610d9 Switch to version 2 to avoid circular dependencies
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-02-10 00:28:20 +01:00
Drasko DRASKOVIC 669a3b67e5 Add preliminary LoRa Server support
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-02-09 23:26:09 +01:00
Drasko DRASKOVIC 3d4d5291c3 Change links
Core is no longer connected to MQTT server - they
all communicate via NATS.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-02-03 19:30:44 +01:00
Drasko DRASKOVIC b84f268e14 Add GitHub admin files
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-02-01 22:56:06 +01:00
Drasko DRASKOVIC 637eb34178 Merge pull request #76 from darkodraskovic/master
Fix typo
2017-01-18 00:14:42 +01:00
Darko Draskovic e0fbc05c4d Fix typo
Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2017-01-18 00:01:23 +01:00
Drasko DRASKOVIC c64337bf03 Update README.md 2017-01-15 00:57:59 +01:00
Drasko DRASKOVIC ad91c25082 Update README.md 2016-12-30 20:41:40 +01:00
Drasko DRASKOVIC e775c2a94b Kill whitespaces
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-12-30 18:18:09 +01:00
Drasko DRASKOVIC cfa40c70fb Fix comments
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-12-30 18:15:45 +01:00
Drasko DRASKOVIC 691dcbeb80 Add script to install from sources
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-12-30 18:09:58 +01:00
Drasko DRASKOVIC 2a07613c75 Add Redis, correct Nginx
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-12-28 22:54:22 +01:00
Drasko DRASKOVIC abd8c9b6c9 Add docker-compose with Auth and NGINX
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-12-28 18:17:40 +01:00
Drasko DRASKOVIC b60341db1d Add NATS info 2016-12-04 20:32:20 +01:00
Drasko DRASKOVIC b2417b9bd6 Use correct NATS Docker image
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-12-04 20:06:06 +01:00
Drasko DRASKOVIC ad0278005c Lock NATS version to latest stable
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-12-04 19:36:28 +01:00
Drasko DRASKOVIC ff238a3491 Update README.md 2016-12-03 18:49:41 +01:00
Nikola 15240dc391 Added mainflux-mqtt links in compose file.
Signed-off-by: Nikola <nikola.marcetic@nsystems.rs>
2016-11-27 19:49:02 +01:00
Drasko DRASKOVIC 4e8e7dbf4e Change NATS monitoring port
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-11-27 16:11:42 +01:00
Drasko DRASKOVIC e0e17f0e18 Go NATS
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-11-27 12:56:52 +01:00
Drasko DRASKOVIC e389395d4e Add Redis
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-11-26 01:44:35 +01:00
Drasko DRASKOVIC 38ad5172e1 Update README.md 2016-11-24 02:23:24 +01:00
Drasko DRASKOVIC 8e98cb5e0c Update README.md 2016-11-24 02:22:40 +01:00
Drasko DRASKOVIC 939f2612dd Update README.md 2016-11-24 02:19:06 +01:00
Drasko DRASKOVIC 133ca7116a Update docker-compose.yml 2016-11-21 22:53:26 +01:00
Drasko DRASKOVIC a005fd8398 Use mainflux-mqtt
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-11-21 22:52:14 +01:00
Drasko DRASKOVIC 13417691ad Update 2016-11-12 19:49:58 +01:00
Drasko DRASKOVIC d71eb8b20f Update README.md 2016-11-12 19:49:23 +01:00
Drasko DRASKOVIC f90d043b29 Update README.md 2016-11-12 19:44:51 +01:00
Drasko DRASKOVIC d647f62a27 Update README.md 2016-11-12 19:39:53 +01:00
Drasko DRASKOVIC 1b938002b5 Update README.md 2016-11-12 19:39:18 +01:00
Drasko DRASKOVIC 0e34885c73 Update README.md 2016-11-12 19:29:14 +01:00
Drasko DRASKOVIC f58915dd79 Remove not-needed badges 2016-11-12 19:16:27 +01:00
Drasko DRASKOVIC ed7b640700 Not needed any more 2016-11-12 19:15:55 +01:00
Drasko DRASKOVIC 9363cb6804 Correct docker-compose for core microservice
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-11-12 19:13:10 +01:00
Drasko DRASKOVIC 48779e856f Remove all from main repo
We will now use dedicated repos for microservices.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-11-12 19:11:40 +01:00
Drasko DRASKOVIC 20ce5268d4 Update README.md 2016-11-06 16:44:59 +01:00
Drasko DRASKOVIC a6aca34769 Update README.md 2016-11-05 23:33:21 +01:00
Drasko DRASKOVIC 722381a637 Update README.md 2016-11-05 23:25:48 +01:00
Drasko DRASKOVIC a93de22af7 Update README.md 2016-11-05 02:51:13 +01:00
Drasko DRASKOVIC 9561949e60 Fix Go report
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-11-05 01:36:12 +01:00
Drasko DRASKOVIC a3886c64e9 Improve Go report
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-11-05 00:51:26 +01:00
Drasko DRASKOVIC d38ea79dde Gofmt
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-11-04 23:10:13 +01:00
Drasko DRASKOVIC c12a88d12f Fix typo
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-11-04 22:30:19 +01:00
Drasko DRASKOVIC 6b54d38d53 Add dockerize to docker-commpose.yml
As described in issue #67, the order of services is important,
and mainflux-core must wait for emqtt to be available on port 1883.

docker-compose do not guarantees the order of starting services,
but we must use dockerize to check if one service is avilable before
we can start other service that depends on it.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-11-02 22:55:04 +01:00
Drasko DRASKOVIC ad6f9ee721 Update README.md 2016-11-02 01:31:07 +01:00
Drasko DRASKOVIC d0ff035688 Update README.md 2016-11-02 01:30:46 +01:00
Drasko DRASKOVIC fa9bc47482 Update README.md 2016-11-02 01:29:33 +01:00
Drasko DRASKOVIC b605341f73 Update MAINTAINERS 2016-10-29 20:15:38 +02:00
Drasko DRASKOVIC c9e7fb112a Update README.md 2016-10-29 20:07:58 +02:00
Drasko DRASKOVIC 1b2b58f6b0 Update README.md 2016-10-25 01:58:34 +02:00
Drasko DRASKOVIC 73f7af3eeb Expose HTTP ports
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-17 22:06:04 +02:00
Drasko DRASKOVIC cc50880217 Fix MQTT port
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-17 20:18:46 +02:00
Drasko DRASKOVIC bbc66553b2 Fix Glide installation
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-13 22:55:20 +02:00
Drasko DRASKOVIC 3f0eaaec31 Use Glide's novendor
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-13 22:47:22 +02:00
Drasko DRASKOVIC 1a6102c5fe Update README.md 2016-10-13 00:25:31 +02:00
Drasko DRASKOVIC d2b03d09ae Update .travis.yml 2016-10-13 00:08:49 +02:00
Drasko DRASKOVIC 2cd0e70d80 Update .travis.yml 2016-10-13 00:05:05 +02:00
Drasko DRASKOVIC 05f0fc776d Update .travis.yml 2016-10-12 23:59:13 +02:00
Drasko DRASKOVIC f7a21d43da Fix typo 2016-10-12 23:57:03 +02:00
Drasko DRASKOVIC 520006f06d Add comment for .travis.yml
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-12 23:54:39 +02:00
Drasko DRASKOVIC 180aaeae6f Remove vendor before build
Because of many problems with vedored package testing (missing
DB connections, etc), remove vendoring for Travis build

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-12 23:45:26 +02:00
Drasko DRASKOVIC e847ac251a Bump Go version in Travis to 1.7
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-12 23:31:25 +02:00
Drasko DRASKOVIC 808dbb82df Updated vendor packages
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-12 21:55:14 +02:00
Drasko DRASKOVIC 1cf4558d11 Merge pull request #65 from nmarcetic/master
glide.yaml pull latest version of paho.mqtt from master branch
2016-10-12 19:41:47 +02:00
Nikola Marčetić b1fab11c32 Pulled latest master branch version of paho mqtt with glide
Signed-off-by: Nikola Marčetić <nikola.marcetic@nsystems.rs>
2016-10-12 17:45:05 +02:00
Nikola Marčetić 63a97748b6 Changed glide.yml, set master branch for version
Signed-off-by: Nikola Marčetić <nikola.marcetic@nsystems.rs>
2016-10-12 17:43:37 +02:00
Drasko DRASKOVIC 122179b8c5 Merge pull request #63 from nmarcetic/master
Fixed docker-compose and updated paho package, to resolve travis issue https://github.com/eclipse/paho.mqtt.golang/issues/62
2016-10-12 16:56:28 +02:00
Nikola Marčetić bb5f4c1196 Updated paho package, to resolve travis issue
Signed-off-by: Nikola Marčetić <nikola.marcetic@ntsystems.rs>
2016-10-12 15:26:27 +02:00
Nikola Marčetić 4f5ef30b30 Merge branch 'master' of https://github.com/mainflux/mainflux 2016-10-12 15:22:04 +02:00
Drasko DRASKOVIC d1c44a5413 Removed Sevice field - we do not need it for now
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-10 20:28:51 +02:00
Drasko DRASKOVIC 1d74046154 Add Glide and vendoring
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-09 20:48:34 +02:00
Nikola Marcetic de236fcc90 Fixed docker-compose 2016-10-08 16:48:27 +02:00
Drasko DRASKOVIC 9de6bc1448 Prefix DB entries with channel name and unit
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-08 02:42:07 +02:00
Drasko DRASKOVIC ce928986ba Initialize service and online params
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-08 02:39:30 +02:00
Drasko DRASKOVIC 37399c8944 Limit the GET counts. Use service.
Now GET results for nb of returned channels and
nb of their values can be limited via HTTP req param.

Also, `service` is used to construct MQTT topic.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-08 02:37:09 +02:00
Drasko DRASKOVIC 849ce6e1ad Add channel name and unit (used as bn and bu)
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-08 02:35:30 +02:00
Drasko DRASKOVIC 96fd2bf2b5 Added service field. Simplified device model.
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-08 02:34:19 +02:00
Drasko DRASKOVIC 62c43f1ba4 Move "device" param to payload 2016-10-05 20:16:23 +02:00
Drasko DRASKOVIC 3db4ab8440 Move Dockerfile to root folder
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-04 23:51:44 +02:00
Drasko DRASKOVIC 5d7d5d43ff Update Dockerfile 2016-10-04 23:44:40 +02:00
Drasko DRASKOVIC 2d8ddd7b0c Organize Docker stuff
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-04 23:28:08 +02:00
Drasko DRASKOVIC 779b254c04 Correct test to use stdlib approach
Corrected server test to use std lib strategy

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-04 23:06:55 +02:00
Drasko DRASKOVIC f3f2586f03 Remove Iris, part 2
Removed Iris from /channels, switched to stdlib

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-04 22:47:47 +02:00
Drasko DRASKOVIC d02009744e Remove Iris, part 1
Remove iris and switch to more Go idiomatic API of std lib.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-04 21:55:07 +02:00
Drasko DRASKOVIC d38b125fb7 Remove print of config
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-02 22:57:06 +02:00
Drasko DRASKOVIC 551172ed0a Abandon YAML and switch to TOML
Mainflux has very simple configuration. No need for all the YAML
structures. YAML is complex and overkill. Keep it lean.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-10-02 21:20:56 +02:00
Drasko DRASKOVIC 04710ad019 Remove lite, correct /channels
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-09-20 23:48:01 +02:00
Drasko DRASKOVIC 57a4535bc4 Change /channels API
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-09-20 23:03:54 +02:00
Drasko DRASKOVIC 52f0017be5 Correct banner
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-09-20 22:47:55 +02:00
Drasko DRASKOVIC 2074bac535 Correct banner
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-09-20 21:56:01 +02:00
Drasko DRASKOVIC 106c8996d4 Add schema
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-09-20 21:55:48 +02:00
Drasko DRASKOVIC fd0ca0e6d6 Add Travis
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-09-20 21:28:42 +02:00
Drasko DRASKOVIC bd4a97fdbe Add .dockerignore
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-09-20 21:28:42 +02:00
Drasko DRASKOVIC 120acd8564 Update README.md 2016-09-20 21:25:46 +02:00
Drasko DRASKOVIC 566d8ea254 Update README.md 2016-09-20 21:24:27 +02:00
Drasko DRASKOVIC aa3e23906f Correct MAINTAINERS
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-09-20 21:21:25 +02:00
Drasko DRASKOVIC be956accd6 Update README.md 2016-09-20 21:01:33 +02:00
Drasko DRASKOVIC c06d62a8a7 Update README.md 2016-09-20 20:07:54 +02:00
Drasko DRASKOVIC 20b0207a3c Update README.md 2016-09-20 20:03:31 +02:00
Drasko DRASKOVIC 469b8f0c79 🐭 GO GO GO!
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-09-20 19:24:54 +02:00
Drasko DRASKOVIC f3dfcd7e7e Update README.md 2016-08-23 10:50:31 +02:00
Drasko DRASKOVIC b8f938e180 Update README.md 2016-08-23 00:35:56 +02:00
Drasko DRASKOVIC bbc45150cc Update README.md 2016-08-23 00:24:31 +02:00
Drasko DRASKOVIC d429dec1d8 Update README.md 2016-08-23 00:21:32 +02:00
Drasko DRASKOVIC eaf6863d1c Update README.md 2016-08-22 23:54:41 +02:00
Drasko DRASKOVIC 0bc2fd8ff6 Update configs to use docker-compose hostnames
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-08-14 20:07:20 +02:00
Drasko DRASKOVIC 2afd866ec3 Add InfluxDB
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-08-14 20:06:59 +02:00
Drasko DRASKOVIC 9e64f3a7d3 Migrate to Go
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-08-09 21:28:44 +02:00
Drasko DRASKOVIC 3ef7035689 Update README.md 2016-08-08 23:38:08 +02:00
Drasko DRASKOVIC b7be831b8b Update README.md 2016-08-08 23:37:24 +02:00
Drasko DRASKOVIC 6a24aa91e6 Update README.md 2016-05-18 23:20:39 +02:00
Drasko DRASKOVIC b88fc346d0 Update README.md 2016-05-18 23:18:40 +02:00
Drasko DRASKOVIC fb4140d69c Add Locust test template
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-05-18 20:41:21 +02:00
Drasko DRASKOVIC f92db09290 Add Postman HTTP RESTful API testing collections
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-05-18 20:38:36 +02:00
Drasko DRASKOVIC b76461e773 Add Vim ignore
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-05-18 20:37:46 +02:00
Drasko DRASKOVIC bc54a9ad6a Fix Docker host names
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-05-18 20:35:58 +02:00
Drasko DRASKOVIC 3bb18620b2 Add NATS configs
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-05-17 23:24:19 +02:00
Drasko DRASKOVIC 2f1e5163b5 Update README.md 2016-05-10 22:32:09 +02:00
Drasko DRASKOVIC f06687e2f4 Update README.md 2016-05-10 22:30:43 +02:00
Drasko DRASKOVIC 460874b9ab Add docker-compose with local config
This docker-commpose takes local `config` dir and
mounts it into containers, so that microservices can take
locally customized configuration upon deployment.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-28 23:58:57 +02:00
Drasko DRASKOVIC fc4c658ff2 Add docker-compose with local config
This docker-commpose takes local `config` dir and
mounts it into containers, so that microservices can take
locally customized configuration upon deployment.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-28 23:53:26 +02:00
Drasko DRASKOVIC 8f4ef8464e Correct docker-compose configs
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-28 23:50:18 +02:00
Drasko DRASKOVIC 454760e62e Add microservices local configurations
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-28 23:46:29 +02:00
Drasko DRASKOVIC 797a804cda Use microservices
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-28 23:36:20 +02:00
Drasko DRASKOVIC 8aa4bbc053 Update README.md 2016-04-28 22:57:41 +02:00
Drasko DRASKOVIC 0934fbe834 Update README.md 2016-04-28 22:56:58 +02:00
Drasko DRASKOVIC 09907fd78f Update README.md 2016-04-28 22:25:08 +02:00
Drasko DRASKOVIC dcd45d8bda Remove .dockerignore and .travis.yml
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-28 22:23:05 +02:00
Drasko DRASKOVIC daf9f39a11 Update README.md 2016-04-28 22:19:08 +02:00
Drasko DRASKOVIC 1750395240 Update README.md 2016-04-28 22:16:01 +02:00
Drasko DRASKOVIC 4c013fac6f Update README.md 2016-04-28 22:07:16 +02:00
Drasko DRASKOVIC d950002593 Refractored in Microservices
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-28 21:49:54 +02:00
Drasko DRASKOVIC 0dca37b656 Correct Gulpfile
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-27 23:12:31 +02:00
Drasko DRASKOVIC cf17b53bb6 Add MQTT, HTTP and WS API servers
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-27 23:05:42 +02:00
Drasko DRASKOVIC 8fee81d8bc Move config.js in root dir, add MQTT and HTTP conf
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-27 23:05:42 +02:00
Drasko DRASKOVIC eff9fd2411 Add NATS broker client
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-27 23:05:42 +02:00
Drasko DRASKOVIC 396727b4d5 Add MQTT and WS server
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-27 23:05:42 +02:00
Nikola Marcetic 2fb79f1a19 --Readme changed 2016-04-22 10:59:42 +02:00
Drasko DRASKOVIC 7d332297fc Change compostion ports
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-20 21:00:38 +02:00
Drasko DRASKOVIC bb0ead885f Make app port more configurable
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-20 20:58:41 +02:00
Drasko DRASKOVIC 00c6cb77c6 Revert "Move back to mongoose. Remove JWT."
This reverts commit 129e911652.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-20 20:28:39 +02:00
Drasko DRASKOVIC 021427431a Correct Docker files
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-20 00:20:57 +02:00
Drasko DRASKOVIC 129e911652 Move back to mongoose. Remove JWT.
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2016-04-19 23:14:28 +02:00
Drasko DRASKOVIC 41c1bc03b4 Update README.md 2016-02-15 20:06:54 +01:00
Drasko DRASKOVIC 88405089f6 Update README.md 2016-02-15 01:12:00 +01:00
Drasko DRASKOVIC 9e8888fdff Merge pull request #41 from drasko/master
Correct GET on single device
2015-12-08 02:44:50 +01:00
Drasko DRASKOVIC bd16fa2616 Correct GET on single device
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-12-08 02:39:16 +01:00
Drasko DRASKOVIC 8eee6f1bcf Merge pull request #40 from drasko/master
Update README.md
2015-12-07 01:33:12 +01:00
Drasko DRASKOVIC fbb527b435 Update README.md 2015-12-07 01:29:56 +01:00
Drasko DRASKOVIC b046ce5dd7 Merge pull request #39 from drasko/master
Update README.md
2015-12-07 01:19:44 +01:00
Drasko DRASKOVIC 08c3bac64e Update README.md 2015-12-07 01:03:28 +01:00
Drasko DRASKOVIC f88a913333 Merge pull request #38 from drasko/master
Correct Docker stuff
2015-12-07 00:34:35 +01:00
Drasko DRASKOVIC ef00dac107 Correct Docker stuff
This commit corrects docker-compose.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-12-07 00:27:52 +01:00
Drasko DRASKOVIC 87fa44f9c9 Merge pull request #37 from drasko/master
Cosmetics
2015-12-06 19:48:04 +01:00
Drasko DRASKOVIC 7eb4c34ab1 Cosmetics
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-12-06 19:42:27 +01:00
Drasko DRASKOVIC f3fd689305 Merge pull request #36 from drasko/master
JWT corrections
2015-12-06 19:42:13 +01:00
Drasko DRASKOVIC 55b28f90f0 Add JWT data in the signature
This commit adds Mainflux metadata embedded in JWT.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-12-06 14:57:40 +01:00
Drasko DRASKOVIC 40194aeb9b Create logger as a separate file
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-12-06 14:57:40 +01:00
Drasko DRASKOVIC b930a8f75f Add utils dir and generateToken.js utility
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-12-06 14:57:40 +01:00
Drasko DRASKOVIC 469880a3fa Merge pull request #35 from drasko/master
Add `bunyan` logger
2015-12-06 14:54:26 +01:00
Drasko DRASKOVIC 5efcacc731 Add bunyan logger
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-12-05 19:02:49 +01:00
Drasko DRASKOVIC 7382ab9073 Merge pull request #34 from drasko/master
Swagger file updates
2015-12-05 19:02:41 +01:00
Drasko DRASKOVIC 0faf6d85c0 Update swagger.yaml
Add tags
2015-12-05 01:23:59 +01:00
Drasko DRASKOVIC e2ab3e19e6 Correct Swagger
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-12-05 01:15:29 +01:00
Drasko DRASKOVIC 980f6ac525 Merge pull request #33 from drasko/master
Correct Swagger file
2015-12-04 01:16:44 +01:00
Drasko DRASKOVIC e7e4da29bb Add jwt
Devices routes are now JWT protected. We are using `restify-jwt`
which is using `jsonwebtoken` behind.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-12-04 00:54:39 +01:00
Drasko DRASKOVIC 54913c7d23 Correct Swagger file
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-12-04 00:54:39 +01:00
Drasko DRASKOVIC be79cae443 Merge pull request #32 from drasko/master
Use restify and mongojs. Change structure.
2015-12-02 22:21:10 +01:00
Drasko DRASKOVIC 59da29ff2b Use restify and mongojs. Change structure.
This commit introducess massive change:
- Replace Express by Restify for simplicity and lean approach
- Replace Mongoose by MongoJS for DB schema-less paradigm
- Introduce `controllers` dir, and isolate all routes in `routes.js`

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-12-02 00:17:10 +01:00
Drasko DRASKOVIC 744068bda8 Correct README
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-12-02 00:17:10 +01:00
Nikola 122c02769d Merge pull request #31 from drasko/master
Launch test with `npm test`
2015-11-02 10:55:44 +01:00
Drasko DRASKOVIC 276a505eeb Add gulp-exit - gulp exits after finished tests
Some plugins, like gulp-mocha, have problems with a proper termination
after finishing the task. This plugin guarantees that the task will exit
successfully.

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-11-02 01:49:39 +01:00
Drasko DRASKOVIC 2e27375adb Add server.close() in apiTest.js
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-11-02 01:49:39 +01:00
Drasko DRASKOVIC 38311af348 Add mongodb in Travis build
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-11-02 01:49:39 +01:00
Drasko DRASKOVIC 455b469bc2 Add gulp locally
Gulp has to be added both globally and locally for
Travis to work.
Aome explanations:
http://blog.dwaynecrooks.com/post/110903139442/why-do-we-need-to-install-gulp-globally-and

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-11-02 01:49:39 +01:00
Drasko DRASKOVIC 63281acac5 Add local mocha and fix .travis.yml
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-11-02 01:49:39 +01:00
Drasko DRASKOVIC 253495d5bb Launch test with npm test
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-11-02 01:49:39 +01:00
Drasko DRASKOVIC 66ef92dbf7 Merge pull request #30 from drasko/master
Add Travis YAML
2015-11-01 15:54:21 +01:00
Drasko DRASKOVIC f2fd735dbd Add Travis YAML
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-11-01 15:51:39 +01:00
Drasko DRASKOVIC 4e5edad061 Merge pull request #29 from drasko/master
Add Mocha, Chai and Supertest combo for testing
2015-11-01 15:33:52 +01:00
Drasko DRASKOVIC cb6471790b Add test task in gulp
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-11-01 15:27:49 +01:00
Drasko DRASKOVIC 5e31f45b27 Add Mocha, Chai and Supertest combo for testing
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-11-01 03:43:23 +01:00
Drasko DRASKOVIC 51898276f3 Add Community links 2015-10-17 00:03:21 +02:00
Drasko DRASKOVIC 9f3a728ccb Merge pull request #25 from nmarcetic/master
-- Hello JWT
2015-10-13 16:47:58 +02:00
nmarcetic f36013016e -- Hello JWT
Signed-off-by: nmarcetic <nikola.marcetic@ntsystems.rs>
2015-10-13 16:35:32 +02:00
Nikola b520216351 Merge pull request #21 from drasko/master
Add license to package.json. Correct HTTP headers.
2015-10-12 20:48:08 +02:00
Drasko DRASKOVIC 92b4a70528 Correct headers for token. Send full device JSON on creation, update and delete
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-10-11 22:35:05 +02:00
Drasko DRASKOVIC fafa623680 Add license to package.json
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-10-11 22:35:05 +02:00
Drasko DRASKOVIC e6203967bb Merge pull request #17 from drasko/master
Add comments for device model, fix typos
2015-10-10 01:40:52 +02:00
Drasko DRASKOVIC 3b86bf249c Add comments for device model, fix typos
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2015-10-10 01:37:50 +02:00
Drasko DRASKOVIC 700a34b589 Merge pull request #16 from drasko/master
Update README.md
2015-10-10 01:11:01 +02:00
Drasko DRASKOVIC a3a2c1f449 Update README.md 2015-10-10 01:06:40 +02:00
Drasko DRASKOVIC 910791c8fa Merge pull request #15 from drasko/master
Update README.md
2015-10-10 00:56:17 +02:00
Drasko DRASKOVIC dd806d2a2e Update README.md 2015-10-10 00:55:04 +02:00
Drasko DRASKOVIC 83e439bb5a Merge pull request #14 from drasko/master
Switch LICENSE to Apache v2.0
2015-10-09 23:40:59 +02:00
Drasko DRASKOVIC 45451c8266 Switch LICENSE to Apache v2.0 2015-10-09 23:35:23 +02:00
Drasko DRASKOVIC 47597331f1 Add NodeJS styleguide 2015-10-05 20:07:01 +02:00
Drasko DRASKOVIC 8d914647c8 Corrected typo 2015-10-05 20:04:33 +02:00
Drasko DRASKOVIC 4c7b046824 Merge pull request #13 from drasko/master
LICENSE, CONTRIBUTING and MAINTAINERS files
2015-10-04 05:14:16 +02:00
Drasko DRASKOVIC 46498c152f LICENSE, CONTRIBUTING and MAINTAINERS files
Update MAINTAINERS

Update CONTRIBUTING.md

Update CONTRIBUTING.md

Update CONTRIBUTING.md

Update CONTRIBUTING.md
2015-10-04 05:10:45 +02:00
Drasko DRASKOVIC 427d03fa0a Update README.md
Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md
2015-10-03 01:56:02 +02:00
The Gitter Badger 1c9c5e6605 Add Gitter badge 2015-10-03 01:56:02 +02:00
Drasko DRASKOVIC 014d13298a Correct comments 2015-10-03 01:56:02 +02:00
Drasko DRASKOVIC 9d8004ee4c Add device schema mock-up 2015-10-03 01:56:02 +02:00
janko-isidorovic a2d57cae38 Added Visual Studio files to .gitignore 2015-10-03 01:56:02 +02:00
nmarcetic 3e5a93efbf Docker file fix 2015-07-28 01:10:32 +02:00
nmarcetic c137bda7c4 -- Readme update 2015-07-28 01:01:00 +02:00
nmarcetic 70805a0b2a -- Hello docker-compose 2015-07-28 00:50:20 +02:00
Nikola 8979bb96db Merge pull request #2 from drasko/master
Config and routes directory structure + Docker file
2015-07-27 12:50:45 +02:00
Drasko DRASKOVIC fc410bd89f Added Docker file 2015-07-26 23:39:09 +02:00
Drasko DRASKOVIC c8c61bfe4a Added config and routes dirs 2015-07-26 23:37:22 +02:00
Drasko DRASKOVIC ac018a665c Merge pull request #1 from drasko/master
Several commits
2015-07-07 11:50:51 +02:00
Drasko DRASKOVIC 17adff355c Added gulpfile 2015-07-07 00:31:31 +02:00
Drasko DRASKOVIC 38c08359a9 Added MIT LICENSE.md file 2015-07-06 23:51:10 +02:00
Drasko DRASKOVIC 12fc1e4bcc Added README.md file 2015-07-06 23:43:19 +02:00
Drasko DRASKOVIC 5711803c8d Added more stuff to .gitignore 2015-07-06 23:33:01 +02:00
Drasko DRASKOVIC 7d5b901dc9 Initial commit 2015-07-06 22:32:02 +02:00
2020 changed files with 611584 additions and 13462 deletions
+1
View File
@@ -0,0 +1 @@
* @mainflux/maintainers
+88
View File
@@ -0,0 +1,88 @@
# Contributing to Mainflux
The following is a set of guidelines for contributing to Mainflux and its libraries, which are
hosted in the [Mainflux Organization](https://github.com/mainflux) on GitHub.
This project adheres to the [Contributor Covenant 1.2](http://contributor-covenant.org/version/1/2/0).
By participating, you are expected to uphold this code. Please report unacceptable behavior to
[abuse@mainflux.com](mailto:abuse@mainflux.com).
## Reporting issues
Reporting issues is a great way to contribute to the project. We always appreciate a well-written,
thorough bug reports.
Prior to raising a new issue, check out [our issue
list](https://github.com/mainflux/mainflux/issues) to determine whether it already include the
problem you are facing.
A good bug report shouldn't leave others needing to chase you up for more information. Please try to
be as detailed as possible. The following questions might serve as a template for writing a detailed
reports:
- What were you trying to achieve?
- What are the expected results?
- What are the received results?
- What are the steps to reproduce the issue?
- In what environment did you encounter the issue?
## Pull requests
Good pull requests (e.g. patches, improvements, new features) are a fantastic help. They should
remain focused in scope and avoid containing unrelated commits.
**Please ask first** before embarking any significant pull request (e.g. implementing new features,
refactoring code etc.), otherwise you risk spending a lot of time working on something that the
maintainers might not want to merge into the project.
Please adhere to the coding conventions used throughout the project. If in doubt, consult the
[Effective Go](https://golang.org/doc/effective_go.html) style guide.
To start contributing to the project, [fork](https://help.github.com/articles/fork-a-repo/) it,
clone your fork repository, and configure the remotes:
```
git clone https://github.com/<your-username>/mainflux.git
cd mainflux
git remote add upstream https://github.com/mainflux/mainflux.git
```
If you cloned a while ago, get the latest changes from upstream:
```
git checkout master
git pull --rebase upstream master
```
Create a new topic branch from `master` using the naming convention `MF-[issue-number]`
to help us keep track of your contribution scope:
```
git checkout -b MF-[issue-number]
```
Commit your changes in logical chunks. When you are ready to commit, make sure
to write a Good Commit Message™. Consult the [Erlang's contributing guide](https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
if you're not sure what constitutes a Good Commit Message™. Use [interactive rebase](https://help.github.com/articles/about-git-rebase)
to group your commits into logical units of working before making them public.
Note that every commit you make must be signed. By signing off your work you indicate that you
are accepting the [Developer Certificate of Origin](https://developercertificate.org/).
Use your real name (sorry, no pseudonyms or anonymous contributions). If you set your `user.name`
and `user.email` git configs, you can sign your commit automatically with `git commit -s`.
Locally merge (or rebase) the upstream development branch into your topic branch:
```
git pull --rebase upstream master
```
Push your topic branch up to your fork:
```
git push origin MF-[issue-number]
```
[Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title
and detailed description.
+30
View File
@@ -0,0 +1,30 @@
<!--
The GitHub issue tracker is for bug reports and feature requests. General support can be found at
the following locations:
- Google group - https://groups.google.com/forum/#!forum/mainflux
- Gitter - https://gitter.im/mainflux/mainflux
-->
**FEATURE REQUEST**
1. Is there an open issue addressing this request? If it does, please add a "+1" reaction to the
existing issue, otherwise proceed to step 2.
2. Describe the feature you are requesting, as well as the possible use case(s) for it.
3. Indicate the importance of this feature to you (must-have, should-have, nice-to-have).
**BUG REPORT**
1. What were you trying to achieve?
2. What are the expected results?
3. What are the received results?
4. What are the steps to reproduce the issue?
5. In what environment did you encounter the issue?
6. Additional information you deem important:
+4
View File
@@ -0,0 +1,4 @@
build
site/
-1
View File
@@ -1 +0,0 @@
docs.api.magistrala.absmach.eu
Generated
+573
View File
@@ -0,0 +1,573 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
branch = "master"
name = "github.com/Azure/go-ansiterm"
packages = [
".",
"winterm"
]
revision = "d6e3b3328b783f23731bc4d058875b0371ff8109"
[[projects]]
name = "github.com/Microsoft/go-winio"
packages = ["."]
revision = "7da180ee92d8bd8bb8c37fc560e673e6557c392f"
version = "v0.4.7"
[[projects]]
branch = "master"
name = "github.com/Nvveen/Gotty"
packages = ["."]
revision = "cd527374f1e5bff4938207604a14f2e38a9cf512"
[[projects]]
name = "github.com/asaskevich/govalidator"
packages = ["."]
revision = "ccb8e960c48f04d6935e72476ae4a51028f9e22f"
version = "v9"
[[projects]]
branch = "master"
name = "github.com/beorn7/perks"
packages = ["quantile"]
revision = "3a771d992973f24aa725d07868b467d1ddfceafb"
[[projects]]
branch = "master"
name = "github.com/buger/jsonparser"
packages = ["."]
revision = "2cac668e8456b4284edb0715e17e2af02d3ec993"
[[projects]]
name = "github.com/cenkalti/backoff"
packages = ["."]
revision = "2ea60e5f094469f9e65adb9cd103795b73ae743e"
version = "v2.0.0"
[[projects]]
branch = "master"
name = "github.com/cisco/senml"
packages = ["."]
revision = "448c9510575e1dd6f780cb10addbad998cf80418"
[[projects]]
branch = "master"
name = "github.com/containerd/continuity"
packages = ["pathdriver"]
revision = "c6cef34830231743494fe2969284df7b82cc0ad0"
[[projects]]
name = "github.com/davecgh/go-spew"
packages = ["spew"]
revision = "346938d642f2ec3594ed81d874461961cd0faa76"
version = "v1.1.0"
[[projects]]
name = "github.com/dgrijalva/jwt-go"
packages = ["."]
revision = "06ea1031745cb8b3dab3f6a236daf2b0aa468b7e"
version = "v3.2.0"
[[projects]]
name = "github.com/docker/go-connections"
packages = ["nat"]
revision = "3ede32e2033de7505e6500d6c868c2b9ed9f169d"
version = "v0.3.0"
[[projects]]
name = "github.com/docker/go-units"
packages = ["."]
revision = "47565b4f722fb6ceae66b95f853feed578a4a51c"
version = "v0.3.3"
[[projects]]
name = "github.com/fatih/color"
packages = ["."]
revision = "5b77d2a35fb0ede96d138fc9a99f5c9b6aef11b4"
version = "v1.7.0"
[[projects]]
name = "github.com/go-kit/kit"
packages = [
"endpoint",
"log",
"metrics",
"metrics/internal/lv",
"metrics/prometheus",
"transport/grpc",
"transport/http"
]
revision = "4dc7be5d2d12881735283bcab7352178e190fc71"
version = "v0.6.0"
[[projects]]
name = "github.com/go-logfmt/logfmt"
packages = ["."]
revision = "390ab7935ee28ec6b286364bba9b4dd6410cb3d5"
version = "v0.3.0"
[[projects]]
name = "github.com/go-stack/stack"
packages = ["."]
revision = "259ab82a6cad3992b4e21ff5cac294ccb06474bc"
version = "v1.7.0"
[[projects]]
name = "github.com/go-zoo/bone"
packages = ["."]
revision = "fd0aebc74e908868b09ac140fb5a53cb363884c1"
version = "1.2"
[[projects]]
branch = "master"
name = "github.com/gocql/gocql"
packages = [
".",
"internal/lru",
"internal/murmur",
"internal/streams"
]
revision = "651d6b1f343c6e168e45d119dcfe8f71e5bafb32"
[[projects]]
name = "github.com/gogo/protobuf"
packages = ["proto"]
revision = "1adfc126b41513cc696b209667c8656ea7aac67c"
version = "v1.0.0"
[[projects]]
name = "github.com/golang/protobuf"
packages = [
"proto",
"ptypes",
"ptypes/any",
"ptypes/duration",
"ptypes/timestamp"
]
revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265"
version = "v1.1.0"
[[projects]]
branch = "master"
name = "github.com/golang/snappy"
packages = ["."]
revision = "2e65f85255dbc3072edf28d6b5b8efc472979f5a"
[[projects]]
name = "github.com/gorilla/websocket"
packages = ["."]
revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b"
version = "v1.2.0"
[[projects]]
name = "github.com/hailocab/go-hostpool"
packages = ["."]
revision = "e80d13ce29ede4452c43dea11e79b9bc8a15b478"
[[projects]]
branch = "master"
name = "github.com/hokaccha/go-prettyjson"
packages = ["."]
revision = "e6b9231a2b1cc5798b336fdbf99c16cd8ad1e0c9"
[[projects]]
name = "github.com/inconshreveable/mousetrap"
packages = ["."]
revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"
version = "v1.0"
[[projects]]
name = "github.com/influxdata/influxdb"
packages = [
"client/v2",
"models",
"pkg/escape"
]
revision = "02d7d4f043b34ecb4e9b2dbec298c6f9450c2a32"
version = "v1.5.2"
[[projects]]
branch = "master"
name = "github.com/kr/logfmt"
packages = ["."]
revision = "b84e30acd515aadc4b783ad4ff83aff3299bdfe0"
[[projects]]
branch = "master"
name = "github.com/lib/pq"
packages = [
".",
"oid"
]
revision = "d34b9ff171c21ad295489235aec8b6626023cd04"
[[projects]]
name = "github.com/mattn/go-colorable"
packages = ["."]
revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072"
version = "v0.0.9"
[[projects]]
name = "github.com/mattn/go-isatty"
packages = ["."]
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
version = "v0.0.3"
[[projects]]
name = "github.com/matttproud/golang_protobuf_extensions"
packages = ["pbutil"]
revision = "3247c84500bff8d9fb6d579d800f20b3e091582c"
version = "v1.0.0"
[[projects]]
name = "github.com/mongodb/mongo-go-driver"
packages = [
"bson",
"bson/builder",
"bson/decimal",
"bson/elements",
"bson/objectid",
"bson/parser",
"bson/parser/ast",
"core/address",
"core/auth",
"core/auth/internal/gssapi",
"core/command",
"core/compressor",
"core/connection",
"core/connstring",
"core/description",
"core/dispatch",
"core/event",
"core/option",
"core/readconcern",
"core/readpref",
"core/result",
"core/session",
"core/tag",
"core/topology",
"core/uuid",
"core/version",
"core/wiremessage",
"core/writeconcern",
"internal",
"mongo",
"mongo/aggregateopt",
"mongo/changestreamopt",
"mongo/clientopt",
"mongo/collectionopt",
"mongo/countopt",
"mongo/dbopt",
"mongo/deleteopt",
"mongo/distinctopt",
"mongo/dropcollopt",
"mongo/findopt",
"mongo/indexopt",
"mongo/insertopt",
"mongo/listcollectionopt",
"mongo/listdbopt",
"mongo/mongoopt",
"mongo/replaceopt",
"mongo/runcmdopt",
"mongo/updateopt"
]
revision = "8df56f107cdd485351eb2523992c3364114b4b2e"
version = "v0.0.10"
[[projects]]
name = "github.com/nats-io/go-nats"
packages = [
".",
"encoders/builtin",
"util"
]
revision = "062418ea1c2181f52dc0f954f6204370519a868b"
version = "v1.5.0"
[[projects]]
name = "github.com/nats-io/nuid"
packages = ["."]
revision = "289cccf02c178dc782430d534e3c1f5b72af807f"
version = "v1.0.0"
[[projects]]
name = "github.com/opencontainers/go-digest"
packages = ["."]
revision = "279bed98673dd5bef374d3b6e4b09e2af76183bf"
version = "v1.0.0-rc1"
[[projects]]
name = "github.com/opencontainers/image-spec"
packages = [
"specs-go",
"specs-go/v1"
]
revision = "d60099175f88c47cd379c4738d158884749ed235"
version = "v1.0.1"
[[projects]]
name = "github.com/opencontainers/runc"
packages = [
"libcontainer/system",
"libcontainer/user"
]
revision = "baf6536d6259209c3edfa2b22237af82942d3dfa"
version = "v0.1.1"
[[projects]]
name = "github.com/ory/dockertest"
packages = [
"docker",
"docker/opts",
"docker/pkg/archive",
"docker/pkg/fileutils",
"docker/pkg/homedir",
"docker/pkg/idtools",
"docker/pkg/ioutils",
"docker/pkg/jsonmessage",
"docker/pkg/longpath",
"docker/pkg/mount",
"docker/pkg/pools",
"docker/pkg/stdcopy",
"docker/pkg/system",
"docker/pkg/term",
"docker/pkg/term/windows",
"docker/types",
"docker/types/blkiodev",
"docker/types/container",
"docker/types/filters",
"docker/types/mount",
"docker/types/network",
"docker/types/registry",
"docker/types/strslice",
"docker/types/versions"
]
revision = "2e92e7784b6fb199fd168aa46269a2f1b34f299e"
version = "v3.3.0"
[[projects]]
name = "github.com/pkg/errors"
packages = ["."]
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
version = "v0.8.0"
[[projects]]
name = "github.com/pmezard/go-difflib"
packages = ["difflib"]
revision = "792786c7400a136282c1664665ae0a8db921c6c2"
version = "v1.0.0"
[[projects]]
name = "github.com/prometheus/client_golang"
packages = [
"prometheus",
"prometheus/promhttp"
]
revision = "c5b7fccd204277076155f10851dad72b76a49317"
version = "v0.8.0"
[[projects]]
branch = "master"
name = "github.com/prometheus/client_model"
packages = ["go"]
revision = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c"
[[projects]]
branch = "master"
name = "github.com/prometheus/common"
packages = [
"expfmt",
"internal/bitbucket.org/ww/goautoneg",
"model"
]
revision = "d811d2e9bf898806ecfb6ef6296774b13ffc314c"
[[projects]]
branch = "master"
name = "github.com/prometheus/procfs"
packages = [
".",
"internal/util",
"nfs",
"xfs"
]
revision = "8b1c2da0d56deffdbb9e48d4414b4e674bd8083e"
[[projects]]
branch = "master"
name = "github.com/rubenv/sql-migrate"
packages = [
".",
"sqlparse"
]
revision = "081fe17d19ff4e2dd9f5a0c1158e6bcf74da6906"
[[projects]]
name = "github.com/satori/go.uuid"
packages = ["."]
revision = "f58768cc1a7a7e77a3bd49e98cdd21419399b6a3"
version = "v1.2.0"
[[projects]]
name = "github.com/sirupsen/logrus"
packages = ["."]
revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc"
version = "v1.0.5"
[[projects]]
name = "github.com/sony/gobreaker"
packages = ["."]
revision = "e9556a45379ef1da12e54847edb2fb3d7d566f36"
version = "0.3.0"
[[projects]]
name = "github.com/spf13/cobra"
packages = ["."]
revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385"
version = "v0.0.3"
[[projects]]
name = "github.com/spf13/pflag"
packages = ["."]
revision = "583c0c0531f06d5278b7d917446061adc344b5cd"
version = "v1.0.1"
[[projects]]
name = "github.com/stretchr/testify"
packages = [
"assert",
"require"
]
revision = "12b6f73e6084dad08a7c6e575284b177ecafbc71"
version = "v1.2.1"
[[projects]]
name = "github.com/ugorji/go"
packages = ["codec"]
revision = "b4c50a2b199d93b13dc15e78929cfb23bfdf21ab"
version = "v1.1.1"
[[projects]]
branch = "master"
name = "golang.org/x/crypto"
packages = [
"bcrypt",
"blowfish",
"pbkdf2",
"ssh/terminal"
]
revision = "2d027ae1dddd4694d54f7a8b6cbe78dca8720226"
[[projects]]
branch = "master"
name = "golang.org/x/net"
packages = [
"context",
"http/httpguts",
"http2",
"http2/hpack",
"idna",
"internal/timeseries",
"trace"
]
revision = "f73e4c9ed3b7ebdd5f699a16a880c2b1994e50dd"
[[projects]]
branch = "master"
name = "golang.org/x/sync"
packages = ["semaphore"]
revision = "1d60e4601c6fd243af51cc01ddf169918a5407ca"
[[projects]]
branch = "master"
name = "golang.org/x/sys"
packages = [
"unix",
"windows"
]
revision = "7dfd1290c7917b7ba22824b9d24954ab3002fe24"
[[projects]]
name = "golang.org/x/text"
packages = [
"collate",
"collate/build",
"internal/colltab",
"internal/gen",
"internal/tag",
"internal/triegen",
"internal/ucd",
"language",
"secure/bidirule",
"transform",
"unicode/bidi",
"unicode/cldr",
"unicode/norm",
"unicode/rangetable"
]
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
version = "v0.3.0"
[[projects]]
branch = "master"
name = "google.golang.org/genproto"
packages = ["googleapis/rpc/status"]
revision = "86e600f69ee4704c6efbf6a2a40a5c10700e76c2"
[[projects]]
name = "google.golang.org/grpc"
packages = [
".",
"balancer",
"balancer/base",
"balancer/roundrobin",
"channelz",
"codes",
"connectivity",
"credentials",
"encoding",
"encoding/proto",
"grpclb/grpc_lb_v1/messages",
"grpclog",
"internal",
"keepalive",
"metadata",
"naming",
"peer",
"resolver",
"resolver/dns",
"resolver/passthrough",
"stats",
"status",
"tap",
"transport"
]
revision = "41344da2231b913fa3d983840a57a6b1b7b631a1"
version = "v1.12.0"
[[projects]]
name = "gopkg.in/gorp.v1"
packages = ["."]
revision = "c87af80f3cc5036b55b83d77171e156791085e2e"
version = "v1.7.1"
[[projects]]
name = "gopkg.in/inf.v0"
packages = ["."]
revision = "d2d2541c53f18d2a059457998ce2876cc8e67cbf"
version = "v0.9.1"
[[projects]]
name = "gopkg.in/ory-am/dockertest.v3"
packages = ["."]
revision = "2e92e7784b6fb199fd168aa46269a2f1b34f299e"
version = "v3.3.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "e3b07d2098253644fc2f77fede1f00fcc077a20e4f46c59466ffd61c4998bb00"
solver-name = "gps-cdcl"
solver-version = 1
+91
View File
@@ -0,0 +1,91 @@
[[constraint]]
name = "github.com/asaskevich/govalidator"
version = "9.0.0"
[[constraint]]
branch = "master"
name = "github.com/cisco/senml"
[[constraint]]
name = "github.com/dgrijalva/jwt-go"
version = "3.2.0"
[[constraint]]
name = "github.com/fatih/color"
version = "1.7.0"
[[constraint]]
name = "github.com/go-kit/kit"
version = "0.6.0"
[[constraint]]
name = "github.com/go-zoo/bone"
version = "1.2.0"
[[constraint]]
name = "github.com/golang/protobuf"
version = "1.1.0"
[[constraint]]
branch = "master"
name = "github.com/hokaccha/go-prettyjson"
[[constraint]]
branch = "master"
name = "github.com/lib/pq"
[[constraint]]
name = "github.com/nats-io/go-nats"
version = "1.4.0"
[[constraint]]
name = "github.com/prometheus/client_golang"
version = "0.8.0"
[[constraint]]
name = "github.com/satori/go.uuid"
version = "1.2.0"
[[constraint]]
name = "github.com/sony/gobreaker"
version = "0.3.0"
[[constraint]]
name = "github.com/spf13/cobra"
version = "0.0.3"
[[constraint]]
name = "github.com/stretchr/testify"
version = "1.2.1"
[[constraint]]
branch = "master"
name = "golang.org/x/crypto"
[[constraint]]
name = "gopkg.in/ory-am/dockertest.v3"
version = "3.1.6"
[[constraint]]
name = "github.com/gorilla/websocket"
version = "1.2.0"
[[constraint]]
branch = "master"
name = "github.com/rubenv/sql-migrate"
[[constraint]]
name = "github.com/influxdata/influxdb"
version = "1.5.2"
[[constraint]]
name = "github.com/mongodb/mongo-go-driver"
version = "0.0.5"
[[constraint]]
branch = "master"
name = "github.com/gocql/gocql"
[prune]
go-tests = true
unused-packages = true
+191
View File
@@ -0,0 +1,191 @@
Apache License
Version 2.0, January 2004
https://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
Copyright 2015-2018 Mainflux
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+45
View File
@@ -0,0 +1,45 @@
# Mainflux follows the timeless, highly efficient and totally unfair system
# known as [Benevolent dictator for
# life](https://en.wikipedia.org/wiki/Benevolent_Dictator_for_Life), with
# Drasko DRASKOVIC in the role of BDFL.
[bdfl]
[[drasko]]
Name = "Drasko DRASKOVIC"
Email = "drasko.draskovic@mainflux.com"
GitHub = "drasko"
# However, this role serves only in dead-lock events, or in a special and very rare cases
# when BDFL completely disagrees with the decisions made.
# In the normal flow of events, decisions on the project design are made through discussions,
# most often on the Pull Requests.
#
# Maintainers have the special role in the project in managing and accepting PRs,
# overall leading the project and making design decisions on the maintained subsystems.
#
# A reference list of all maintainers of the Mainflux project.
# ADD YOURSELF HERE IN ALPHABETICAL ORDER
[maintainers]
[[manuel]]
Name = "Manuel IMPERIALE"
Email = "manuel.imperiale@gmail.com"
GitHub = "manuIO"
[[janko]]
Name = "Janko ISIDOROVIC"
Email = "janko.isidorovic@mainflux.com"
GitHub = "janko-isidorovic"
[[nikola]]
Name = "Nikola MARCETIC"
Email = "nikola.marcetic@mainflux.com"
GitHub = "nmarcetic"
[[dejan]]
Name = "Dejan MIJIC"
Email = "dejan.mijic@mainflux.com"
GitHub = "mijicd"
+66
View File
@@ -0,0 +1,66 @@
BUILD_DIR = build
SERVICES = users things http normalizer ws influxdb-writer influxdb-reader mongodb-writer mongodb-reader cassandra-writer cassandra-reader cli
DOCKERS = $(addprefix docker_,$(SERVICES))
CGO_ENABLED ?= 0
GOOS ?= linux
define compile_service
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) go build -ldflags "-s -w" -o ${BUILD_DIR}/mainflux-$(1) cmd/$(1)/main.go
endef
define make_docker
docker build --build-arg SVC_NAME=$(subst docker_,,$(1)) --tag=mainflux/$(subst docker_,,$(1)) -f docker/Dockerfile .
endef
all: $(SERVICES) mqtt
.PHONY: all $(SERVICES) dockers latest release mqtt
clean:
rm -rf ${BUILD_DIR}
rm -rf mqtt/node_modules
install:
cp ${BUILD_DIR}/* $(GOBIN)
test:
GOCACHE=off go test -v -race -tags test $(shell go list ./... | grep -v 'vendor\|cmd')
proto:
protoc --go_out=plugins=grpc:. *.proto
$(SERVICES):
$(call compile_service,$(@))
$(DOCKERS):
$(call make_docker,$(@))
dockers: $(DOCKERS)
docker build --tag=mainflux/dashflux -f dashflux/docker/Dockerfile dashflux
docker build --tag=mainflux/mqtt -f mqtt/Dockerfile .
mqtt:
cd mqtt && npm install
latest: dockers
for svc in $(SERVICES); do \
docker push mainflux/$$svc; \
done
docker push mainflux/dashflux
docker push mainflux/mqtt
release:
$(eval version = $(shell git describe --abbrev=0 --tags))
git checkout $(version)
$(MAKE) dockers
for svc in $(SERVICES); do \
docker tag mainflux/$$svc mainflux/$$svc:$(version); \
docker push mainflux/$$svc:$(version); \
done
docker tag mainflux/dashflux mainflux/dashflux:$(version)
docker push mainflux/dashflux:$(version)
docker tag mainflux/mqtt mainflux/mqtt:$(version)
docker push mainflux/mqtt:$(version)
run:
cd scripts && ./run.sh
+67
View File
@@ -0,0 +1,67 @@
# Mainflux
[![build][ci-badge]][ci-url]
[![go report card][grc-badge]][grc-url]
[![coverage][cov-badge]][cov-url]
[![license][license]](LICENSE)
[![chat][gitter-badge]][gitter]
![banner][banner]
Mainflux is modern, scalable, secure open source and patent-free IoT cloud platform written in Go.
It accepts user, device, and application connections over various network protocols (i.e. HTTP,
MQTT, WebSocket, CoAP), thus making a seamless bridge between them. It is used as the IoT middleware
for building complex IoT solutions.
For more details, check out the [official documentation][docs].
## Features
- Protocol bridging (i.e. HTTP, MQTT, WebSocket, CoAP)
- Device management and provisioning
- Fine-grained access control
- Platform logging and instrumentation support
- Container-based deployment using [Docker][docker]
## Quickstart
Before proceeding, install the following prerequisites:
- [Docker](https://docs.docker.com/install/)
- [Docker compose](https://docs.docker.com/compose/install/)
Once everything is installed, execute the following commands from project root:
```bash
docker-compose -f docker/docker-compose.yml up -d
```
## Contributing
Thank you for your interest in Mainflux and wish to contribute!
1. Take a look at our [open issues](https://github.com/mainflux/mainflux/issues).
2. Checkout the [contribution guide](.github/CONTRIBUTING.md) to learn more about our style and conventions.
3. Make your changes compatible to our workflow.
## Community
- [Google group][forum]
- [Gitter][gitter]
- [Twitter][twitter]
[banner]: https://github.com/mainflux/mainflux/blob/master/docs/img/gopherBanner.jpg
[ci-badge]: https://semaphoreci.com/api/v1/mainflux/mainflux/branches/master/badge.svg
[ci-url]: https://semaphoreci.com/mainflux/mainflux
[docs]: http://mainflux.readthedocs.io
[docker]: https://www.docker.com
[forum]: https://groups.google.com/forum/#!forum/mainflux
[gitter]: https://gitter.im/mainflux/mainflux?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[gitter-badge]: https://badges.gitter.im/Join%20Chat.svg
[grc-badge]: https://goreportcard.com/badge/github.com/mainflux/mainflux
[grc-url]: https://goreportcard.com/report/github.com/mainflux/mainflux
[cov-badge]: https://codecov.io/gh/mainflux/mainflux/branch/master/graph/badge.svg
[cov-url]: https://codecov.io/gh/mainflux/mainflux
[license]: https://img.shields.io/badge/license-Apache%20v2.0-blue.svg
[twitter]: https://twitter.com/mainflux
-508
View File
@@ -1,508 +0,0 @@
# Copyright (c) Abstract Machines
# SPDX-License-Identifier: Apache-2.0
openapi: 3.0.1
info:
title: Magistrala Alarms API
description: |
HTTP API for managing alarms service.
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
contact:
email: info@absmach.eu
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
version: 0.18.5
servers:
- url: http://localhost:8050
- url: https://localhost:8050
tags:
- name: alarms
description: Everything about your Alarms
externalDocs:
description: Find out more about alarms
url: https://magistrala.absmach.eu/docs/
paths:
/{domainID}/alarms:
get:
operationId: listAlarms
summary: List Alarms
description: |
Retrieves a list of alarms with optional filtering
tags:
- alarms
parameters:
- $ref: '#/components/parameters/DomainID'
- $ref: '#/components/parameters/Offset'
- $ref: '#/components/parameters/Limit'
- $ref: '#/components/parameters/Order'
- $ref: '#/components/parameters/Dir'
- $ref: '#/components/parameters/ChannelID'
- $ref: '#/components/parameters/ClientID'
- $ref: '#/components/parameters/Subtopic'
- $ref: '#/components/parameters/RuleID'
- $ref: '#/components/parameters/Status'
- $ref: '#/components/parameters/AssigneeID'
- $ref: '#/components/parameters/Severity'
- $ref: '#/components/parameters/UpdatedBy'
- $ref: '#/components/parameters/AssignedBy'
- $ref: '#/components/parameters/AcknowledgedBy'
- $ref: '#/components/parameters/ResolvedBy'
- $ref: '#/components/parameters/CreatedFrom'
- $ref: '#/components/parameters/CreatedTo'
security:
- bearerAuth: []
responses:
'200':
$ref: '#/components/responses/AlarmsPageRes'
'400':
description: Failed due to malformed query parameters
'401':
description: Missing or invalid access token
'422':
description: Database can't process request
'500':
$ref: '#/components/responses/ServiceError'
/{domainID}/alarms/{alarmID}:
get:
operationId: viewAlarm
summary: View Alarm
description: Retrieves an alarm by ID
tags:
- alarms
parameters:
- $ref: '#/components/parameters/DomainID'
- $ref: '#/components/parameters/AlarmID'
security:
- bearerAuth: []
responses:
'200':
$ref: '#/components/responses/AlarmRes'
'400':
description: Missing or invalid alarm ID
'401':
description: Missing or invalid access token
'403':
description: Failed to perform authorization over the entity
'404':
description: Alarm does not exist
'422':
description: Database can't process request
'500':
$ref: '#/components/responses/ServiceError'
put:
operationId: updateAlarm
summary: Update Alarm
description: Updates an existing alarm
tags:
- alarms
parameters:
- $ref: '#/components/parameters/DomainID'
- $ref: '#/components/parameters/AlarmID'
security:
- bearerAuth: []
requestBody:
$ref: '#/components/requestBodies/AlarmUpdateReq'
responses:
'200':
$ref: '#/components/responses/AlarmRes'
'400':
description: Failed due to malformed JSON
'401':
description: Missing or invalid access token
'403':
description: Failed to perform authorization over the entity
'404':
description: Alarm does not exist
'415':
description: Missing or invalid content type
'422':
description: Database can't process request
'500':
$ref: '#/components/responses/ServiceError'
delete:
operationId: deleteAlarm
summary: Delete Alarm
description: Deletes an alarm
tags:
- alarms
parameters:
- $ref: '#/components/parameters/DomainID'
- $ref: '#/components/parameters/AlarmID'
security:
- bearerAuth: []
responses:
'204':
description: Alarm deleted successfully
'400':
description: Failed due to malformed alarm ID
'401':
description: Missing or invalid access token
'403':
description: Failed to perform authorization over the entity
'404':
description: Alarm does not exist
'422':
description: Database can't process request
'500':
$ref: '#/components/responses/ServiceError'
/health:
get:
summary: Retrieves service health check info
tags:
- health
security: []
responses:
'200':
$ref: '#/components/responses/HealthRes'
'500':
$ref: '#/components/responses/ServiceError'
components:
schemas:
Alarm:
type: object
properties:
id:
type: string
description: Unique alarm identifier
readOnly: true
rule_id:
type: string
description: Rule ID that triggered this alarm
domain_id:
type: string
description: Domain ID this alarm belongs to
channel_id:
type: string
description: Channel ID where the alarm was triggered
client_id:
type: string
description: Client ID that triggered the alarm
subtopic:
type: string
description: Subtopic associated with the alarm
status:
type: string
description: Alarm status
enum: [active, cleared]
measurement:
type: string
description: Measurement that triggered the alarm
value:
type: string
description: Value that triggered the alarm
unit:
type: string
description: Unit of measurement
threshold:
type: string
description: Threshold value that was exceeded
cause:
type: string
description: Cause or description of the alarm
severity:
type: integer
description: Severity level (0-100)
minimum: 0
maximum: 100
assignee_id:
type: string
description: ID of the user assigned to this alarm
created_at:
type: string
format: date-time
description: Creation timestamp
readOnly: true
updated_at:
type: string
format: date-time
description: Last update timestamp
readOnly: true
updated_by:
type: string
description: User who last updated the alarm
readOnly: true
assigned_at:
type: string
format: date-time
description: When the alarm was assigned
readOnly: true
assigned_by:
type: string
description: User who assigned the alarm
readOnly: true
acknowledged_at:
type: string
format: date-time
description: When the alarm was acknowledged
readOnly: true
acknowledged_by:
type: string
description: User who acknowledged the alarm
readOnly: true
resolved_at:
type: string
format: date-time
description: When the alarm was resolved
readOnly: true
resolved_by:
type: string
description: User who resolved the alarm
readOnly: true
metadata:
type: object
description: Custom metadata
additionalProperties: true
AlarmsPage:
type: object
properties:
offset:
type: integer
description: Number of items to skip during retrieval
minimum: 0
default: 0
limit:
type: integer
description: Size of the subset to retrieve
minimum: 1
maximum: 1000
default: 10
total:
type: integer
description: Total number of results
minimum: 0
alarms:
type: array
minItems: 0
items:
$ref: '#/components/schemas/Alarm'
required:
- alarms
- total
- offset
- limit
parameters:
DomainID:
name: domainID
description: Domain ID
in: path
required: true
schema:
type: string
AlarmID:
name: alarmID
description: Alarm ID
in: path
required: true
schema:
type: string
Offset:
name: offset
description: Number of items to skip
in: query
required: false
schema:
type: integer
default: 0
minimum: 0
Limit:
name: limit
description: Size of the subset to retrieve
in: query
required: false
schema:
type: integer
default: 10
minimum: 1
maximum: 1000
Order:
name: order
description: Order by field
in: query
required: false
schema:
type: string
enum: [created_at, updated_at]
default: created_at
Dir:
name: dir
description: Sort direction
in: query
required: false
schema:
type: string
enum: [asc, desc]
default: desc
ChannelID:
name: channel_id
description: Filter by channel ID
in: query
required: false
schema:
type: string
ClientID:
name: client_id
description: Filter by client ID
in: query
required: false
schema:
type: string
Subtopic:
name: subtopic
description: Filter by subtopic
in: query
required: false
schema:
type: string
RuleID:
name: rule_id
description: Filter by rule ID
in: query
required: false
schema:
type: string
Status:
name: status
description: Filter by alarm status
in: query
required: false
schema:
type: string
enum: [active, cleared, all]
default: all
AssigneeID:
name: assignee_id
description: Filter by assignee ID
in: query
required: false
schema:
type: string
Severity:
name: severity
description: Filter by severity level
in: query
required: false
schema:
type: integer
minimum: 0
maximum: 100
UpdatedBy:
name: updated_by
description: Filter by user who updated
in: query
required: false
schema:
type: string
AssignedBy:
name: assigned_by
description: Filter by user who assigned
in: query
required: false
schema:
type: string
AcknowledgedBy:
name: acknowledged_by
description: Filter by user who acknowledged
in: query
required: false
schema:
type: string
ResolvedBy:
name: resolved_by
description: Filter by user who resolved
in: query
required: false
schema:
type: string
CreatedFrom:
name: created_from
description: Filter alarms created after this time (RFC3339 format)
in: query
required: false
schema:
type: string
format: date-time
CreatedTo:
name: created_to
description: Filter alarms created before this time (RFC3339 format)
in: query
required: false
schema:
type: string
format: date-time
requestBodies:
AlarmUpdateReq:
description: JSON-formatted document describing the alarm update
required: true
content:
application/json:
schema:
type: object
properties:
status:
type: string
description: Alarm status
enum: [active, cleared]
assignee_id:
type: string
description: ID of the user assigned to this alarm
severity:
type: integer
description: Severity level (0-100)
minimum: 0
maximum: 100
metadata:
type: object
description: Custom metadata
additionalProperties: true
responses:
AlarmRes:
description: Alarm data retrieved
content:
application/json:
schema:
$ref: '#/components/schemas/Alarm'
links:
update:
operationId: updateAlarm
parameters:
alarmID: $response.body#/id
domainID: $response.body#/domain_id
delete:
operationId: deleteAlarm
parameters:
alarmID: $response.body#/id
domainID: $response.body#/domain_id
AlarmsPageRes:
description: Alarms page retrieved
content:
application/json:
schema:
$ref: '#/components/schemas/AlarmsPage'
ServiceError:
description: Unexpected server-side error occurred
HealthRes:
description: Service Health Check
content:
application/health+json:
schema:
$ref: "./schemas/health_info.yaml"
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
description: |
* Users access: "Authorization: Bearer <user_token>"
+20
View File
@@ -0,0 +1,20 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package mainflux
// Response contains HTTP response specific methods.
type Response interface {
// Code returns HTTP response code.
Code() int
// Headers returns map of HTTP headers with their values.
Headers() map[string]string
// Empty indicates if HTTP response has content.
Empty() bool
}
-851
View File
@@ -1,851 +0,0 @@
# Copyright (c) Abstract Machines
# SPDX-License-Identifier: Apache-2.0
openapi: 3.0.3
info:
title: Magistrala Auth Service
description: |
This is the Auth Server based on the OpenAPI 3.0 specification. It is the HTTP API for managing platform users. You can now help us improve the API whether it's by making changes to the definition itself or to the code.
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
contact:
email: info@absmach.eu
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
version: 0.18.0
servers:
- url: http://localhost:9001
- url: https://localhost:9001
tags:
- name: Keys
description: Everything about your Keys.
externalDocs:
description: Find out more about keys
url: https://magistrala.absmach.eu/docs/
- name: PATs
description: Everything about your Personal Access Tokens.
externalDocs:
description: Find out more about Personal Access Tokens
url: https://magistrala.absmach.eu/docs/
- name: Health
description: Service health check endpoint.
externalDocs:
description: Find out more about health check
url: https://magistrala.absmach.eu/docs/
paths:
/keys:
post:
operationId: issueKey
tags:
- Keys
summary: Issue API key
description: |
Generates a new API key. Thew new API key will
be uniquely identified by its ID.
requestBody:
$ref: "#/components/requestBodies/KeyRequest"
responses:
"201":
description: Issued new key.
"400":
description: Failed due to malformed JSON.
"401":
description: Missing or invalid access token provided.
"409":
description: Failed due to using already existing ID.
"415":
description: Missing or invalid content type.
"500":
$ref: "#/components/responses/ServiceError"
/keys/{keyID}:
get:
operationId: getKey
summary: Gets API key details.
description: |
Gets API key details for the given key.
tags:
- Keys
parameters:
- $ref: "#/components/parameters/ApiKeyId"
responses:
"200":
$ref: "#/components/responses/KeyRes"
"400":
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"404":
description: A non-existent entity request.
"422":
description: Service can't process request.
"500":
$ref: "#/components/responses/ServiceError"
delete:
operationId: revokeKey
summary: Revoke API key
description: |
Revoke API key identified by the given ID.
tags:
- Keys
parameters:
- $ref: "#/components/parameters/ApiKeyId"
responses:
"204":
description: Key revoked.
"401":
description: Missing or invalid access token provided.
"404":
description: A non-existent entity request.
"422":
description: Service can't process request.
"500":
$ref: "#/components/responses/ServiceError"
/pats:
post:
operationId: createPAT
tags:
- PATs
summary: Create a new Personal Access Token
description: |
Creates a new Personal Access Token (PAT) for the authenticated user.
requestBody:
$ref: "#/components/requestBodies/CreatePATRequest"
responses:
"201":
$ref: "#/components/responses/PATRes"
"400":
description: Failed due to malformed JSON or validation errors.
"401":
description: Missing or invalid access token provided.
"415":
description: Missing or invalid content type.
"500":
$ref: "#/components/responses/ServiceError"
get:
operationId: listPATs
tags:
- PATs
summary: List all Personal Access Tokens
description: |
Lists all Personal Access Tokens (PATs) for the authenticated user.
parameters:
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Offset"
responses:
"200":
$ref: "#/components/responses/PATsPageRes"
"400":
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"500":
$ref: "#/components/responses/ServiceError"
delete:
operationId: clearAllPATs
tags:
- PATs
summary: Remove all Personal Access Tokens
description: |
Removes all Personal Access Tokens (PATs) for the authenticated user.
responses:
"200":
description: All PATs removed successfully.
"401":
description: Missing or invalid access token provided.
"500":
$ref: "#/components/responses/ServiceError"
/pats/{patID}:
get:
operationId: retrievePAT
tags:
- PATs
summary: Retrieve a Personal Access Token
description: |
Retrieves details of a specific Personal Access Token (PAT).
parameters:
- $ref: "#/components/parameters/PatID"
responses:
"200":
$ref: "#/components/responses/PATRes"
"400":
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"404":
description: PAT not found.
"500":
$ref: "#/components/responses/ServiceError"
delete:
operationId: deletePAT
tags:
- PATs
summary: Delete a Personal Access Token
description: |
Deletes a specific Personal Access Token (PAT).
parameters:
- $ref: "#/components/parameters/PatID"
responses:
"204":
description: PAT deleted successfully.
"401":
description: Missing or invalid access token provided.
"404":
description: PAT not found.
"500":
$ref: "#/components/responses/ServiceError"
/pats/{patID}/name:
patch:
operationId: updatePATName
tags:
- PATs
summary: Update Personal Access Token name
description: |
Updates the name of a specific Personal Access Token (PAT).
parameters:
- $ref: "#/components/parameters/PatID"
requestBody:
$ref: "#/components/requestBodies/UpdatePATNameRequest"
responses:
"202":
$ref: "#/components/responses/PATRes"
"400":
description: Failed due to malformed JSON or validation errors.
"401":
description: Missing or invalid access token provided.
"404":
description: PAT not found.
"415":
description: Missing or invalid content type.
"500":
$ref: "#/components/responses/ServiceError"
/pats/{patID}/description:
patch:
operationId: updatePATDescription
tags:
- PATs
summary: Update Personal Access Token description
description: |
Updates the description of a specific Personal Access Token (PAT).
parameters:
- $ref: "#/components/parameters/PatID"
requestBody:
$ref: "#/components/requestBodies/UpdatePATDescriptionRequest"
responses:
"202":
$ref: "#/components/responses/PATRes"
"400":
description: Failed due to malformed JSON or validation errors.
"401":
description: Missing or invalid access token provided.
"404":
description: PAT not found.
"415":
description: Missing or invalid content type.
"500":
$ref: "#/components/responses/ServiceError"
/pats/{patID}/secret/reset:
patch:
operationId: resetPATSecret
tags:
- PATs
summary: Reset Personal Access Token secret
description: |
Resets the secret of a specific Personal Access Token (PAT).
parameters:
- $ref: "#/components/parameters/PatID"
requestBody:
$ref: "#/components/requestBodies/ResetPATSecretRequest"
responses:
"200":
$ref: "#/components/responses/PATRes"
"400":
description: Failed due to malformed JSON or validation errors.
"401":
description: Missing or invalid access token provided.
"404":
description: PAT not found.
"415":
description: Missing or invalid content type.
"500":
$ref: "#/components/responses/ServiceError"
/pats/{patID}/secret/revoke:
patch:
operationId: revokePATSecret
tags:
- PATs
summary: Revoke Personal Access Token secret
description: |
Revokes the secret of a specific Personal Access Token (PAT).
parameters:
- $ref: "#/components/parameters/PatID"
responses:
"204":
description: PAT secret revoked successfully.
"401":
description: Missing or invalid access token provided.
"404":
description: PAT not found.
"500":
$ref: "#/components/responses/ServiceError"
/pats/{patID}/scope:
get:
operationId: listScopes
tags:
- PATs
summary: List scopes for a Personal Access Token
description: |
Lists all scopes for a specific Personal Access Token (PAT).
parameters:
- $ref: "#/components/parameters/PatID"
- $ref: "#/components/parameters/Limit"
- $ref: "#/components/parameters/Offset"
responses:
"200":
$ref: "#/components/responses/ScopesPageRes"
"400":
description: Failed due to malformed query parameters.
"401":
description: Missing or invalid access token provided.
"404":
description: PAT not found.
"500":
$ref: "#/components/responses/ServiceError"
delete:
operationId: clearAllScopes
tags:
- PATs
summary: Remove all scopes from a Personal Access Token
description: |
Removes all scopes from a specific Personal Access Token (PAT).
parameters:
- $ref: "#/components/parameters/PatID"
responses:
"200":
description: All scopes removed successfully.
"401":
description: Missing or invalid access token provided.
"404":
description: PAT not found.
"500":
$ref: "#/components/responses/ServiceError"
/pats/{patID}/scope/add:
patch:
operationId: addScope
tags:
- PATs
summary: Add scope to a Personal Access Token
description: |
Adds a scope to a specific Personal Access Token (PAT).
parameters:
- $ref: "#/components/parameters/PatID"
requestBody:
$ref: "#/components/requestBodies/AddScopeRequest"
responses:
"200":
description: Scope added successfully.
"400":
description: Failed due to malformed JSON or validation errors.
"401":
description: Missing or invalid access token provided.
"404":
description: PAT not found.
"415":
description: Missing or invalid content type.
"422":
description: Database cannot process the request.
"500":
$ref: "#/components/responses/ServiceError"
/pats/{patID}/scope/remove:
patch:
operationId: removeScope
tags:
- PATs
summary: Remove scope from a Personal Access Token
description: |
Removes a scope from a specific Personal Access Token (PAT).
parameters:
- $ref: "#/components/parameters/PatID"
requestBody:
$ref: "#/components/requestBodies/RemoveScopeRequest"
responses:
"200":
description: Scope removed successfully.
"400":
description: Failed due to malformed JSON or validation errors.
"401":
description: Missing or invalid access token provided.
"404":
description: PAT not found.
"415":
description: Missing or invalid content type.
"500":
$ref: "#/components/responses/ServiceError"
/health:
get:
summary: Retrieves service health check info.
tags:
- Health
security: []
responses:
"200":
$ref: "#/components/responses/HealthRes"
"500":
$ref: "#/components/responses/ServiceError"
components:
schemas:
PAT:
type: object
properties:
id:
type: string
format: uuid
example: "c5747f2f-2a7c-4fe1-b41a-51a5ae290945"
description: Personal Access Token unique identifier
user_id:
type: string
format: uuid
example: "9118de62-c680-46b7-ad0a-21748a52833a"
description: User ID of the PAT owner
name:
type: string
example: "My PAT"
description: Name of the Personal Access Token
description:
type: string
example: "Token for automation"
description: Description of the Personal Access Token
secret:
type: string
example: "pat_1234567890abcdef"
description: Secret value of the Personal Access Token
issued_at:
type: string
format: date-time
example: "2019-11-26T13:31:52Z"
description: Time when the PAT was issued
expires_at:
type: string
format: date-time
example: "2020-11-26T13:31:52Z"
description: Time when the PAT expires
updated_at:
type: string
format: date-time
example: "2019-11-26T13:31:52Z"
description: Time when the PAT was last updated
last_used_at:
type: string
format: date-time
example: "2019-11-26T13:31:52Z"
description: Time when the PAT was last used
revoked:
type: boolean
example: false
description: Whether the PAT is revoked
revoked_at:
type: string
format: date-time
example: "2019-11-26T13:31:52Z"
description: Time when the PAT was revoked
PATsPage:
type: object
properties:
total:
type: integer
example: 10
description: Total number of PATs
offset:
type: integer
example: 0
description: Number of items to skip during retrieval
limit:
type: integer
example: 10
description: Size of the subset to retrieve
pats:
type: array
items:
$ref: "#/components/schemas/PAT"
description: List of Personal Access Tokens
Scope:
type: object
properties:
optional_domain_id:
type: string
format: uuid
example: "bb7edb32-2eac-4aad-aebe-ed96fe073879"
description: Optional domain ID for the scope
entity_type:
type: string
enum:
[groups, channels, clients, domains, users, dashboards, messages]
example: "groups"
description: Type of entity the scope applies to
entity_id:
type: string
example: "*"
description: ID of the entity the scope applies to. '*' means all entities of the specified type.
operation:
type: string
enum:
[
create,
read,
list,
update,
delete,
share,
unshare,
publish,
subscribe,
]
example: "read"
description: Operation allowed by this scope
ScopesPage:
type: object
properties:
total:
type: integer
example: 10
description: Total number of scopes
offset:
type: integer
example: 0
description: Number of items to skip during retrieval
limit:
type: integer
example: 10
description: Size of the subset to retrieve
scopes:
type: array
items:
$ref: "#/components/schemas/Scope"
description: List of scopes
Key:
type: object
properties:
id:
type: string
format: uuid
example: "c5747f2f-2a7c-4fe1-b41a-51a5ae290945"
description: API key unique identifier
issuer_id:
type: string
format: uuid
example: "9118de62-c680-46b7-ad0a-21748a52833a"
description: In ID of the entity that issued the token.
type:
type: integer
example: 0
description: API key type. Keys of different type are processed differently.
subject:
type: string
format: string
example: "test@example.com"
description: User's email or service identifier of API key subject.
issued_at:
type: string
format: date-time
example: "2019-11-26 13:31:52"
description: Time when the key is generated.
expires_at:
type: string
format: date-time
example: "2019-11-26 13:31:52"
description: Time when the Key expires. If this field is missing,
that means that Key is valid indefinitely.
parameters:
PatID:
name: patID
description: Personal Access Token ID.
in: path
schema:
type: string
format: uuid
required: true
DomainID:
name: domainID
description: Unique domain identifier.
in: path
schema:
type: string
format: uuid
required: true
example: bb7edb32-2eac-4aad-aebe-ed96fe073879
Status:
name: status
description: Domain status.
in: query
schema:
type: string
default: enabled
required: false
example: enabled
DomainName:
name: name
description: Domain's name.
in: query
schema:
type: string
required: false
example: "domainName"
Permission:
name: permission
description: permission.
in: query
schema:
type: string
required: false
example: "edit"
ApiKeyId:
name: keyID
description: API Key ID.
in: path
schema:
type: string
format: uuid
required: true
Limit:
name: limit
description: Size of the subset to retrieve.
in: query
schema:
type: integer
default: 10
maximum: 100
minimum: 1
required: false
Offset:
name: offset
description: Number of items to skip during retrieval.
in: query
schema:
type: integer
default: 0
minimum: 0
required: false
Metadata:
name: metadata
description: Metadata filter. Filtering is performed matching the parameter with metadata on top level. Parameter is json.
in: query
required: false
schema:
type: object
additionalProperties: {}
Type:
name: type
description: The type of the API Key.
in: query
schema:
type: integer
default: 0
minimum: 0
required: false
Subject:
name: subject
description: The subject of an API Key
in: query
schema:
type: string
required: false
requestBodies:
CreatePATRequest:
description: JSON-formatted document describing PAT creation request.
required: true
content:
application/json:
schema:
type: object
required:
- name
- duration
properties:
name:
type: string
minLength: 1
example: "My PAT"
description: Name of the Personal Access Token
description:
type: string
example: "Token for automation"
description: Description of the Personal Access Token
duration:
type: string
pattern: "^[0-9]+(ns|us|µs|ms|s|m|h|d|w|y)$"
example: "30d"
description: Duration for which the PAT is valid. Format is a duration string (e.g. "30d", "24h", "1y").
UpdatePATNameRequest:
description: JSON-formatted document describing PAT name update request.
required: true
content:
application/json:
schema:
type: object
required:
- name
properties:
name:
type: string
example: "New PAT Name"
description: New name for the Personal Access Token
UpdatePATDescriptionRequest:
description: JSON-formatted document describing PAT description update request.
required: true
content:
application/json:
schema:
type: object
required:
- description
properties:
description:
type: string
example: "New PAT Description"
description: New description for the Personal Access Token
ResetPATSecretRequest:
description: JSON-formatted document describing PAT secret reset request.
required: true
content:
application/json:
schema:
type: object
required:
- duration
properties:
duration:
type: string
pattern: "^[0-9]+(ns|us|µs|ms|s|m|h|d|w|y)$"
example: "30d"
description: Duration for which the new PAT secret is valid. Format is a duration string (e.g. "30d", "24h", "1y").
AddScopeRequest:
description: JSON-formatted document describing add scope request.
required: true
content:
application/json:
schema:
type: object
required:
- scopes
properties:
scopes:
type: array
items:
$ref: "#/components/schemas/Scope"
description: List of scopes to add
RemoveScopeRequest:
description: JSON-formatted document describing remove scope request.
required: true
content:
application/json:
schema:
type: object
required:
- scopes_id
properties:
scopes_id:
type: array
items:
type: string
format: uuid
description: List of scope IDs to remove
KeyRequest:
description: JSON-formatted document describing key request.
required: true
content:
application/json:
schema:
type: object
properties:
type:
type: integer
example: 0
description: API key type. Keys of different type are processed differently.
duration:
type: number
format: integer
example: 23456
description: Number of seconds issued token is valid for.
responses:
PATRes:
description: Personal Access Token data.
content:
application/json:
schema:
$ref: "#/components/schemas/PAT"
PATsPageRes:
description: Page of Personal Access Tokens.
content:
application/json:
schema:
$ref: "#/components/schemas/PATsPage"
ScopesPageRes:
description: Page of scopes.
content:
application/json:
schema:
$ref: "#/components/schemas/ScopesPage"
ServiceError:
description: Unexpected server-side error occurred.
KeyRes:
description: Data retrieved.
content:
application/json:
schema:
$ref: "#/components/schemas/Key"
links:
revoke:
operationId: revokeKey
parameters:
keyID: $response.body#/id
HealthRes:
description: Service Health Check.
content:
application/health+json:
schema:
$ref: "./schemas/health_info.yaml"
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
description: |
* Users access: "Authorization: Bearer <user_token>"
security:
- bearerAuth: []
-1151
View File
File diff suppressed because it is too large Load Diff
-722
View File
@@ -1,722 +0,0 @@
# Copyright (c) Abstract Machines
# SPDX-License-Identifier: Apache-2.0
openapi: 3.0.3
info:
title: Certs Service API
description: |
Certificate management service for issuing, renewing, revoking, and managing X.509 certificates.
This service provides PKI functionality including certificate lifecycle management, OCSP responder,
and CRL generation.
version: 1.0.0
contact:
name: Abstract Machines
license:
name: Apache-2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
- url: http://localhost:9019
description: Development server
tags:
- name: certificates
description: Certificate lifecycle management operations
- name: pki
description: PKI infrastructure operations (OCSP, CRL, CA)
- name: health
description: Service health and monitoring
security:
- BearerAuth: []
paths:
/{domainID}/certs/issue/{entityID}:
post:
tags:
- certificates
summary: Issue a new certificate
description: Issues a new X.509 certificate for the specified entity with custom subject options
operationId: issueCert
security:
- BearerAuth: []
parameters:
- $ref: '#/components/parameters/DomainID'
- $ref: '#/components/parameters/EntityID'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/IssueCertRequest'
responses:
'201':
description: Certificate successfully issued
content:
application/json:
schema:
$ref: '#/components/schemas/CertificateResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalServerError'
/{domainID}/certs/{id}/renew:
patch:
tags:
- certificates
summary: Renew a certificate
description: Renews an existing certificate with extended TTL and new serial number
operationId: renewCert
security:
- BearerAuth: []
parameters:
- $ref: '#/components/parameters/DomainID'
- $ref: '#/components/parameters/CertID'
responses:
'200':
description: Certificate successfully renewed
content:
application/json:
schema:
$ref: '#/components/schemas/RenewCertResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
/{domainID}/certs/{id}/revoke:
patch:
tags:
- certificates
summary: Revoke a certificate
description: Revokes a certificate by its serial number
operationId: revokeCert
security:
- BearerAuth: []
parameters:
- $ref: '#/components/parameters/DomainID'
- $ref: '#/components/parameters/CertID'
responses:
'204':
description: Certificate successfully revoked
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'422':
$ref: '#/components/responses/UnprocessableEntity'
'500':
$ref: '#/components/responses/InternalServerError'
/{domainID}/certs/{entityID}/delete:
delete:
tags:
- certificates
summary: Delete certificates for an entity
description: Deletes all certificates associated with the specified entity
operationId: deleteCert
security:
- BearerAuth: []
parameters:
- $ref: '#/components/parameters/DomainID'
- $ref: '#/components/parameters/EntityID'
responses:
'204':
description: Certificates successfully deleted
'401':
$ref: '#/components/responses/Unauthorized'
'422':
$ref: '#/components/responses/UnprocessableEntity'
'500':
$ref: '#/components/responses/InternalServerError'
/{domainID}/certs:
get:
tags:
- certificates
summary: List certificates
description: Retrieves a paginated list of certificates with optional filtering by entity ID
operationId: listCerts
security:
- BearerAuth: []
parameters:
- $ref: '#/components/parameters/DomainID'
- $ref: '#/components/parameters/Offset'
- $ref: '#/components/parameters/Limit'
- $ref: '#/components/parameters/EntityIDFilter'
responses:
'200':
description: Certificates successfully retrieved
content:
application/json:
schema:
$ref: '#/components/schemas/CertificateListResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalServerError'
/{domainID}/certs/{id}:
get:
tags:
- certificates
summary: View certificate details
description: Retrieves detailed information about a specific certificate by serial number
operationId: viewCert
security:
- BearerAuth: []
parameters:
- $ref: '#/components/parameters/DomainID'
- $ref: '#/components/parameters/CertID'
responses:
'200':
description: Certificate details successfully retrieved
content:
application/json:
schema:
$ref: '#/components/schemas/ViewCertResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
/{domainID}/certs/csrs/{entityID}:
post:
tags:
- certificates
summary: Issue certificate from CSR
description: Issues a certificate from a Certificate Signing Request (CSR)
operationId: issueFromCSR
security:
- BearerAuth: []
parameters:
- $ref: '#/components/parameters/DomainID'
- $ref: '#/components/parameters/EntityID'
- $ref: '#/components/parameters/TTL'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/IssueFromCSRRequest'
responses:
'200':
description: Certificate successfully issued from CSR
content:
application/json:
schema:
$ref: '#/components/schemas/IssueFromCSRResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalServerError'
/certs/csrs/{entityID}:
post:
tags:
- certificates
summary: Issue certificate from CSR (Internal)
description: Issues a certificate from a CSR using internal agent authentication
operationId: issueFromCSRInternal
security:
- AgentAuth: []
parameters:
- $ref: '#/components/parameters/EntityID'
- $ref: '#/components/parameters/TTL'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/IssueFromCSRRequest'
responses:
'200':
description: Certificate successfully issued from CSR
content:
application/json:
schema:
$ref: '#/components/schemas/IssueFromCSRResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalServerError'
/certs/ocsp:
post:
tags:
- pki
summary: OCSP responder
description: |
Online Certificate Status Protocol (OCSP) responder endpoint.
Accepts both binary OCSP requests and JSON format requests.
operationId: ocsp
security: []
parameters:
- name: force_status
in: query
description: Force a specific OCSP status for testing
required: false
schema:
type: string
requestBody:
required: true
content:
application/ocsp-request:
schema:
type: string
format: binary
description: DER-encoded OCSP request
application/json:
schema:
$ref: '#/components/schemas/OCSPRequest'
responses:
'200':
description: OCSP response
content:
application/ocsp-response:
schema:
type: string
format: binary
description: DER-encoded OCSP response
'400':
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/InternalServerError'
/certs/crl:
get:
tags:
- pki
summary: Generate Certificate Revocation List
description: Generates and returns the current Certificate Revocation List (CRL)
operationId: generateCRL
security: []
responses:
'200':
description: CRL successfully generated
content:
application/json:
schema:
$ref: '#/components/schemas/CRLResponse'
'500':
$ref: '#/components/responses/InternalServerError'
/certs/view-ca:
get:
tags:
- pki
summary: View CA certificate
description: Retrieves the CA certificate chain (root and intermediate certificates)
operationId: viewCA
security: []
responses:
'200':
description: CA certificate successfully retrieved
content:
application/json:
schema:
$ref: '#/components/schemas/ViewCertResponse'
'500':
$ref: '#/components/responses/InternalServerError'
/certs/download-ca:
get:
tags:
- pki
summary: Download CA certificate
description: Downloads the CA certificate as a ZIP file
operationId: downloadCA
security: []
responses:
'200':
description: CA certificate ZIP file
content:
application/zip:
schema:
type: string
format: binary
'500':
$ref: '#/components/responses/InternalServerError'
/health:
get:
summary: Retrieves service health check info.
tags:
- health
security: []
responses:
'200':
$ref: '#/components/responses/HealthRes'
'500':
$ref: '#/components/responses/InternalServerError'
/metrics:
get:
tags:
- health
summary: Prometheus metrics
description: Returns Prometheus metrics for monitoring
operationId: metrics
security: []
responses:
'200':
description: Metrics successfully retrieved
content:
text/plain:
schema:
type: string
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
description: User authentication token
AgentAuth:
type: http
scheme: bearer
description: Agent authentication token for internal operations
parameters:
DomainID:
name: domainID
in: path
required: true
description: Domain identifier
schema:
type: string
EntityID:
name: entityID
in: path
required: true
description: Entity identifier for the certificate
schema:
type: string
CertID:
name: id
in: path
required: true
description: Certificate serial number
schema:
type: string
Offset:
name: offset
in: query
description: Number of items to skip
schema:
type: integer
minimum: 0
default: 0
Limit:
name: limit
in: query
description: Maximum number of items to return
schema:
type: integer
minimum: 1
maximum: 100
default: 10
EntityIDFilter:
name: entity_id
in: query
description: Filter certificates by entity ID
schema:
type: string
TTL:
name: ttl
in: query
description: Time to live for the certificate (e.g., "8760h", "365d")
schema:
type: string
schemas:
IssueCertRequest:
type: object
required:
- options
properties:
ttl:
type: string
description: Time to live for the certificate (e.g., "8760h" for 1 year)
example: "8760h"
ip_addresses:
type: array
items:
type: string
description: IP addresses to include in the certificate
example: ["192.168.1.1", "10.0.0.1"]
options:
$ref: '#/components/schemas/SubjectOptions'
SubjectOptions:
type: object
required:
- common_name
properties:
common_name:
type: string
description: Common Name (CN) for the certificate subject
example: "example.com"
organization:
type: array
items:
type: string
description: Organization (O)
example: ["Abstract Machines"]
organizational_unit:
type: array
items:
type: string
description: Organizational Unit (OU)
example: ["Engineering"]
country:
type: array
items:
type: string
description: Country (C)
example: ["US"]
province:
type: array
items:
type: string
description: Province or State (ST)
example: ["California"]
locality:
type: array
items:
type: string
description: Locality or City (L)
example: ["San Francisco"]
street_address:
type: array
items:
type: string
description: Street Address
example: ["123 Main St"]
postal_code:
type: array
items:
type: string
description: Postal Code
example: ["94105"]
dns_names:
type: array
items:
type: string
description: DNS names for Subject Alternative Names
example: ["example.com", "www.example.com"]
ip_addresses:
type: array
items:
type: string
description: IP addresses for Subject Alternative Names
example: ["192.168.1.1"]
CertificateResponse:
type: object
properties:
serial_number:
type: string
description: Unique serial number of the certificate
example: "4a:3f:5e:2c:1b:8d:9e:7f"
certificate:
type: string
description: PEM-encoded certificate
example: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"
key:
type: string
description: PEM-encoded private key
example: "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
revoked:
type: boolean
description: Whether the certificate is revoked
example: false
expiry_time:
type: string
format: date-time
description: Certificate expiration time
example: "2026-11-05T12:00:00Z"
entity_id:
type: string
description: Entity identifier associated with the certificate
example: "entity-123"
RenewCertResponse:
type: object
properties:
certificate:
$ref: '#/components/schemas/ViewCertResponse'
ViewCertResponse:
type: object
properties:
serial_number:
type: string
description: Certificate serial number
example: "4a:3f:5e:2c:1b:8d:9e:7f"
certificate:
type: string
description: PEM-encoded certificate
example: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"
key:
type: string
description: PEM-encoded private key
example: "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
revoked:
type: boolean
description: Revocation status
example: false
expiry_time:
type: string
format: date-time
description: Expiration timestamp
example: "2026-11-05T12:00:00Z"
entity_id:
type: string
description: Associated entity identifier
example: "entity-123"
CertificateListResponse:
type: object
properties:
total:
type: integer
format: uint64
description: Total number of certificates
example: 100
offset:
type: integer
format: uint64
description: Current offset
example: 0
limit:
type: integer
format: uint64
description: Current limit
example: 10
certificates:
type: array
items:
$ref: '#/components/schemas/ViewCertResponse'
IssueFromCSRRequest:
type: object
required:
- csr
properties:
csr:
type: string
format: byte
description: PEM-encoded Certificate Signing Request
example: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURSBSRVFVRVNULS0tLS0K..."
IssueFromCSRResponse:
type: object
properties:
serial_number:
type: string
description: Serial number of the issued certificate
example: "4a:3f:5e:2c:1b:8d:9e:7f"
certificate:
type: string
description: PEM-encoded certificate
example: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"
revoked:
type: boolean
description: Revocation status
example: false
expiry_time:
type: string
format: date-time
description: Expiration timestamp
example: "2026-11-05T12:00:00Z"
entity_id:
type: string
description: Associated entity identifier
example: "entity-123"
OCSPRequest:
type: object
properties:
serial_number:
type: string
description: Certificate serial number to check
example: "4a:3f:5e:2c:1b:8d:9e:7f"
certificate:
type: string
description: PEM-encoded certificate to check
example: "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"
status:
type: string
description: Force a specific status (for testing)
enum: [good, revoked, unknown]
CRLResponse:
type: object
properties:
crl:
type: string
format: byte
description: DER-encoded Certificate Revocation List
Error:
type: object
properties:
error:
type: string
description: Error message
example: "invalid request"
responses:
BadRequest:
description: Bad request - invalid parameters or malformed request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Unauthorized:
description: Unauthorized - invalid or missing authentication token
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
NotFound:
description: Resource not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
UnprocessableEntity:
description: Unprocessable entity - request cannot be processed
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
InternalServerError:
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
HealthRes:
description: Service Health Check.
content:
application/health+json:
schema:
$ref: './schemas/health_info.yaml'
-1149
View File
File diff suppressed because it is too large Load Diff
+87
View File
@@ -0,0 +1,87 @@
# Mainflux CLI
## Build
From the project root:
```
make cli
```
## Usage
### Service
#### Get the service verison
```
mainflux-cli version
```
### User management
#### Create User
```
mainflux-cli users create john.doe@email.com password
```
#### Login User
```
mainflux-cli users token john.doe@email.com password
```
### System Provisioning
#### Provision Device
```
mainflux-cli things create '{"type":"device", "name":"nyDevice"}' <user_auth_token>
```
#### Provision Application
```
mainflux-cli things create '{"type":"app", "name":"nyDevice"}' <user_auth_token>
```
#### Retrieve All Things
```
mainflux-cli things get all --offset=1 --limit=5 <user_auth_token>
```
#### Retrieve Thing By ID
```
mainflux-cli things get <thing_id> --offset=1 --limit=5 <user_auth_token>
```
#### Remove Thing
```
mainflux-cli things delete <thing_id> <user_auth_token>
```
#### Provision Channel
```
mainflux-cli channels create '{"name":"nyChannel"}' <user_auth_token>
```
#### Retrieve All Channels
```
mainflux-cli channels get all --offset=1 --limit=5 <user_auth_token>
```
#### Retrievie Channel By ID
```
mainflux-cli channels get <channel_id> --offset=1 --limit=5 <user_auth_token>
```
#### Remove Channel
```
mainflux-cli channels delete <channel_id> <user_auth_token>
```
### Access control
#### Connect Thing to a Channel
```
mainflux-cli things connect <thing_id> <channel_id> <user_auth_token>
```
#### Disconnect Things from a Channel
```
mainflux-cli things disconnect <thing_id> <channel_id> <user_auth_token>
```
### Messaging
#### Send a message over HTTP
```
mainflux-cli msg send <channel_id> '[{"bn":"some-base-name:","bt":1.276020076001e+09, "bu":"A","bver":5, "n":"voltage","u":"V","v":120.1}, {"n":"current","t":-5,"v":1.2}, {"n":"current","t":-4,"v":1.3}]' <thing_auth_token>
```
+127
View File
@@ -0,0 +1,127 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package cli
import (
"fmt"
"net/http"
"strconv"
"strings"
"github.com/spf13/cobra"
)
const channelsEP = "channels"
var cmdChannels = []cobra.Command{
cobra.Command{
Use: "create",
Short: "create <JSON_channel> <user_auth_token>",
Long: `Creates new channel and generates it's UUID`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
LogUsage(cmd.Short)
return
}
CreateChannel(args[0], args[1])
},
},
cobra.Command{
Use: "get",
Short: "get all/<channel_id> <user_auth_token>",
Long: `Gets list of all channels or gets channel by id`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
LogUsage(cmd.Short)
return
}
if args[0] == "all" {
GetChannels(args[1])
return
}
GetChannel(args[0], args[1])
},
},
cobra.Command{
Use: "update",
Short: "update <channel_id> <JSON_string> <user_auth_token>",
Long: `Updates channel record`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 3 {
LogUsage(cmd.Short)
return
}
UpdateChannel(args[0], args[1], args[2])
},
},
cobra.Command{
Use: "delete",
Short: "delete <channel_id> <user_auth_token>",
Long: `Delete channel by ID`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
LogUsage(cmd.Short)
return
}
DeleteChannel(args[0], args[1])
},
},
}
func NewChannelsCmd() *cobra.Command {
cmd := cobra.Command{
Use: "channels",
Short: "Manipulation with channels",
Long: `Manipulation with channels: create, delete or update channels`,
Run: func(cmd *cobra.Command, args []string) {
LogUsage(cmd.Short)
},
}
for i, _ := range cmdChannels {
cmd.AddCommand(&cmdChannels[i])
}
return &cmd
}
// CreateChannel - creates new channel and generates UUID
func CreateChannel(data, token string) {
url := fmt.Sprintf("%s/%s", serverAddr, channelsEP)
req, err := http.NewRequest("POST", url, strings.NewReader(data))
SendRequest(req, token, err)
}
// GetChannels - gets all channels
func GetChannels(token string) {
url := fmt.Sprintf("%s/%s?offset=%s&limit=%s",
serverAddr, channelsEP, strconv.Itoa(Offset), strconv.Itoa(Limit))
req, err := http.NewRequest("GET", url, nil)
SendRequest(req, token, err)
}
// GetChannel - gets channel by ID
func GetChannel(id, token string) {
url := fmt.Sprintf("%s/%s/%s", serverAddr, channelsEP, id)
req, err := http.NewRequest("GET", url, nil)
SendRequest(req, token, err)
}
// UpdateChannel - update a channel
func UpdateChannel(id, data, token string) {
url := fmt.Sprintf("%s/%s/%s", serverAddr, channelsEP, id)
req, err := http.NewRequest("PUT", url, strings.NewReader(data))
SendRequest(req, token, err)
}
// DeleteChannel - removes channel
func DeleteChannel(id, token string) {
url := fmt.Sprintf("%s/%s/%s", serverAddr, channelsEP, id)
req, err := http.NewRequest("DELETE", url, nil)
SendRequest(req, token, err)
}
+76
View File
@@ -0,0 +1,76 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package cli
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strconv"
"github.com/mainflux/mainflux"
)
const (
defCertsPath = "/src/github.com/mainflux/mainflux/docker/ssl/certs/"
envCertFile = "MF_CERT_FILE"
envKeyFile = "MF_KEY_FILE"
envCaFile = "MF_CA_FILE"
)
var (
httpClient = &http.Client{}
serverAddr = fmt.Sprintf("https://%s", "localhost")
defCertFile = fmt.Sprintf("%s%s%s", os.Getenv("GOPATH"), defCertsPath, "mainflux-server.crt")
defKeyFile = fmt.Sprintf("%s%s%s", os.Getenv("GOPATH"), defCertsPath, "mainflux-server.key")
defCaFile = fmt.Sprintf("%s%s%s", os.Getenv("GOPATH"), defCertsPath, "ca.crt")
)
// SetServerAddr - set addr using host and port
func SetServerAddr(proto string, host string, port int) {
serverAddr = fmt.Sprintf("%s://%s", proto, host)
if port != 0 {
serverAddr = fmt.Sprintf("%s:%s", serverAddr, strconv.Itoa(port))
}
}
func SetCerts() {
// Set certificates paths
certFile := mainflux.Env(envCertFile, defCertFile)
keyFile := mainflux.Env(envKeyFile, defKeyFile)
caFile := mainflux.Env(envCaFile, defCaFile)
// Load client cert
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
if err != nil {
log.Fatal(err)
}
// Load CA cert
caCert, err := ioutil.ReadFile(caFile)
if err != nil {
log.Fatal(err)
}
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
// Setup HTTPS client
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: caCertPool,
}
tlsConfig.BuildNameToCertificate()
transport := &http.Transport{TLSClientConfig: tlsConfig}
httpClient = &http.Client{Transport: transport}
}
+59
View File
@@ -0,0 +1,59 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package cli
import (
"net/http"
"strings"
"github.com/spf13/cobra"
)
const contentTypeSenml = "application/senml+json"
var cmdMessages = []cobra.Command{
cobra.Command{
Use: "send",
Short: "send <channel_id> <JSON_string> <client_token>",
Long: `Sends message on the channel`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 3 {
LogUsage(cmd.Short)
return
}
SendMsg(args[0], args[1], args[2])
},
},
}
func NewMessagesCmd() *cobra.Command {
cmd := cobra.Command{
Use: "msg",
Short: "Send or retrieve messages",
Long: `Send or retrieve messages: control message flow on the channel`,
}
for i, _ := range cmdMessages {
cmd.AddCommand(&cmdMessages[i])
}
return &cmd
}
// SendMsg - publishes SenML message on the channel
func SendMsg(id, msg, token string) {
url := serverAddr + "/http/channels/" + id + "/messages"
req, err := http.NewRequest("POST", url, strings.NewReader(msg))
LogError(err)
req.Header.Set("Authorization", token)
req.Header.Add("Content-Type", contentTypeSenml)
resp, err := httpClient.Do(req)
FormatResLog(resp, err)
}
+167
View File
@@ -0,0 +1,167 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package cli
import (
"fmt"
"net/http"
"strconv"
"strings"
"github.com/spf13/cobra"
)
const thingsEP = "things"
var cmdThings = []cobra.Command{
cobra.Command{
Use: "create",
Short: "create <JSON_thing> <user_auth_token>",
Long: `Create new thing, generate his UUID and store it`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
LogUsage(cmd.Short)
return
}
CreateThing(args[0], args[1])
},
},
cobra.Command{
Use: "get",
Short: "get all/<thing_id> <user_auth_token>",
Long: `Get all thingss or thing by id`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
LogUsage(cmd.Short)
return
}
if args[0] == "all" {
GetThings(args[1])
return
}
GetThing(args[0], args[1])
},
},
cobra.Command{
Use: "delete",
Short: "delete <thing_id> <user_auth_token>",
Long: `Removes thing from database`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
LogUsage(cmd.Short)
return
}
DeleteThing(args[0], args[1])
},
},
cobra.Command{
Use: "update",
Short: "update <thing_id> <JSON_string> <user_auth_token>",
Long: `Update thing record`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 3 {
LogUsage(cmd.Short)
return
}
UpdateThing(args[0], args[1], args[2])
},
},
cobra.Command{
Use: "connect",
Short: "connect <thing_id> <channel_id> <user_auth_token>",
Long: `Connect thing to the channel`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 3 {
LogUsage(cmd.Short)
return
}
ConnectThing(args[0], args[1], args[2])
},
},
cobra.Command{
Use: "disconnect",
Short: "disconnect <thing_id> <channel_id> <user_auth_token>",
Long: `Disconnect thing to the channel`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 3 {
LogUsage(cmd.Short)
return
}
DisconnectThing(args[0], args[1], args[2])
},
},
}
func NewThingsCmd() *cobra.Command {
cmd := cobra.Command{
Use: "things",
Short: "things <options>",
Long: `Things handling: create, delete or update things.`,
Run: func(cmd *cobra.Command, args []string) {
LogUsage(cmd.Short)
},
}
for i, _ := range cmdThings {
cmd.AddCommand(&cmdThings[i])
}
return &cmd
}
// CreateThing - creates new thing and generates thing UUID
func CreateThing(data, token string) {
url := fmt.Sprintf("%s/%s", serverAddr, thingsEP)
req, err := http.NewRequest("POST", url, strings.NewReader(data))
SendRequest(req, token, err)
}
// GetThings - gets all things
func GetThings(token string) {
url := fmt.Sprintf("%s/%s?offset=%s&limit=%s",
serverAddr, thingsEP, strconv.Itoa(Offset), strconv.Itoa(Limit))
req, err := http.NewRequest("GET", url, nil)
SendRequest(req, token, err)
}
// GetThing - gets thing by ID
func GetThing(id, token string) {
url := fmt.Sprintf("%s/%s/%s", serverAddr, thingsEP, id)
req, err := http.NewRequest("GET", url, nil)
SendRequest(req, token, err)
}
// UpdateThing - updates thing by ID
func UpdateThing(id, data, token string) {
url := fmt.Sprintf("%s/%s/%s", serverAddr, thingsEP, id)
req, err := http.NewRequest("PUT", url, strings.NewReader(data))
SendRequest(req, token, err)
}
// DeleteThing - removes thing
func DeleteThing(id, token string) {
url := fmt.Sprintf("%s/%s/%s", serverAddr, thingsEP, id)
req, err := http.NewRequest("DELETE", url, nil)
SendRequest(req, token, err)
}
// ConnectThing - connect thing to a channel
func ConnectThing(cliId, chanId, token string) {
url := fmt.Sprintf("%s/%s/%s/%s/%s", serverAddr, channelsEP,
chanId, thingsEP, cliId)
req, err := http.NewRequest("PUT", url, nil)
SendRequest(req, token, err)
}
// DisconnectThing - connect thing to a channel
func DisconnectThing(cliId, chanId, token string) {
url := fmt.Sprintf("%s/%s/%s/%s/%s", serverAddr, channelsEP,
chanId, thingsEP, cliId)
req, err := http.NewRequest("DELETE", url, nil)
SendRequest(req, token, err)
}
+75
View File
@@ -0,0 +1,75 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package cli
import (
"fmt"
"strings"
"github.com/spf13/cobra"
)
var cmdUsers = []cobra.Command{
cobra.Command{
Use: "create",
Short: "create <username> <password>",
Long: `Creates new user`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
LogUsage(cmd.Short)
return
}
CreateUser(args[0], args[1])
},
},
cobra.Command{
Use: "token",
Short: "token <username> <password>",
Long: `Creates new token`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
LogUsage(cmd.Short)
return
}
CreateToken(args[0], args[1])
},
},
}
func NewUsersCmd() *cobra.Command {
cmd := cobra.Command{
Use: "users",
Short: "users create/token <email> <password>",
Long: `Manages users in the system (create account or token)`,
Run: func(cmd *cobra.Command, args []string) {
LogUsage(cmd.Short)
},
}
for i, _ := range cmdUsers {
cmd.AddCommand(&cmdUsers[i])
}
return &cmd
}
// CreateUser - create user
func CreateUser(user, pwd string) {
msg := fmt.Sprintf(`{"email": "%s", "password": "%s"}`, user, pwd)
url := fmt.Sprintf("%s/users", serverAddr)
resp, err := httpClient.Post(url, contentType, strings.NewReader(msg))
FormatResLog(resp, err)
}
// CreateToken - create user token
func CreateToken(user, pwd string) {
msg := fmt.Sprintf(`{"email": "%s", "password": "%s"}`, user, pwd)
url := fmt.Sprintf("%s/tokens", serverAddr)
resp, err := httpClient.Post(url, contentType, strings.NewReader(msg))
FormatResLog(resp, err)
}
+75
View File
@@ -0,0 +1,75 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package cli
import (
"fmt"
"io/ioutil"
"net/http"
"github.com/fatih/color"
"github.com/hokaccha/go-prettyjson"
)
const contentType = "application/json"
var Limit = 10
var Offset = 0
func SendRequest(req *http.Request, token string, e error) {
req.Header.Set("Authorization", token)
req.Header.Add("Content-Type", contentType)
if e != nil {
LogError(e)
return
}
resp, err := httpClient.Do(req)
FormatResLog(resp, err)
}
// FormatResLog - format http response
func FormatResLog(resp *http.Response, err error) {
if err != nil {
LogError(err)
return
}
defer resp.Body.Close()
fmt.Printf(color.CyanString("%s %s\nContent-Length: %v\n\n"),
resp.Proto, resp.Status, resp.ContentLength)
if len(resp.Header.Get("Location")) != 0 {
fmt.Printf(color.BlueString("Resource location: %s\n\n"),
resp.Header.Get("Location"))
return
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
LogError(err)
return
}
if len(body) != 0 {
pj, err := prettyjson.Format([]byte(body))
if err != nil {
fmt.Printf("%s\n\n", color.BlueString(string(body)))
return
}
fmt.Printf("%s\n\n", string(pj))
}
}
func LogUsage(u string) {
fmt.Printf(color.YellowString("Usage: %s\n\n"), u)
}
func LogError(err error) {
fmt.Printf("%s\n\n", color.RedString(err.Error()))
}
+31
View File
@@ -0,0 +1,31 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package cli
import (
"fmt"
"github.com/spf13/cobra"
)
func NewVersionCmd() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Get version of Mainflux Things Service",
Long: `Mainflux server health checkt.`,
Run: func(cmd *cobra.Command, args []string) {
Version()
},
}
}
// Version - server health check
func Version() {
url := fmt.Sprintf("%s/version", serverAddr)
FormatResLog(httpClient.Get(url))
}
-1585
View File
File diff suppressed because it is too large Load Diff
+134
View File
@@ -0,0 +1,134 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"fmt"
"net/http"
"os"
"os/signal"
"strings"
"syscall"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
"github.com/gocql/gocql"
"github.com/mainflux/mainflux"
log "github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/readers"
"github.com/mainflux/mainflux/readers/api"
"github.com/mainflux/mainflux/readers/cassandra"
thingsapi "github.com/mainflux/mainflux/things/api/grpc"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
)
const (
sep = ","
defPort = "8180"
defCluster = "127.0.0.1"
defKeyspace = "mainflux"
defThingsURL = "localhost:8181"
envPort = "MF_CASSANDRA_READER_PORT"
envCluster = "MF_CASSANDRA_READER_DB_CLUSTER"
envKeyspace = "MF_CASSANDRA_READER_DB_KEYSPACE"
envThingsURL = "MF_THINGS_URL"
)
type config struct {
port string
cluster string
keyspace string
thingsURL string
}
func main() {
cfg := loadConfig()
logger := log.New(os.Stdout)
session := connectToCassandra(cfg.cluster, cfg.keyspace, logger)
defer session.Close()
conn := connectToThings(cfg.thingsURL, logger)
defer conn.Close()
tc := thingsapi.NewClient(conn)
repo := newService(session, logger)
errs := make(chan error, 2)
go startHTTPServer(repo, tc, cfg.port, errs, logger)
go func() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGINT)
errs <- fmt.Errorf("%s", <-c)
}()
err := <-errs
logger.Error(fmt.Sprintf("Cassandra reader service terminated: %s", err))
}
func loadConfig() config {
return config{
port: mainflux.Env(envPort, defPort),
cluster: mainflux.Env(envCluster, defCluster),
keyspace: mainflux.Env(envKeyspace, defKeyspace),
thingsURL: mainflux.Env(envThingsURL, defThingsURL),
}
}
func connectToCassandra(cluster, keyspace string, logger log.Logger) *gocql.Session {
session, err := cassandra.Connect(strings.Split(cluster, sep), keyspace)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to Cassandra cluster: %s", err))
os.Exit(1)
}
return session
}
func connectToThings(url string, logger log.Logger) *grpc.ClientConn {
conn, err := grpc.Dial(url, grpc.WithInsecure())
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to things service: %s", err))
os.Exit(1)
}
return conn
}
func newService(session *gocql.Session, logger log.Logger) readers.MessageRepository {
repo := cassandra.New(session)
repo = api.LoggingMiddleware(repo, logger)
repo = api.MetricsMiddleware(
repo,
kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "cassandra",
Subsystem: "message_reader",
Name: "request_count",
Help: "Number of requests received.",
}, []string{"method"}),
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "cassandra",
Subsystem: "message_reader",
Name: "request_latency_microseconds",
Help: "Total duration of requests in microseconds.",
}, []string{"method"}),
)
return repo
}
func startHTTPServer(repo readers.MessageRepository, tc mainflux.ThingsServiceClient, port string, errs chan error, logger log.Logger) {
p := fmt.Sprintf(":%s", port)
logger.Info(fmt.Sprintf("Cassandra reader service started, exposed port %s", port))
errs <- http.ListenAndServe(p, api.MakeHandler(repo, tc, "cassandra-reader"))
}
+134
View File
@@ -0,0 +1,134 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"fmt"
"net/http"
"os"
"os/signal"
"strings"
"syscall"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
"github.com/gocql/gocql"
"github.com/mainflux/mainflux"
log "github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/writers"
"github.com/mainflux/mainflux/writers/cassandra"
nats "github.com/nats-io/go-nats"
stdprometheus "github.com/prometheus/client_golang/prometheus"
)
const (
sep = ","
defNatsURL = nats.DefaultURL
defPort = "8180"
defCluster = "127.0.0.1"
defKeyspace = "mainflux"
envNatsURL = "MF_NATS_URL"
envPort = "MF_CASSANDRA_WRITER_PORT"
envCluster = "MF_CASSANDRA_WRITER_DB_CLUSTER"
envKeyspace = "MF_CASSANDRA_WRITER_DB_KEYSPACE"
)
type config struct {
natsURL string
port string
cluster string
keyspace string
}
func main() {
cfg := loadConfig()
logger := log.New(os.Stdout)
nc := connectToNATS(cfg.natsURL, logger)
defer nc.Close()
session := connectToCassandra(cfg.cluster, cfg.keyspace, logger)
defer session.Close()
repo := newService(session, logger)
if err := writers.Start(nc, logger, repo); err != nil {
logger.Error(fmt.Sprintf("Failed to create Cassandra writer: %s", err))
}
errs := make(chan error, 2)
go startHTTPServer(cfg.port, errs, logger)
go func() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGINT)
errs <- fmt.Errorf("%s", <-c)
}()
err := <-errs
logger.Error(fmt.Sprintf("Cassandra writer service terminated: %s", err))
}
func loadConfig() config {
return config{
natsURL: mainflux.Env(envNatsURL, defNatsURL),
port: mainflux.Env(envPort, defPort),
cluster: mainflux.Env(envCluster, defCluster),
keyspace: mainflux.Env(envKeyspace, defKeyspace),
}
}
func connectToNATS(url string, logger log.Logger) *nats.Conn {
nc, err := nats.Connect(url)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
os.Exit(1)
}
return nc
}
func connectToCassandra(cluster, keyspace string, logger log.Logger) *gocql.Session {
session, err := cassandra.Connect(strings.Split(cluster, sep), keyspace)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to Cassandra cluster: %s", err))
os.Exit(1)
}
return session
}
func newService(session *gocql.Session, logger log.Logger) writers.MessageRepository {
repo := cassandra.New(session)
repo = writers.LoggingMiddleware(repo, logger)
repo = writers.MetricsMiddleware(
repo,
kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "cassandra",
Subsystem: "message_writer",
Name: "request_count",
Help: "Number of requests received.",
}, []string{"method"}),
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "cassandra",
Subsystem: "message_writer",
Name: "request_latency_microseconds",
Help: "Total duration of requests in microseconds.",
}, []string{"method"}),
)
return repo
}
func startHTTPServer(port string, errs chan error, logger log.Logger) {
p := fmt.Sprintf(":%s", port)
logger.Info(fmt.Sprintf("Cassandra writer service started, exposed port %s", port))
errs <- http.ListenAndServe(p, cassandra.MakeHandler())
}
+77
View File
@@ -0,0 +1,77 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"log"
"github.com/mainflux/mainflux/cli"
"github.com/spf13/cobra"
)
func main() {
conf := struct {
host string
port int
insecure bool
}{
"localhost",
0,
false,
}
// Root
var rootCmd = &cobra.Command{
Use: "mainflux-cli",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
var proto string
if conf.insecure {
proto = "http"
} else {
proto = "https"
cli.SetCerts()
}
cli.SetServerAddr(proto, conf.host, conf.port)
},
}
// API commands
versionCmd := cli.NewVersionCmd()
usersCmd := cli.NewUsersCmd()
thingsCmd := cli.NewThingsCmd()
channelsCmd := cli.NewChannelsCmd()
messagesCmd := cli.NewMessagesCmd()
// Root Commands
rootCmd.AddCommand(versionCmd)
rootCmd.AddCommand(usersCmd)
rootCmd.AddCommand(thingsCmd)
rootCmd.AddCommand(channelsCmd)
rootCmd.AddCommand(messagesCmd)
// Root Flags
rootCmd.PersistentFlags().StringVarP(
&conf.host, "host", "m", conf.host, "HTTP Host address")
rootCmd.PersistentFlags().IntVarP(
&conf.port, "port", "p", conf.port, "HTTP Host Port")
rootCmd.PersistentFlags().BoolVarP(
&conf.insecure, "insecure", "i", false, "do not use TLS")
// Client and Channels Flags
rootCmd.PersistentFlags().IntVarP(
&cli.Limit, "limit", "l", 100, "limit query parameter")
rootCmd.PersistentFlags().IntVarP(
&cli.Offset, "offset", "o", 0, "offset query parameter")
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}
}
+104
View File
@@ -0,0 +1,104 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
"github.com/mainflux/mainflux"
adapter "github.com/mainflux/mainflux/http"
"github.com/mainflux/mainflux/http/api"
"github.com/mainflux/mainflux/http/nats"
log "github.com/mainflux/mainflux/logger"
thingsapi "github.com/mainflux/mainflux/things/api/grpc"
broker "github.com/nats-io/go-nats"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
)
const (
defPort string = "8180"
defNatsURL string = broker.DefaultURL
defThingsURL string = "localhost:8181"
envPort string = "MF_HTTP_ADAPTER_PORT"
envNatsURL string = "MF_NATS_URL"
envThingsURL string = "MF_THINGS_URL"
)
type config struct {
ThingsURL string
NatsURL string
Port string
}
func main() {
cfg := config{
ThingsURL: mainflux.Env(envThingsURL, defThingsURL),
NatsURL: mainflux.Env(envNatsURL, defNatsURL),
Port: mainflux.Env(envPort, defPort),
}
logger := log.New(os.Stdout)
nc, err := broker.Connect(cfg.NatsURL)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
os.Exit(1)
}
defer nc.Close()
conn, err := grpc.Dial(cfg.ThingsURL, grpc.WithInsecure())
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to things service: %s", err))
os.Exit(1)
}
defer conn.Close()
cc := thingsapi.NewClient(conn)
pub := nats.NewMessagePublisher(nc)
svc := adapter.New(pub)
svc = api.LoggingMiddleware(svc, logger)
svc = api.MetricsMiddleware(
svc,
kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "http_adapter",
Subsystem: "api",
Name: "request_count",
Help: "Number of requests received.",
}, []string{"method"}),
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "http_adapter",
Subsystem: "api",
Name: "request_latency_microseconds",
Help: "Total duration of requests in microseconds.",
}, []string{"method"}),
)
errs := make(chan error, 2)
go func() {
p := fmt.Sprintf(":%s", cfg.Port)
logger.Info(fmt.Sprintf("HTTP adapter service started, exposed port %s", cfg.Port))
errs <- http.ListenAndServe(p, api.MakeHandler(svc, cc))
}()
go func() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGINT)
errs <- fmt.Errorf("%s", <-c)
}()
err = <-errs
logger.Error(fmt.Sprintf("HTTP adapter terminated: %s", err))
}
+141
View File
@@ -0,0 +1,141 @@
package main
import (
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
influxdata "github.com/influxdata/influxdb/client/v2"
"github.com/mainflux/mainflux"
log "github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/readers"
"github.com/mainflux/mainflux/readers/api"
"github.com/mainflux/mainflux/readers/influxdb"
thingsapi "github.com/mainflux/mainflux/things/api/grpc"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
)
const (
defThingsURL = "localhost:8181"
defPort = "8180"
defDBName = "mainflux"
defDBHost = "localhost"
defDBPort = "8086"
defDBUser = "mainflux"
defDBPass = "mainflux"
envThingsURL = "MF_THINGS_URL"
envPort = "MF_INFLUX_READER_PORT"
envDBName = "MF_INFLUX_READER_DB_NAME"
envDBHost = "MF_INFLUX_READER_DB_HOST"
envDBPort = "MF_INFLUX_READER_DB_PORT"
envDBUser = "MF_INFLUX_READER_DB_USER"
envDBPass = "MF_INFLUX_READER_DB_PASS"
)
type config struct {
ThingsURL string
Port string
DBName string
DBHost string
DBPort string
DBUser string
DBPass string
}
func main() {
cfg, clientCfg := loadConfigs()
logger := log.New(os.Stdout)
conn := connectToThings(cfg.ThingsURL, logger)
defer conn.Close()
tc := thingsapi.NewClient(conn)
client, err := influxdata.NewHTTPClient(clientCfg)
if err != nil {
logger.Error(fmt.Sprintf("Failed to create InfluxDB client: %s", err))
os.Exit(1)
}
defer client.Close()
repo, err := influxdb.New(client, cfg.DBName)
if err != nil {
logger.Error(fmt.Sprintf("Failed to create InfluxDB writer: %s", err))
os.Exit(1)
}
errs := make(chan error, 2)
go func() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGINT)
errs <- fmt.Errorf("%s", <-c)
}()
go startHTTPServer(repo, tc, cfg.Port, logger, errs)
err = <-errs
logger.Error(fmt.Sprintf("InfluxDB writer service terminated: %s", err))
}
func loadConfigs() (config, influxdata.HTTPConfig) {
cfg := config{
ThingsURL: mainflux.Env(envThingsURL, defThingsURL),
Port: mainflux.Env(envPort, defPort),
DBName: mainflux.Env(envDBName, defDBName),
DBHost: mainflux.Env(envDBHost, defDBHost),
DBPort: mainflux.Env(envDBPort, defDBPort),
DBUser: mainflux.Env(envDBUser, defDBUser),
DBPass: mainflux.Env(envDBPass, defDBPass),
}
clientCfg := influxdata.HTTPConfig{
Addr: fmt.Sprintf("http://%s:%s", cfg.DBHost, cfg.DBPort),
Username: cfg.DBUser,
Password: cfg.DBPass,
}
return cfg, clientCfg
}
func connectToThings(url string, logger log.Logger) *grpc.ClientConn {
conn, err := grpc.Dial(url, grpc.WithInsecure())
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to things service: %s", err))
os.Exit(1)
}
return conn
}
func newService(client influxdata.Client, logger log.Logger) readers.MessageRepository {
repo, _ := influxdb.New(client, "mainflux")
repo = api.LoggingMiddleware(repo, logger)
repo = api.MetricsMiddleware(
repo,
kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "influxdb",
Subsystem: "message_reader",
Name: "request_count",
Help: "Number of requests received.",
}, []string{"method"}),
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "influxdb",
Subsystem: "message_reader",
Name: "request_latency_microseconds",
Help: "Total duration of requests in microseconds.",
}, []string{"method"}),
)
return repo
}
func startHTTPServer(repo readers.MessageRepository, tc mainflux.ThingsServiceClient, port string, logger log.Logger, errs chan error) {
p := fmt.Sprintf(":%s", port)
logger.Info(fmt.Sprintf("InfluxDB reader service started, exposed port %s", port))
errs <- http.ListenAndServe(p, api.MakeHandler(repo, tc, "influxdb-reader"))
}
+143
View File
@@ -0,0 +1,143 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
influxdata "github.com/influxdata/influxdb/client/v2"
"github.com/mainflux/mainflux"
log "github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/writers"
"github.com/mainflux/mainflux/writers/influxdb"
nats "github.com/nats-io/go-nats"
stdprometheus "github.com/prometheus/client_golang/prometheus"
)
const (
defNatsURL = nats.DefaultURL
defPort = "8180"
defPointName = "messages"
defDBName = "mainflux"
defDBHost = "localhost"
defDBPort = "8086"
defDBUser = "mainflux"
defDBPass = "mainflux"
envNatsURL = "MF_NATS_URL"
envPort = "MF_INFLUX_WRITER_PORT"
envDBName = "MF_INFLUX_WRITER_DB_NAME"
envDBHost = "MF_INFLUX_WRITER_DB_HOST"
envDBPort = "MF_INFLUX_WRITER_DB_PORT"
envDBUser = "MF_INFLUX_WRITER_DB_USER"
envDBPass = "MF_INFLUX_WRITER_DB_PASS"
)
type config struct {
NatsURL string
Port string
DBName string
DBHost string
DBPort string
DBUser string
DBPass string
}
func main() {
cfg, clientCfg := loadConfigs()
logger := log.New(os.Stdout)
nc, err := nats.Connect(cfg.NatsURL)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
os.Exit(1)
}
defer nc.Close()
client, err := influxdata.NewHTTPClient(clientCfg)
if err != nil {
logger.Error(fmt.Sprintf("Failed to create InfluxDB client: %s", err))
os.Exit(1)
}
defer client.Close()
repo, err := influxdb.New(client, cfg.DBName)
if err != nil {
logger.Error(fmt.Sprintf("Failed to create InfluxDB writer: %s", err))
os.Exit(1)
}
counter, latency := makeMetrics()
repo = writers.LoggingMiddleware(repo, logger)
repo = writers.MetricsMiddleware(repo, counter, latency)
if err := writers.Start(nc, logger, repo); err != nil {
logger.Error(fmt.Sprintf("Failed to start message writer: %s", err))
os.Exit(1)
}
errs := make(chan error, 2)
go func() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGINT)
errs <- fmt.Errorf("%s", <-c)
}()
go startHTTPService(cfg.Port, logger, errs)
err = <-errs
logger.Error(fmt.Sprintf("InfluxDB writer service terminated: %s", err))
}
func loadConfigs() (config, influxdata.HTTPConfig) {
cfg := config{
NatsURL: mainflux.Env(envNatsURL, defNatsURL),
Port: mainflux.Env(envPort, defPort),
DBName: mainflux.Env(envDBName, defDBName),
DBHost: mainflux.Env(envDBHost, defDBHost),
DBPort: mainflux.Env(envDBPort, defDBPort),
DBUser: mainflux.Env(envDBUser, defDBUser),
DBPass: mainflux.Env(envDBPass, defDBPass),
}
clientCfg := influxdata.HTTPConfig{
Addr: fmt.Sprintf("http://%s:%s", cfg.DBHost, cfg.DBPort),
Username: cfg.DBUser,
Password: cfg.DBPass,
}
return cfg, clientCfg
}
func makeMetrics() (*kitprometheus.Counter, *kitprometheus.Summary) {
counter := kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "influxdb",
Subsystem: "message_writer",
Name: "request_count",
Help: "Number of database inserts.",
}, []string{"method"})
latency := kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "influxdb",
Subsystem: "message_writer",
Name: "request_latency_microseconds",
Help: "Total duration of inserts in microseconds.",
}, []string{"method"})
return counter, latency
}
func startHTTPService(port string, logger log.Logger, errs chan error) {
p := fmt.Sprintf(":%s", port)
logger.Info(fmt.Sprintf("Influxdb writer service started, exposed port %s", p))
errs <- http.ListenAndServe(p, influxdb.MakeHandler())
}
+134
View File
@@ -0,0 +1,134 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"context"
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
"github.com/mainflux/mainflux"
log "github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/readers"
"github.com/mainflux/mainflux/readers/api"
"github.com/mainflux/mainflux/readers/mongodb"
thingsapi "github.com/mainflux/mainflux/things/api/grpc"
"github.com/mongodb/mongo-go-driver/mongo"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
)
const (
defThingsURL = "localhost:8181"
defPort = "8180"
defDBName = "mainflux"
defDBHost = "localhost"
defDBPort = "27017"
envThingsURL = "MF_THINGS_URL"
envPort = "MF_MONGO_READER_PORT"
envDBName = "MF_MONGO_READER_DB_NAME"
envDBHost = "MF_MONGO_READER_DB_HOST"
envDBPort = "MF_MONGO_READER_DB_PORT"
)
type config struct {
thingsURL string
port string
dbName string
dbHost string
dbPort string
}
func main() {
cfg := loadConfigs()
logger := log.New(os.Stdout)
conn := connectToThings(cfg.thingsURL, logger)
defer conn.Close()
tc := thingsapi.NewClient(conn)
db := connectToMongoDB(cfg.dbHost, cfg.dbPort, cfg.dbName, logger)
repo := newService(db, logger)
errs := make(chan error, 2)
go func() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGINT)
errs <- fmt.Errorf("%s", <-c)
}()
go startHTTPServer(repo, tc, cfg.port, logger, errs)
err := <-errs
logger.Error(fmt.Sprintf("MongoDB reader service terminated: %s", err))
}
func loadConfigs() config {
return config{
thingsURL: mainflux.Env(envThingsURL, defThingsURL),
port: mainflux.Env(envPort, defPort),
dbName: mainflux.Env(envDBName, defDBName),
dbHost: mainflux.Env(envDBHost, defDBHost),
dbPort: mainflux.Env(envDBPort, defDBPort),
}
}
func connectToMongoDB(host, port, name string, logger log.Logger) *mongo.Database {
client, err := mongo.Connect(context.Background(), fmt.Sprintf("mongodb://%s:%s", host, port), nil)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to database: %s", err))
os.Exit(1)
}
return client.Database(name)
}
func connectToThings(url string, logger log.Logger) *grpc.ClientConn {
conn, err := grpc.Dial(url, grpc.WithInsecure())
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to things service: %s", err))
os.Exit(1)
}
return conn
}
func newService(db *mongo.Database, logger log.Logger) readers.MessageRepository {
repo := mongodb.New(db)
repo = api.LoggingMiddleware(repo, logger)
repo = api.MetricsMiddleware(
repo,
kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "mongodb",
Subsystem: "message_reader",
Name: "request_count",
Help: "Number of requests received.",
}, []string{"method"}),
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "mongodb",
Subsystem: "message_reader",
Name: "request_latency_microseconds",
Help: "Total duration of requests in microseconds.",
}, []string{"method"}),
)
return repo
}
func startHTTPServer(repo readers.MessageRepository, tc mainflux.ThingsServiceClient, port string, logger log.Logger, errs chan error) {
p := fmt.Sprintf(":%s", port)
logger.Info(fmt.Sprintf("Mongo reader service started, exposed port %s", port))
errs <- http.ListenAndServe(p, api.MakeHandler(repo, tc, "cassandra-reader"))
}
+123
View File
@@ -0,0 +1,123 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"context"
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
"github.com/mainflux/mainflux"
log "github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/writers"
mongodb "github.com/mainflux/mainflux/writers/mongodb"
"github.com/mongodb/mongo-go-driver/mongo"
nats "github.com/nats-io/go-nats"
stdprometheus "github.com/prometheus/client_golang/prometheus"
)
const (
defNatsURL = nats.DefaultURL
defPort = "8180"
defDBName = "mainflux"
defDBHost = "localhost"
defDBPort = "27017"
envNatsURL = "MF_NATS_URL"
envPort = "MF_MONGO_WRITER_PORT"
envDBName = "MF_MONGO_WRITER_DB_NAME"
envDBHost = "MF_MONGO_WRITER_DB_HOST"
envDBPort = "MF_MONGO_WRITER_DB_PORT"
)
type config struct {
NatsURL string
Port string
DBName string
DBHost string
DBPort string
}
func main() {
cfg := loadConfigs()
logger := log.New(os.Stdout)
nc, err := nats.Connect(cfg.NatsURL)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
os.Exit(1)
}
defer nc.Close()
client, err := mongo.Connect(context.Background(), fmt.Sprintf("mongodb://%s:%s", cfg.DBHost, cfg.DBPort), nil)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to database: %s", err))
os.Exit(1)
}
db := client.Database(cfg.DBName)
repo := mongodb.New(db)
counter, latency := makeMetrics()
repo = writers.LoggingMiddleware(repo, logger)
repo = writers.MetricsMiddleware(repo, counter, latency)
if err := writers.Start(nc, logger, repo); err != nil {
logger.Error(fmt.Sprintf("Failed to start message writer: %s", err))
os.Exit(1)
}
errs := make(chan error, 2)
go func() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGINT)
errs <- fmt.Errorf("%s", <-c)
}()
go startHTTPService(cfg.Port, logger, errs)
err = <-errs
logger.Error(fmt.Sprintf("MongoDB writer service terminated: %s", err))
}
func loadConfigs() config {
return config{
NatsURL: mainflux.Env(envNatsURL, defNatsURL),
Port: mainflux.Env(envPort, defPort),
DBName: mainflux.Env(envDBName, defDBName),
DBHost: mainflux.Env(envDBHost, defDBHost),
DBPort: mainflux.Env(envDBPort, defDBPort),
}
}
func makeMetrics() (*kitprometheus.Counter, *kitprometheus.Summary) {
counter := kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "mongodb",
Subsystem: "message_writer",
Name: "request_count",
Help: "Number of database inserts.",
}, []string{"method"})
latency := kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "mongodb",
Subsystem: "message_writer",
Name: "request_latency_microseconds",
Help: "Total duration of inserts in microseconds.",
}, []string{"method"})
return counter, latency
}
func startHTTPService(port string, logger log.Logger, errs chan error) {
p := fmt.Sprintf(":%s", port)
logger.Info(fmt.Sprintf("Mongodb writer service started, exposed port %s", p))
errs <- http.ListenAndServe(p, mongodb.MakeHandler())
}
+91
View File
@@ -0,0 +1,91 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
"github.com/mainflux/mainflux"
log "github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/normalizer"
"github.com/mainflux/mainflux/normalizer/api"
"github.com/mainflux/mainflux/normalizer/nats"
broker "github.com/nats-io/go-nats"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
stdprometheus "github.com/prometheus/client_golang/prometheus"
)
const (
defNatsURL string = broker.DefaultURL
defPort string = "8180"
envNatsURL string = "MF_NATS_URL"
envPort string = "MF_NORMALIZER_PORT"
)
type config struct {
NatsURL string
Port string
}
func main() {
cfg := config{
NatsURL: mainflux.Env(envNatsURL, defNatsURL),
Port: mainflux.Env(envPort, defPort),
}
logger := log.New(os.Stdout)
nc, err := broker.Connect(cfg.NatsURL)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
os.Exit(1)
}
defer nc.Close()
svc := normalizer.New()
svc = api.LoggingMiddleware(svc, logger)
svc = api.MetricsMiddleware(
svc,
kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "normalizer",
Subsystem: "api",
Name: "request_count",
Help: "Number of requests received.",
}, []string{"method"}),
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "normalizer",
Subsystem: "api",
Name: "request_latency_microseconds",
Help: "Total duration of requests in microseconds.",
}, []string{"method"}),
)
errs := make(chan error, 2)
go func() {
p := fmt.Sprintf(":%s", cfg.Port)
logger.Info(fmt.Sprintf("Normalizer service started, exposed port %s", cfg.Port))
errs <- http.ListenAndServe(p, api.MakeHandler())
}()
go func() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGINT)
errs <- fmt.Errorf("%s", <-c)
}()
nats.Subscribe(svc, nc, logger)
err = <-errs
logger.Error(fmt.Sprintf("Normalizer service terminated: %s", err))
}
+163
View File
@@ -0,0 +1,163 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"database/sql"
"fmt"
"net"
"net/http"
"os"
"os/signal"
"syscall"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
"github.com/mainflux/mainflux"
log "github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/things"
"github.com/mainflux/mainflux/things/api"
grpcapi "github.com/mainflux/mainflux/things/api/grpc"
httpapi "github.com/mainflux/mainflux/things/api/http"
"github.com/mainflux/mainflux/things/postgres"
"github.com/mainflux/mainflux/things/uuid"
usersapi "github.com/mainflux/mainflux/users/api/grpc"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
)
const (
defDBHost = "localhost"
defDBPort = "5432"
defDBUser = "mainflux"
defDBPass = "mainflux"
defDBName = "things"
defHTTPPort = "8180"
defGRPCPort = "8181"
defUsersURL = "localhost:8181"
envDBHost = "MF_THINGS_DB_HOST"
envDBPort = "MF_THINGS_DB_PORT"
envDBUser = "MF_THINGS_DB_USER"
envDBPass = "MF_THINGS_DB_PASS"
envDBName = "MF_THINGS_DB"
envHTTPPort = "MF_THINGS_HTTP_PORT"
envGRPCPort = "MF_THINGS_GRPC_PORT"
envUsersURL = "MF_USERS_URL"
)
type config struct {
DBHost string
DBPort string
DBUser string
DBPass string
DBName string
HTTPPort string
GRPCPort string
UsersURL string
}
func main() {
cfg := loadConfig()
logger := log.New(os.Stdout)
db := connectToDB(cfg, logger)
defer db.Close()
conn := connectToUsersService(cfg.UsersURL, logger)
defer conn.Close()
svc := newService(conn, db, logger)
errs := make(chan error, 2)
go startHTTPServer(svc, cfg.HTTPPort, logger, errs)
go startGRPCServer(svc, cfg.GRPCPort, logger, errs)
go func() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGINT)
errs <- fmt.Errorf("%s", <-c)
}()
err := <-errs
logger.Error(fmt.Sprintf("Things service terminated: %s", err))
}
func loadConfig() config {
return config{
DBHost: mainflux.Env(envDBHost, defDBHost),
DBPort: mainflux.Env(envDBPort, defDBPort),
DBUser: mainflux.Env(envDBUser, defDBUser),
DBPass: mainflux.Env(envDBPass, defDBPass),
DBName: mainflux.Env(envDBName, defDBName),
HTTPPort: mainflux.Env(envHTTPPort, defHTTPPort),
GRPCPort: mainflux.Env(envGRPCPort, defGRPCPort),
UsersURL: mainflux.Env(envUsersURL, defUsersURL),
}
}
func connectToDB(cfg config, logger log.Logger) *sql.DB {
db, err := postgres.Connect(cfg.DBHost, cfg.DBPort, cfg.DBName, cfg.DBUser, cfg.DBPass)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to postgres: %s", err))
os.Exit(1)
}
return db
}
func connectToUsersService(usersAddr string, logger log.Logger) *grpc.ClientConn {
conn, err := grpc.Dial(usersAddr, grpc.WithInsecure())
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to users service: %s", err))
os.Exit(1)
}
return conn
}
func newService(conn *grpc.ClientConn, db *sql.DB, logger log.Logger) things.Service {
users := usersapi.NewClient(conn)
thingsRepo := postgres.NewThingRepository(db, logger)
channelsRepo := postgres.NewChannelRepository(db, logger)
idp := uuid.New()
svc := things.New(users, thingsRepo, channelsRepo, idp)
svc = api.LoggingMiddleware(svc, logger)
svc = api.MetricsMiddleware(
svc,
kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "things",
Subsystem: "api",
Name: "request_count",
Help: "Number of requests received.",
}, []string{"method"}),
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "things",
Subsystem: "api",
Name: "request_latency_microseconds",
Help: "Total duration of requests in microseconds.",
}, []string{"method"}),
)
return svc
}
func startHTTPServer(svc things.Service, port string, logger log.Logger, errs chan error) {
p := fmt.Sprintf(":%s", port)
logger.Info(fmt.Sprintf("Things service started, exposed port %s", port))
errs <- http.ListenAndServe(p, httpapi.MakeHandler(svc))
}
func startGRPCServer(svc things.Service, port string, logger log.Logger, errs chan error) {
p := fmt.Sprintf(":%s", port)
listener, err := net.Listen("tcp", p)
if err != nil {
logger.Error(fmt.Sprintf("Failed to listen on port %s: %s", port, err))
}
server := grpc.NewServer()
mainflux.RegisterThingsServiceServer(server, grpcapi.NewServer(svc))
logger.Info(fmt.Sprintf("Things gRPC service started, exposed port %s", port))
errs <- server.Serve(listener)
}
+150
View File
@@ -0,0 +1,150 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"database/sql"
"fmt"
"net"
"net/http"
"os"
"os/signal"
"syscall"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
"github.com/mainflux/mainflux"
log "github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/users"
"github.com/mainflux/mainflux/users/api"
grpcapi "github.com/mainflux/mainflux/users/api/grpc"
httpapi "github.com/mainflux/mainflux/users/api/http"
"github.com/mainflux/mainflux/users/bcrypt"
"github.com/mainflux/mainflux/users/jwt"
"github.com/mainflux/mainflux/users/postgres"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
)
const (
defDBHost = "localhost"
defDBPort = "5432"
defDBUser = "mainflux"
defDBPass = "mainflux"
defDBName = "users"
defHTTPPort = "8180"
defGRPCPort = "8181"
defSecret = "users"
envDBHost = "MF_USERS_DB_HOST"
envDBPort = "MF_USERS_DB_PORT"
envDBUser = "MF_USERS_DB_USER"
envDBPass = "MF_USERS_DB_PASS"
envDBName = "MF_USERS_DB"
envHTTPPort = "MF_USERS_HTTP_PORT"
envGRPCPort = "MF_USERS_GRPC_PORT"
envSecret = "MF_USERS_SECRET"
)
type config struct {
DBHost string
DBPort string
DBUser string
DBPass string
DBName string
HTTPPort string
GRPCPort string
Secret string
}
func main() {
cfg := loadConfig()
logger := log.New(os.Stdout)
db := connectToDB(cfg, logger)
defer db.Close()
svc := newService(db, cfg.Secret, logger)
errs := make(chan error, 2)
go startHTTPServer(svc, cfg.HTTPPort, logger, errs)
go startGRPCServer(svc, cfg.GRPCPort, logger, errs)
go func() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGINT)
errs <- fmt.Errorf("%s", <-c)
}()
err := <-errs
logger.Error(fmt.Sprintf("Users service terminated: %s", err))
}
func loadConfig() config {
return config{
DBHost: mainflux.Env(envDBHost, defDBHost),
DBPort: mainflux.Env(envDBPort, defDBPort),
DBUser: mainflux.Env(envDBUser, defDBUser),
DBPass: mainflux.Env(envDBPass, defDBPass),
DBName: mainflux.Env(envDBName, defDBName),
HTTPPort: mainflux.Env(envHTTPPort, defHTTPPort),
GRPCPort: mainflux.Env(envGRPCPort, defGRPCPort),
Secret: mainflux.Env(envSecret, defSecret),
}
}
func connectToDB(cfg config, logger log.Logger) *sql.DB {
db, err := postgres.Connect(cfg.DBHost, cfg.DBPort, cfg.DBName, cfg.DBUser, cfg.DBPass)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to postgres: %s", err))
os.Exit(1)
}
return db
}
func newService(db *sql.DB, secret string, logger log.Logger) users.Service {
repo := postgres.New(db)
hasher := bcrypt.New()
idp := jwt.New(secret)
svc := users.New(repo, hasher, idp)
svc = api.LoggingMiddleware(svc, logger)
svc = api.MetricsMiddleware(
svc,
kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "users",
Subsystem: "api",
Name: "request_count",
Help: "Number of requests received.",
}, []string{"method"}),
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "users",
Subsystem: "api",
Name: "request_latency_microseconds",
Help: "Total duration of requests in microseconds.",
}, []string{"method"}),
)
return svc
}
func startHTTPServer(svc users.Service, port string, logger log.Logger, errs chan error) {
p := fmt.Sprintf(":%s", port)
logger.Info(fmt.Sprintf("Users HTTP service started, exposed port %s", port))
errs <- http.ListenAndServe(p, httpapi.MakeHandler(svc, logger))
}
func startGRPCServer(svc users.Service, port string, logger log.Logger, errs chan error) {
p := fmt.Sprintf(":%s", port)
listener, err := net.Listen("tcp", p)
if err != nil {
logger.Error(fmt.Sprintf("Failed to listen on port %s: %s", port, err))
}
server := grpc.NewServer()
mainflux.RegisterUsersServiceServer(server, grpcapi.NewServer(svc))
logger.Info(fmt.Sprintf("Users gRPC service started, exposed port %s", port))
errs <- server.Serve(listener)
}
+103
View File
@@ -0,0 +1,103 @@
//
// Copyright (c) 2018
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
"github.com/mainflux/mainflux"
log "github.com/mainflux/mainflux/logger"
thingsapi "github.com/mainflux/mainflux/things/api/grpc"
adapter "github.com/mainflux/mainflux/ws"
"github.com/mainflux/mainflux/ws/api"
"github.com/mainflux/mainflux/ws/nats"
broker "github.com/nats-io/go-nats"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
)
const (
defPort = "8180"
defNatsURL = broker.DefaultURL
defThingsURL = "localhost:8181"
envPort = "MF_WS_ADAPTER_PORT"
envNatsURL = "MF_NATS_URL"
envThingsURL = "MF_THINGS_URL"
)
type config struct {
ThingsURL string
NatsURL string
Port string
}
func main() {
cfg := config{
ThingsURL: mainflux.Env(envThingsURL, defThingsURL),
NatsURL: mainflux.Env(envNatsURL, defNatsURL),
Port: mainflux.Env(envPort, defPort),
}
logger := log.New(os.Stdout)
nc, err := broker.Connect(cfg.NatsURL)
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
os.Exit(1)
}
defer nc.Close()
conn, err := grpc.Dial(cfg.ThingsURL, grpc.WithInsecure())
if err != nil {
logger.Error(fmt.Sprintf("Failed to connect to users service: %s", err))
os.Exit(1)
}
defer conn.Close()
cc := thingsapi.NewClient(conn)
pubsub := nats.New(nc)
svc := adapter.New(pubsub)
svc = api.LoggingMiddleware(svc, logger)
svc = api.MetricsMiddleware(
svc,
kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "ws_adapter",
Subsystem: "api",
Name: "request_count",
Help: "Number of requests received.",
}, []string{"method"}),
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "ws_adapter",
Subsystem: "api",
Name: "request_latency_microseconds",
Help: "Total duration of requests in microseconds.",
}, []string{"method"}),
)
errs := make(chan error, 2)
go func() {
p := fmt.Sprintf(":%s", cfg.Port)
logger.Info(fmt.Sprintf("WebSocket adapter service started, exposed port %s", cfg.Port))
errs <- http.ListenAndServe(p, api.MakeHandler(svc, cc, logger))
}()
go func() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGINT)
errs <- fmt.Errorf("%s", <-c)
}()
err = <-errs
logger.Error(fmt.Sprintf("WebSocket adapter terminated: %s", err))
}
+60
View File
@@ -0,0 +1,60 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "mainflux-ui"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.png"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.scss"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"component": {}
}
}
+13
View File
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
+58
View File
@@ -0,0 +1,58 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
# dependencies
/node_modules
/bower_components
# IDEs and editors
/.idea
/.vscode
/out-tsc
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# misc
/.sass-cache
/connect.lock
/coverage/*
/coverage
/libpeerconnection.log
npm-debug.log
testem.log
/typings
# e2e
/e2e/*.js
/e2e/*.map
#System Files
.DS_Store
Thumbs.db
#json-server database
db.json
db.*
# System Files
.DS_Store
Thumbs.db
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+73
View File
@@ -0,0 +1,73 @@
# Mainflux UI Dashboad
Mainflux UI, dashboard for [Mainflux](https://github.com/mainflux/mainflux) Industrial IoT Messaging and Device Management Server.
> **N.B.** Mainflux UI service is WIP and not suitable for deployment at this moment. You are welcome to contribute and improve it.
> ## Development
>- Follow angular-cli [documentation](https://github.com/angular/angular-cli)
>- Follow [official angular style guide](https://angular.io/styleguide)
## Requirements
You'll need the following software installed to get started.
- [Node](https://nodejs.org/en/) 6 or higher, we recommend current LTS version, together with NPM 3 or higher.
- [Angular-cli](https://github.com/angular/angular-cli) Newest version with Webpack integration
- - Depending on how Node is configured on your machine, you may need to run installation command with `sudo`
- [Git](http://git-scm.com/downloads): Use the installer for your OS.
- Windows users can also try [Git for Windows](http://git-for-windows.github.io/).
- For local Development with [Mainflux composition](https://github.com/mainflux/mainflux) running locally, [Chrome extension for Cross origin](https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?utm_source=chrome-app-launcher-info-dialog) is required. Because composition is running on different port then our Angular app, we have cross origin.
## Configuration
Change into the directory.
```bash
cd dashflux
```
Install the dependencies. If you're running Mac OS or Linux, you may need to run `sudo npm install` instead, depending on how your machine is configured.
```bash
npm install
```
Set appropriate endpoint URLs in **environment.ts** (for local development will probably be 0.0.0.0:<_port_>) or **environment.prod.ts** for production.
To start the server, run:
```bash
ng serve
```
This will run and assemble our app.
**Now go to `localhost:4200` in your browser to see it in action.**
## Deployment
Dashflux is distributed as Docker container. We use nginx to serve dashflux from docker container, supporting environments using docker multi-stage builds.
Dashflux docker image is available on [Dockerhub mainflux/dashflux](https://hub.docker.com/r/mainflux/dashflux/)
If you want to build image locally, you can build image using the **development** environment:
```bash
docker build -f docker/Dockerfile -t dashflux:dev --build-arg env=dev .
```
Build image using the **production** environment:
```bash
docker build -t dashflux:prod -f ./docker/Dockerfile .
```
**Note:** before running *docker build* command, please make sure appropriate endpoint URLs in *environment.ts* or *environment.prod.ts* are set up.
You can test image running
```bash
docker run -p 80:80 dashflux:dev
```
This will run dashflux in docker container.
Now go to `http://localhost` in your browser to see it in action.
+1
View File
@@ -0,0 +1 @@
node_modules
+13
View File
@@ -0,0 +1,13 @@
# Stage 0, based on Node.js, to build and compile Angular
FROM node:9.5 as node
WORKDIR /app
COPY package.json /app/
RUN npm install
COPY ./ /app/
ARG env=prod
RUN npm run build -- --prod --environment $env
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:1.13-alpine
COPY --from=node /app/dist/ /usr/share/nginx/html
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
+8
View File
@@ -0,0 +1,8 @@
server {
listen 3000;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
+14
View File
@@ -0,0 +1,14 @@
import { AppPage } from './app.po';
describe('mainflux-ui App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('Welcome to app!');
});
});
+11
View File
@@ -0,0 +1,11 @@
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() {
return browser.get('/');
}
getParagraphText() {
return element(by.css('app-root h1')).getText();
}
}
+14
View File
@@ -0,0 +1,14 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"baseUrl": "./",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}
+33
View File
@@ -0,0 +1,33 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
singleRun: false
});
};
+10394
View File
File diff suppressed because it is too large Load Diff
+57
View File
@@ -0,0 +1,57 @@
{
"name": "mainflux-ui",
"version": "0.1.0",
"license": "Apache License, version 2.0",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy-config.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.4",
"@angular/common": "^5.2.4",
"@angular/compiler": "^5.2.4",
"@angular/core": "^5.2.4",
"@angular/flex-layout": "2.0.0-beta.10-4905443",
"@angular/forms": "^5.2.4",
"@angular/http": "^5.2.4",
"@angular/platform-browser": "^5.2.4",
"@angular/platform-browser-dynamic": "^5.2.4",
"@angular/router": "^5.2.4",
"core-js": "^2.4.1",
"mobx": "^3.5.1",
"mobx-angular": "^2.1.1",
"ngx-auth": "^2.2.0",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cdk": "^5.2.0",
"@angular/cli": "^1.7.3",
"@angular/compiler-cli": "^5.2.4",
"@angular/language-service": "^5.2.4",
"@angular/material": "^5.2.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "^6.0.100",
"codelyzer": "~3.2.0",
"hammerjs": "^2.0.8",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.4",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
}
+28
View File
@@ -0,0 +1,28 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
+9
View File
@@ -0,0 +1,9 @@
{
"/api/*": {
"target": "http://localhost:8180",
"secure":false,
"pathRewrite": {
"^/api": ""
}
}
}
+35
View File
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { Route, RouterModule } from '@angular/router';
import { ProtectedGuard, PublicGuard } from 'ngx-auth';
import { LoginComponent } from './components/auth/login/login.component';
import { SignupComponent } from './components/auth/signup/signup.component';
import { ChannelsComponent } from './components/channels/channels.component';
import { ThingsComponent } from './components/things/things.component';
const routes: Route[] = [
{ path: '', redirectTo: 'things', pathMatch: 'full'},
{ path: 'login', component: LoginComponent, canActivate: [PublicGuard]},
{ path: 'signup', component: SignupComponent, canActivate: [PublicGuard]},
{ path: 'things', component: ThingsComponent, canActivate: [ProtectedGuard]},
{ path: 'channels', component: ChannelsComponent, canActivate: [ProtectedGuard]}
];
@NgModule({
imports: [
CommonModule,
RouterModule.forRoot(routes)
],
exports: [
RouterModule
]
})
export class AppRoutingModule { }
+22
View File
@@ -0,0 +1,22 @@
<!--
Copyright (c) 2018
Mainflux
SPDX-License-Identifier: Apache-2.0
-->
<div *mobxAutorun>
<div class="loading" *ngIf="uiStore.loading" fxLayoutAlign="center center">
<mat-progress-spinner [mode]="'indeterminate'"></mat-progress-spinner>
</div>
<mat-toolbar color="primary" class="mat-elevation-z6">
<h1 fxFlex>Mainflux</h1>
<ng-container *ngIf="authStore.isAuthenticated">
<a [routerLink]="['/things']" mat-button>Things</a>
<a [routerLink]="['/channels']" mat-button>Channels</a>
<a (click)="logout()" mat-button>Logout</a>
</ng-container>
</mat-toolbar>
<router-outlet></router-outlet>
</div>
+13
View File
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
.loading {
position: absolute;
width: 100%;
height: 100%;
z-index: 999;
}
+47
View File
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { HttpClientModule } from '@angular/common/http';
import { async, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
import { MaterialModule } from './core/material/material.module';
import { AuthenticationService } from './core/services/auth/authentication.service';
import { TokenStorage } from './core/services/auth/token-storage.service';
import { ChannelsService } from './core/services/channels/channels.service';
import { ThingsService } from './core/services/things/things.service';
import { UiStore } from './core/store/ui.store';
import { AuthStore } from './core/store/auth.store';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
imports: [
MaterialModule,
HttpClientModule,
RouterTestingModule
],
providers: [
UiStore,
AuthStore,
AuthenticationService,
TokenStorage,
ThingsService,
ChannelsService,
]
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
});
+40
View File
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { Component, OnInit } from '@angular/core';
import { MatSnackBar } from '@angular/material';
import { reaction } from 'mobx';
import { UiStore } from './core/store/ui.store';
import { AuthStore } from './core/store/auth.store';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
constructor(
private snackBar: MatSnackBar,
public uiStore: UiStore,
public authStore: AuthStore,
) { }
ngOnInit() {
reaction(() => this.authStore.authError, (authError) => {
if (authError) {
this.snackBar.open(authError, '', {
duration: 3000
});
}
});
}
logout() {
this.authStore.logout();
}
}
+99
View File
@@ -0,0 +1,99 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import './rxjs-extensions.ts';
import 'hammerjs';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { APP_BASE_HREF } from '@angular/common';
import { NgModule } from '@angular/core';
import { FlexLayoutModule } from '@angular/flex-layout';
import { ReactiveFormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MobxAngularModule } from 'mobx-angular';
import { AUTH_SERVICE, AuthModule, PROTECTED_FALLBACK_PAGE_URI, PUBLIC_FALLBACK_PAGE_URI } from 'ngx-auth';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { LoginComponent } from './components/auth/login/login.component';
import { SignupComponent } from './components/auth/signup/signup.component';
import { ChannelDialogComponent } from './components/channels/channel-dialog/channel-dialog.component';
import { ChannelsComponent } from './components/channels/channels.component';
import { ThingDialogComponent } from './components/things/thing-dialog/thing-dialog.component';
import { ThingsComponent } from './components/things/things.component';
import { ConfirmationDialogComponent } from './components/shared/confirmation-dialog/confirmation-dialog.component';
import { MaterialModule } from './core/material/material.module';
import { AuthenticationService } from './core/services/auth/authentication.service';
import { TokenStorage } from './core/services/auth/token-storage.service';
import { ChannelsService } from './core/services/channels/channels.service';
import { ThingsService } from './core/services/things/things.service';
import { MockAuthService } from './core/services/mock-auth.service';
import { MockChannelsService } from './core/services/mock-channels.service';
import { MockThingsService } from './core/services/mock-things.service';
import { ChannelsStore } from './core/store/channels.store';
import { ThingsStore } from './core/store/things.store';
import { UiStore } from './core/store/ui.store';
import { AuthStore } from './core/store/auth.store';
import { UnauthorizedInterceptor } from './core/services/auth/unauthorized.interceptor';
export function factory(authenticationService: AuthenticationService) {
return authenticationService;
}
@NgModule({
declarations: [
AppComponent,
ThingsComponent,
ChannelsComponent,
SignupComponent,
LoginComponent,
ThingDialogComponent,
ConfirmationDialogComponent,
ChannelDialogComponent,
],
imports: [
AuthModule,
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule,
HttpClientModule,
MaterialModule,
FlexLayoutModule,
ReactiveFormsModule,
MobxAngularModule,
],
providers: [
UiStore,
ThingsStore,
ChannelsStore,
AuthStore,
MockAuthService,
MockThingsService,
MockChannelsService,
ThingsService,
ChannelsService,
TokenStorage,
AuthenticationService,
{ provide: PROTECTED_FALLBACK_PAGE_URI, useValue: '/' },
{ provide: PUBLIC_FALLBACK_PAGE_URI, useValue: '/login' },
{
provide: AUTH_SERVICE,
deps: [AuthenticationService],
useFactory: factory
},
{ provide: HTTP_INTERCEPTORS, useClass: UnauthorizedInterceptor, multi: true },
{ provide: APP_BASE_HREF, useValue: '/app/' }
],
bootstrap: [AppComponent],
entryComponents: [
ThingDialogComponent,
ChannelDialogComponent,
ConfirmationDialogComponent
]
})
export class AppModule { }
@@ -0,0 +1,35 @@
<!--
Copyright (c) 2018
Mainflux
SPDX-License-Identifier: Apache-2.0
-->
<div class="container" style="height: 80vh" fxLayoutAlign="center center">
<form fxLayout="column" [formGroup]="loginForm" (ngSubmit)="login()" fxFlex="30%" fxFlex.sm="70%" fxFlex.xs="90%">
<mat-card>
<mat-card-title>Login</mat-card-title>
<mat-card-content class="loginCard" fxLayout="column" fxLayoutAlign="space-evenly">
<mat-form-field fxFlex="40%">
<input type="text" class="emailInput" required matInput placeholder="Email" formControlName="email"/>
<mat-error *ngIf="loginForm.get('email').errors?.required">
Email is required
</mat-error>
<mat-error *ngIf="loginForm.get('email').errors?.email">
Email must be valid
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="30%">
<input type="password" class="passwordInput" required matInput placeholder="Password" formControlName="password" />
<mat-error *ngIf="loginForm.get('password').errors?.required">
Password is required
</mat-error>
</mat-form-field>
</mat-card-content>
<mat-card-actions fxLayout="column">
<button type="submit" [disabled]="loginForm.invalid" mat-raised-button color="primary" class="loginButton">Login</button>
<button mat-button (click)="signup()" class="signupButton">Sign Up with Email</button>
</mat-card-actions>
</mat-card>
</form>
</div>
@@ -0,0 +1,10 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
::ng-deep mat-card-content.loginCard {
height: 200px;
}
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { HttpClientModule } from '@angular/common/http';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { MaterialModule } from '../../../core/material/material.module';
import { AuthenticationService } from '../../../core/services/auth/authentication.service';
import { TokenStorage } from '../../../core/services/auth/token-storage.service';
import { LoginComponent } from './login.component';
import { UiStore } from '../../../core/store/ui.store';
import { AuthStore } from '../../../core/store/auth.store';
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoginComponent ],
imports: [
MaterialModule,
HttpClientModule,
RouterTestingModule,
FormsModule,
ReactiveFormsModule,
NoopAnimationsModule
],
providers: [
UiStore,
AuthStore,
AuthenticationService,
TokenStorage,
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should call the store goToSignup when clicked on Sign Up with Email', inject([UiStore], (store: UiStore) => {
const signupButton = fixture.debugElement.nativeElement.querySelector('.signupButton');
const signupSpy = spyOn(store, 'goToSignup').and.stub();
signupButton.click();
fixture.detectChanges();
expect(signupSpy).toHaveBeenCalled();
}));
});
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { UiStore } from '../../../core/store/ui.store';
import { AuthStore } from '../../../core/store/auth.store';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
loginForm: FormGroup;
constructor(
private fb: FormBuilder,
private uiStore: UiStore,
private authStore: AuthStore,
) { }
ngOnInit() {
this.loginForm = this.fb.group({
email: ['', [Validators.required, Validators.email]],
password: ['', [Validators.required]],
});
}
login() {
this.authStore.login(this.getUserDataFromForm());
}
signup() {
this.uiStore.goToSignup();
}
getUserDataFromForm() {
return {
email: this.loginForm.get('email').value,
password: this.loginForm.get('password').value
};
}
}
@@ -0,0 +1,41 @@
<!--
Copyright (c) 2018
Mainflux
SPDX-License-Identifier: Apache-2.0
-->
<div class="container" style="height: 80vh" fxLayoutAlign="center center">
<form fxLayout="column" [formGroup]="signupForm" (ngSubmit)="signup()" fxFlex="30%" fxFlex.sm="70%" fxFlex.xs="90%">
<mat-card>
<mat-card-title>Signup</mat-card-title>
<mat-card-content class="loginCard" fxLayout="column" fxLayoutAlign="space-evenly">
<mat-form-field fxFlex="40%">
<input type="text" required matInput placeholder="Email" formControlName="email"/>
<mat-error *ngIf="signupForm.get('email').errors?.required">
Email is required
</mat-error>
<mat-error *ngIf="signupForm.get('email').errors?.email">
Email must be valid
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="30%" formGroupName="passwords">
<input type="password" required matInput placeholder="Password" formControlName="password" />
<mat-error *ngIf="signupForm.get('passwords.password').errors?.required">
Password is required
</mat-error>
</mat-form-field>
<mat-form-field fxFlex="30%" formGroupName="passwords">
<input type="password" required matInput placeholder="Repeat password" formControlName="repeatPassword" />
<mat-error *ngIf="signupForm.get('passwords.repeatPassword').errors?.required">
Repeat the password
</mat-error>
</mat-form-field>
</mat-card-content>
<mat-card-actions fxLayout="column">
<button type="submit" [disabled]="signupForm.invalid" mat-raised-button color="primary" class="large-button">Signup</button>
<a mat-button (click)="login()">Login</a>
</mat-card-actions>
</mat-card>
</form>
</div>
@@ -0,0 +1,10 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
::ng-deep mat-card-content.loginCard {
height: 200px;
}
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { HttpClientModule } from '@angular/common/http';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { MaterialModule } from '../../../core/material/material.module';
import { AuthenticationService } from '../../../core/services/auth/authentication.service';
import { TokenStorage } from '../../../core/services/auth/token-storage.service';
import { SignupComponent } from './signup.component';
import { AuthStore } from '../../../core/store/auth.store';
import { UiStore } from '../../../core/store/ui.store';
describe('SignupComponent', () => {
let component: SignupComponent;
let fixture: ComponentFixture<SignupComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SignupComponent ],
imports: [
MaterialModule,
HttpClientModule,
RouterTestingModule,
FormsModule,
ReactiveFormsModule,
NoopAnimationsModule
],
providers: [
UiStore,
AuthStore,
AuthenticationService,
TokenStorage
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SignupComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { Component, OnInit } from '@angular/core';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AuthStore } from '../../../core/store/auth.store';
import { UiStore } from '../../../core/store/ui.store';
@Component({
selector: 'app-signup',
templateUrl: './signup.component.html',
styleUrls: ['./signup.component.scss']
})
export class SignupComponent implements OnInit {
signupForm: FormGroup;
constructor(
private fb: FormBuilder,
private uiStore: UiStore,
private authStore: AuthStore,
) { }
ngOnInit() {
this.signupForm = this.fb.group({
email: ['', [Validators.required, Validators.email]],
passwords: this.fb.group({
password: ['', [Validators.required]],
repeatPassword: ['', [Validators.required]]
}, { validator: this.comparePasswords })
});
}
comparePasswords(c: AbstractControl): { [key: string]: boolean } {
const pass = c.get('password');
const repeatPassword = c.get('repeatPassword');
if (pass.value !== repeatPassword.value) {
return { 'match': true };
}
return null;
}
signup() {
this.authStore.signup(this.getUserDataFromForm());
}
login() {
this.uiStore.goToLogin();
}
getUserDataFromForm() {
return {
email: this.signupForm.get('email').value,
password: this.signupForm.get('passwords.password').value
};
}
}
@@ -0,0 +1,29 @@
<!--
Copyright (c) 2018
Mainflux
SPDX-License-Identifier: Apache-2.0
-->
<form [formGroup]="addChannelForm" (ngSubmit)="onAddChannel()">
<h1 *ngIf="!editMode" mat-dialog-title>Add channel</h1>
<h1 *ngIf="editMode" mat-dialog-title>Edit channel</h1>
<div mat-dialog-content fxLayout="column">
<input type="hidden" formControlName="id">
<mat-form-field>
<input matInput tabindex="1" placeholder="Name" formControlName="name" />
<mat-error *ngIf="addChannelForm.get('name').errors?.required">
Name is required
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-select placeholder="Connected things" formControlName="connected" [compareWith]="compareFunction" multiple>
<mat-option *ngFor="let thing of thingsStore.things" [value]="thing">{{thing.name}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<div mat-dialog-actions>
<button mat-button mat-dialog-close>Cancel</button>
<button mat-button mat-raised-button color="primary" type="submit" [disabled]="addChannelForm.invalid">Ok</button>
</div>
</form>
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { HttpClientModule } from '@angular/common/http';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { MaterialModule } from '../../../core/material/material.module';
import { AuthenticationService } from '../../../core/services/auth/authentication.service';
import { TokenStorage } from '../../../core/services/auth/token-storage.service';
import { ChannelsService } from '../../../core/services/channels/channels.service';
import { ThingsService } from '../../../core/services/things/things.service';
import { ChannelDialogComponent } from './channel-dialog.component';
import { ThingsStore } from '../../../core/store/things.store';
import { UiStore } from '../../../core/store/ui.store';
describe('ChannelDialogComponent', () => {
let component: ChannelDialogComponent;
let fixture: ComponentFixture<ChannelDialogComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ChannelDialogComponent ],
imports: [
MaterialModule,
MatDialogModule,
HttpClientModule,
RouterTestingModule,
FormsModule,
ReactiveFormsModule,
NoopAnimationsModule
],
providers: [
ThingsStore,
UiStore,
AuthenticationService,
TokenStorage,
ThingsService,
ChannelsService,
{ provide: MatDialogRef, useValue: {} },
{ provide: MAT_DIALOG_DATA, useValue: [] },
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ChannelDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { Component, EventEmitter, Inject, OnInit, Output } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { toJS } from 'mobx';
import { ThingsStore } from '../../../core/store/things.store';
import { Channel, Thing } from '../../../core/store/models';
@Component({
selector: 'app-channel-dialog',
templateUrl: './channel-dialog.component.html',
styleUrls: ['./channel-dialog.component.scss']
})
export class ChannelDialogComponent implements OnInit {
addChannelForm: FormGroup;
@Output() submit: EventEmitter<Channel> = new EventEmitter<Channel>();
editMode: boolean;
constructor(
private fb: FormBuilder,
private dialogRef: MatDialogRef<ChannelDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: Channel,
public thingsStore: ThingsStore,
) { }
ngOnInit() {
this.addChannelForm = this.fb.group(
{
id: [''],
name: [''],
connected: [[]]
}
);
if (this.data) {
this.editMode = true;
this.addChannelForm.patchValue(toJS(this.data));
} else {
this.editMode = false;
}
}
onAddChannel() {
const channel = this.addChannelForm.value;
this.submit.emit(channel);
this.dialogRef.close();
}
compareFunction(obj1: Thing, obj2: Thing) {
return obj1.id === obj2.id;
}
}
@@ -0,0 +1,56 @@
<!--
Copyright (c) 2018
Mainflux
SPDX-License-Identifier: Apache-2.0
-->
<div class="channelsContainer" fxLayout="row" fxLayoutWrap>
<ng-container [ngSwitch]="channelsStore.channels?.length > 0">
<ng-container *ngSwitchCase="true">
<!-- List -->
<div class="channel-list-container">
<mat-table #table [dataSource]="channelsStore.channels.toJS()" matSort class="mat-cell">
<!-- Columns -->
<ng-container matColumnDef="id">
<mat-header-cell fxFlex="32%" *matHeaderCellDef mat-sort-header>Id</mat-header-cell>
<mat-cell fxFlex="32%" *matCellDef="let row" >{{row.id}}</mat-cell>
</ng-container>
<ng-container matColumnDef="name">
<mat-header-cell fxFlex="30%" *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
<mat-cell fxFlex="30%" *matCellDef="let row"> {{row.name}}</mat-cell>
</ng-container>
<ng-container matColumnDef="connected">
<mat-header-cell fxFlex="30%" *matHeaderCellDef mat-sort-header>Connected</mat-header-cell>
<mat-cell fxFlex="30%" *matCellDef="let row">
<li *ngFor="let item of row.connected"> {{item.id}} </li>
</mat-cell>
</ng-container>
<!-- Actions -->
<ng-container matColumnDef="actions">
<mat-header-cell fxFlex="8%" *matHeaderCellDef mat-sort-header></mat-header-cell>
<mat-cell fxFlex="8%" *matCellDef="let row" >
<button mat-icon-button color="accent" (click)="editChannel(row)">
<mat-icon aria-label="Delete">edit</mat-icon>
</button>
<button mat-icon-button color="accent" (click)="deleteChannel(row)">
<mat-icon aria-label="Delete">delete</mat-icon>
</button>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
</div>
</ng-container>
<ng-container *ngSwitchDefault>
<h3>It looks like you don't have any channels in your account.</h3>
</ng-container>
</ng-container>
</div>
<button mat-mini-fab class="addButton" (click)="addChannel()">
<mat-icon>add</mat-icon>
</button>
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
.addButton {
position: fixed;
bottom: 12px;
right: 12px;
}
/* List container */
.channel-list-container {
width: 100%;
}
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { HttpClientModule } from '@angular/common/http';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { MaterialModule } from '../../core/material/material.module';
import { AuthenticationService } from '../../core/services/auth/authentication.service';
import { TokenStorage } from '../../core/services/auth/token-storage.service';
import { ChannelsService } from '../../core/services/channels/channels.service';
import { ThingsService } from '../../core/services/things/things.service';
import { ChannelsComponent } from './channels.component';
import { ThingsStore } from '../../core/store/things.store';
import { UiStore } from '../../core/store/ui.store';
import { ChannelsStore } from '../../core/store/channels.store';
describe('ChannelsComponent', () => {
let component: ChannelsComponent;
let fixture: ComponentFixture<ChannelsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ChannelsComponent ],
imports: [
MaterialModule,
MatDialogModule,
HttpClientModule,
RouterTestingModule,
FormsModule,
ReactiveFormsModule,
NoopAnimationsModule,
],
providers: [
{
provide: ThingsStore,
useClass: class {
getThings = jasmine.createSpy('getThings');
}
},
UiStore,
{
provide: ChannelsStore,
useClass: class {
getChannels = jasmine.createSpy('getChannels');
}
},
AuthenticationService,
TokenStorage,
ThingsService,
ChannelsService,
{ provide: MatDialogRef, useValue: {} },
{ provide: MAT_DIALOG_DATA, useValue: [] },
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ChannelsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material';
import { Observable } from 'rxjs/Observable';
import { ChannelsStore } from '../../core/store/channels.store';
import { ThingsStore } from '../../core/store/things.store';
import { Channel } from '../../core/store/models';
import { ConfirmationDialogComponent } from '../shared/confirmation-dialog/confirmation-dialog.component';
import { ChannelDialogComponent } from './channel-dialog/channel-dialog.component';
@Component({
selector: 'app-channels',
templateUrl: './channels.component.html',
styleUrls: ['./channels.component.scss'],
})
export class ChannelsComponent implements OnInit {
channels: Observable<Channel[]>;
displayedColumns = ['id', 'name', 'connected', 'actions'];
constructor(
private dialog: MatDialog,
public thingsStore: ThingsStore,
public channelsStore: ChannelsStore,
) { }
ngOnInit() {
this.channelsStore.getChannels();
this.thingsStore.getThings();
}
addChannel() {
const dialogRef = this.dialog.open(ChannelDialogComponent);
dialogRef.componentInstance.submit.subscribe((channel: Channel) => {
this.channelsStore.addChannel(channel);
});
}
editChannel(channel: Channel) {
const dialogRef = this.dialog.open(ChannelDialogComponent, {
data: channel
});
dialogRef.componentInstance.submit.subscribe((editedChannel: Channel) => {
this.channelsStore.editChannel(editedChannel);
});
}
deleteChannel(channel: Channel) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: {
question: 'Are you sure you want to delete the channel?'
}
});
dialogRef.afterClosed().subscribe((result) => {
if (result) {
this.channelsStore.deleteChannel(channel);
}
});
}
}
@@ -0,0 +1,12 @@
<!--
Copyright (c) 2018
Mainflux
SPDX-License-Identifier: Apache-2.0
-->
<h1 mat-dialog-title>{{data.question}}</h1>
<div mat-dialog-actions fxLayoutAlign="end end">
<button mat-button mat-dialog-close>Cancel</button>
<button mat-button mat-raised-button color="primary" [mat-dialog-close]="true">Ok</button>
</div>
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MaterialModule } from '../../../core/material/material.module';
import { ConfirmationDialogComponent } from './confirmation-dialog.component';
describe('ConfirmationDialogComponent', () => {
let component: ConfirmationDialogComponent;
let fixture: ComponentFixture<ConfirmationDialogComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ConfirmationDialogComponent ],
imports: [
MaterialModule,
MatDialogModule,
FormsModule,
ReactiveFormsModule,
NoopAnimationsModule
],
providers: [
{ provide: MatDialogRef, useValue: {} },
{ provide: MAT_DIALOG_DATA, useValue: [] },
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ConfirmationDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material';
@Component({
selector: 'app-confirmation-dialog',
templateUrl: './confirmation-dialog.component.html',
styleUrls: ['./confirmation-dialog.component.scss']
})
export class ConfirmationDialogComponent implements OnInit {
constructor(@Inject(MAT_DIALOG_DATA) public data: any) { }
ngOnInit() {
}
}
@@ -0,0 +1,34 @@
<form [formGroup]="addThingForm" (ngSubmit)="onAddThing()">
<h1 mat-dialog-title>Add thing</h1>
<div mat-dialog-content fxLayout="column">
<input type="hidden" formControlName="id">
<mat-form-field *ngIf="!editMode">
<mat-select placeholder="Thing type" formControlName="type">
<mat-option value="app">
App
</mat-option>
<mat-option value="device">
Device
</mat-option>
</mat-select>
<mat-error *ngIf="addThingForm.get('type').errors?.required">
Type is required
</mat-error>
</mat-form-field>
<mat-form-field>
<input matInput tabindex="1" placeholder="Name" formControlName="name" />
<mat-error *ngIf="addThingForm.get('name').errors?.required">
Name is required
</mat-error>
</mat-form-field>
<mat-form-field>
<textarea formControlName="metadata" matInput placeholder="Metadata" matTextareaAutosize matAutosizeMinRows="2"
matAutosizeMaxRows="5"></textarea>
</mat-form-field>
</div>
<div mat-dialog-actions>
<button mat-button mat-dialog-close>Cancel</button>
<button mat-button mat-raised-button color="primary" type="submit" [disabled]="addThingForm.invalid">Ok</button>
</div>
</form>
@@ -0,0 +1,52 @@
import { HttpClientModule } from '@angular/common/http';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { MaterialModule } from '../../../core/material/material.module';
import { AuthenticationService } from '../../../core/services/auth/authentication.service';
import { TokenStorage } from '../../../core/services/auth/token-storage.service';
import { ChannelsService } from '../../../core/services/channels/channels.service';
import { ThingsService } from '../../../core/services/things/things.service';
import { ThingDialogComponent } from './thing-dialog.component';
describe('ThingDialogComponent', () => {
let component: ThingDialogComponent;
let fixture: ComponentFixture<ThingDialogComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ThingDialogComponent ],
imports: [
MaterialModule,
MatDialogModule,
HttpClientModule,
RouterTestingModule,
FormsModule,
ReactiveFormsModule,
NoopAnimationsModule
],
providers: [
AuthenticationService,
TokenStorage,
ThingsService,
ChannelsService,
{ provide: MatDialogRef, useValue: {} },
{ provide: MAT_DIALOG_DATA, useValue: [] },
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ThingDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,44 @@
import { Component, EventEmitter, Inject, OnInit, Output } from '@angular/core';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { Thing } from '../../../core/store/models';
@Component({
selector: 'app-thing-dialog',
templateUrl: './thing-dialog.component.html',
styleUrls: ['./thing-dialog.component.scss']
})
export class ThingDialogComponent implements OnInit {
addThingForm: FormGroup;
@Output() submit: EventEmitter<Thing> = new EventEmitter<Thing>();
editMode: boolean;
constructor(
private fb: FormBuilder,
private dialogRef: MatDialogRef<ThingDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: Thing
) { }
ngOnInit() {
this.addThingForm = this.fb.group(
{
id: null,
type: ['', [Validators.required]],
name: ['', [Validators.required, Validators.minLength(5)]],
metadata: ['']
}
);
if (this.data) {
this.editMode = true;
this.addThingForm.patchValue(this.data);
}
}
onAddThing() {
const thing = this.addThingForm.value;
this.submit.emit(thing);
this.dialogRef.close();
}
}
@@ -0,0 +1,58 @@
<!--
Copyright (c) 2018
Mainflux
SPDX-License-Identifier: Apache-2.0
-->
<div class="thingsContainer" fxLayout="row" fxLayoutWrap>
<ng-container [ngSwitch]="thingsStore.things?.length > 0">
<ng-container *ngSwitchCase="true">
<!-- List -->
<div class="things-list-container">
<mat-table #table [dataSource]="thingsStore.things.toJS()" matSort class="mat-cell">
<!-- Columns -->
<ng-container matColumnDef="id">
<mat-header-cell fxFlex="32%" *matHeaderCellDef mat-sort-header>Id</mat-header-cell>
<mat-cell fxFlex="32%" *matCellDef="let row" >{{row.id}}</mat-cell>
</ng-container>
<ng-container matColumnDef="name">
<mat-header-cell fxFlex="15%" *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
<mat-cell fxFlex="15%" *matCellDef="let row"> {{row.name}}</mat-cell>
</ng-container>
<ng-container matColumnDef="type">
<mat-header-cell fxFlex="10%" *matHeaderCellDef mat-sort-header>Type</mat-header-cell>
<mat-cell fxFlex="10%" *matCellDef="let row"> {{row.type}}</mat-cell>
</ng-container>
<ng-container matColumnDef="metadata">
<mat-header-cell fxFlex="35%" *matHeaderCellDef mat-sort-header>Metadata</mat-header-cell>
<mat-cell fxFlex="35%" *matCellDef="let row"> {{row.metadata | json}}</mat-cell>
</ng-container>
<!-- Actions -->
<ng-container matColumnDef="actions">
<mat-header-cell fxFlex="8%" *matHeaderCellDef mat-sort-header></mat-header-cell>
<mat-cell fxFlex="8%" *matCellDef="let row" >
<button mat-icon-button color="accent" (click)="editThing(row)">
<mat-icon aria-label="Delete">edit</mat-icon>
</button>
<button mat-icon-button color="accent" (click)="deleteThing(row)">
<mat-icon aria-label="Delete">delete</mat-icon>
</button>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
</div>
</ng-container>
<ng-container *ngSwitchDefault>
<h3 >It looks like you don't have any device in your account.</h3>
</ng-container>
</ng-container>
</div>
<button mat-mini-fab class="addButton" (click)="addThing()">
<mat-icon>add</mat-icon>
</button>
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
.addButton {
position: fixed;
bottom: 12px;
right: 12px;
}
/* List container */
.things-list-container {
width: 100%;
}
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { HttpClientModule } from '@angular/common/http';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { MaterialModule } from '../../core/material/material.module';
import { AuthenticationService } from '../../core/services/auth/authentication.service';
import { TokenStorage } from '../../core/services/auth/token-storage.service';
import { ChannelsService } from '../../core/services/channels/channels.service';
import { ThingsService } from '../../core/services/things/things.service';
import { ThingsComponent } from './things.component';
import { UiStore } from '../../core/store/ui.store';
import { ThingsStore } from '../../core/store/things.store';
import { ChannelsStore } from '../../core/store/channels.store';
describe('ThingsComponent', () => {
let component: ThingsComponent;
let fixture: ComponentFixture<ThingsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ThingsComponent ],
imports: [
MaterialModule,
MatDialogModule,
HttpClientModule,
RouterTestingModule,
FormsModule,
ReactiveFormsModule,
NoopAnimationsModule,
],
providers: [
UiStore,
{
provide: ThingsStore,
useClass: class {
getThings = jasmine.createSpy('getThings');
}
},
ChannelsStore,
AuthenticationService,
TokenStorage,
ThingsService,
ChannelsService,
{ provide: MatDialogRef, useValue: {} },
{ provide: MAT_DIALOG_DATA, useValue: [] },
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ThingsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material';
import { toJS } from 'mobx';
import { Observable } from 'rxjs/Observable';
import { Thing } from '../../core/store/models';
import { ConfirmationDialogComponent } from '../shared/confirmation-dialog/confirmation-dialog.component';
import { ThingDialogComponent } from './thing-dialog/thing-dialog.component';
import { ThingsStore } from '../../core/store/things.store';
import { ChannelsStore } from '../../core/store/channels.store';
@Component({
selector: 'app-things',
templateUrl: './things.component.html',
styleUrls: ['./things.component.scss']
})
export class ThingsComponent implements OnInit {
things: Observable<Thing[]>;
displayedColumns = ['id', 'name', 'type', 'metadata', 'actions'];
constructor(
private dialog: MatDialog,
public thingsStore: ThingsStore,
public channelsStore: ChannelsStore,
) { }
ngOnInit() {
this.thingsStore.getThings();
this.channelsStore.getChannels();
}
addThing() {
const dialogRef = this.dialog.open(ThingDialogComponent);
dialogRef.componentInstance.submit.subscribe((thing: Thing) => {
this.thingsStore.addThing(thing);
});
}
editThing(thing: Thing) {
const dialogRef = this.dialog.open(ThingDialogComponent, {
data: thing
});
dialogRef.componentInstance.submit.subscribe((editedThing: Thing) => {
this.thingsStore.editThing(toJS(editedThing));
});
}
deleteThing(thing: Thing) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: {
question: 'Are you sure you want to delete the thing?'
}
});
dialogRef.afterClosed().subscribe((result) => {
if (result) {
this.thingsStore.deleteThing(toJS(thing));
}
});
}
}
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { NgModule } from '@angular/core';
import {
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatChipsModule,
MatDialogModule,
MatIconModule,
MatInputModule,
MatListModule,
MatMenuModule,
MatProgressSpinnerModule,
MatSelectModule,
MatSidenavModule,
MatSliderModule,
MatSlideToggleModule,
MatSnackBarModule,
MatTabsModule,
MatToolbarModule,
MatTooltipModule,
MatTableModule,
} from '@angular/material';
@NgModule({
imports: [
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatDialogModule,
MatIconModule,
MatInputModule,
MatListModule,
MatMenuModule,
MatProgressSpinnerModule,
MatSelectModule,
MatSidenavModule,
MatSnackBarModule,
MatTabsModule,
MatToolbarModule,
MatTooltipModule,
MatCheckboxModule,
MatSliderModule,
MatSlideToggleModule,
MatChipsModule,
MatTableModule
],
exports: [
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatDialogModule,
MatIconModule,
MatInputModule,
MatListModule,
MatMenuModule,
MatProgressSpinnerModule,
MatSelectModule,
MatSidenavModule,
MatSnackBarModule,
MatTabsModule,
MatToolbarModule,
MatTooltipModule,
MatCheckboxModule,
MatSliderModule,
MatSlideToggleModule,
MatChipsModule,
MatTableModule
],
})
export class MaterialModule { }
@@ -0,0 +1,151 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import '../../../rxjs-extensions';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { AuthService } from 'ngx-auth';
import { Observable } from 'rxjs/Observable';
import { environment } from '../../../../environments/environment';
import { TokenStorage } from './token-storage.service';
interface AccessData {
token: string;
}
@Injectable()
export class AuthenticationService implements AuthService {
constructor(
private http: HttpClient,
private tokenStorage: TokenStorage
) { }
/**
* Check, if user already authorized.
* @description Should return Observable with true or false values
* @returns {Observable<boolean>}
* @memberOf AuthService
*/
public isAuthorized(): Observable<boolean> {
return this.tokenStorage
.getAccessToken()
.map(token => !!token);
}
public getHeaders(token) {
return {
'Authorization': token
};
}
/**
* Get access token
* @description Should return access token in Observable from e.g.
* localStorage
* @returns {Observable<string>}
*/
public getAccessToken(): Observable<string> {
return this.tokenStorage.getAccessToken();
}
/**
* Function, that should perform refresh token verifyTokenRequest
* @description Should be successfully completed so interceptor
* can execute pending requests or retry original one
* @returns {Observable<any>}
*/
public refreshToken(): Observable<AccessData> {
return this.tokenStorage
.getRefreshToken()
.switchMap((refreshToken: string) => {
return this.http.post(`http://localhost:3000/refresh`, { refreshToken });
})
.do(this.saveAccessData.bind(this))
.catch((err) => {
this.logout();
return Observable.throw(err);
});
}
/**
* Function, checks response of failed request to determine,
* whether token be refreshed or not.
* @description Essentialy checks status
* @param {Response} response
* @returns {boolean}
*/
public refreshShouldHappen(response: HttpErrorResponse): boolean {
return response.status === 401;
}
/**
* Verify that outgoing request is refresh-token,
* so interceptor won't intercept this request
* @param {string} url
* @returns {boolean}
*/
public verifyTokenRequest(url: string): boolean {
return url.endsWith('/refresh');
}
/**
* EXTRA AUTH METHODS
*/
public login(payload): Observable<any> {
return this.http.post(environment.loginUrl, payload)
.do((tokens: AccessData) => this.saveAccessData(tokens))
.catch((error) => {
let message = '';
if (error.status === 403) {
message = 'Wrong password or email';
} else {
message = 'Server side error';
}
return Observable.throw(message);
});
}
public signup(payload): Observable<any> {
return this.http.post(environment.signupUrl, payload)
.catch((error) => {
let message = '';
if (error.status === 409) {
message = 'Already existing email address';
} else {
message = 'Server side error';
}
return Observable.throw(message);
});
}
/**
* Logout
*/
public logout(): void {
this.tokenStorage.clear();
}
/**
* Save access data in the storage
*
* @private
* @param {AccessData} data
*/
private saveAccessData({ token }: AccessData) {
this.tokenStorage
.setAccessToken(token);
}
}
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class TokenStorage {
/**
* Get access token
* @returns {Observable<string>}
*/
public getAccessToken(): Observable<string> {
const token: string = <string>localStorage.getItem('accessToken');
return Observable.of(token);
}
/**
* Get refresh token
* @returns {Observable<string>}
*/
public getRefreshToken(): Observable<string> {
const token: string = <string>localStorage.getItem('refreshToken');
return Observable.of(token);
}
/**
* Set access token
* @returns {TokenStorage}
*/
public setAccessToken(token: string): TokenStorage {
localStorage.setItem('accessToken', token);
return this;
}
/**
* Set refresh token
* @returns {TokenStorage}
*/
public setRefreshToken(token: string): TokenStorage {
localStorage.setItem('refreshToken', token);
return this;
}
/**
* Remove tokens
*/
public clear() {
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
}
}
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpErrorResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/do';
import { AuthStore } from '../../store/auth.store';
@Injectable()
export class UnauthorizedInterceptor implements HttpInterceptor {
constructor(
private authStore: AuthStore
) {}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(req).do(event => {}, err => {
if (err instanceof HttpErrorResponse && err.status === 403) {
this.authStore.logout();
}
});
}
}
@@ -0,0 +1,114 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { HttpClient, HttpResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { forkJoin } from 'rxjs/observable/forkJoin';
import { environment } from '../../../../environments/environment';
import { Channel, Thing } from '../../store/models';
interface ChannelsPayload {
channels: Channel[];
}
@Injectable()
export class ChannelsService {
constructor(private http: HttpClient) { }
getChannels() {
return this.http.get(environment.channelsUrl).switchMap((payload: ChannelsPayload) => {
const allChannels = forkJoin(this.createChannelsRequests(payload.channels));
return allChannels;
}).switchMap((responses: Channel[]) => {
responses.forEach(channel => {
channel.connected = channel.connected ? channel.connected : [];
});
return Observable.of(responses);
});
}
createChannelsRequests(channels) {
return channels.map((channel => this.http.get(environment.channelsUrl + '/' + channel.id)));
}
addChannel(channel: Channel) {
const payload = {
name: channel.name
};
if (!channel.connected.length) {
console.log('send add ch');
return this.http.post(environment.channelsUrl, payload);
}
return this.http.post(environment.channelsUrl, payload, { observe: 'response' })
.switchMap((res) => {
const id = this.getChannelIdFrom(res);
return forkJoin(this.createThingsConnectRequests(id, channel.connected));
});
}
private getChannelIdFrom(res: HttpResponse<Object>) {
const location = res.headers.get('Location');
return location.replace('/channels/', '');
}
deleteChannel(channel: Channel) {
return this.http.delete(environment.channelsUrl + '/' + channel.id);
}
editChannel(channelFormData: Channel, channel: Channel) {
const payload = {
name: channelFormData.name
};
const editChannel = this.http.put(environment.channelsUrl + '/' + channel.id, payload);
return editChannel.switchMap(() => {
const thingsToAdd = this.getThingsToAdd(channelFormData, channel);
if (thingsToAdd.length) {
return forkJoin(this.createThingsConnectRequests(channel.id, thingsToAdd));
} else {
return Observable.of([]);
}
}).switchMap(() => {
const thingsToDelete = this.getThingsToDelete(channelFormData, channel);
console.log(thingsToDelete);
if (thingsToDelete.length) {
return forkJoin(this.createThingsDisconnectRequests(channel.id, thingsToDelete));
} else {
return Observable.of([]);
}
});
}
getThingsToDelete(channelFormData: Channel, channel: Channel) {
return channel.connected.filter(thing => {
return channelFormData.connected.find(th => th.id === thing.id) === undefined;
});
}
getThingsToAdd(channelFormData: Channel, channel: Channel) {
return channelFormData.connected.filter(thing => {
return channel.connected.find(th => th.id === thing.id) === undefined;
});
}
createThingsConnectRequests(channelId: string , connected: Thing[]) {
return connected.map((connection) => {
return this.http.put(environment.channelsUrl + '/' + channelId + '/things/' + connection.id, {});
});
}
createThingsDisconnectRequests(channelId: string , connected: Thing[]) {
return connected.map((connection) => {
return this.http.delete(environment.channelsUrl + '/' + channelId + '/things/' + connection.id, {});
});
}
}
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { User } from '../store/models';
export const MOCK_USER = {
email: 'asdf@asdf.com',
password: 'asdf'
};
export const EXISTING_USER = {
email: '1234@1234.com',
password: '1234'
};
export const INVALID_CREDENTIALS_USER = {
email: 'pera@pera.com',
password: 'pera'
};
@Injectable()
export class MockAuthService {
public signup(user: User): Observable<User> {
if (user.email === MOCK_USER.email) {
return Observable.of(user).delay(5000);
}
if (user.email === EXISTING_USER.email) {
return Observable.throw(new Error('User with email already exists.'));
}
return Observable.throw(new Error('Failed connecting to server.'));
}
public login(user: User): Observable<User> {
if (user.email === MOCK_USER.email) {
return Observable.of(user).delay(1000);
}
if (user.email === INVALID_CREDENTIALS_USER.email) {
return Observable.throw(new Error('Invalid credentials'));
}
return Observable.throw(new Error('Cannot connect to server'));
}
}
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Thing } from '../store/models';
const MOCK_CHANNELS = {
channels: [
{
name: 'pera'
},
{
name: 'dzoni'
}
]
};
@Injectable()
export class MockChannelsService {
getChannels() {
return Observable.of(MOCK_CHANNELS).delay(1000);
}
addChannel(client: Thing) {
MOCK_CHANNELS.channels.push(client);
return Observable.of(1).delay(1000);
}
}
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Thing } from '../store/models';
const MOCK_THINGS = [
];
@Injectable()
export class MockThingsService {
getThings() {
return Observable.of(MOCK_THINGS).delay(1000);
}
addThing(thing: Thing) {
MOCK_THINGS.push(thing);
return Observable.of(1).delay(1000);
}
}
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2018
* Mainflux
*
* SPDX-License-Identifier: Apache-2.0
*/
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from '../../../../environments/environment';
import { Thing } from '../../store/models';
@Injectable()
export class ThingsService {
constructor(private http: HttpClient) { }
getThings() {
return this.http.get(environment.thingsUrl);
}
addThing(thing: Thing) {
return this.http.post(environment.thingsUrl, thing);
}
deleteThing(thing: Thing) {
return this.http.delete(environment.thingsUrl + '/' + thing.id);
}
editThing(thing: Thing) {
return this.http.put(environment.thingsUrl + '/' + thing.id, thing);
}
}
@@ -0,0 +1,178 @@
import { HttpClientModule } from '@angular/common/http';
import { inject, TestBed } from '@angular/core/testing';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { Observable } from 'rxjs/Observable';
import { AuthenticationService } from '../services/auth/authentication.service';
import { TokenStorage } from '../services/auth/token-storage.service';
import { ChannelsService } from '../services/channels/channels.service';
import { ThingsService } from '../services/things/things.service';
import { AuthStore } from './auth.store';
import { UiStore } from './ui.store';
describe('AuthStore', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
HttpClientModule,
RouterTestingModule.withRoutes([])
],
providers: [
AuthStore,
UiStore,
TokenStorage,
AuthenticationService,
ThingsService,
ChannelsService,
]
});
});
it('should be created', inject([AuthStore], (authStore: AuthStore) => {
expect(authStore).toBeTruthy();
}));
describe('login', () => {
const user = {
email: 'user@user.com',
password: 'userPassword',
};
it('should set the loading flag to true before calling service', inject([AuthStore, UiStore, AuthenticationService],
(authStore: AuthStore, uiStore: UiStore, authService: AuthenticationService) => {
const spy = spyOn(authService, 'login').and.returnValue({ subscribe: () => { } });
authStore.login(user);
expect(uiStore.loading).toBeTruthy();
}));
it('should set the isAuthenticated flag to true when successfully authenticated', inject([AuthStore, AuthenticationService, Router],
(authStore: AuthStore, authService: AuthenticationService, router: Router) => {
const spy = spyOn(authService, 'login').and.returnValue(Observable.of(true));
const routerSpy = spyOn(router, 'navigate').and.stub();
authStore.login(user);
expect(authStore.isAuthenticated).toBeTruthy();
}));
it('should navigate to /things when successfully authenticated', inject([AuthStore, AuthenticationService, Router],
(authStore: AuthStore, authService: AuthenticationService, router: Router) => {
const spy = spyOn(authService, 'login').and.returnValue(Observable.of(true));
const routerSpy = spyOn(router, 'navigate').and.stub();
authStore.login(user);
expect(routerSpy).toHaveBeenCalledWith(['/things']);
}));
it('should set the loading flag to false when successfully authenticated',
inject([AuthStore, UiStore, AuthenticationService, Router],
(authStore: AuthStore, uiStore: UiStore, authService: AuthenticationService, router: Router) => {
const spy = spyOn(authService, 'login').and.returnValue(Observable.of(true));
const routerSpy = spyOn(router, 'navigate').and.stub();
authStore.login(user);
expect(uiStore.loading).toBeFalsy();
}));
it('should set the loading flag to false when authentication failed', inject([AuthStore, UiStore, AuthenticationService],
(authStore: AuthStore, uiStore: UiStore, authService: AuthenticationService) => {
const spy = spyOn(authService, 'login').and.returnValue(Observable.throw({ status: 403 }));
authStore.login(user);
expect(uiStore.loading).toBeFalsy();
}));
it('should set the authError to authentication error', inject([AuthStore, AuthenticationService],
(authStore: AuthStore, authService: AuthenticationService) => {
const spy = spyOn(authService, 'login').and.returnValue(Observable.throw('Auth failed'));
authStore.login(user);
expect(authStore.authError).toEqual('Auth failed');
}));
});
describe('signup', () => {
const user = {
email: 'user@user.com',
password: 'userPassword',
};
it('should set the loading flag to true before calling service', inject([AuthStore, UiStore, AuthenticationService],
(authStore: AuthStore, uiStore: UiStore, authService: AuthenticationService) => {
const spy = spyOn(authService, 'signup').and.returnValue({ subscribe: () => { } });
authStore.signup(user);
expect(uiStore.loading).toBeTruthy();
}));
it('should call the login when signup successfull', inject([AuthStore, AuthenticationService, Router],
(authStore: AuthStore, authService: AuthenticationService, router: Router) => {
const spy = spyOn(authService, 'signup').and.returnValue(Observable.of(true));
const routerSpy = spyOn(router, 'navigate').and.stub();
const loginSpy = spyOn(authStore, 'login').and.stub();
authStore.signup(user);
expect(loginSpy).toHaveBeenCalled();
}));
it('should set the loading flag to false when signup failed', inject([AuthStore, UiStore, AuthenticationService],
(authStore: AuthStore, uiStore: UiStore, authService: AuthenticationService) => {
const spy = spyOn(authService, 'signup').and.returnValue(Observable.throw('Signup failed'));
authStore.signup(user);
expect(uiStore.loading).toBeFalsy();
}));
it('should set the authError to signup error', inject([AuthStore, AuthenticationService],
(authStore: AuthStore, authService: AuthenticationService) => {
const spy = spyOn(authService, 'signup').and.returnValue(Observable.throw('Signup failed'));
authStore.signup(user);
expect(authStore.authError).toEqual('Signup failed');
}));
});
describe('logout', () => {
it('should call the authentication service logout', inject([AuthStore, AuthenticationService, Router],
(authStore: AuthStore, authService: AuthenticationService, router: Router) => {
const spy = spyOn(authService, 'logout');
const routerSpy = spyOn(router, 'navigate').and.stub();
authStore.logout();
expect(spy).toHaveBeenCalled();
}));
it('should set the isAuthenticated flag to false', inject([AuthStore, AuthenticationService, Router],
(authStore: AuthStore, authService: AuthenticationService, router: Router) => {
const spy = spyOn(authService, 'logout');
const routerSpy = spyOn(router, 'navigate').and.stub();
authStore.logout();
expect(authStore.isAuthenticated).toBeFalsy();
}));
it('should navigate to /login', inject([AuthStore, AuthenticationService, Router],
(authStore: AuthStore, authService: AuthenticationService, router: Router) => {
const spy = spyOn(authService, 'logout');
const routerSpy = spyOn(router, 'navigate').and.stub();
authStore.logout();
expect(routerSpy).toHaveBeenCalledWith(['/login']);
}));
});
});
+63
View File
@@ -0,0 +1,63 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { action, observable } from 'mobx';
import { AuthenticationService } from '../services/auth/authentication.service';
import { User } from './models';
import { UiStore } from './ui.store';
@Injectable()
export class AuthStore {
@observable isAuthenticated = false;
@observable authError = '';
constructor(
private authenticationService: AuthenticationService,
private uiState: UiStore,
private router: Router,
) {
this.authenticationService.isAuthorized().subscribe(
(isAuthenticated) => {
this.isAuthenticated = isAuthenticated;
}
);
}
@action
login(user: User) {
this.uiState.loading = true;
this.authenticationService.login(user)
.subscribe(() => {
this.uiState.loading = false;
this.isAuthenticated = true;
this.router.navigate(['/things']);
},
(error) => {
this.uiState.loading = false;
this.authError = error;
}
);
}
@action
signup(user: User) {
this.uiState.loading = true;
this.authenticationService.signup(user)
.subscribe(() => {
this.login(user);
},
(error) => {
this.uiState.loading = false;
this.authError = error;
});
}
@action
logout() {
this.authenticationService.logout();
this.isAuthenticated = false;
this.router.navigate(['/login']);
}
}
@@ -0,0 +1,247 @@
import { HttpClientModule } from '@angular/common/http';
import { inject, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { toJS } from 'mobx';
import { Observable } from 'rxjs/Observable';
import { ChannelsService } from '../services/channels/channels.service';
import { ChannelsStore } from './channels.store';
import { Channel } from './models';
import { UiStore } from './ui.store';
describe('ChannelsStore', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
HttpClientModule,
RouterTestingModule.withRoutes([])
],
providers: [
ChannelsStore,
UiStore,
ChannelsService,
]
});
});
it('should be created', inject([ChannelsStore], (channelsStore: ChannelsStore) => {
expect(channelsStore).toBeTruthy();
}));
describe('getChannels', () => {
it('should set the loading flag to true before service call', inject([ChannelsStore, UiStore, ChannelsService],
(channelsStore: ChannelsStore, uiStore: UiStore, channelsService: ChannelsService) => {
const getChannels = spyOn(channelsService, 'getChannels').and.returnValue({ subscribe: () => { } });
channelsStore.getChannels();
expect(uiStore.loading).toBeTruthy();
}));
it('should set the loading flag to false after successful get', inject([ChannelsStore, UiStore, ChannelsService],
(channelsStore: ChannelsStore, uiStore: UiStore, channelsService: ChannelsService) => {
const getChannels = spyOn(channelsService, 'getChannels').and.returnValue(Observable.of(true));
channelsStore.getChannels();
expect(uiStore.loading).toBeFalsy();
}));
it('should set the channels property to the returned channels from the service', inject([ChannelsStore, ChannelsService],
(channelsStore: ChannelsStore, channelsService: ChannelsService) => {
const serviceReturnValue = [];
const getChannels = spyOn(channelsService, 'getChannels').and.returnValue(Observable.of(serviceReturnValue));
channelsStore.getChannels();
expect(toJS(channelsStore.channels)).toEqual(serviceReturnValue);
}));
it('should set the loading flag to false after failed get', inject([ChannelsStore, UiStore, ChannelsService],
(channelsStore: ChannelsStore, uiStore: UiStore, channelsService: ChannelsService) => {
const getChannels = spyOn(channelsService, 'getChannels').and.returnValue(Observable.throw(''));
channelsStore.getChannels();
expect(uiStore.loading).toBeFalsy();
}));
});
describe('addChannel', () => {
it('should set the loading flag to true before service call', inject([ChannelsStore, UiStore, ChannelsService],
(channelsStore: ChannelsStore, uiStore: UiStore, channelsService: ChannelsService) => {
const addChannel = spyOn(channelsService, 'addChannel').and.returnValue({ subscribe: () => { } });
const newChannel: Channel = {
name: 'new channel',
connected: [],
};
channelsStore.addChannel(newChannel);
expect(uiStore.loading).toBeTruthy();
}));
it('should set the loading flag to false after successful service call', inject([ChannelsStore, UiStore, ChannelsService],
(channelsStore: ChannelsStore, uiStore: UiStore, channelsService: ChannelsService) => {
const addChannel = spyOn(channelsService, 'addChannel').and.returnValue(Observable.of(true));
const storeGetChannelsSpy = spyOn(channelsStore, 'getChannels').and.stub();
const newChannel: Channel = {
name: 'new channel',
connected: [],
};
channelsStore.addChannel(newChannel);
expect(uiStore.loading).toBeFalsy();
}));
it('should set the loading flag to false after failed service call', inject([ChannelsStore, UiStore, ChannelsService],
(channelsStore: ChannelsStore, uiStore: UiStore, channelsService: ChannelsService) => {
const addChannel = spyOn(channelsService, 'addChannel').and.returnValue(Observable.throw(''));
const storeGetChannelsSpy = spyOn(channelsStore, 'getChannels').and.stub();
const newChannel: Channel = {
name: 'new channel',
connected: [],
};
channelsStore.addChannel(newChannel);
expect(uiStore.loading).toBeFalsy();
}));
it('should call the channelsStore.getChannels after successful add', inject([ChannelsStore, ChannelsService],
(channelsStore: ChannelsStore, channelsService: ChannelsService) => {
const addChannel = spyOn(channelsService, 'addChannel').and.returnValue(Observable.of(true));
const storeGetChannelsSpy = spyOn(channelsStore, 'getChannels').and.stub();
const newChannel: Channel = {
name: 'new channel',
connected: [],
};
channelsStore.addChannel(newChannel);
expect(storeGetChannelsSpy).toHaveBeenCalled();
}));
});
describe('editChannel', () => {
it('should set the loading flag to true before service call', inject([ChannelsStore, UiStore, ChannelsService],
(channelsStore: ChannelsStore, uiStore: UiStore, channelsService: ChannelsService) => {
const addChannel = spyOn(channelsService, 'editChannel').and.returnValue({ subscribe: () => { } });
const editedChannel: Channel = {
name: 'edited channel',
connected: [],
};
channelsStore.editChannel(editedChannel);
expect(uiStore.loading).toBeTruthy();
}));
it('should set the loading flag to false after successful service call', inject([ChannelsStore, UiStore, ChannelsService],
(channelsStore: ChannelsStore, uiStore: UiStore, channelsService: ChannelsService) => {
const editChannel = spyOn(channelsService, 'editChannel').and.returnValue(Observable.of(true));
const storeGetChannelsSpy = spyOn(channelsStore, 'getChannels').and.stub();
const editedChannel: Channel = {
name: 'edited channel',
connected: [],
};
channelsStore.editChannel(editedChannel);
expect(uiStore.loading).toBeFalsy();
}));
it('should set the loading flag to false after failed service call', inject([ChannelsStore, UiStore, ChannelsService],
(channelsStore: ChannelsStore, uiStore: UiStore, channelsService: ChannelsService) => {
const editChannel = spyOn(channelsService, 'editChannel').and.returnValue(Observable.throw(''));
const storeGetChannelsSpy = spyOn(channelsStore, 'getChannels').and.stub();
const editedChannel: Channel = {
name: 'edited channel',
connected: [],
};
channelsStore.editChannel(editedChannel);
expect(uiStore.loading).toBeFalsy();
}));
it('should call the channelsStore.getChannels after successful add', inject([ChannelsStore, ChannelsService],
(channelsStore: ChannelsStore, channelsService: ChannelsService) => {
const editChannel = spyOn(channelsService, 'editChannel').and.returnValue(Observable.of(true));
const storeGetChannelsSpy = spyOn(channelsStore, 'getChannels').and.stub();
const editedChannel: Channel = {
name: 'edited channel',
connected: [],
};
channelsStore.editChannel(editedChannel);
expect(storeGetChannelsSpy).toHaveBeenCalled();
}));
});
describe('deleteChannel', () => {
it('should set the loading flag to true before service call', inject([ChannelsStore, UiStore, ChannelsService],
(channelsStore: ChannelsStore, uiStore: UiStore, channelsService: ChannelsService) => {
const deleteChannel = spyOn(channelsService, 'deleteChannel').and.returnValue({ subscribe: () => { } });
const channelToBeDeleted: Channel = {
name: 'channelToBeDeleted',
connected: [],
};
channelsStore.deleteChannel(channelToBeDeleted);
expect(uiStore.loading).toBeTruthy();
}));
it('should set the loading flag to false after successful service call', inject([ChannelsStore, UiStore, ChannelsService],
(channelsStore: ChannelsStore, uiStore: UiStore, channelsService: ChannelsService) => {
const deleteChannel = spyOn(channelsService, 'deleteChannel').and.returnValue(Observable.of(true));
const storeGetChannelsSpy = spyOn(channelsStore, 'getChannels').and.stub();
const channelToBeDeleted: Channel = {
name: 'channelToBeDeleted',
connected: [],
};
channelsStore.deleteChannel(channelToBeDeleted);
expect(uiStore.loading).toBeFalsy();
}));
it('should set the loading flag to false after failed service call', inject([ChannelsStore, UiStore, ChannelsService],
(channelsStore: ChannelsStore, uiStore: UiStore, channelsService: ChannelsService) => {
const deleteChannel = spyOn(channelsService, 'deleteChannel').and.returnValue(Observable.throw(''));
const storeGetChannelsSpy = spyOn(channelsStore, 'getChannels').and.stub();
const channelToBeDeleted: Channel = {
name: 'channelToBeDeleted',
connected: [],
};
channelsStore.deleteChannel(channelToBeDeleted);
expect(uiStore.loading).toBeFalsy();
}));
it('should call the channelsStore.getChannels after successful add', inject([ChannelsStore, ChannelsService],
(channelsStore: ChannelsStore, channelsService: ChannelsService) => {
const deleteChannel = spyOn(channelsService, 'deleteChannel').and.returnValue(Observable.of(true));
const storeGetChannelsSpy = spyOn(channelsStore, 'getChannels').and.stub();
const channelToBeDeleted: Channel = {
name: 'channelToBeDeleted',
connected: [],
};
channelsStore.deleteChannel(channelToBeDeleted);
expect(storeGetChannelsSpy).toHaveBeenCalled();
}));
});
});

Some files were not shown because too many files have changed in this diff Show More