diff --git a/app/api/processingnodes.py b/app/api/processingnodes.py index ed4fe6d7..af1975ae 100644 --- a/app/api/processingnodes.py +++ b/app/api/processingnodes.py @@ -10,6 +10,11 @@ from nodeodm.models import ProcessingNode class ProcessingNodeSerializer(serializers.ModelSerializer): + online = serializers.SerializerMethodField() + + def get_online(self, obj): + return obj.is_online() + class Meta: model = ProcessingNode fields = '__all__' diff --git a/app/static/app/js/components/EditTaskForm.jsx b/app/static/app/js/components/EditTaskForm.jsx index 89a33c19..198c8320 100644 --- a/app/static/app/js/components/EditTaskForm.jsx +++ b/app/static/app/js/components/EditTaskForm.jsx @@ -76,16 +76,13 @@ class EditTaskForm extends React.Component { let now = new Date(); let nodes = json.map(node => { - let last_refreshed = new Date(node.last_refreshed); - let enabled = (now - last_refreshed) < 1000 * 60 * 5; // 5 minutes - return { id: node.id, key: node.id, label: `${node.hostname}:${node.port} (queue: ${node.queue_count})`, options: node.available_options, queue_count: node.queue_count, - enabled: enabled, + enabled: node.online, url: `http://${node.hostname}:${node.port}` }; }); diff --git a/app/tests/test_api.py b/app/tests/test_api.py index e4f7ada2..c2ce9b09 100644 --- a/app/tests/test_api.py +++ b/app/tests/test_api.py @@ -321,6 +321,11 @@ class TestApi(BootTestCase): self.assertEqual(res.status_code, status.HTTP_200_OK) self.assertTrue(res.data["hostname"] == "localhost") + # Verify online field exists + self.assertTrue("online" in res.data) + + # Should be set to false + self.assertFalse(res.data['online']) # Cannot delete a processing node as normal user res = client.delete('/api/processingnodes/{}/'.format(pnode.id)) diff --git a/slate/source/includes/reference/_processingnode.md b/slate/source/includes/reference/_processingnode.md index fd22527d..29bbbdab 100644 --- a/slate/source/includes/reference/_processingnode.md +++ b/slate/source/includes/reference/_processingnode.md @@ -5,6 +5,7 @@ ```json { "id": 2, + "online": true, "hostname": "nodeodm.masseranolabs.com", "port": 80, "api_version": "1.0.1", @@ -27,6 +28,7 @@ take care of processing input images. Processing nodes are computers or virtual Field | Type | Description ----- | ---- | ----------- id | int | Unique Identifier +online | bool | Whether the processing node could be reached in the last 5 minutes hostname | string | Hostname/IP address port | int | Port api_version | string | Version of node-OpenDroneMap currently running