[SECIOTSRK-503] Control App Dashboard is updated to display SMACK & DAC reports
authorArtem Motchanyi <a.motchanyi@samsung.com>
Fri, 15 Sep 2017 08:59:32 +0000 (11:59 +0300)
committerArtem Motchanyi <a.motchanyi@samsung.com>
Fri, 15 Sep 2017 12:32:51 +0000 (15:32 +0300)
control_app/iot-manager-dashboard/.gitignore
control_app/iot-manager-dashboard/.package/config.xml
control_app/iot-manager-dashboard/css/styles.css
control_app/iot-manager-dashboard/js/controllers/dashboard_controller.js
control_app/iot-manager-dashboard/js/main.js
control_app/iot-manager-popup/.gitignore

index 8a11a5d..27ba2f4 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<widget xmlns:tizen="http://tizen.org/ns/widgets" xmlns="http://www.w3.org/ns/widgets" id="http://yourdomain/iotmanagerdashboard" version="1.0.0" viewmodes="maximized">
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://yourdomain/iotmanagerdashboard" version="1.0.0" viewmodes="maximized">
     <tizen:application id="lFI9TOMZjd.iotmanagerdashboard" package="lFI9TOMZjd" required_version="3.0"/>
     <content src="views/index.html"/>
     <feature name="http://tizen.org/feature/screen.size.all"/>
index ab4c55a..7783769 100644 (file)
@@ -426,11 +426,27 @@ img {
     margin-top: 1em;
 }
 
-#reports-list .body textarea {
-    width: 100%;
-    height: 24em;
-    max-height: 24em;
-    resize: none;
+#reports-list .movie-list thead th,
+#reports-list .movie-list tbody tr:last-child {
+    border-bottom: 1px solid #d6d6d6; /* non-RGBA fallback */
+    border-bottom: 1px solid rgba(0,0,0,.1);
+}
+
+#reports-list .movie-list tbody th,
+#reports-list .movie-list tbody td {
+    border-bottom: 1px solid #e6e6e6; /* non-RGBA fallback  */
+    border-bottom: 1px solid rgba(0,0,0,.05);
+}
+
+#reports-list .movie-list tbody tr:last-child th,
+#reports-list .movie-list tbody tr:last-child td {
+    border-bottom: 0;
+}
+
+#reports-list .movie-list tbody tr:nth-child(odd) td,
+#reports-list .movie-list tbody tr:nth-child(odd) th {
+    background-color: #eeeeee; /* non-RGBA fallback  */
+    background-color: rgba(0,0,0,.04);
 }
 /*security dashboard styles*//*END*/
 
index e73570d..c5d1a16 100644 (file)
@@ -88,21 +88,6 @@ function DashboardController() {
                 "</div>"
             );
 
-            data.reports.forEach(function(report) {
-                var status = "ok";
-
-                if (report.result != 0) {
-                    status = "err";
-                }
-
-                $(m_dashboard).find(".device-info .list").append(
-                    "<div class='item'>" +
-                        "<div class='key'>" + report.name + "</div>" +
-                        "<div class='value " + status + "'</div>" +
-                    "</div>"
-                );
-            });
-
             $(m_dashboard).append("<div class='agent-list'></div>");
 
             data.agents.forEach(function(agent) {
@@ -138,19 +123,107 @@ function DashboardController() {
             devicesController.appendDeviceHtml(device, m_reports);
             $(m_reports).append("<div id='reports-list'></div>");
 
-            reports.forEach(function(report){
-                $(m_reportsList).append(
-                    "<div class='item' data-item='" + report.name + "'>" +
-                        "<div class='name-lable'>Name:</div><div class='name'>" + report.name + "</div>" +
-                        "<div class='date-lable'>Date:</div><div class='date'>" + report.date + "</div>" +
-                        "<div class='body'><textarea readonly='readonly' data-role='none'>" + JSON.stringify(report.data, null, 4) + "</textarea></div>" +
-                    "</div>"
-                );
+            var reportNames =[];
+
+            if (reports.hasOwnProperty(DashboardController.Report.SMACK) &&
+                reports[DashboardController.Report.SMACK].length > 0) {
+                reportNames.push(DashboardController.Report.SMACK);
+            }
+            if (reports.hasOwnProperty(DashboardController.Report.DAC) &&
+                reports[DashboardController.Report.DAC].length > 0) {
+                reportNames.push(DashboardController.Report.DAC);
+            }
+            if (reports.hasOwnProperty(DashboardController.Report.SYSCALL) &&
+                reports[DashboardController.Report.SYSCALL].length > 0) {
+                reportNames.push(DashboardController.Report.SYSCALL);
+            }
+
+            reportNames.forEach(function(reportName) {
+                var displayName = DashboardController.getReportName(reportName);
+
+                var thead = "";
+                var tbody = "";
+
+                switch (reportName) {
+                case DashboardController.Report.SMACK:
+                    thead =
+                        "<tr>" +
+                            "<th>PID</th>" +
+                             "<th>Command</th>" +
+                             "<th>Subject</th>" +
+                             "<th>Object</th>" +
+                             "<th>LSM</th>" +
+                             "<th>Path</th>" +
+                             "<th>Requested</th>" +
+                             "<th>Dev</th>" +
+                             "<th>Date</th>" +
+                         "</tr>";
+
+                    reports[reportName].forEach(function(report) {
+                        tbody +=
+                            "<tr>" +
+                                "<th>" + report.pid + "</td>" +
+                                "<td>" + report.comm + "</td>" +
+                                "<td>" + report.subject + "</td>" +
+                                "<td>" + report.object + "</td>" +
+                                "<td>" + report.lsm + "</td>" +
+                                "<td>" + report.path + "</td>" +
+                                "<td>" + report.requested + "</td>" +
+                                "<td>" + report.dev + "</td>" +
+                                "<td>" + report.date + "</td>" +
+                            "</tr>";
+                    });
+                    break;
+                case DashboardController.Report.DAC:
+                    thead =
+                        "<tr>" +
+                            "<th>PID</th>" +
+                             "<th>UID</th>" +
+                             "<th>Exe</th>" +
+                             "<th>Subj</th>" +
+                             "<th>Command</th>" +
+                             "<th>TTY</th>" +
+                             "<th>Success</th>" +
+                             "<th>Date</th>" +
+                         "</tr>";
+
+                    reports[reportName].forEach(function(report) {
+                        tbody +=
+                            "<tr>" +
+                                "<th>" + report.pid + "</td>" +
+                                "<td>" + report.uid + "</td>" +
+                                "<td>" + report.exe + "</td>" +
+                                "<td>" + report.subj + "</td>" +
+                                "<td>" + report.comm + "</td>" +
+                                "<td>" + report.success + "</td>" +
+                                "<td>" + report.tty + "</td>" +
+                                "<td>" + report.date + "</td>" +
+                            "</tr>";
+                    });
+                    break;
+                default:
+                    break;
+                }
+
+                var reportHtml = "<div class='item' data-item='" + reportName + "'>" +
+                                    "<div class='name-lable'>Name:</div><div class='name'>" + displayName + " report</div>" +
+                                    "<table data-role='table' data-mode='reflow' class='movie-list ui-responsive'>" +
+                                        "<thead>" +
+                                            thead +
+                                        "</thead>" +
+                                        "<tbody>" +
+                                            tbody +
+                                        "</tbody>" +
+                                    "</table>" +
+                                "</div>";
+
+                $(m_reportsList).append(reportHtml);
             });
 
-            $(m_reportsList).find(".item:first").addClass("active");
             var reportCarousel = new Carousel();
             reportCarousel.init(m_reportsList);
+            $(m_reportsList).trigger("create");
+            $(m_reportsList).find(".item:first").addClass("active");
         }
     }
 }
@@ -158,4 +231,24 @@ function DashboardController() {
 //context of the current dashboard
 DashboardController.Context = {
     device: {}
+}
+
+DashboardController.Report = {
+    SMACK:      "smack",
+    DAC:        "dac",
+    SYSCALL:    "syscall"
+};
+
+DashboardController.getReportName = function(type) {
+    switch(type) {
+    case DashboardController.Report.SMACK:
+        return "SMACK";
+    case DashboardController.Report.DAC:
+        return "DAC";
+    case DashboardController.Report.SYSCALL:
+        return "SYSCALL";
+    default:
+        console.log("No such report type: " + type);
+        return type;
+    }
 }
\ No newline at end of file
index edbe408..c82a8ab 100644 (file)
@@ -204,7 +204,7 @@ var init = function() {
     pageHistory.push(currentPage);
     initAllPages();
     //TODO: remove in the production
-    $("#login-submit input[name='login']").val('admin@samsung.com');
+    //$("#login-submit input[name='login']").val('admin@samsung.com');
 
     authorizationController = new AuthorizationController();
     devicesController = new DevicesController();