c3b2eb2b4f
* Generate a UUIDv5 from a random namespace based on WWN, model name, and serial number * Migrate sqlite and influxdb data accordingly * Update frontend API routes and components * Fixes #923
30 lines
825 B
Go
30 lines
825 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/analogj/scrutiny/webapp/backend/pkg/database"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gofrs/uuid/v5"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func UnarchiveDevice(c *gin.Context) {
|
|
logger := c.MustGet("LOGGER").(*logrus.Entry)
|
|
deviceRepo := c.MustGet("DEVICE_REPOSITORY").(database.DeviceRepo)
|
|
scrutiny_uuid, err := uuid.FromString(c.Param("scrutiny_uuid"))
|
|
if err != nil {
|
|
logger.Errorln("Invalid scrutiny uuid", err)
|
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
|
|
return
|
|
}
|
|
err = deviceRepo.UpdateDeviceArchived(c, scrutiny_uuid, false)
|
|
if err != nil {
|
|
logger.Errorln("An error occurred while unarchiving device", err)
|
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{"success": true})
|
|
}
|