Compare commits
No commits in common. "885b27bfe182a0b1e48720eab3d70eabc2f7749f" and "3e00fc61971dc35cd54de7964dfdfb7671599c0b" have entirely different histories.
885b27bfe1
...
3e00fc6197
|
|
@ -6,7 +6,7 @@ on:
|
||||||
paths: ["velconnect/**"]
|
paths: ["velconnect/**"]
|
||||||
jobs:
|
jobs:
|
||||||
run_pull:
|
run_pull:
|
||||||
name: Pull new version on Oracle
|
name: Pull new version
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: install ssh keys
|
- name: install ssh keys
|
||||||
|
|
|
||||||
|
|
@ -37,4 +37,4 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@velaboratory/velconnect": "../../VEL-Connect/velconnect-npm"
|
"@velaboratory/velconnect": "../../VEL-Connect/velconnect-npm"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,8 +15,7 @@ export function prettyDate(date: string | Date | DateTime, includeYear = false)
|
||||||
}
|
}
|
||||||
// return DateTime.fromISO(date).toFormat("yyyy-LL-dd hh:mm a ZZZZ");
|
// return DateTime.fromISO(date).toFormat("yyyy-LL-dd hh:mm a ZZZZ");
|
||||||
const fromNow = DateTime.utc().minus(d.toMillis()).toMillis();
|
const fromNow = DateTime.utc().minus(d.toMillis()).toMillis();
|
||||||
// TODO fix
|
const yearReplace = includeYear ? '' : ', 2023';
|
||||||
const yearReplace = includeYear ? '' : ', 2024';
|
|
||||||
if (fromNow > 0) {
|
if (fromNow > 0) {
|
||||||
return `${d.toLocaleString(DateTime.DATETIME_MED)} (${humanizeDuration(fromNow, {
|
return `${d.toLocaleString(DateTime.DATETIME_MED)} (${humanizeDuration(fromNow, {
|
||||||
round: true,
|
round: true,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "VEL-Connect",
|
"name": "VEL-Connect",
|
||||||
"rootNamespace": "VELConnect",
|
"rootNamespace": "VEL-Connect",
|
||||||
"references": [
|
"references": [
|
||||||
"GUID:1e55e2c4387020247a1ae212bbcbd381",
|
"GUID:1e55e2c4387020247a1ae212bbcbd381",
|
||||||
"GUID:343deaaf83e0cee4ca978e7df0b80d21",
|
"GUID:343deaaf83e0cee4ca978e7df0b80d21",
|
||||||
|
|
|
||||||
|
|
@ -185,23 +185,7 @@ namespace VELConnect
|
||||||
sb.Append("EDITOR");
|
sb.Append("EDITOR");
|
||||||
#endif
|
#endif
|
||||||
string id = Convert.ToBase64String(md5.ComputeHash(Encoding.UTF8.GetBytes(sb.ToString())));
|
string id = Convert.ToBase64String(md5.ComputeHash(Encoding.UTF8.GetBytes(sb.ToString())));
|
||||||
deviceId = CreateDeviceId();
|
deviceId = id[..15];
|
||||||
}
|
|
||||||
|
|
||||||
// Computes 15-char device id compatibly with pocketbase
|
|
||||||
private static string CreateDeviceId()
|
|
||||||
{
|
|
||||||
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
|
|
||||||
StringBuilder sb = new StringBuilder(SystemInfo.deviceUniqueIdentifier);
|
|
||||||
sb.Append(Application.productName);
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
// allows running multiple builds on the same computer
|
|
||||||
// return SystemInfo.deviceUniqueIdentifier + Hash128.Compute(Application.dataPath);
|
|
||||||
sb.Append(Application.dataPath);
|
|
||||||
sb.Append("EDITOR");
|
|
||||||
#endif
|
|
||||||
string id = Convert.ToBase64String(md5.ComputeHash(Encoding.UTF8.GetBytes(sb.ToString())));
|
|
||||||
return id[..15];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
|
|
@ -917,7 +901,7 @@ namespace VELConnect
|
||||||
case UnityWebRequest.Result.ConnectionError:
|
case UnityWebRequest.Result.ConnectionError:
|
||||||
case UnityWebRequest.Result.DataProcessingError:
|
case UnityWebRequest.Result.DataProcessingError:
|
||||||
case UnityWebRequest.Result.ProtocolError:
|
case UnityWebRequest.Result.ProtocolError:
|
||||||
Debug.LogError(url + ": Error: " + webRequest.error + "\n" + webRequest.downloadHandler.text + "\n" + Environment.StackTrace);
|
Debug.LogError(url + ": Error: " + webRequest.error + "\n" + Environment.StackTrace);
|
||||||
failureCallback?.Invoke(webRequest.error);
|
failureCallback?.Invoke(webRequest.error);
|
||||||
break;
|
break;
|
||||||
case UnityWebRequest.Result.Success:
|
case UnityWebRequest.Result.Success:
|
||||||
|
|
@ -929,23 +913,6 @@ namespace VELConnect
|
||||||
webRequest.Dispose();
|
webRequest.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetDataBlock(string blockId, State.DataBlock dataBlock)
|
|
||||||
{
|
|
||||||
PostRequestCallback(instance.velConnectUrl + "/data_block/" + blockId, JsonConvert.SerializeObject(dataBlock, Formatting.None, new JsonSerializerSettings
|
|
||||||
{
|
|
||||||
NullValueHandling = NullValueHandling.Ignore
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void GetDataBlock(string blockId, Action<State.DataBlock> successCallback = null, Action<string> failureCallback = null)
|
|
||||||
{
|
|
||||||
GetRequestCallback(instance.velConnectUrl + "/data_block/" + blockId, data =>
|
|
||||||
{
|
|
||||||
State.DataBlock dict = JsonConvert.DeserializeObject<State.DataBlock>(data);
|
|
||||||
successCallback?.Invoke(dict);
|
|
||||||
}, failureCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnApplicationFocus(bool focus)
|
private void OnApplicationFocus(bool focus)
|
||||||
{
|
{
|
||||||
UpdateUserCount(!focus);
|
UpdateUserCount(!focus);
|
||||||
|
|
|
||||||
|
|
@ -1,85 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using VelNet;
|
|
||||||
|
|
||||||
namespace VELConnect
|
|
||||||
{
|
|
||||||
public class VelNetPersist : MonoBehaviour
|
|
||||||
{
|
|
||||||
public SyncState syncState;
|
|
||||||
private string Id => $"{Application.productName}_{VelNetManager.Room}_{syncState.networkObject.sceneNetworkId}_{syncState.networkObject.syncedComponents.IndexOf(syncState)}";
|
|
||||||
private const float interval = 5f;
|
|
||||||
private double nextUpdate;
|
|
||||||
private bool loading;
|
|
||||||
private const bool debugLogs = false;
|
|
||||||
|
|
||||||
private void Update()
|
|
||||||
{
|
|
||||||
if (Time.timeAsDouble > nextUpdate && VelNetManager.InRoom && !loading)
|
|
||||||
{
|
|
||||||
nextUpdate = Time.timeAsDouble + interval + UnityEngine.Random.Range(0, interval);
|
|
||||||
if (syncState.networkObject.IsMine)
|
|
||||||
{
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEnable()
|
|
||||||
{
|
|
||||||
VelNetManager.OnJoinedRoom += OnJoinedRoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDisable()
|
|
||||||
{
|
|
||||||
VelNetManager.OnJoinedRoom -= OnJoinedRoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnJoinedRoom(string roomName)
|
|
||||||
{
|
|
||||||
Load();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Load()
|
|
||||||
{
|
|
||||||
loading = true;
|
|
||||||
if (debugLogs) Debug.Log($"[VelNetPersist] Loading {Id}");
|
|
||||||
VELConnectManager.GetDataBlock(Id, data =>
|
|
||||||
{
|
|
||||||
if (!data.data.TryGetValue("state", out string d))
|
|
||||||
{
|
|
||||||
Debug.LogError($"[VelNetPersist] Failed to parse {Id}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (syncState == null)
|
|
||||||
{
|
|
||||||
Debug.LogError("[VelNetPersist] Object doesn't exist anymore");
|
|
||||||
}
|
|
||||||
|
|
||||||
syncState.UnpackState(Convert.FromBase64String(d));
|
|
||||||
if (debugLogs) Debug.Log($"[VelNetPersist] Loaded {Id}");
|
|
||||||
loading = false;
|
|
||||||
}, s =>
|
|
||||||
{
|
|
||||||
Debug.LogError(s);
|
|
||||||
loading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Save()
|
|
||||||
{
|
|
||||||
if (debugLogs) Debug.Log($"[VelNetPersist] Saving {Id}");
|
|
||||||
VELConnectManager.SetDataBlock(Id, new VELConnectManager.State.DataBlock()
|
|
||||||
{
|
|
||||||
category = "object_persist",
|
|
||||||
data = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "name", syncState.networkObject.name },
|
|
||||||
{ "state", Convert.ToBase64String(syncState.PackState()) }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: cd4cd3f927d9998449837165f749c9c2
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "edu.uga.engr.vel.vel-connect",
|
"name": "edu.uga.engr.vel.vel-connect",
|
||||||
"displayName": "VEL-Connect",
|
"displayName": "VEL-Connect",
|
||||||
"version": "4.0.1",
|
"version": "4.0.0",
|
||||||
"unity": "2019.1",
|
"unity": "2019.1",
|
||||||
"description": "Web-based configuration for VR applications",
|
"description": "Web-based configuration for VR applications",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,22 @@
|
||||||
# syntax=docker/dockerfile:1
|
FROM alpine:latest
|
||||||
FROM golang:1.21 as build
|
|
||||||
WORKDIR /src
|
|
||||||
COPY go.mod go.sum ./
|
|
||||||
RUN go mod download
|
|
||||||
|
|
||||||
COPY *.go ./
|
ARG PB_VERSION=0.20.7
|
||||||
COPY pb_migrations/ ./pb_migrations
|
|
||||||
|
|
||||||
# Build
|
RUN apk add --no-cache \
|
||||||
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o ./velconnect
|
unzip \
|
||||||
# RUN ./velconnect-pb migrate up
|
ca-certificates
|
||||||
|
|
||||||
FROM alpine:3.19.1
|
# download and unzip PocketBase
|
||||||
COPY --from=build /src/velconnect /velconnect
|
ADD https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_arm64.zip /tmp/pb.zip
|
||||||
|
RUN unzip /tmp/pb.zip -d /pb/
|
||||||
|
|
||||||
EXPOSE 8090
|
# uncomment to copy the local pb_migrations dir into the image
|
||||||
|
# COPY ./pb_migrations /pb/pb_migrations
|
||||||
|
|
||||||
# Run
|
# uncomment to copy the local pb_hooks dir into the image
|
||||||
ENTRYPOINT ["./velconnect", "serve", "--http=0.0.0.0:8090"]
|
# COPY ./pb_hooks /pb/pb_hooks
|
||||||
|
|
||||||
|
EXPOSE 8092
|
||||||
|
|
||||||
|
# start PocketBase
|
||||||
|
CMD ["/pb/pocketbase", "serve", "--http=0.0.0.0:8092"]
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,6 @@ services:
|
||||||
build: .
|
build: .
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "8094:8090"
|
- "8091:8092"
|
||||||
volumes:
|
volumes:
|
||||||
- ./pb_data:/pb/pb_data
|
- ./pb_data:/pb/pb_data
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/labstack/echo/v5 v5.0.0-20220201181537-ed2888cfa198
|
github.com/labstack/echo/v5 v5.0.0-20220201181537-ed2888cfa198
|
||||||
github.com/pocketbase/dbx v1.10.0
|
|
||||||
github.com/pocketbase/pocketbase v0.16.7
|
github.com/pocketbase/pocketbase v0.16.7
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -51,6 +50,7 @@ require (
|
||||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||||
github.com/mattn/go-sqlite3 v1.14.17 // indirect
|
github.com/mattn/go-sqlite3 v1.14.17 // indirect
|
||||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
||||||
|
github.com/pocketbase/dbx v1.10.0 // indirect
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
github.com/spf13/cast v1.5.1 // indirect
|
github.com/spf13/cast v1.5.1 // indirect
|
||||||
github.com/spf13/cobra v1.7.0 // indirect
|
github.com/spf13/cobra v1.7.0 // indirect
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
_ "velaboratory/velconnect/pb_migrations"
|
_ "velaboratory/velconnect/migrations"
|
||||||
|
|
||||||
"github.com/labstack/echo/v5"
|
"github.com/labstack/echo/v5"
|
||||||
"github.com/pocketbase/pocketbase"
|
"github.com/pocketbase/pocketbase"
|
||||||
|
|
|
||||||
|
|
@ -1,453 +0,0 @@
|
||||||
package migrations
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
|
||||||
"github.com/pocketbase/pocketbase/models"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
m.Register(func(db dbx.Builder) error {
|
|
||||||
jsonData := `[
|
|
||||||
{
|
|
||||||
"id": "ve85cwsj7syqvxu",
|
|
||||||
"created": "2023-07-06 23:08:13.962Z",
|
|
||||||
"updated": "2023-11-03 18:47:06.094Z",
|
|
||||||
"name": "UserCount",
|
|
||||||
"type": "base",
|
|
||||||
"system": false,
|
|
||||||
"schema": [
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "pnhtdbcx",
|
|
||||||
"name": "app_id",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "wkf3zyyb",
|
|
||||||
"name": "room_id",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "f7k9hdoc",
|
|
||||||
"name": "total_users",
|
|
||||||
"type": "number",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "uevek8os",
|
|
||||||
"name": "room_users",
|
|
||||||
"type": "number",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "coilxuep",
|
|
||||||
"name": "version",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "zee0a2yb",
|
|
||||||
"name": "platform",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"indexes": [],
|
|
||||||
"listRule": null,
|
|
||||||
"viewRule": null,
|
|
||||||
"createRule": "",
|
|
||||||
"updateRule": null,
|
|
||||||
"deleteRule": null,
|
|
||||||
"options": {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "fupstz47c55s69f",
|
|
||||||
"created": "2023-07-06 23:10:31.321Z",
|
|
||||||
"updated": "2023-11-03 18:47:06.120Z",
|
|
||||||
"name": "Device",
|
|
||||||
"type": "base",
|
|
||||||
"system": false,
|
|
||||||
"schema": [
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "1tkrnxqf",
|
|
||||||
"name": "os_info",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "knspamfx",
|
|
||||||
"name": "friendly_name",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "qfalwg3c",
|
|
||||||
"name": "modified_by",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "x0zlup7v",
|
|
||||||
"name": "current_app",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "vpzen2th",
|
|
||||||
"name": "current_room",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "d0ckgjhm",
|
|
||||||
"name": "pairing_code",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "hglbl7da",
|
|
||||||
"name": "last_online",
|
|
||||||
"type": "date",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": "",
|
|
||||||
"max": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "qxsvm1rf",
|
|
||||||
"name": "data",
|
|
||||||
"type": "relation",
|
|
||||||
"required": true,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"collectionId": "3qwwkz4wb0lyi78",
|
|
||||||
"cascadeDelete": false,
|
|
||||||
"minSelect": null,
|
|
||||||
"maxSelect": 1,
|
|
||||||
"displayFields": [
|
|
||||||
"data"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "nfernq2q",
|
|
||||||
"name": "owner",
|
|
||||||
"type": "relation",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"collectionId": "_pb_users_auth_",
|
|
||||||
"cascadeDelete": false,
|
|
||||||
"minSelect": null,
|
|
||||||
"maxSelect": 1,
|
|
||||||
"displayFields": [
|
|
||||||
"username"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "p1aruqz5",
|
|
||||||
"name": "past_owners",
|
|
||||||
"type": "relation",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"collectionId": "_pb_users_auth_",
|
|
||||||
"cascadeDelete": false,
|
|
||||||
"minSelect": null,
|
|
||||||
"maxSelect": null,
|
|
||||||
"displayFields": [
|
|
||||||
"username"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"indexes": [],
|
|
||||||
"listRule": "",
|
|
||||||
"viewRule": "",
|
|
||||||
"createRule": null,
|
|
||||||
"updateRule": "",
|
|
||||||
"deleteRule": null,
|
|
||||||
"options": {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "3qwwkz4wb0lyi78",
|
|
||||||
"created": "2023-07-06 23:12:11.113Z",
|
|
||||||
"updated": "2024-01-31 21:26:53.835Z",
|
|
||||||
"name": "DataBlock",
|
|
||||||
"type": "base",
|
|
||||||
"system": false,
|
|
||||||
"schema": [
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "wbifl8pv",
|
|
||||||
"name": "category",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "5a3nwg7m",
|
|
||||||
"name": "modified_by",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "mkzyfsng",
|
|
||||||
"name": "data",
|
|
||||||
"type": "json",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "a3d7pkoh",
|
|
||||||
"name": "owner",
|
|
||||||
"type": "relation",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"collectionId": "_pb_users_auth_",
|
|
||||||
"cascadeDelete": false,
|
|
||||||
"minSelect": null,
|
|
||||||
"maxSelect": 1,
|
|
||||||
"displayFields": [
|
|
||||||
"username"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "80tmi6fm",
|
|
||||||
"name": "block_id",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"indexes": [
|
|
||||||
"CREATE INDEX ` + "`" + `idx_aYVfg1q` + "`" + ` ON ` + "`" + `DataBlock` + "`" + ` (` + "`" + `block_id` + "`" + `)"
|
|
||||||
],
|
|
||||||
"listRule": "",
|
|
||||||
"viewRule": "",
|
|
||||||
"createRule": "",
|
|
||||||
"updateRule": "",
|
|
||||||
"deleteRule": null,
|
|
||||||
"options": {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "_pb_users_auth_",
|
|
||||||
"created": "2023-11-03 18:47:06.067Z",
|
|
||||||
"updated": "2024-01-31 21:26:53.820Z",
|
|
||||||
"name": "Users",
|
|
||||||
"type": "auth",
|
|
||||||
"system": false,
|
|
||||||
"schema": [
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "users_name",
|
|
||||||
"name": "name",
|
|
||||||
"type": "text",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"min": null,
|
|
||||||
"max": null,
|
|
||||||
"pattern": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "users_avatar",
|
|
||||||
"name": "avatar",
|
|
||||||
"type": "file",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"maxSelect": 1,
|
|
||||||
"maxSize": 5242880,
|
|
||||||
"mimeTypes": [
|
|
||||||
"image/jpeg",
|
|
||||||
"image/png",
|
|
||||||
"image/svg+xml",
|
|
||||||
"image/gif",
|
|
||||||
"image/webp"
|
|
||||||
],
|
|
||||||
"thumbs": null,
|
|
||||||
"protected": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "1hwaooub",
|
|
||||||
"name": "devices",
|
|
||||||
"type": "relation",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"collectionId": "fupstz47c55s69f",
|
|
||||||
"cascadeDelete": false,
|
|
||||||
"minSelect": null,
|
|
||||||
"maxSelect": null,
|
|
||||||
"displayFields": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"system": false,
|
|
||||||
"id": "xvw8arlm",
|
|
||||||
"name": "profiles",
|
|
||||||
"type": "relation",
|
|
||||||
"required": false,
|
|
||||||
"unique": false,
|
|
||||||
"options": {
|
|
||||||
"collectionId": "3qwwkz4wb0lyi78",
|
|
||||||
"cascadeDelete": false,
|
|
||||||
"minSelect": null,
|
|
||||||
"maxSelect": null,
|
|
||||||
"displayFields": [
|
|
||||||
"data"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"indexes": [],
|
|
||||||
"listRule": "id = @request.auth.id",
|
|
||||||
"viewRule": "id = @request.auth.id",
|
|
||||||
"createRule": "",
|
|
||||||
"updateRule": "id = @request.auth.id",
|
|
||||||
"deleteRule": "id = @request.auth.id",
|
|
||||||
"options": {
|
|
||||||
"allowEmailAuth": true,
|
|
||||||
"allowOAuth2Auth": true,
|
|
||||||
"allowUsernameAuth": true,
|
|
||||||
"exceptEmailDomains": null,
|
|
||||||
"manageRule": null,
|
|
||||||
"minPasswordLength": 6,
|
|
||||||
"onlyEmailDomains": null,
|
|
||||||
"requireEmail": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]`
|
|
||||||
|
|
||||||
collections := []*models.Collection{}
|
|
||||||
if err := json.Unmarshal([]byte(jsonData), &collections); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return daos.New(db).ImportCollections(collections, true, nil)
|
|
||||||
}, func(db dbx.Builder) error {
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue