Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
9885585516 | |||
b8b0bc8f65 | |||
![]() |
402f755497 | ||
![]() |
95e9ae41ef | ||
![]() |
282c3bbc0e |
4 changed files with 62 additions and 61 deletions
54
.drone.yml
54
.drone.yml
|
@ -1,54 +0,0 @@
|
|||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: default
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
|
||||
steps:
|
||||
- name: go get
|
||||
image: golang
|
||||
commands:
|
||||
- go get
|
||||
- mkdir dist
|
||||
- name: Building for Linux
|
||||
image: golang
|
||||
environment:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
commands:
|
||||
- go build -v -o dist/machinelock-manager-linux-amd64
|
||||
- name: Building for Windows
|
||||
image: golang
|
||||
environment:
|
||||
GOOS: windows
|
||||
GOARCH: amd64
|
||||
commands:
|
||||
- go build -v -o dist/machinelock-manager-windows-amd64
|
||||
- name: Building for Mac
|
||||
image: golang
|
||||
environment:
|
||||
GOOS: darwin
|
||||
GOARCH: amd64
|
||||
commands:
|
||||
- go build -v -o dist/machinelock-manager-darwin-amd64
|
||||
- name: Building for Mac Silicon
|
||||
image: golang
|
||||
environment:
|
||||
GOOS: darwin
|
||||
GOARCH: arm64
|
||||
commands:
|
||||
- go build -v -o dist/machinelock-manager-darwin-arm64
|
||||
- name: gitea release
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: token
|
||||
base_url: https://git.ctdo.de
|
||||
files: dist/*
|
||||
checksum:
|
||||
- md5
|
||||
- sha1
|
||||
- sha256
|
||||
|
43
.forgejo/workflows/release.yaml
Normal file
43
.forgejo/workflows/release.yaml
Normal file
|
@ -0,0 +1,43 @@
|
|||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '^1.23'
|
||||
- name: go get
|
||||
run: |
|
||||
go get
|
||||
mkdir dist
|
||||
- name: Building for Linux
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
run: go build -v -o dist/machinelock-manager-linux-amd64
|
||||
- name: forgejo release
|
||||
uses: actions/forgejo-release@v2.6.2
|
||||
with:
|
||||
direction: upload
|
||||
release-dir: dist
|
||||
- name: Docker CLI installation
|
||||
run: |
|
||||
apt update
|
||||
apt install -y ca-certificates curl
|
||||
curl -fsSL https://get.docker.com -o get-docker.sh
|
||||
sh get-docker.sh
|
||||
- name: login to docker hub
|
||||
uses: https://github.com/docker/login-action@v3
|
||||
with:
|
||||
username: ctdo
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
- name: build docker image
|
||||
uses: https://github.com/docker/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
tags: ctdo/machinelock-manager:latest
|
||||
|
16
main.go
16
main.go
|
@ -121,14 +121,26 @@ func editMachine(c *gin.Context) {
|
|||
c.Redirect(http.StatusFound, "/machines")
|
||||
}
|
||||
func deleteMachine(c *gin.Context) {
|
||||
if err := db.DB.Where("id = ?", c.Param("id")).Delete(db.Machine{}).Error; err != nil {
|
||||
var machine db.Machine
|
||||
if err := db.DB.Where("id = ?", c.Param("id")).First(&machine).Error; err != nil {
|
||||
returnInternalError(c, err)
|
||||
return
|
||||
}
|
||||
db.DB.Model(&machine).Association("Tokens").Clear()
|
||||
if err := db.DB.Delete(machine).Error; err != nil {
|
||||
returnInternalError(c, err)
|
||||
return
|
||||
}
|
||||
c.Redirect(http.StatusFound, "/machines")
|
||||
}
|
||||
func deleteToken(c *gin.Context) {
|
||||
if err := db.DB.Where("id = ?", c.Param("id")).Delete(db.Token{}).Error; err != nil {
|
||||
var token db.Token
|
||||
if err := db.DB.Where("id = ?", c.Param("id")).First(&token).Error; err != nil {
|
||||
returnInternalError(c, err)
|
||||
return
|
||||
}
|
||||
db.DB.Model(&token).Association("Machines").Clear()
|
||||
if err := db.DB.Delete(token).Error; err != nil {
|
||||
returnInternalError(c, err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>User</th>
|
||||
<th style="min-width:120px">RFID ID</th>
|
||||
<th class="sticky-top">User</th>
|
||||
<th style="min-width:120px" class="sticky-top">RFID ID</th>
|
||||
{{range .Machines}}
|
||||
<th style="writing-mode:vertical-rl">{{.Name}}</th>
|
||||
<th style="writing-mode:vertical-rl" class="sticky-top">{{.Name}}</th>
|
||||
{{end}}
|
||||
<th></th>
|
||||
<th class="sticky-top"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<td><input type="text" class="form-control" value="{{.Nick}}" name="nick"></td>
|
||||
<td>{{.ID}}</td>
|
||||
{{range $.Machines}}
|
||||
<td><input type="checkbox" class="form-check-input" name="machine[{{.ID}}]" value="1" {{if IsAllowed $token .ID}}checked{{end}}/></td>
|
||||
<td><input type="checkbox" class="form-check-input" name="machine[{{.ID}}]" value="1" {{if IsAllowed $token .ID}}checked{{end}} title="{{.Name}}"/></td>
|
||||
{{end}}
|
||||
<td><input type="submit" class="btn btn-sm btn-success" value="Speichern" /><a href="/tokens/{{.ID}}/delete" class="btn btn-sm btn-danger">Löschen</a></td>
|
||||
</tr>
|
||||
|
|
Loading…
Add table
Reference in a new issue