Files
boc/vims-backend/scripts/quick-start.sh
T
Bernt 6de2455917 v1.2.0: Add Global Markets footer, translated to 9 languages
- Added GLOBAL_MARKETS_TITLE to all translation files
- Updated footer with 12 markets (4 active + 8 upcoming)
- Translated market section to: zh-cn, zh-tw, ja, ko, th, vi, id, ms, hi
- Built and deployed to production
- CloudFront invalidation: I3RTMXVFDJXWLG3SYX208OP1CC
2026-07-08 19:56:03 +00:00

151 lines
4.1 KiB
Bash
Executable File

#!/bin/bash
# VIMS Quick Start Script
# Complete setup and first upload
set -e
API_URL="${VIMS_API_URL:-http://localhost:3450}"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
echo -e "${BLUE}"
echo "╔══════════════════════════════════════════╗"
echo "║ VIMS - Quick Start Guide ║"
echo "║ Visual Infrastructure Monitoring ║"
echo "╚══════════════════════════════════════════╝"
echo -e "${NC}"
# Check if server is running
echo -e "${YELLOW}Checking server...${NC}"
if ! curl -s "$API_URL/health" > /dev/null 2>&1; then
echo -e "${RED}Server not running!${NC}"
echo ""
echo "Start server with:"
echo " cd vims-backend"
echo " docker-compose up -d postgres redis minio"
echo " npm run dev"
exit 1
fi
echo -e "${GREEN}✓ Server running${NC}"
# Step 1: Create object
echo ""
echo -e "${YELLOW}Step 1: Creating ATM object...${NC}"
OBJECT_RESPONSE=$(curl -s -X POST "$API_URL/api/v1/objects" \
-H "Content-Type: application/json" \
-d '{
"objectTypeId": "atm-type-uuid",
"customerId": "demo-customer",
"name": "ATM Quick Start",
"externalId": "ATM-QUICK-001",
"location": {
"latitude": 59.3368,
"longitude": 18.0555
},
"address": "Stureplan 4, Stockholm"
}')
OBJECT_ID=$(echo "$OBJECT_RESPONSE" | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)
if [ -z "$OBJECT_ID" ]; then
echo -e "${RED}Failed to create object${NC}"
echo "$OBJECT_RESPONSE"
exit 1
fi
echo -e "${GREEN}✓ Object created: $OBJECT_ID${NC}"
# Step 2: Check if photo provided
if [ -z "$1" ]; then
echo ""
echo -e "${YELLOW}Step 2: Upload photo${NC}"
echo ""
echo "To upload a photo, run:"
echo " $0 /path/to/photo.jpg"
echo ""
echo "Example:"
echo " $0 ~/photos/atm-front.jpg"
echo ""
echo "Object ID for manual upload: ${GREEN}$OBJECT_ID${NC}"
echo ""
echo "Or use the upload script:"
echo " ./scripts/upload-photo.sh -f photo.jpg -o $OBJECT_ID -a front"
exit 0
fi
PHOTO="$1"
if [ ! -f "$PHOTO" ]; then
echo -e "${RED}Photo not found: $PHOTO${NC}"
exit 1
fi
# Step 2: Upload photo
echo ""
echo -e "${YELLOW}Step 2: Uploading photo...${NC}"
UPLOAD_RESPONSE=$(curl -s -X POST "$API_URL/api/v1/observations" \
-F "images=@$PHOTO" \
-F "objectId=$OBJECT_ID" \
-F "angle=front")
if echo "$UPLOAD_RESPONSE" | grep -q "error"; then
echo -e "${RED}Upload failed${NC}"
echo "$UPLOAD_RESPONSE"
exit 1
fi
echo -e "${GREEN}✓ Photo uploaded${NC}"
# Step 3: Process observation
OBS_ID=$(echo "$UPLOAD_RESPONSE" | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)
echo ""
echo -e "${YELLOW}Step 3: Processing observation...${NC}"
PROCESS_RESPONSE=$(curl -s -X POST "$API_URL/api/v1/observations/$OBS_ID/process")
echo -e "${GREEN}✓ Observation processed${NC}"
# Step 4: Show results
echo ""
echo -e "${YELLOW}Step 4: Results${NC}"
echo ""
# Get object status
OBJECT_STATUS=$(curl -s "$API_URL/api/v1/objects/$OBJECT_ID")
STATUS=$(echo "$OBJECT_STATUS" | grep -o '"currentStatus":"[^"]*"' | cut -d'"' -f4)
echo "Object Status: ${GREEN}$STATUS${NC}"
# Get detections
DETECTIONS=$(curl -s "$API_URL/api/v1/detections?observationId=$OBS_ID")
DETECTION_COUNT=$(echo "$DETECTIONS" | grep -o '"detections"' | wc -l)
echo "Detections: $DETECTION_COUNT"
# Get alerts
ALERTS=$(curl -s "$API_URL/api/v1/alerts?objectId=$OBJECT_ID")
ALERT_COUNT=$(echo "$ALERTS" | grep -o '"alerts"' | wc -l)
echo "Alerts: $ALERT_COUNT"
echo ""
echo -e "${GREEN}✓ Quick start complete!${NC}"
echo ""
echo "Object ID: ${BLUE}$OBJECT_ID${NC}"
echo "Observation ID: ${BLUE}$OBS_ID${NC}"
echo ""
echo "View details:"
echo " Object: curl $API_URL/api/v1/objects/$OBJECT_ID"
echo " Detection: curl $API_URL/api/v1/detections?observationId=$OBS_ID"
echo " Alerts: curl $API_URL/api/v1/alerts?objectId=$OBJECT_ID"