Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

UV-82 - Update to Magistrala #2

Merged
merged 6 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.21.x

- name: Checkout code
uses: actions/checkout@v2
Expand Down Expand Up @@ -49,4 +49,4 @@ jobs:
run: go build -v ./...

- name: Run tests
run: go test -mod=vendor -v --race -covermode=atomic -coverprofile cover.out ./...
run: go test -v --race -covermode=atomic -coverprofile cover.out ./...
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MF_DOCKER_IMAGE_NAME_PREFIX ?= mainflux
MF_DOCKER_IMAGE_NAME_PREFIX ?= magistrala
SVC = ui
BUILD_DIR = build
CGO_ENABLED ?= 0
Expand All @@ -10,11 +10,11 @@ TIME ?= $(shell date +%F_%T)

define compile_service
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \
go build -mod=vendor -ldflags "-s -w \
-X 'github.com/mainflux/mainflux.BuildTime=$(TIME)' \
-X 'github.com/mainflux/mainflux.Version=$(VERSION)' \
-X 'github.com/mainflux/mainflux.Commit=$(COMMIT)'" \
-o ${BUILD_DIR}/mainflux-$(1) cmd/$(1)/main.go
go build -ldflags "-s -w \
-X 'github.com/absmach/magistrala-ui.BuildTime=$(TIME)' \
-X 'github.com/absmach/magistrala-ui.Version=$(VERSION)' \
-X 'github.com/absmach/magistrala-ui.Commit=$(COMMIT)'" \
-o ${BUILD_DIR}/magistrala-$(1) cmd/$(1)/main.go
endef

define make_docker
Expand Down Expand Up @@ -57,7 +57,7 @@ install:
cp ${BUILD_DIR}/* $(GOBIN)

test:
GOCACHE=off go test -mod=vendor -v -race -count 1 -tags test $(shell go list ./... | grep -v 'vendor\|cmd')
go test -v -race -count 1 -tags test $(shell go list ./... | grep -v 'vendor\|cmd')

lint:
golangci-lint run --no-config --disable-all --enable gosimple --enable errcheck --enable govet --enable unused --enable goconst --enable godot --timeout 3m
Expand All @@ -76,4 +76,4 @@ run_docker:
docker-compose -f docker/docker-compose.yml --env-file docker/.env up

run:
${BUILD_DIR}/mainflux-ui
${BUILD_DIR}/magistrala-ui
26 changes: 9 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Mainflux-ui
# Magistrala-ui

The Mainflux-ui functions as a Graphical User Interface (GUI) designed to interact with Mainflux services, encompassing both the creation and management aspects of users, things, channels, and groups. It streamlines tasks such as user and thing creation, channel establishment, policy configuration, and HTTP message transmission across various channels.
The Magistrala-ui functions as a Graphical User Interface (GUI) designed to interact with Magistrala services, encompassing both the creation and management aspects of users, things, channels, and groups. It streamlines tasks such as user and thing creation, channel establishment, policy configuration, and HTTP message transmission across various channels.

Mainflux-ui can be obtained as an independent subset of Mainflux; however, it requires integration with the mainflux core services to function properly.
Magistrala-ui can be obtained as an independent subset of Magistrala; however, it requires integration with the Magistrala core services to function properly.

## Prerequisites

To run Mainflux-ui, you need the following components:
To run Magistrala-ui, you need the following components:

- [Mainflux](https://github.com/mainflux/mainflux) (latest version)
- [Magistrala](https://github.com/absmach/magistrala) (latest version)
- [Go](https://golang.org/doc/install) (version 1.19.2)
- [Docker-compose](https://docs.docker.com/compose/install/) (latest version)
- [make](https://www.gnu.org/software/make/manual/make.html)
Expand All @@ -25,7 +25,7 @@ make
make run
```

These commands will launch Mainflux-ui. To use the Mainflux-ui, ensure that the Mainflux core services are operational. You can achieve this by installing [Mainflux](https://github.com/mainflux/mainflux) and its prerequisites.
These commands will launch Magistrala-ui. To use the Magistrala-ui, ensure that the Mainflux core services are operational. You can achieve this by installing [Magistrala](https://github.com/absmach/magistrala) and its prerequisites.

To build the docker images for the ui service, run the following commands which will build the docker images in different configurations.

Expand All @@ -51,7 +51,7 @@ This brings up the docker images and runs ui in the configuration specified in t

## Usage

Once both Mainflux core and Mainflux-ui are running, you can access the Mainflux-ui interface locally by entering the address: [http://localhost:9090](http://localhost:9090).
Once both Magistrala core and Magistrala-ui are running, you can access the Magistrala-ui interface locally by entering the address: [http://localhost:9095](http://localhost:9095).

On the login page, use the provided credentials to log in to the interface:

Expand All @@ -60,7 +60,7 @@ Email: admin@example.com
Password: 12345678
```

Upon logging in, you will be directed to the Dashboard, which provides an overview of the Mainflux user interface. The sidebar elements, such as Users/Groups, allow you to navigate to specific pages for performing actions related to Users, Groups, Users Policies, Things, Channels, Things Policies, and viewing Deleted Clients.
Upon logging in, you will be directed to the Dashboard, which provides an overview of the Magistrala user interface. The sidebar elements, such as Users/Groups, allow you to navigate to specific pages for performing actions related to Users, Groups, Things, Channels, and Bootstraps.

### Users

Expand All @@ -76,10 +76,6 @@ When using a CSV file to create multiple groups, the file should contain group n

For more details, refer to the official [Documentation](http://docs.mainflux.io/cli/#things-management).

### Users Policies

To create a user policy, select the subject and object, and choose the relevant actions (multiple selections are allowed). User policies are utilized to manage permissions for users and groups entities. These Policies determine access rights for these entities. For instance, they define which users can access specific groups. Learn more about policies from the official [Documentation](https://docs.mainflux.io/authorization/#summary-of-defined-policies).

### Things

You can create individual things or upload a CSV file for multiple things. When adding a thing, provide the Thing Name (required), Thing ID, Identity, Secret, Tags (as a string slice), and Metadata (in JSON format). The Thing Secret should be unique and is used to identify the thing. Metadata offers additional information about the thing.
Expand All @@ -90,13 +86,9 @@ For multiple things, use a CSV file with thing names in one column. Refer to the

Similarly, you can add individual or multiple channels using a CSV file. For channel creation, enter the Channel Name (required), select the Parent ID, provide a Description, and include Metadata (in JSON format).

### Things Policies

Creating a thing policy involves selecting the subject and object and specifying the actions (multiple selections are allowed). Things policies control permissions for things and channels entities. They define access permissions, such as a thing's access to a channel. For detailed policy information, consult the official [Documentation](https://docs.mainflux.io/authorization/#summary-of-defined-policies).

### Bootstrap

To use bootstrap, ensure that the [bootstrap](http://docs.mainflux.io/bootstrap/) addon is active as part of the Mainflux core services.
To use bootstrap, ensure that the [bootstrap](http://docs.mainflux.io/bootstrap/) addon is active as part of the Magistrala core services.

To configure bootstrap, provide the Name, Thing ID, External ID, External Key, Channel (as a string slice), Content (in JSON format), Client Cert, Client Key, and CA Cert.

Expand Down
34 changes: 17 additions & 17 deletions cmd/ui/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Mainflux
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0

package main
Expand All @@ -11,29 +11,29 @@ import (
"os/signal"
"syscall"

"github.com/absmach/magistrala-ui/ui"
"github.com/absmach/magistrala-ui/ui/api"
"github.com/absmach/magistrala/logger"
sdk "github.com/absmach/magistrala/pkg/sdk/go"
"github.com/absmach/magistrala/pkg/uuid"
"github.com/caarlos0/env/v9"
"github.com/go-chi/chi/v5"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
"github.com/mainflux/mainflux/logger"
sdk "github.com/mainflux/mainflux/pkg/sdk/go"
"github.com/mainflux/mainflux/pkg/uuid"
stdprometheus "github.com/prometheus/client_golang/prometheus"
"github.com/ultravioletrs/mainflux-ui/ui"
"github.com/ultravioletrs/mainflux-ui/ui/api"
)

type config struct {
LogLevel string `env:"MF_UI_LOG_LEVEL" envDefault:"info"`
Port string `env:"MF_UI_PORT" envDefault:"9095"`
InstanceID string `env:"MF_UI_INSTANCE_ID" envDefault:""`
HTTPAdapterURL string `env:"MF_HTTP_ADAPTER_URL" envDefault:"http://localhost:8008"`
ReaderURL string `env:"MF_READER_URL" envDefault:"http://localhost:9007"`
ThingsURL string `env:"MF_THINGS_URL" envDefault:"http://localhost:9000"`
UsersURL string `env:"MF_USERS_URL" envDefault:"http://localhost:9002"`
HostURL string `env:"MF_UI_HOST_URL" envDefault:"http://localhost:9095"`
BootstrapURL string `env:"MF_BOOTSTRAP_URL" envDefault:"http://localhost:9013"`
MsgContentType sdk.ContentType `env:"MF_CONTENT-TYPE" envDefault:"application/senml+json"`
TLSVerification bool `env:"MF_VERIFICATION_TLS" envDefault:"false"`
LogLevel string `env:"MG_UI_LOG_LEVEL" envDefault:"info"`
Port string `env:"MG_UI_PORT" envDefault:"9095"`
InstanceID string `env:"MG_UI_INSTANCE_ID" envDefault:""`
HTTPAdapterURL string `env:"MG_HTTP_ADAPTER_URL" envDefault:"http://localhost:8008"`
ReaderURL string `env:"MG_READER_URL" envDefault:"http://localhost:9007"`
ThingsURL string `env:"MG_THINGS_URL" envDefault:"http://localhost:9000"`
UsersURL string `env:"MG_USERS_URL" envDefault:"http://localhost:9002"`
HostURL string `env:"MG_UI_HOST_URL" envDefault:"http://localhost:9095"`
BootstrapURL string `env:"MG_BOOTSTRAP_URL" envDefault:"http://localhost:9013"`
MsgContentType sdk.ContentType `env:"MG_CONTENT-TYPE" envDefault:"application/senml+json"`
TLSVerification bool `env:"MG_VERIFICATION_TLS" envDefault:"false"`
}

func main() {
Expand Down
22 changes: 11 additions & 11 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Docker: Environment variables in Compose

## UI
MF_UI_LOG_LEVEL=debug
MF_UI_PORT=9095
MF_HTTP_ADAPTER_URL=http://localhost:8008
MF_READER_URL=http://localhost:9007
MF_THINGS_URL=http://localhost:9000
MF_USERS_URL=http://localhost:9002
MF_VERIFICATION_TLS=false
MF_BOOTSTRAP_URL=http://localhost:9013
MF_UI_INSTANCE_ID=
MF_UI_HOST_URL=http://localhost:9095
MG_UI_LOG_LEVEL=debug
MG_UI_PORT=9095
MG_HTTP_ADAPTER_URL=http://localhost:8008
MG_READER_URL=http://localhost:9007
MG_THINGS_URL=http://localhost:9000
MG_USERS_URL=http://localhost:9002
MG_VERIFICATION_TLS=false
MG_BOOTSTRAP_URL=http://localhost:9013
MG_UI_INSTANCE_ID=
MG_UI_HOST_URL=http://localhost:9095

# Docker image tag
MF_RELEASE_TAG=latest
MG_RELEASE_TAG=latest
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM scratch
ARG SVC
COPY ./build/mainflux-$SVC /exe
COPY ./build/magistrala-$SVC /exe
COPY ./$SVC/web /$SVC/web
ENTRYPOINT ["/exe"]
2 changes: 1 addition & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Docker Composition

Configure environment variables and run Mainflux Docker Composition.
Configure environment variables and run Magistrala UI Docker Composition.

\*Note\*\*: `docker-compose` uses `.env` file to set all environment variables. Ensure that you run the command from the same location as .env file.

Expand Down
32 changes: 16 additions & 16 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# Copyright (c) Mainflux
# Copyright (c) Magistrala
# SPDX-License-Identifier: Apache-2.0

version: "3.7"

networks:
mainflux-base-net:
magistrala-base-net:
driver: bridge

services:
ui:
image: mainflux/ui:${MF_RELEASE_TAG}
container_name: mainflux-ui
image: magistrala/ui:${MG_RELEASE_TAG}
container_name: magistrala-ui
restart: on-failure
ports:
- ${MF_UI_PORT}:${MF_UI_PORT}
- ${MG_UI_PORT}:${MG_UI_PORT}
networks:
- mainflux-base-net
- magistrala-base-net
environment:
MF_UI_LOG_LEVEL: ${MF_UI_LOG_LEVEL}
MF_UI_PORT: ${MF_UI_PORT}
MF_HTTP_ADAPTER_URL: ${MF_HTTP_ADAPTER_URL}
MF_READER_URL: ${MF_READER_URL}
MF_THINGS_URL: ${MF_THINGS_URL}
MF_USERS_URL: ${MF_USERS_URL}
MF_BOOTSTRAP_URL: ${MF_BOOTSTRAP_URL}
MF_VERIFICATION_TLS: ${MF_VERIFICATION_TLS}
MF_UI_INSTANCE_ID: ${MF_UI_INSTANCE_ID}
MF_UI_HOST_URL: ${MF_UI_HOST_URL}
MG_UI_LOG_LEVEL: ${MG_UI_LOG_LEVEL}
MG_UI_PORT: ${MG_UI_PORT}
MG_HTTP_ADAPTER_URL: ${MG_HTTP_ADAPTER_URL}
MG_READER_URL: ${MG_READER_URL}
MG_THINGS_URL: ${MG_THINGS_URL}
MG_USERS_URL: ${MG_USERS_URL}
MG_BOOTSTRAP_URL: ${MG_BOOTSTRAP_URL}
MG_VERIFICATION_TLS: ${MG_VERIFICATION_TLS}
MG_UI_INSTANCE_ID: ${MG_UI_INSTANCE_ID}
MG_UI_HOST_URL: ${MG_UI_HOST_URL}
45 changes: 19 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,53 +1,46 @@
module github.com/ultravioletrs/mainflux-ui
module github.com/absmach/magistrala-ui

go 1.21
go 1.21.0

require (
github.com/absmach/agent v0.0.0-20231107115142-c8b509f24d50
github.com/absmach/magistrala v0.11.1-0.20231102134813-44408395e6a3
github.com/caarlos0/env/v9 v9.0.0
github.com/eclipse/paho.mqtt.golang v1.4.3
github.com/go-chi/chi/v5 v5.0.10
github.com/go-kit/kit v0.13.0
github.com/go-zoo/bone v1.3.0
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/mainflux/agent v0.11.1-0.20230724130550-0cd3f4c8c27c
github.com/mainflux/mainflux v0.0.0-20231021215047-ab832aff1b52
github.com/mainflux/senml v1.5.0
github.com/prometheus/client_golang v1.17.0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
golang.org/x/sync v0.4.0
google.golang.org/grpc v1.58.3
)

require (
github.com/creack/pty v1.1.18 // indirect
github.com/edgexfoundry/go-mod-core-contracts v0.1.70 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/mainflux/export v0.1.1-0.20230724124847-67d0bc7f38cb // indirect
github.com/nats-io/nats.go v1.30.2 // indirect
github.com/nats-io/nkeys v0.4.5 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a // indirect
google.golang.org/grpc v1.59.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/eclipse/paho.mqtt.golang v1.4.3
github.com/creack/pty v1.1.18 // indirect
github.com/edgexfoundry/go-mod-core-contracts v0.1.70 // indirect
github.com/fxamacker/cbor/v2 v2.5.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/mainflux/senml v1.5.0
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/mainflux/export v0.1.1-0.20230724124847-67d0bc7f38cb // indirect
github.com/mainflux/mainflux v0.12.0 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
Loading
Loading