sdn controllers: list, create, show
[osm/LW-UI.git] / static / src / sdnctrlhandler / sdn_list.js
diff --git a/static/src/sdnctrlhandler/sdn_list.js b/static/src/sdnctrlhandler/sdn_list.js
new file mode 100644 (file)
index 0000000..8069474
--- /dev/null
@@ -0,0 +1,57 @@
+function deleteSDN(project_id, sdn_uuid) {
+    bootbox.confirm("Are you sure want to delete?", function (result) {
+        if (result) {
+            location.href = '/projects/' + project_id + '/sdn/' + sdn_uuid + '/delete'
+        }
+    })
+}
+
+function showSDN(project_id, sdn_uuid) {
+    var dialog = bootbox.dialog({
+        message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
+        closeButton: true
+    });
+
+    $.ajax({
+        url: '/projects/' + project_id + '/sdn/' + sdn_uuid ,
+        //url: '/sdn/' + sdn_uuid,
+        type: 'GET',
+        dataType: "json",
+        contentType: "application/json;charset=utf-8",
+        success: function (result) {
+            //$('#modal_show_vim_body').empty();
+            var sdn = result.sdn;
+            if (sdn) {
+                $('#modal_show_sdn_body').find('span').text('-');
+                for (var k in sdn) {
+                    $('#' + k).text(sdn[k])
+                }
+                if (sdn['_admin']) {
+                    for (var i in sdn['_admin']) {
+                        if (i === 'modified' || i === 'created') {
+                            //$('#' + i).text(new Date(sdn['_admin'][i]* 1000).toUTCString());
+                            $('#' + i).text(moment(sdn['_admin'][i] * 1000).format('DD/MM/YY hh:mm:ss'));
+                        }
+                        else if (i === 'deployed') {
+                            $('#' + i).text(JSON.stringify(sdn['_admin'][i]))
+                        }
+                        else
+                            $('#' + i).text(sdn['_admin'][i])
+                    }
+                }
+                dialog.modal('hide');
+                $('#modal_show_sdn').modal('show');
+            }
+            else {
+                dialog.modal('hide');
+                bootbox.alert("An error occurred while retrieving the SDN controller info.");
+            }
+
+        },
+        error: function (result) {
+            dialog.modal('hide');
+            bootbox.alert("An error occurred while retrieving the SDN controller info.");
+        }
+    });
+
+}
\ No newline at end of file