Expose ODM version, label for processing nodes

pull/600/head
Piero Toffanin 2019-01-15 09:06:22 -05:00
rodzic 6960c811b0
commit 3e5de5ad64
8 zmienionych plików z 49 dodań i 7 usunięć

Wyświetl plik

@ -10,10 +10,14 @@ from nodeodm.models import ProcessingNode
class ProcessingNodeSerializer(serializers.ModelSerializer):
online = serializers.SerializerMethodField()
label = serializers.SerializerMethodField()
def get_online(self, obj):
return obj.is_online()
def get_label(self, obj):
return str(obj)
class Meta:
model = ProcessingNode
fields = '__all__'
@ -30,7 +34,7 @@ class ProcessingNodeFilter(FilterSet):
class Meta:
model = ProcessingNode
fields = ['has_available_options', 'id', 'hostname', 'port', 'api_version', 'queue_count', 'max_images', ]
fields = ['has_available_options', 'id', 'hostname', 'port', 'api_version', 'queue_count', 'max_images', 'label', ]
class ProcessingNodeViewSet(viewsets.ModelViewSet):
"""

Wyświetl plik

@ -108,7 +108,7 @@ class EditTaskForm extends React.Component {
return {
id: node.id,
key: node.id,
label: `${node.hostname}:${node.port} (queue: ${node.queue_count})`,
label: `${node.label} (queue: ${node.queue_count})`,
options: node.available_options,
queue_count: node.queue_count,
enabled: node.online,

Wyświetl plik

@ -19,6 +19,10 @@
<td>{% trans "API Version" %}</td>
<td>{{ processing_node.api_version }}</td>
</tr>
<tr>
<td>{% trans "ODM Version" %}</td>
<td>{{ processing_node.odm_version }}</td>
</tr>
<tr>
<td>{% trans "Queue Count" %}</td>
<td>{{ processing_node.queue_count }}</td>
@ -27,6 +31,10 @@
<td>{% trans "Max Images Limit" %}</td>
<td>{{ processing_node.max_images }}</td>
</tr>
<tr>
<td>{% trans "Label" %}</td>
<td>{{ processing_node.label|default:"None" }}</td>
</tr>
<tr>
<td>{% trans "Last Refreshed" %}</td>
<td>{{ processing_node.last_refreshed|timesince }} {% trans 'ago' %} ({{ processing_node.last_refreshed|localtime }})</td> <!-- TODO: timezone? -->

Wyświetl plik

@ -4,6 +4,6 @@ from guardian.admin import GuardedModelAdmin
from .models import ProcessingNode
class ProcessingNodeAdmin(GuardedModelAdmin):
fields = ('hostname', 'port', 'token')
fields = ('hostname', 'port', 'token', 'label', )
admin.site.register(ProcessingNode, ProcessingNodeAdmin)

Wyświetl plik

@ -0,0 +1,23 @@
# Generated by Django 2.0.3 on 2019-01-15 13:46
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('nodeodm', '0004_processingnode_max_images'),
]
operations = [
migrations.AddField(
model_name='processingnode',
name='label',
field=models.CharField(blank=True, default='', help_text='Optional label for this node. When set, this label will be shown instead of hostname:port.', max_length=255),
),
migrations.AddField(
model_name='processingnode',
name='odm_version',
field=models.CharField(help_text='OpenDroneMap version used by the node.', max_length=32, null=True),
),
]

Wyświetl plik

@ -43,9 +43,14 @@ class ProcessingNode(models.Model):
available_options = fields.JSONField(default=dict(), help_text="Description of the options that can be used for processing")
token = models.CharField(max_length=1024, blank=True, default="", help_text="Token to use for authentication. If the node doesn't have authentication, you can leave this field blank.")
max_images = models.PositiveIntegerField(help_text="Maximum number of images accepted by this node.", blank=True, null=True)
odm_version = models.CharField(max_length=32, null=True, help_text="OpenDroneMap version used by the node")
label = models.CharField(max_length=255, default="", blank=True, help_text="Optional label for this node. When set, this label will be shown instead of the hostname:port name.")
def __str__(self):
return '{}:{}'.format(self.hostname, self.port)
if self.label != "":
return self.label
else:
return '{}:{}'.format(self.hostname, self.port)
@staticmethod
def find_best_available_node():
@ -79,6 +84,8 @@ class ProcessingNode(models.Model):
if 'maxImages' in info:
self.max_images = info['maxImages']
if 'odmVersion' in info:
self.odm_version = info['odmVersion']
options = api_client.options()
self.available_options = options

Wyświetl plik

@ -64,7 +64,7 @@ class Plugin(PluginBase):
matches = [n for n in nodes if n.hostname == hostname and n.port == port and n.token == token]
if len(matches) == 0:
# Add
node = ProcessingNode.objects.create(hostname=hostname, port=port, token=token)
node = ProcessingNode.objects.create(hostname=hostname, port=port, token=token, label="Lightning")
assign_perm('view_processingnode', request.user, node)
assign_perm('change_processingnode', request.user, node)
assign_perm('delete_processingnode', request.user, node)

Wyświetl plik

@ -130,7 +130,7 @@ export default class Dashboard extends React.Component {
<div>
<ul>
{nodes.map(n =>
<li key={n.id}><i className="fa fa-laptop"></i> <a href={`/processingnode/${n.id}/`}>{n.hostname}:{n.port}</a></li>
<li key={n.id}><i className="fa fa-laptop"></i> <a href={`/processingnode/${n.id}/`}>{n.label}</a></li>
)}
</ul>
<button className="btn btn-sm btn-default" onClick={this.handleSyncProcessingNode}><i className="fa fa-refresh"></i> Resync</button>
@ -140,7 +140,7 @@ export default class Dashboard extends React.Component {
{nodes.length > 0 ?
<div>
<hr/>
<i className="fa fa-thumbs-o-up"></i> You are all set! When creating a new task from the <a href="/dashboard">Dashboard</a>, select <strong>{nodes[0].hostname}:{nodes[0].port}</strong> from the <strong>Processing Node</strong> drop-down instead of Auto.
<i className="fa fa-thumbs-o-up"></i> You are all set! When creating a new task from the <a href="/dashboard">Dashboard</a>, select <strong>{nodes[0].label}</strong> from the <strong>Processing Node</strong> drop-down instead of Auto.
</div> : ""}
<div className="buttons text-right">