Browse Source

Restyled some menus and minor fixes.

Change-Id: Idd6cb9c8af0cd525c262229241aa8af5981bbb5f
Carmelo Romeo 4 months ago
parent
commit
7321b63630

+ 0
- 55
iotronic_ui/iot/boards/forms.py View File

@@ -217,7 +217,6 @@ class EnableServiceForm(forms.SelfHandlingForm):
217 217
                 exceptions.handle(request, _(message_text))
218 218
 
219 219
 
220
-"""
221 220
 class DisableServiceForm(forms.SelfHandlingForm):
222 221
 
223 222
     uuid = forms.CharField(label=_("Board ID"), widget=forms.HiddenInput)
@@ -259,7 +258,6 @@ class DisableServiceForm(forms.SelfHandlingForm):
259 258
             except Exception:
260 259
                 message_text = "Unable to disable service."
261 260
                 exceptions.handle(request, _(message_text))
262
-"""
263 261
 
264 262
 
265 263
 class AttachPortForm(forms.SelfHandlingForm):
@@ -461,56 +459,3 @@ class RemovePluginsForm(forms.SelfHandlingForm):
461 459
                         exceptions.handle(request, _(message_text))
462 460
 
463 461
                     break
464
-
465
-
466
-class RemoveServicesForm(forms.SelfHandlingForm):
467
-
468
-    uuid = forms.CharField(label=_("Board ID"), widget=forms.HiddenInput)
469
-
470
-    name = forms.CharField(
471
-        label=_('Board Name'),
472
-        widget=forms.TextInput(attrs={'readonly': 'readonly'})
473
-    )
474
-
475
-    service_list = forms.MultipleChoiceField(
476
-        label=_("Services List"),
477
-        widget=forms.SelectMultiple(
478
-            attrs={'class': 'switchable',
479
-                   'data-slug': 'slug-remove-services'}),
480
-        help_text=_("Select services in this pool")
481
-    )
482
-
483
-    def __init__(self, *args, **kwargs):
484
-
485
-        super(RemoveServicesForm, self).__init__(*args, **kwargs)
486
-        # input=kwargs.get('initial',{})
487
-        self.fields["service_list"].choices = kwargs["initial"]["service_list"]
488
-
489
-    def handle(self, request, data):
490
-
491
-        counter = 0
492
-
493
-        for service in data["service_list"]:
494
-            for key, value in self.fields["service_list"].choices:
495
-                if key == service:
496
-
497
-                    try:
498
-                        disable = iotronic.service_action(request,
499
-                                                          data["uuid"],
500
-                                                          key,
501
-                                                          "ServiceDisable")
502
-
503
-                        message_text = disable
504
-                        messages.success(request, _(message_text))
505
-
506
-                        if counter != len(data["service_list"]) - 1:
507
-                            counter += 1
508
-                        else:
509
-                            return True
510
-
511
-                    except Exception:
512
-                        message_text = "Unable to disable service " \
513
-                                       + str(value) + "."
514
-                        exceptions.handle(request, _(message_text))
515
-
516
-                    break

+ 6
- 19
iotronic_ui/iot/boards/tables.py View File

@@ -51,11 +51,11 @@ class RestoreServices(tables.BatchAction):
51 51
 
52 52
     @staticmethod
53 53
     def action_present(count):
54
-        return u"Restore Services"
54
+        return u"Restore ALL Services"
55 55
 
56 56
     @staticmethod
57 57
     def action_past(count):
58
-        return u"Restore Services"
58
+        return u"Restored ALL Services"
59 59
 
60 60
     def allowed(self, request, board=None):
61 61
         return True
@@ -73,7 +73,6 @@ class EnableServiceLink(tables.LinkAction):
73 73
     # policy_rules = (("iot", "iot:service_action"),)
74 74
 
75 75
 
76
-"""
77 76
 class DisableServiceLink(tables.LinkAction):
78 77
     name = "disableservice"
79 78
     verbose_name = _("Disable Service(s)")
@@ -81,7 +80,6 @@ class DisableServiceLink(tables.LinkAction):
81 80
     classes = ("ajax-modal",)
82 81
     # icon = "plus"
83 82
     # policy_rules = (("iot", "iot:service_action"),)
84
-"""
85 83
 
86 84
 
87 85
 class RemovePluginsLink(tables.LinkAction):
@@ -93,15 +91,6 @@ class RemovePluginsLink(tables.LinkAction):
93 91
     # policy_rules = (("iot", "iot:remove_plugins"),)
94 92
 
95 93
 
96
-class RemoveServicesLink(tables.LinkAction):
97
-    name = "removeservices"
98
-    verbose_name = _("Remove Service(s)")
99
-    url = "horizon:iot:boards:removeservices"
100
-    classes = ("ajax-modal",)
101
-    icon = "plus"
102
-    # policy_rules = (("iot", "iot:remove_services"),)
103
-
104
-
105 94
 class AttachPortLink(tables.LinkAction):
106 95
     name = "attachport"
107 96
     verbose_name = _("Attach Port")
@@ -120,7 +109,7 @@ class DetachPortLink(tables.LinkAction):
120 109
 
121 110
 class EnableWebServiceLink(tables.LinkAction):
122 111
     name = "enablewebservice"
123
-    verbose_name = _("Enable Web Services")
112
+    verbose_name = _("Enable Web Services Manager")
124 113
     url = "horizon:iot:boards:enablewebservice"
125 114
     classes = ("ajax-modal",)
126 115
     icon = "plus"
@@ -128,7 +117,7 @@ class EnableWebServiceLink(tables.LinkAction):
128 117
 
129 118
 class DisableWebServiceLink(tables.LinkAction):
130 119
     name = "disablewebservice"
131
-    verbose_name = _("Disable Web Services")
120
+    verbose_name = _("Disable Web Services Manager")
132 121
     url = "horizon:iot:boards:disablewebservice"
133 122
     classes = ("ajax-modal",)
134 123
     icon = "plus"
@@ -209,11 +198,9 @@ class BoardsTable(tables.DataTable):
209 198
     class Meta(object):
210 199
         name = "boards"
211 200
         verbose_name = _("boards")
212
-        # row_actions = (EditBoardLink, EnableServiceLink, DisableServiceLink,
213
-        row_actions = (EditBoardLink, EnableServiceLink,
201
+        row_actions = (EditBoardLink, EnableServiceLink, DisableServiceLink,
214 202
                        RestoreServices, AttachPortLink, DetachPortLink,
215 203
                        EnableWebServiceLink, DisableWebServiceLink,
216
-                       RemovePluginsLink, RemoveServicesLink,
217
-                       DeleteBoardsAction)
204
+                       RemovePluginsLink, DeleteBoardsAction)
218 205
         table_actions = (BoardFilterAction, CreateBoardLink,
219 206
                          DeleteBoardsAction)

+ 8
- 10
iotronic_ui/iot/boards/urls.py View File

@@ -20,22 +20,20 @@ urlpatterns = [
20 20
     url(r'^create/$', views.CreateView.as_view(), name='create'),
21 21
     url(r'^(?P<board_id>[^/]+)/update/$', views.UpdateView.as_view(),
22 22
         name='update'),
23
-    url(r'^(?P<board_id>[^/]+)/removeplugins/$',
24
-        views.RemovePluginsView.as_view(), name='removeplugins'),
25
-    url(r'^(?P<board_id>[^/]+)/removeservices/$',
26
-        views.RemoveServicesView.as_view(), name='removeservices'),
27 23
     url(r'^(?P<board_id>[^/]+)/enableservice/$',
28 24
         views.EnableServiceView.as_view(), name='enableservice'),
29
-    # url(r'^(?P<board_id>[^/]+)/disableservice/$',
30
-    #     views.DisableServiceView.as_view(), name='disableservice'),
25
+    url(r'^(?P<board_id>[^/]+)/disableservice/$',
26
+        views.DisableServiceView.as_view(), name='disableservice'),
31 27
     url(r'^(?P<board_id>[^/]+)/attachport/$',
32
-        views.EnableWebServiceView.as_view(), name='enablewebservice'),
33
-    url(r'^(?P<board_id>[^/]+)/enablewebservice/$',
34
-        views.DisableWebServiceView.as_view(), name='disablewebservice'),
35
-    url(r'^(?P<board_id>[^/]+)/disablewebservice/$',
36 28
         views.AttachPortView.as_view(), name='attachport'),
37 29
     url(r'^(?P<board_id>[^/]+)/detachport/$',
38 30
         views.DetachPortView.as_view(), name='detachport'),
31
+    url(r'^(?P<board_id>[^/]+)/enablewebservice/$',
32
+        views.EnableWebServiceView.as_view(), name='enablewebservice'),
33
+    url(r'^(?P<board_id>[^/]+)/disablewebservice/$',
34
+        views.DisableWebServiceView.as_view(), name='disablewebservice'),
35
+    url(r'^(?P<board_id>[^/]+)/removeplugins/$',
36
+        views.RemovePluginsView.as_view(), name='removeplugins'),
39 37
     url(r'^(?P<board_id>[^/]+)/detail/$', views.BoardDetailView.as_view(),
40 38
         name='detail'),
41 39
 ]

+ 38
- 72
iotronic_ui/iot/boards/views.py View File

@@ -99,6 +99,7 @@ class IndexView(tables.DataTableView):
99 99
             else:
100 100
                 board.fleet_name = None
101 101
 
102
+        boards.sort(key=lambda b: b.name)
102 103
         return boards
103 104
 
104 105
 
@@ -193,14 +194,26 @@ class EnableServiceView(forms.ModalFormView):
193 194
         board_services = api.iotronic.services_on_board(self.request,
194 195
                                                         board.uuid,
195 196
                                                         True)
196
-
197
+        cloud_services.sort(key=lambda b: b.name)
197 198
         service_list = []
199
+        # LOG.debug('CLOUD SERVICES: %s', cloud_services)
198 200
 
199 201
         for cloud_service in cloud_services:
200 202
 
203
+            uuid = cloud_service._info["uuid"]
204
+            name = cloud_service._info["name"]
205
+
201 206
             if len(board_services) == 0:
202
-                service_list.append((cloud_service._info["uuid"],
203
-                                    _(cloud_service._info["name"])))
207
+
208
+                # BEFORE filtering necessity
209
+                # service_list.append((cloud_service._info["uuid"],
210
+                #                     _(cloud_service._info["name"])))
211
+
212
+                # AFTER filtering necessity
213
+                # We are filtering the services that starts with "webservice"
214
+                if ((name != "webservice") and (name != "webservice_ssl")):
215
+                    service_list.append((uuid, _(name)))
216
+
204 217
             else:
205 218
                 counter = 0
206 219
                 for board_service in board_services:
@@ -209,15 +222,22 @@ class EnableServiceView(forms.ModalFormView):
209 222
                     elif counter != len(board_services) - 1:
210 223
                         counter += 1
211 224
                     else:
212
-                        service_list.append((cloud_service._info["uuid"],
213
-                                            _(cloud_service._info["name"])))
225
+                        # BEFORE filtering necessity
226
+                        # service_list.append((uuid, _(name)))
227
+
228
+                        # AFTER filtering necessity
229
+                        # We are filtering the services that starts
230
+                        # with "webservice"
231
+                        if ((name != "webservice") and
232
+                           ("name" != "webservice_ssl")):
233
+                            service_list.append((uuid, _(name)))
214 234
 
235
+        # LOG.debug('SERVICES: %s', service_list)
215 236
         return {'uuid': board.uuid,
216 237
                 'name': board.name,
217 238
                 'service_list': service_list}
218 239
 
219 240
 
220
-"""
221 241
 class DisableServiceView(forms.ModalFormView):
222 242
     template_name = 'iot/boards/disableservice.html'
223 243
     modal_header = _("Disable Service(s)")
@@ -256,21 +276,21 @@ class DisableServiceView(forms.ModalFormView):
256 276
         board_services = api.iotronic.services_on_board(self.request,
257 277
                                                         board.uuid,
258 278
                                                         True)
259
-
279
+        cloud_services.sort(key=lambda b: b.name)
260 280
         service_list = []
261 281
 
262
-
263 282
         # BEFORE filtering necessity
264
-        # for cloud_service in cloud_services:
265
-        #     for board_service in board_services:
266
-        #         if board_service["uuid"] == cloud_service._info["uuid"]:
267
-        #             service_list.append((cloud_service._info["uuid"],
268
-        #                                 _(cloud_service._info["name"])))
283
+        """
284
+        for cloud_service in cloud_services:
285
+            for board_service in board_services:
286
+                if board_service["uuid"] == cloud_service._info["uuid"]:
287
+                    service_list.append((cloud_service._info["uuid"],
288
+                                        _(cloud_service._info["name"])))
289
+        """
269 290
 
270 291
         # AFTER filtering necessity
271 292
         # We are filtering the services that starts with "webservice"
272 293
         # ------------------------------------------------------------
273
-
274 294
         for cloud_service in cloud_services:
275 295
             for board_service in board_services:
276 296
                 if ((board_service["uuid"] == cloud_service._info["uuid"]) and
@@ -283,7 +303,6 @@ class DisableServiceView(forms.ModalFormView):
283 303
         return {'uuid': board.uuid,
284 304
                 'name': board.name,
285 305
                 'service_list': service_list}
286
-"""
287 306
 
288 307
 
289 308
 class AttachPortView(forms.ModalFormView):
@@ -322,6 +341,7 @@ class AttachPortView(forms.ModalFormView):
322 341
         networks = api.neutron.network_list(self.request)
323 342
         net_choices = []
324 343
 
344
+        networks.sort(key=lambda b: b.name)
325 345
         for net in networks:
326 346
             for subnet in net["subnets"]:
327 347
                 net_choices.append((net["id"] + ':' + subnet["id"],
@@ -371,6 +391,7 @@ class DetachPortView(forms.ModalFormView):
371 391
         # ################################################################
372 392
         # LOG.debug("PORTS: %s", ports)
373 393
 
394
+        ports.sort(key=lambda b: b.name)
374 395
         filtered_ports = []
375 396
         for port in ports:
376 397
             if port._info["board_uuid"] == board.uuid:
@@ -388,7 +409,7 @@ class DetachPortView(forms.ModalFormView):
388 409
 
389 410
 class EnableWebServiceView(forms.ModalFormView):
390 411
     template_name = 'iot/boards/enablewebservice.html'
391
-    modal_header = _("Enable Web Service(s)")
412
+    modal_header = _("Enable Web Services Manager")
392 413
     form_id = "webservice_enable_form"
393 414
     form_class = project_forms.EnableWebServiceForm
394 415
     submit_label = _("Enable")
@@ -425,7 +446,7 @@ class EnableWebServiceView(forms.ModalFormView):
425 446
 
426 447
 class DisableWebServiceView(forms.ModalFormView):
427 448
     template_name = 'iot/boards/disablewebservice.html'
428
-    modal_header = _("Disable Web Service(s)")
449
+    modal_header = _("Disable Web Services Manager")
429 450
     form_id = "webservice_disable_form"
430 451
     form_class = project_forms.DisableWebServiceForm
431 452
     submit_label = _("Disable")
@@ -508,61 +529,6 @@ class RemovePluginsView(forms.ModalFormView):
508 529
                 'plugin_list': plugin_list}
509 530
 
510 531
 
511
-class RemoveServicesView(forms.ModalFormView):
512
-    template_name = 'iot/boards/removeservices.html'
513
-    modal_header = _("Remove Services from board")
514
-    form_id = "remove_boardservices_form"
515
-    form_class = project_forms.RemoveServicesForm
516
-    submit_label = _("Remove")
517
-    # submit_url = reverse_lazy("horizon:iot:boards:removeservices")
518
-    submit_url = "horizon:iot:boards:removeservices"
519
-    success_url = reverse_lazy('horizon:iot:boards:index')
520
-    page_title = _("Remove Services from board")
521
-
522
-    @memoized.memoized_method
523
-    def get_object(self):
524
-        try:
525
-            return api.iotronic.board_get(self.request,
526
-                                          self.kwargs['board_id'],
527
-                                          None)
528
-        except Exception:
529
-            redirect = reverse("horizon:iot:boards:index")
530
-            exceptions.handle(self.request,
531
-                              _('Unable to get board information.'),
532
-                              redirect=redirect)
533
-
534
-    def get_context_data(self, **kwargs):
535
-        context = super(RemoveServicesView, self).get_context_data(**kwargs)
536
-        args = (self.get_object().uuid,)
537
-        context['submit_url'] = reverse(self.submit_url, args=args)
538
-        return context
539
-
540
-    def get_initial(self):
541
-        board = self.get_object()
542
-
543
-        # Populate services
544
-        services = api.iotronic.services_on_board(self.request,
545
-                                                  board.uuid,
546
-                                                  True)
547
-        services.sort(key=lambda b: b["name"])
548
-
549
-        service_list = []
550
-        for service in services:
551
-            # service_list.append((service["uuid"], _(service["name"])))
552
-
553
-            # TO BE REMOVED
554
-            # ###########################################################
555
-            # We are filtering the services that starts with "webservice"
556
-            if ((service["name"] != "webservice") and
557
-               (service["name"] != "webservice_ssl")):
558
-                service_list.append((service["uuid"], _(service["name"])))
559
-            # ###########################################################
560
-
561
-        return {'uuid': board.uuid,
562
-                'name': board.name,
563
-                'service_list': service_list}
564
-
565
-
566 532
 class DetailView(tabs.TabView):
567 533
     tab_group_class = project_tabs.BoardDetailTabs
568 534
     template_name = 'horizon/common/_detail.html'

+ 5
- 2
iotronic_ui/iot/webservices/forms.py View File

@@ -33,11 +33,15 @@ class ExposeWebserviceForm(forms.SelfHandlingForm):
33 33
         widget=forms.TextInput(attrs={'readonly': 'readonly'})
34 34
     )
35 35
 
36
+    zone = forms.CharField(label=_("Zone"),
37
+                           widget=forms.TextInput(attrs={'readonly':
38
+                                                         'readonly'}))
39
+
36 40
     ws_name = forms.CharField(label=_("Web Service Name"))
37 41
 
38 42
     port = forms.IntegerField(
39 43
         label=_("Port"),
40
-        help_text=_("The port used by the service")
44
+        help_text=_("The local port used by the service")
41 45
     )
42 46
 
43 47
     secure = forms.BooleanField(label=_("Secure"), initial=True)
@@ -98,6 +102,5 @@ class UnexposeWebserviceForm(forms.SelfHandlingForm):
98 102
                     return True
99 103
 
100 104
             except Exception:
101
-                LOG.debug("HERE")
102 105
                 message_text = "Unable to unexpose web service."
103 106
                 exceptions.handle(request, _(message_text))

+ 4
- 1
iotronic_ui/iot/webservices/views.py View File

@@ -129,8 +129,11 @@ class ExposeView(forms.ModalFormView):
129 129
 
130 130
     def get_initial(self):
131 131
         board = self.get_object()
132
+        board_exp_info = iotronic.webservice_get_enabled_info(self.request,
133
+                                                              board.uuid)
134
+        zone = board_exp_info.dns + "." + board_exp_info.zone
132 135
 
133
-        return {'uuid': board.uuid, 'name': board.name}
136
+        return {'uuid': board.uuid, 'name': board.name, 'zone': zone}
134 137
 
135 138
 
136 139
 class UnexposeView(forms.ModalFormView):

Loading…
Cancel
Save