Browse Source

Fixed some minor bugs and improved change fleet management for boards

Change-Id: Iec9848fb2a1cbb951591a6dad420543d9e7b6a8c
Carmelo Romeo 5 months ago
parent
commit
b660cbfb5e

+ 13
- 1
iotronic_ui/iot/boards/forms.py View File

@@ -100,7 +100,19 @@ class UpdateBoardForm(forms.SelfHandlingForm):
100 100
     def __init__(self, *args, **kwargs):
101 101
 
102 102
         super(UpdateBoardForm, self).__init__(*args, **kwargs)
103
-        self.fields["fleet_list"].choices = kwargs["initial"]["fleet_list"]
103
+
104
+        # Populate fleets
105
+        fleets = iotronic.fleet_list(self.request, None)
106
+        fleets.sort(key=lambda b: b.name)
107
+
108
+        fleet_list = []
109
+        fleet_list.append((None, _("-")))
110
+        for fleet in fleets:
111
+            fleet_list.append((fleet.uuid, _(fleet.name)))
112
+
113
+        # LOG.debug("FLEETS: %s", fleet_list)
114
+        self.fields["fleet_list"].choices = fleet_list
115
+        self.fields["fleet_list"].initial = kwargs["initial"]["fleet_id"]
104 116
 
105 117
         # LOG.debug("INITIAL: %s", kwargs["initial"])
106 118
 

+ 2
- 1
iotronic_ui/iot/boards/tables.py View File

@@ -175,7 +175,8 @@ class BoardsTable(tables.DataTable):
175 175
     type = tables.Column('type', verbose_name=_('Type'))
176 176
     # mobile = tables.Column('mobile', verbose_name=_('Mobile'))
177 177
     uuid = tables.Column('uuid', verbose_name=_('Board ID'))
178
-    fleet = tables.Column('fleet', verbose_name=_('Fleet ID'))
178
+    # fleet = tables.Column('fleet', verbose_name=_('Fleet ID'))
179
+    fleet_name = tables.Column('fleet_name', verbose_name=_('Fleet Name'))
179 180
     # code = tables.Column('code', verbose_name=_('Code'))
180 181
     status = tables.Column('status', verbose_name=_('Status'))
181 182
     # location = tables.Column('location', verbose_name=_('Geo'))

+ 2
- 0
iotronic_ui/iot/boards/templates/boards/_detail_overview.html View File

@@ -25,6 +25,8 @@
25 25
       <dd>{{ board.mobile }}</dd>
26 26
       <dt>{% trans "Extra" %}</dt>
27 27
       <dd>{{ board.extra }}</dd>
28
+      <dt>{% trans "Fleet Name" %}</dt>
29
+      <dd>{{ board.fleet_name }}</dd>
28 30
       <dt>{% trans "Fleet ID" %}</dt>
29 31
       <dd>{{ board.fleet }}</dd>
30 32
     </dl>

+ 21
- 9
iotronic_ui/iot/boards/views.py View File

@@ -77,6 +77,16 @@ class IndexView(tables.DataTableView):
77 77
 
78 78
             # board.__dict__.update(dict(services=board_services))
79 79
             board._info.update(dict(services=board_services))
80
+
81
+            if board.fleet != None:            
82
+                fleet_info = api.iotronic.fleet_get(self.request,
83
+                                                    board.fleet,
84
+                                                    None)
85
+
86
+                board.fleet_name = fleet_info.name
87
+            else:
88
+                board.fleet_name = None
89
+
80 90
         return boards
81 91
 
82 92
 
@@ -123,19 +133,11 @@ class UpdateView(forms.ModalFormView):
123 133
         board = self.get_object()
124 134
         location = board.location[0]
125 135
 
126
-        # Populate fleets
127
-        fleets = api.iotronic.fleet_list(self.request, None)
128
-        fleets.sort(key=lambda b: b.name)
129
-
130
-        fleet_list = []
131
-        for fleet in fleets:
132
-            fleet_list.append((fleet.uuid, _(fleet.name)))
133
-
134 136
         return {'uuid': board.uuid,
135 137
                 'name': board.name,
136 138
                 'mobile': board.mobile,
137 139
                 'owner': board.owner,
138
-                'fleet_list': fleet_list,
140
+                'fleet_id': board.fleet,
139 141
                 'latitude': location["latitude"],
140 142
                 'longitude': location["longitude"],
141 143
                 'altitude': location["altitude"]}
@@ -499,6 +501,16 @@ class DetailView(tabs.TabView):
499 501
                                                           board_id)
500 502
             board._info.update(dict(plugins=board_plugins))
501 503
 
504
+            # Adding fleet name
505
+            if board.fleet != None:
506
+                fleet_info = api.iotronic.fleet_get(self.request,
507
+                                                    board.fleet,
508
+                                                    None)
509
+
510
+                board.fleet_name = fleet_info.name
511
+            else:
512
+                board.fleet_name = None
513
+
502 514
             # LOG.debug("BOARD: %s\n\n%s", board, board._info)
503 515
 
504 516
         except Exception:

+ 3
- 2
iotronic_ui/iot/fleets/tables.py View File

@@ -93,7 +93,8 @@ class FleetsTable(tables.DataTable):
93 93
     class Meta(object):
94 94
         name = "fleets"
95 95
         verbose_name = _("fleets")
96
-        row_actions = (EditFleetLink, ActionFleetLink,
97
-                       DeleteFleetsAction)
96
+        # row_actions = (EditFleetLink, ActionFleetLink,
97
+        #                DeleteFleetsAction)
98
+        row_actions = (EditFleetLink, DeleteFleetsAction)
98 99
         table_actions = (FleetFilterAction, CreateFleetLink,
99 100
                          DeleteFleetsAction)

+ 1
- 1
iotronic_ui/iot/fleets/views.py View File

@@ -193,7 +193,7 @@ class DetailView(tabs.TabView):
193 193
             fleet = iotronic.fleet_get(self.request, fleet_id, None)
194 194
             boards = iotronic.fleet_get_boards(self.request, fleet_id)
195 195
 
196
-            LOG.debug('XXXX: %s', boards)
196
+            # LOG.debug('Boards: %s', boards)
197 197
 
198 198
             for board in boards:
199 199
                 fleet_boards.append(board._info)

Loading…
Cancel
Save