mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 02:12:49 +00:00 
			
		
		
		
	[API] Update build.func to set the status message correct (#1878)
* Testing * Testing * update /data/page.tsx * Update page.tsx
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							a0eb173824
						
					
				
				
					commit
					cd4bcefa58
				
			@@ -195,7 +195,17 @@ const DataFetcher: React.FC = () => {
 | 
			
		||||
            <tbody>
 | 
			
		||||
              {paginatedData.map((item, index) => (
 | 
			
		||||
                <tr key={index}>
 | 
			
		||||
                  <td className="px-4 py-2 border-b">{item.status === "done" ? "✔️" : item.status === "failed" ? "❌" : item.status}</td>
 | 
			
		||||
                  <td className="px-4 py-2 border-b">
 | 
			
		||||
                    {item.status === "done" ? (
 | 
			
		||||
                      "✔️"
 | 
			
		||||
                    ) : item.status === "failed" ? (
 | 
			
		||||
                      "❌"
 | 
			
		||||
                    ) : item.status === "installing" ? (
 | 
			
		||||
                      "🔄"  
 | 
			
		||||
                    ) : (
 | 
			
		||||
                      item.status
 | 
			
		||||
                    )}
 | 
			
		||||
                  </td>
 | 
			
		||||
                  <td className="px-4 py-2 border-b">{item.nsapp}</td>
 | 
			
		||||
                  <td className="px-4 py-2 border-b">{item.os_type}</td>
 | 
			
		||||
                  <td className="px-4 py-2 border-b">{item.os_version}</td>
 | 
			
		||||
 
 | 
			
		||||
@@ -73,6 +73,7 @@ error_handler() {
 | 
			
		||||
  local exit_code="$?"
 | 
			
		||||
  local line_number="$1"
 | 
			
		||||
  local command="$2"
 | 
			
		||||
  post_update_to_api "failed"
 | 
			
		||||
  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
			
		||||
  echo -e "\n$error_message\n"
 | 
			
		||||
}
 | 
			
		||||
@@ -813,7 +814,7 @@ post_to_api() {
 | 
			
		||||
    "nsapp": "$NSAPP",
 | 
			
		||||
    "method": "$METHOD",
 | 
			
		||||
    "pve_version": "$pve_version",
 | 
			
		||||
    "status": "failed",
 | 
			
		||||
    "status": "installing",
 | 
			
		||||
    "random_id": "$RANDOM_UUID"
 | 
			
		||||
}
 | 
			
		||||
EOF
 | 
			
		||||
@@ -829,26 +830,31 @@ EOF
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
post_update_to_api() {
 | 
			
		||||
  local API_URL="http://api.community-scripts.org/upload/updatestatus"
 | 
			
		||||
POST_UPDATE_DONE=false
 | 
			
		||||
 | 
			
		||||
  JSON_PAYLOAD=$(cat <<EOF
 | 
			
		||||
post_update_to_api() {
 | 
			
		||||
    if [ "$POST_UPDATE_DONE" = true ]; then
 | 
			
		||||
        return 0
 | 
			
		||||
    fi
 | 
			
		||||
    local API_URL="http://api.community-scripts.org/upload/updatestatus"    
 | 
			
		||||
    local status="${1:-}"
 | 
			
		||||
    JSON_PAYLOAD=$(cat <<EOF
 | 
			
		||||
{
 | 
			
		||||
    "status": "done",
 | 
			
		||||
    "status": "$status",
 | 
			
		||||
    "random_id": "$RANDOM_UUID"
 | 
			
		||||
}
 | 
			
		||||
EOF
 | 
			
		||||
)
 | 
			
		||||
   
 | 
			
		||||
  RESPONSE=$(curl -s -o response.txt -w "%{http_code}" -L -X POST "$API_URL" --post301 --post302 \
 | 
			
		||||
      -H "Content-Type: application/json" \
 | 
			
		||||
      -d "$JSON_PAYLOAD")
 | 
			
		||||
    
 | 
			
		||||
  if [ "$RESPONSE" -ne 201 ] && [ "$RESPONSE" -ne 302 ]; then
 | 
			
		||||
    msg_error "API request failed with HTTP code $RESPONSE"
 | 
			
		||||
  fi
 | 
			
		||||
   RESPONSE=$(curl -s -o response.txt -w "%{http_code}" -L -X POST "$API_URL" --post301 --post302 \
 | 
			
		||||
        -H "Content-Type: application/json" \
 | 
			
		||||
        -d "$JSON_PAYLOAD")
 | 
			
		||||
 | 
			
		||||
   
 | 
			
		||||
    if [ "$RESPONSE" -ne 201 ] && [ "$RESPONSE" -ne 302 ]; then
 | 
			
		||||
        msg_error "API UPDATE request failed with HTTP code $RESPONSE"
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
   POST_UPDATE_DONE=true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
diagnostics_check(){
 | 
			
		||||
@@ -1231,3 +1237,8 @@ EOF
 | 
			
		||||
    post_update_to_api
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
trap 'post_update_to_api "done"' EXIT
 | 
			
		||||
trap 'post_update_to_api "failed"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed"' SIGTERM
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user