wanglin86769 / clog2

Compact Electronic Logbook System
Other
4 stars 2 forks source link

Clog

Clog (Compact Electronic Logbook System) is a web-based logbook system aimed to be used in accelerators. The goal is to design and implement a logbook system with modern web technology but in a very simple way.

Significant change

Features

Software environment

Alt text

Design

Architecture

Alt text

Block diagram

Alt text

Schema

Alt text

Multi-language

English version

Alt text

Chinese version

Alt text

Screenshots

User login page

Login page for local database authentication

Alt text

Login page for LDAP authentication

Alt text

Login page for CSNS OAuth2 authentication

Alt text

Home page

Alt text

Logbook management page

Alt text

User management page

Alt text

Log preview page

Alt text

Log detail page

Alt text

Log create page

Alt text

Log edit page

Alt text

Attachment viewing page

Alt text

API token

Generate API token

Alt text

Alt text

Use the API token to create logs using Postman

Alt text

Alt text

Alt text

Use the API token to create logs using Python

The append=true query parameter will append the text to the end of a log instead of creating a new one if the log with the title exists.

import requests

headers = {
        'Authorization':'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiYWNjLW1zIiwiZW1haWwiOiJjc25zLWFjY29AaWhlcC5hYy5jbiIsImFkbWluIjpmYWxzZSwiaWF0IjoxNjgyMDQ1OTk5LCJleHAiOjE2ODIwOTI4MDN9.AgXSTsVgVp2ifbvpY_bI3Nu15h4Tj5HFuwv1v7G8pP8'
        }

data={
        'log':'{"logbook":"6423a38977784806a220b058","category":"Info","title":"API test","description":"send from python"}'
        }

response = requests.post('http://10.1.236.131:3000/api/logs?append=true',
        headers=headers, data=data)

print(response.text)

Project structure

Project setup

Configuration

Edit the following files if needed.

frondend/src/config/configuraion.js
backend/config/frontend.js
backend/config/login.js
backend/config/ldap.js
backend/config/smtp.js

Database import

Go to docs directory

cd docs
mongorestore --db clog2 database

Compiles and hot-reloads for development

Go to frontend directory

cd frontend
npm install
npm run serve

Go to backend directory

cd backend
npm install
npm run dev

Deploy for production

Go to frontend directory

cd frontend
npm ci
npm run build
cp -r dist/* /var/www/html

Go to backend directory

cd backend
npm ci
pm2 start server.js

Apache http configuration

Visit web pages

http://localhost:8080/

Test users in the database are as follows:

username: admin    password: 1    admin: true
username: user1    password: 1    admin: false
username: user2    password: 1    admin: false

Deployment with Docker

One compose.yaml and two Dockerfiles (one for frontend and one for backend) are provided to create the following three containers,

Prior to building images and running containers, the values of serverPath in frontend/src/config/configuration and url in backend/config/database.js need to be consistent with the host IP address, because localhost or 127.0.0.1 of the host is not accessible from inside containers by default.

The following commands can be used to build images and run containers,

docker compose build --no-cache
docker compose up

If building and running succeed, the following page can be accessed,

http://ip_address:8080/

Docker deployment has been tested in the following environment,