diff --git a/Dockerfile b/Dockerfile index b46adb6..2681211 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,9 @@ FROM golang:latest AS go_builder WORKDIR /app COPY ./backend/main /app/main -COPY ./backend/grouptasks_lang_log_messages.json /app/ -COPY ./backend/system_lang_log_messages.json /app/ -COPY ./backend/public/swagger/ /app/swagger +#COPY ./backend/grouptasks_lang_log_messages.json /app/ +#COPY ./backend/system_lang_log_messages.json /app/ +#COPY ./backend/public/swagger/ /app/swagger # Assuming you build your Go binary using "go build -o main" #RUN go build -o main diff --git a/README.md b/README.md new file mode 100644 index 0000000..e2d3db4 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +#### Requesting a Token + +{INVEX_URL}/api/user/token/ diff --git a/go.mod b/go.mod index 85f89ea..5b0b840 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module janex/admin-dashboard-backend +module jannex/admin-dashboard-backend go 1.20 diff --git a/groupTasks/groups/requirements.txt b/groupTasks/groups/requirements.txt index e69de29..37dbd1c 100644 --- a/groupTasks/groups/requirements.txt +++ b/groupTasks/groups/requirements.txt @@ -0,0 +1 @@ +numpy==1.24.3 \ No newline at end of file diff --git a/grouptasks_lang_log_messages.json b/grouptasks_lang_log_messages.json index 2d40826..686fe67 100644 --- a/grouptasks_lang_log_messages.json +++ b/grouptasks_lang_log_messages.json @@ -167,5 +167,44 @@ "message": "Installation der Python Pakete für %groupId% von %category% abgeschlossen. Log: %log%" } ] + }, + { + "id": 13, + "languages": [ + { + "lang": "en", + "message": "%userId% has requested installing the global python packages" + }, + { + "lang": "de", + "message": "%userId% hat die Installation der globalen Python Pakete angefordert" + } + ] + }, + { + "id": 14, + "languages": [ + { + "lang": "en", + "message": "Installing the global python packages failed. Error %error%" + }, + { + "lang": "de", + "message": "Installation der globalen Python Pakete fehlgeschlagen. Fehler: %error%" + } + ] + }, + { + "id": 15, + "languages": [ + { + "lang": "en", + "message": "Installation of the global python packages finished. Log %log%" + }, + { + "lang": "de", + "message": "Installation der globalen Python Pakete abgeschlossen. Log: %log%" + } + ] } ] diff --git a/main.go b/main.go index b02b7aa..05a7a2a 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -// Package classification Janex API Documentation. +// Package classification Jannex API Documentation. // // Schemes: https // Host: janex @@ -18,15 +18,15 @@ import ( "encoding/json" "fmt" "io" - "janex/admin-dashboard-backend/modules/config" - "janex/admin-dashboard-backend/modules/database" - "janex/admin-dashboard-backend/modules/grouptasks" - "janex/admin-dashboard-backend/modules/logger" - "janex/admin-dashboard-backend/modules/structs" - "janex/admin-dashboard-backend/modules/systempermissions" - "janex/admin-dashboard-backend/modules/utils" - "janex/admin-dashboard-backend/routers/router" - "janex/admin-dashboard-backend/socketserver" + "jannex/admin-dashboard-backend/modules/config" + "jannex/admin-dashboard-backend/modules/database" + "jannex/admin-dashboard-backend/modules/grouptasks" + "jannex/admin-dashboard-backend/modules/logger" + "jannex/admin-dashboard-backend/modules/structs" + "jannex/admin-dashboard-backend/modules/systempermissions" + "jannex/admin-dashboard-backend/modules/utils" + "jannex/admin-dashboard-backend/routers/router" + "jannex/admin-dashboard-backend/socketserver" "os" "path/filepath" "time" diff --git a/modules/cache/categorygroup.go b/modules/cache/categorygroup.go index 0692da1..5072266 100644 --- a/modules/cache/categorygroup.go +++ b/modules/cache/categorygroup.go @@ -1,7 +1,7 @@ package cache import ( - "janex/admin-dashboard-backend/modules/structs" + "jannex/admin-dashboard-backend/modules/structs" "sort" "sync" ) diff --git a/modules/cache/grouptaskstepsinput.go b/modules/cache/grouptaskstepsinput.go index 324f10c..e18c827 100644 --- a/modules/cache/grouptaskstepsinput.go +++ b/modules/cache/grouptaskstepsinput.go @@ -1,8 +1,8 @@ package cache import ( - "janex/admin-dashboard-backend/modules/structs" - "janex/admin-dashboard-backend/modules/utils" + "jannex/admin-dashboard-backend/modules/structs" + "jannex/admin-dashboard-backend/modules/utils" "sync" ) diff --git a/modules/cache/lockedgrouptasksteps.go b/modules/cache/lockedgrouptasksteps.go index eff03de..c82f4c1 100644 --- a/modules/cache/lockedgrouptasksteps.go +++ b/modules/cache/lockedgrouptasksteps.go @@ -1,8 +1,8 @@ package cache import ( - "janex/admin-dashboard-backend/modules/structs" - "janex/admin-dashboard-backend/modules/utils" + "jannex/admin-dashboard-backend/modules/structs" + "jannex/admin-dashboard-backend/modules/utils" "sync" "time" ) diff --git a/modules/cache/socketclient.go b/modules/cache/socketclient.go index 3a5a647..bb612b1 100644 --- a/modules/cache/socketclient.go +++ b/modules/cache/socketclient.go @@ -1,7 +1,7 @@ package cache import ( - "janex/admin-dashboard-backend/modules/structs" + "jannex/admin-dashboard-backend/modules/structs" "sync" "github.com/gofiber/websocket/v2" diff --git a/modules/database/database.go b/modules/database/database.go index 042d99d..d4ec62f 100644 --- a/modules/database/database.go +++ b/modules/database/database.go @@ -2,21 +2,32 @@ package database import ( "fmt" - "janex/admin-dashboard-backend/modules/config" - "janex/admin-dashboard-backend/modules/structs" + "jannex/admin-dashboard-backend/modules/config" + "jannex/admin-dashboard-backend/modules/structs" "gorm.io/driver/mysql" "gorm.io/gorm" + "gorm.io/gorm/logger" ) var DB *gorm.DB func InitDatabase() { - cfg := config.Cfg.MariaDB + cfg := config.Cfg + + var logMode logger.LogLevel + + if cfg.Debug { + logMode = logger.Error + } else { + logMode = logger.Silent + } db, err := gorm.Open(mysql.Open( - fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", cfg.Username, cfg.Password, cfg.Hostname, cfg.Port, cfg.DatabaseName)), - &gorm.Config{}) + fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", cfg.MariaDB.Username, cfg.MariaDB.Password, cfg.MariaDB.Hostname, cfg.MariaDB.Port, cfg.MariaDB.DatabaseName)), + &gorm.Config{ + Logger: logger.Default.LogMode(logMode), + }) if err != nil { panic(err) @@ -32,4 +43,6 @@ func InitDatabase() { db.AutoMigrate(&structs.Role{}) db.AutoMigrate(&structs.RolePermission{}) db.AutoMigrate(&structs.UserApiKey{}) + db.AutoMigrate(&structs.Equipment{}) + db.AutoMigrate(&structs.EquipmentDocumentation{}) } diff --git a/modules/equipment/equipment.go b/modules/equipment/equipment.go new file mode 100644 index 0000000..605db34 --- /dev/null +++ b/modules/equipment/equipment.go @@ -0,0 +1,99 @@ +package equipment + +import ( + "encoding/json" + "errors" + "jannex/admin-dashboard-backend/modules/database" + "jannex/admin-dashboard-backend/modules/structs" + + "github.com/gofiber/fiber/v2" + "github.com/rs/zerolog/log" + "gorm.io/gorm" +) + +const Base = "https://inv.ex.umbach.dev" +const apiBase = Base + "/api" +const ApiToken = "1367f15d21935e4eb540f897946fb5cd98485c3f" + +func GetEquipmentDocumentation(stockItemId string, c *fiber.Ctx) error { + equipment := structs.Equipment{Id: stockItemId} + + if err := database.DB.Where("id = ?", stockItemId).First(&equipment).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { + log.Info().Msgf("a %s", err) + + log.Error().Msgf("Failed to get equipment, err: %s", err) + return c.JSON([]structs.EquipmentDocumentation{}) + + } + + // if equipment already exists, return the documentation + if equipment.Name != "" { + var equipmentDocumentations []structs.EquipmentDocumentation + + database.DB.Where("equipment_id = ?", stockItemId).Find(&equipmentDocumentations) + + return c.JSON(equipmentDocumentations) + } + + // create new equipment + a := fiber.AcquireAgent() + + a.Add("Authorization", "Token "+ApiToken) + + req := a.Request() + req.Header.SetMethod(fiber.MethodGet) + req.SetRequestURI(apiBase + "/stock/" + stockItemId + "/") + + if err := a.Parse(); err != nil { + log.Error().Msgf("Failed to parse request, err: %s", err) + return c.SendStatus(fiber.StatusInternalServerError) + } + + code, body, _ := a.Bytes() + + if code == 401 { + log.Error().Msgf("invex not authorized, code: %d", code) + return c.SendStatus(fiber.StatusInternalServerError) + } + + if code == 404 { + log.Error().Msgf("Inven stock item not found, code: %d", code) + return c.SendStatus(fiber.StatusNotFound) + } + + // parse body as json + var data map[string]interface{} + + if err := json.Unmarshal(body, &data); err != nil { + log.Error().Msgf("Failed to unmarshal json, err: %s", err) + return c.SendStatus(fiber.StatusInternalServerError) + } + + partDetail := data["part_detail"].(map[string]interface{}) + + database.DB.Create(&structs.Equipment{ + Id: stockItemId, + Name: partDetail["name"].(string), + Thumbnail: partDetail["thumbnail"].(string), + }) + + return c.JSON([]structs.EquipmentDocumentation{}) +} + +func GetEquipment() []structs.Equipment { + var equipments []structs.Equipment + + database.DB.Find(&equipments) + + return equipments +} + +/* +// return whether the scanned equipment is existing in the database +func IsEquipmentExisting(stockItemId string) bool { + var equipment structs.Equipment + + database.DB.Where("id = ?", stockItemId).FirstOrCreate(&equipment) + + return equipment.Id != "" +} */ diff --git a/modules/grouptasks/grouptasks.go b/modules/grouptasks/grouptasks.go index 2b74e05..d1b3c8a 100644 --- a/modules/grouptasks/grouptasks.go +++ b/modules/grouptasks/grouptasks.go @@ -5,14 +5,14 @@ import ( "errors" "fmt" "io/ioutil" - "janex/admin-dashboard-backend/modules/cache" - "janex/admin-dashboard-backend/modules/config" - "janex/admin-dashboard-backend/modules/database" - "janex/admin-dashboard-backend/modules/logger" - "janex/admin-dashboard-backend/modules/structs" - "janex/admin-dashboard-backend/modules/systempermissions" - "janex/admin-dashboard-backend/modules/utils" - "janex/admin-dashboard-backend/socketclients" + "jannex/admin-dashboard-backend/modules/cache" + "jannex/admin-dashboard-backend/modules/config" + "jannex/admin-dashboard-backend/modules/database" + "jannex/admin-dashboard-backend/modules/logger" + "jannex/admin-dashboard-backend/modules/structs" + "jannex/admin-dashboard-backend/modules/systempermissions" + "jannex/admin-dashboard-backend/modules/utils" + "jannex/admin-dashboard-backend/socketclients" "os" "os/exec" "path/filepath" @@ -932,7 +932,77 @@ func StartGroupTask(userId string, groupTask structs.GroupTasks) { }) } -func InstallPythonDependencies(userId string, category, groupId string) { +func InstallGlobalPythonPackages(userId string) { + logger.AddGroupTasksLog(structs.LogMessage{ + Id: 13, + Type: utils.LogTypeInfo, + Messages: []structs.LogData{ + {Type: "userId", Value: userId}, + }, + }) + + socketclients.BroadcastMessageToUsersWithPermission( + utils.PermissionGroupTasksInstallGlobalPythonPackages, + structs.SendSocketMessage{ + Cmd: utils.SentCmdInstallingGlobalPythonPackages, + }) + + // check if requirements.txt exists + if _, err := os.Stat(config.Cfg.FolderPaths.GroupTasksGroups + "requirements.txt"); errors.Is(err, os.ErrNotExist) { + logger.AddGroupTasksLog(structs.LogMessage{ + Id: 14, + Type: utils.LogTypeInfo, + Messages: []structs.LogData{ + {Type: "error", Value: "requirements.txt not found"}, + }, + }) + + socketclients.BroadcastMessageToUsersWithPermission( + utils.PermissionGroupTasksInstallGlobalPythonPackages, + structs.SendSocketMessage{ + Cmd: utils.SentCmdInstallingGlobalPythonPackagesFailed, + }) + return + } + + // install python dependencies + cmd := exec.Command("pip3", "install", "-r", config.Cfg.FolderPaths.GroupTasksGroups+"requirements.txt") + out, err := cmd.CombinedOutput() + + if err != nil { + logger.AddGroupTasksLog(structs.LogMessage{ + Id: 14, + Type: utils.LogTypeInfo, + Messages: []structs.LogData{ + {Type: "error", Value: err.Error()}, + }, + }) + + socketclients.BroadcastMessageToUsersWithPermission( + utils.PermissionGroupTasksInstallGlobalPythonPackages, + structs.SendSocketMessage{ + Cmd: utils.SentCmdInstallingGlobalPythonPackagesFailed, + }) + return + } + + logger.AddGroupTasksLog(structs.LogMessage{ + Id: 15, + Type: utils.LogTypeInfo, + Messages: []structs.LogData{ + {Type: "log", Value: string(out)}, + }, + }) + + socketclients.BroadcastMessageToUsersWithPermission( + utils.PermissionGroupTasksInstallGlobalPythonPackages, + + structs.SendSocketMessage{ + Cmd: utils.SentCmdInstallingGlobalPythonPackagesFinished, + }) +} + +func InstallPythonPackages(userId string, category, groupId string) { logger.AddGroupTasksLog(structs.LogMessage{ Id: 10, Type: utils.LogTypeInfo, @@ -951,10 +1021,12 @@ func InstallPythonDependencies(userId string, category, groupId string) { GroupId: groupId, } + convertedXYPermission := systempermissions.ConvertXYPermission(utils.PermissionGroupTasksOverviewXYInstallPythonPackages, category) + socketclients.BroadcastMessageToUsersWithPermission( - systempermissions.ConvertXYPermission(utils.PermissionGroupTasksOverviewXYInstallPythonDependencies, category), + convertedXYPermission, structs.SendSocketMessage{ - Cmd: utils.SentCmdInstallingPythonDependencies, + Cmd: utils.SentCmdInstallingPythonPackages, Body: messageBody, }) @@ -971,9 +1043,9 @@ func InstallPythonDependencies(userId string, category, groupId string) { }) socketclients.BroadcastMessageToUsersWithPermission( - systempermissions.ConvertXYPermission(utils.PermissionGroupTasksOverviewXYInstallPythonDependencies, category), + convertedXYPermission, structs.SendSocketMessage{ - Cmd: utils.SentCmdInstallingPythonDependenciesFailed, + Cmd: utils.SentCmdInstallingPythonPackagesFailed, Body: messageBody, }) return @@ -995,9 +1067,9 @@ func InstallPythonDependencies(userId string, category, groupId string) { }) socketclients.BroadcastMessageToUsersWithPermission( - systempermissions.ConvertXYPermission(utils.PermissionGroupTasksOverviewXYInstallPythonDependencies, category), + convertedXYPermission, structs.SendSocketMessage{ - Cmd: utils.SentCmdInstallingPythonDependenciesFailed, + Cmd: utils.SentCmdInstallingPythonPackages, Body: messageBody, }) return @@ -1014,9 +1086,9 @@ func InstallPythonDependencies(userId string, category, groupId string) { }) socketclients.BroadcastMessageToUsersWithPermission( - systempermissions.ConvertXYPermission(utils.PermissionGroupTasksOverviewXYInstallPythonDependencies, category), + convertedXYPermission, structs.SendSocketMessage{ - Cmd: utils.SentCmdInstallingPythonDependenciesFinished, + Cmd: utils.SentCmdInstallingPythonPackagesFinished, Body: messageBody, }) } diff --git a/modules/logger/logger.go b/modules/logger/logger.go index a9731b6..3e11e73 100644 --- a/modules/logger/logger.go +++ b/modules/logger/logger.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" "io/ioutil" - "janex/admin-dashboard-backend/modules/config" - "janex/admin-dashboard-backend/modules/structs" - "janex/admin-dashboard-backend/modules/utils" + "jannex/admin-dashboard-backend/modules/config" + "jannex/admin-dashboard-backend/modules/structs" + "jannex/admin-dashboard-backend/modules/utils" "os" "sort" "strconv" diff --git a/modules/structs/equipment.go b/modules/structs/equipment.go new file mode 100644 index 0000000..1552cf3 --- /dev/null +++ b/modules/structs/equipment.go @@ -0,0 +1,22 @@ +package structs + +import "time" + +type Equipment struct { + Id string // stock item id of invex system + Name string + Thumbnail string // url provided by invex system + CreatedAt time.Time + UpdatedAt time.Time +} + +type EquipmentDocumentation struct { + Id string // stock item id of invex system + Content string + CreatedAt time.Time + UpdatedAt time.Time +} + +type ApiEquipmentParamsRequest struct { + StockItemId string `json:"stockItemId"` +} diff --git a/modules/systempermissions/systempermissions.go b/modules/systempermissions/systempermissions.go index 9e18643..a45b023 100644 --- a/modules/systempermissions/systempermissions.go +++ b/modules/systempermissions/systempermissions.go @@ -1,10 +1,10 @@ package systempermissions import ( - "janex/admin-dashboard-backend/modules/cache" - "janex/admin-dashboard-backend/modules/database" - "janex/admin-dashboard-backend/modules/structs" - "janex/admin-dashboard-backend/modules/utils" + "jannex/admin-dashboard-backend/modules/cache" + "jannex/admin-dashboard-backend/modules/database" + "jannex/admin-dashboard-backend/modules/structs" + "jannex/admin-dashboard-backend/modules/utils" "strings" "time" diff --git a/modules/utils/globals.go b/modules/utils/globals.go index bda9d97..80129ab 100644 --- a/modules/utils/globals.go +++ b/modules/utils/globals.go @@ -41,41 +41,44 @@ var ( // commands sent to web clients const ( - SentCmdInitUserSocketConnection = 1 - SentCmdUpdateConnectedUsers = 2 - SentCmdNewGroupTaskStarted = 3 - SentCmdNewGroupTaskStep = 4 - SentCmdUpdateGroupTaskStep = 5 - SentCmdUpdateGroupTask = 6 - SentCmdReloadingGroupTasks = 7 - SentCmdGroupTasksReloaded = 8 - SentCmdUpdateUserSessions = 9 - SentCmdUpdateAllUsersUserAvatar = 10 - SentCmdNewScanner = 11 - SentCmdDeleteScanner = 12 - SentCmdUpdateScannerUsedBy = 13 - SentCmdScanResult = 14 - SentCmdUpdateScannerLastUsed = 15 - SentCmdTaskLocked = 16 - SentCmdTaskUnlocked = 17 - SentCmdUserProfileUpdated = 18 - SentCmdAdminAreaNewRoleCreated = 19 - SentCmdAdminAreaRoleUpdated = 20 - SentCmdAdminAreaUpdateRoleSortingOrder = 21 - SentCmdAdminAreaRoleDeleted = 22 - SentCmdAllUsersUserRoleUpdated = 23 - SentCmdRolePermissionsUpdated = 24 - SentCmdErrorNoPermissions = 25 - SentCmdAllUsersNewUserCreated = 26 - SentCmdAllUsersUserDeleted = 27 - SentCmdAllUsersUserDeactivation = 28 - SentCmdGroupTasksCategoryGroupChanges = 29 - SentCmdNewUserApiKeyCreated = 30 - SentCmdDeletedUserApiKey = 31 - SentCmdNewApiKeyUsageCount = 32 - SentCmdInstallingPythonDependencies = 33 - SentCmdInstallingPythonDependenciesFailed = 34 - SentCmdInstallingPythonDependenciesFinished = 35 + SentCmdInitUserSocketConnection = 1 + SentCmdUpdateConnectedUsers = 2 + SentCmdNewGroupTaskStarted = 3 + SentCmdNewGroupTaskStep = 4 + SentCmdUpdateGroupTaskStep = 5 + SentCmdUpdateGroupTask = 6 + SentCmdReloadingGroupTasks = 7 + SentCmdGroupTasksReloaded = 8 + SentCmdUpdateUserSessions = 9 + SentCmdUpdateAllUsersUserAvatar = 10 + SentCmdNewScanner = 11 + SentCmdDeleteScanner = 12 + SentCmdUpdateScannerUsedBy = 13 + SentCmdScanResult = 14 + SentCmdUpdateScannerLastUsed = 15 + SentCmdTaskLocked = 16 + SentCmdTaskUnlocked = 17 + SentCmdUserProfileUpdated = 18 + SentCmdAdminAreaNewRoleCreated = 19 + SentCmdAdminAreaRoleUpdated = 20 + SentCmdAdminAreaUpdateRoleSortingOrder = 21 + SentCmdAdminAreaRoleDeleted = 22 + SentCmdAllUsersUserRoleUpdated = 23 + SentCmdRolePermissionsUpdated = 24 + SentCmdErrorNoPermissions = 25 + SentCmdAllUsersNewUserCreated = 26 + SentCmdAllUsersUserDeleted = 27 + SentCmdAllUsersUserDeactivation = 28 + SentCmdGroupTasksCategoryGroupChanges = 29 + SentCmdNewUserApiKeyCreated = 30 + SentCmdDeletedUserApiKey = 31 + SentCmdNewApiKeyUsageCount = 32 + SentCmdInstallingPythonPackages = 33 + SentCmdInstallingPythonPackagesFailed = 34 + SentCmdInstallingPythonPackagesFinished = 35 + SentCmdInstallingGlobalPythonPackages = 36 + SentCmdInstallingGlobalPythonPackagesFailed = 37 + SentCmdInstallingGlobalPythonPackagesFinished = 38 ) // commands received from web clients @@ -100,7 +103,8 @@ const ( ReceivedCmdHandleUserActionTaskStep = 18 ReceivedCmdCreateNewUserApiKey = 19 ReceivedCmdDeleteUserApiKey = 20 - ReceivedCmdGroupTasksInstallPythonDependencies = 21 + ReceivedCmdGroupTasksInstallPythonPackages = 21 + ReceivedCmdGroupTasksInstallGlobalPythonPackages = 22 ) const ( @@ -127,22 +131,28 @@ var ( "Description": "required", "GlobalInputs": "required", } + + equipmentRules = map[string]string{ + "StockItemId": "required", + } ) const ( - _groupTasks = "group_tasks." - PermissionGroupTasksOverviewXYNewTask = _groupTasks + "overview.XY.new_task" - PermissionGroupTasksOverviewXYReloadGroupConfig = _groupTasks + "overview.XY.reload_group_config" - PermissionGroupTasksOverviewXYInstallPythonDependencies = _groupTasks + "overview.XY.install_python_dependencies" - PermissionGroupTasksOverviewXYView = _groupTasks + "overview.XY.view" - PermissionGroupTasksHistory = _groupTasks + "history" - PermissionGroupTasksCheckingForCategoryGroupChanges = _groupTasks + "checking_for_category_group_changes" - - PermissionAllUsersCreateNewUser = "all_users.create_new_user" - PermissionAllUsersActionChangeRole = "all_users.action.change_role" - PermissionAllUsersActionDeleteUser = "all_users.action.delete_user" - PermissionAllUsersActionUserDeactivation = "all_users.action.user_deactivation" - PermissionScannerUseScanners = "scanner.use_scanners" + _equipmentDocumentation = "equipment_documentation." + PermissionEquipmentDocumentationView = _equipmentDocumentation + "view" + _groupTasks = "group_tasks." + PermissionGroupTasksOverviewXYNewTask = _groupTasks + "overview.XY.new_task" + PermissionGroupTasksOverviewXYReloadGroupConfig = _groupTasks + "overview.XY.reload_group_config" + PermissionGroupTasksOverviewXYInstallPythonPackages = _groupTasks + "overview.XY.install_python_packages" + PermissionGroupTasksOverviewXYView = _groupTasks + "overview.XY.view" + PermissionGroupTasksHistory = _groupTasks + "history" + PermissionGroupTasksInstallGlobalPythonPackages = _groupTasks + "install_global_python_packages" + PermissionGroupTasksCheckingForCategoryGroupChanges = _groupTasks + "checking_for_category_group_changes" + PermissionAllUsersCreateNewUser = "all_users.create_new_user" + PermissionAllUsersActionChangeRole = "all_users.action.change_role" + PermissionAllUsersActionDeleteUser = "all_users.action.delete_user" + PermissionAllUsersActionUserDeactivation = "all_users.action.user_deactivation" + PermissionScannerUseScanners = "scanner.use_scanners" _adminArea = "admin_area." _adminAreaRoles = _adminArea + "roles." @@ -156,7 +166,9 @@ const ( ) var SystemPermissions = []string{ + PermissionEquipmentDocumentationView, PermissionGroupTasksHistory, + PermissionGroupTasksInstallGlobalPythonPackages, PermissionGroupTasksCheckingForCategoryGroupChanges, PermissionAllUsersActionChangeRole, PermissionAllUsersActionDeleteUser, @@ -174,6 +186,6 @@ var SystemPermissions = []string{ var DynamicGroupTasksPermissions = []string{ PermissionGroupTasksOverviewXYNewTask, PermissionGroupTasksOverviewXYReloadGroupConfig, - PermissionGroupTasksOverviewXYInstallPythonDependencies, + PermissionGroupTasksOverviewXYInstallPythonPackages, PermissionGroupTasksOverviewXYView, } diff --git a/modules/utils/validator.go b/modules/utils/validator.go index 78bb968..5a007e1 100644 --- a/modules/utils/validator.go +++ b/modules/utils/validator.go @@ -1,7 +1,7 @@ package utils import ( - "janex/admin-dashboard-backend/modules/structs" + "jannex/admin-dashboard-backend/modules/structs" "github.com/go-playground/validator/v10" ) @@ -37,4 +37,6 @@ func ValidatorInit() { Validate.RegisterStructValidationMapRules(groupTaskRules, structs.ApiGroupTaskRequest{}) + + Validate.RegisterStructValidationMapRules(equipmentRules, structs.ApiEquipmentParamsRequest{}) } diff --git a/public/sounds/scan_result.mp3 b/public/sounds/scan_result.mp3 new file mode 100644 index 0000000..64315b4 Binary files /dev/null and b/public/sounds/scan_result.mp3 differ diff --git a/public/swagger/favicon-16x16.png b/public/swagger/favicon-16x16.png new file mode 100755 index 0000000..8b194e6 Binary files /dev/null and b/public/swagger/favicon-16x16.png differ diff --git a/public/swagger/favicon-32x32.png b/public/swagger/favicon-32x32.png new file mode 100755 index 0000000..249737f Binary files /dev/null and b/public/swagger/favicon-32x32.png differ diff --git a/public/swagger/index.css b/public/swagger/index.css new file mode 100755 index 0000000..964c8b1 --- /dev/null +++ b/public/swagger/index.css @@ -0,0 +1,59 @@ +html { + box-sizing: border-box; + overflow: -moz-scrollbars-vertical; + overflow-y: scroll; +} + +*, +*:before, +*:after { + box-sizing: inherit; +} + +body { + margin: 0; + background: #fafafa; +} + +/* Position the navbar container inside the image */ +.container { + position: absolute; + width: auto; + font-family: Arial, Helvetica, sans-serif; + margin: 65px 5px; +} + +#container-versions { + margin: 110px 5px; +} + +/* The navbar */ +.topnav { + overflow: hidden; + background-color: #333; + border-radius: 10px; +} + +.topnav:first-child { + margin-bottom: 10px; +} + +/* Navbar links */ +.topnav a { + float: left; + color: #f2f2f2; + text-align: center; + padding: 10px 12px; + text-decoration: none; + font-size: 14px; +} + +.topnav a:hover { + opacity: 0.7; + border-bottom: 5px solid #62a03f; +} + +.topnav a.active { + color: #999494; + border-bottom: 5px solid #62a03f; +} diff --git a/public/swagger/index.html b/public/swagger/index.html new file mode 100755 index 0000000..84ae62d --- /dev/null +++ b/public/swagger/index.html @@ -0,0 +1,19 @@ + + + +
+ +>16&255,u[c++]=t>>8&255,u[c++]=255&t;2===s&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[c++]=255&t);1===s&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t);return u},t.fromByteArray=function(e){for(var t,n=e.length,o=n%3,a=[],i=16383,s=0,l=n-o;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,n){for(var o,a,i=[],s=t;ss&&(r=s-l),a=r;a>=0;a--){let r=!0;for(let n=0;n>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let a=!1;for(;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":case"latin1":case"binary":return x(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const C=4096;function O(e,t,r){let n="";r=Math.min(e.length,r);for(let o=t;o