group tasks
parent
1e978ed6fb
commit
e17e7723b5
|
@ -1,3 +1,16 @@
|
||||||
{
|
{
|
||||||
"name": "Janex Device Acryl Led Lamp"
|
"category": "Janex",
|
||||||
|
"name": "Janex Device Acryl schneiden",
|
||||||
|
"globalInputs": [
|
||||||
|
{
|
||||||
|
"parameterName": "irgendwas",
|
||||||
|
"type": "string",
|
||||||
|
"displayName": "Irgendwas tolles"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parameterName": "kiste",
|
||||||
|
"type": "number",
|
||||||
|
"displayName": "Nummer der Kiste"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
import requests
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
parser.add_argument("--url", help="url", type=str)
|
||||||
|
parser.add_argument("--name", help="name", type=str)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.url is None or args.name is None:
|
||||||
|
parser.print_help()
|
||||||
|
sys.exit(100)
|
||||||
|
|
||||||
|
print("hello friend", args.url, args.name)
|
||||||
|
|
||||||
|
def test():
|
||||||
|
print("hello")
|
||||||
|
|
||||||
|
x = requests.get("http://localhost:3000/test")
|
||||||
|
|
||||||
|
print(x.text)
|
||||||
|
|
||||||
|
# sys.exit(250)
|
||||||
|
|
||||||
|
|
||||||
|
test()
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
|
"category": "Janex",
|
||||||
"name": "Produktionstask 1",
|
"name": "Produktionstask 1",
|
||||||
"inputs": [
|
"globalInputs": [
|
||||||
{
|
{
|
||||||
"parameterName": "irgendwas",
|
"parameterName": "irgendwas",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
{
|
{
|
||||||
"name": "Roese"
|
"category": "Roese",
|
||||||
|
"name": "Roese Home"
|
||||||
}
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
{
|
{
|
||||||
"name": "Umbach"
|
"category": "Umbach",
|
||||||
|
"name": "Umbach Snack bar"
|
||||||
}
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
package grouptasks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Groups []*Group
|
||||||
|
|
||||||
|
type Group struct {
|
||||||
|
Category string `json:"category"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
GlobalInputs []GlobalInputs `json:"globalInputs"`
|
||||||
|
Tasks []Task `json:"tasks"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GlobalInputs struct {
|
||||||
|
ParameterName string `json:"parameterName"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
DisplayName string `json:"displayName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Task struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
OnFinish string `json:"onFinish"`
|
||||||
|
UndoPossible bool `json:"undoPossible"`
|
||||||
|
ScriptPath string `json:"scriptPath"`
|
||||||
|
Parameter []TaskParameter `json:"parameter"`
|
||||||
|
Feedback string `json:"feedback"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TaskParameter struct {
|
||||||
|
ParameterName string `json:"parameterName"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
DisplayName string `json:"displayName"`
|
||||||
|
Global bool `json:"global"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReadGroups() {
|
||||||
|
root := "./groupTasks/groups/"
|
||||||
|
|
||||||
|
entries, err := os.ReadDir(root)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msg("Failed to read groups directory, error: " + err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, entry := range entries {
|
||||||
|
log.Info().Msgf("Entry: %s", entry.Name())
|
||||||
|
|
||||||
|
files, err := os.ReadDir(root + entry.Name())
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msg("Failed to read groups directory files, error: " + err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file := range files {
|
||||||
|
log.Info().Msgf("File: %s", file.Name())
|
||||||
|
|
||||||
|
if file.Name() == "index.json" {
|
||||||
|
content, err := os.ReadFile(root + entry.Name() + "/index.json")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msg("Failed to read file content, error: " + err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//log.Info().Msgf("File content: %s", string(content))
|
||||||
|
|
||||||
|
var group Group
|
||||||
|
|
||||||
|
json.Unmarshal(content, &group)
|
||||||
|
|
||||||
|
Groups = append(Groups, &group)
|
||||||
|
|
||||||
|
log.Info().Msgf("Group: %s", group)
|
||||||
|
log.Info().Msgf("Number of groups: %d", len(Groups))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
main.go
5
main.go
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"janex/admin-dashboard-backend/grouptasks"
|
||||||
"janex/admin-dashboard-backend/modules/config"
|
"janex/admin-dashboard-backend/modules/config"
|
||||||
"janex/admin-dashboard-backend/modules/database"
|
"janex/admin-dashboard-backend/modules/database"
|
||||||
"janex/admin-dashboard-backend/modules/logger"
|
"janex/admin-dashboard-backend/modules/logger"
|
||||||
|
@ -77,8 +78,10 @@ func main() {
|
||||||
return fiber.ErrUpgradeRequired
|
return fiber.ErrUpgradeRequired
|
||||||
})
|
})
|
||||||
|
|
||||||
|
grouptasks.ReadGroups()
|
||||||
|
|
||||||
go socketserver.RunHub()
|
go socketserver.RunHub()
|
||||||
go socketserver.WebSocketServer(app)
|
socketserver.WebSocketServer(app)
|
||||||
|
|
||||||
app.Listen(config.Cfg.Host + ":" + config.Cfg.Port)
|
app.Listen(config.Cfg.Host + ":" + config.Cfg.Port)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue