Skip to content

Commit

Permalink
Initial home page displays some summary tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Shamal Faily committed Jan 16, 2017
1 parent b00fc3b commit 8098d61
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 13 deletions.
65 changes: 57 additions & 8 deletions cairis/web/dist/js/cairis/Cairis.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ $(document).ready(function() {
debugLogger(data);
var sessionID = data.session_id;
$.session.set("sessionID", sessionID);
startingTable();
// startingTable();
createComboboxes();
summaryTables();
hideLoading();
},
error: function(data, status, xhr) {
Expand All @@ -55,7 +57,9 @@ $(document).ready(function() {
});
}
else {
startingTable();
// startingTable();
createComboboxes();
summaryTables();
}
});

Expand Down Expand Up @@ -1135,7 +1139,7 @@ function createComboboxes(){
options.append($("<option />").val(this).text(this));
amoptions.append($("<option />").val(this).text(this));
});
$(".topCombobox").css("visibility", "visible");
// $(".topCombobox").css("visibility", "visible");
},
error: function (xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
Expand Down Expand Up @@ -1176,8 +1180,8 @@ function createComboboxes(){
remEnvBox.append($("<option />").val(this).text(this));
rmEnvBox.append($("<option />").val(this).text(this));
});
envBox.css("visibility", "visible");
window.boxesAreFilled = true;
// envBox.css("visibility", "visible");
// window.boxesAreFilled = true;
},
error: function (xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
Expand All @@ -1186,8 +1190,15 @@ function createComboboxes(){
});
}

function showComboboxes() {
$(".topCombobox").css("visibility", "visible");
$('#environmentsbox').css("visibility", "visible");
window.boxesAreFilled = true;
}

function startingTable(){
createComboboxes();
// createComboboxes();
showComboboxes();
$.ajax({
type:"GET",
dataType: "json",
Expand All @@ -1210,12 +1221,41 @@ function startingTable(){
});
}

function summaryTables() {
activeElement("homePanel");
$.ajax({
type: "GET",
dataType: "json",
accept: "application/json",
data: {
session_id: String($.session.get('sessionID'))
},
crfossDomain: true,
url: serverIP + "/api/dimensions/table/environment",
success: function (envs) {
activeElement("homePanel");
$("#summaryenvironmentsbox option").remove();
$.each(envs,function(idx,env) {
$('#summaryenvironmentsbox').append($("<option></option>").attr("value",env).text(env));
});
$('#summaryenvironmentsbox').change();
$(".loadingWrapper").fadeOut(500);
},
error: function (xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
});
}


// This is for saying which element has the main focus
function activeElement(elementid){
if(elementid == "svgViewer" || elementid == 'homePanel'){
$("#reqTable").hide();
$("#objectViewer").hide();
$("#filtercontent").hide();
$("#filtersummarytables").hide();
$("#filterassetmodelcontent").hide();
$("#filterriskmodelcontent").hide();
$("#filterresponsibilitymodelcontent").hide();
Expand All @@ -1226,9 +1266,11 @@ function activeElement(elementid){
$("#rightnavGear").hide();

if (elementid == 'svgViewer') {
$('#homePanel').hide();
$("#rightnavGear").show();
}


if (window.theVisualModel == 'risk') {
$("#filterriskmodelcontent").show();
}
Expand All @@ -1253,7 +1295,8 @@ function activeElement(elementid){
}
if(elementid != "svgViewer"){
$("#svgViewer").hide();
$("#homePanel").hide();
$('#homePanel').hide();
$("#filtersummarytables").hide();
$("#objectViewer").hide();
$("#filterassetmodelcontent").hide();
$("#filterriskmodelcontent").hide();
Expand All @@ -1274,6 +1317,11 @@ function activeElement(elementid){
$("#reqTable").hide();
}

if (elementid == 'homePanel') {
$("#reqTable").hide();
$("#filtersummarytables").show();
}

elementid = "#" + elementid;
$(elementid).show();
}
Expand Down Expand Up @@ -1484,8 +1532,9 @@ function setActiveOptions(){
function fillSvgViewer(data){

var xmlString = (new XMLSerializer()).serializeToString(data);
activeElement("svgViewer");
var svgDiv = $("#svgViewer");
svgDiv.show();
// svgDiv.show();
svgDiv.css("height",$("#mainContent").height());
svgDiv.css("width","100%");
svgDiv.html(xmlString);
Expand Down
1 change: 0 additions & 1 deletion cairis/web/dist/js/cairis/SVGhandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
'use strict';

$( document ).ajaxComplete(function() {
// $("svg > g > g .node > a ").on('click', function (event) {
$("svg > g > g .node > g > a").on('click', function (event) {
event.stopImmediatePropagation();
event.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/dist/js/cairis/buttonclicks.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ $('#locationsModelClick').click(function(){
$("#newClick").click(function () {
postNewProject(function () {
window.activeTable = "Requirements";
startingTable();
summaryTable();
});
});

Expand Down
2 changes: 1 addition & 1 deletion cairis/web/dist/js/cairis/fileImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $("#importClick").click(function () {
data: objectoutput,
url: serverIP + "/api/import/text",
success: function (data) {
startingTable();
summaryTables();
showPopup(true);
},
complete: function() {
Expand Down
84 changes: 83 additions & 1 deletion cairis/web/dist/js/cairis/homeSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,87 @@
'use strict';

$("#homeClick").click(function () {
activeElement("homePanel");
summaryTables();
});

$('#summaryenvironmentsbox').change(function() {
var envName = $(this).find('option:selected').val();
$.ajax({
type: "GET",
dataType: "json",
accept: "application/json",
data: {
session_id: String($.session.get('sessionID'))
},
crfossDomain: true,
url: serverIP + "/api/summary/dimension/vulnerability/environment/" + encodeURIComponent(envName),
success: function (sums) {
nv.addGraph(function() {
var chart = nv.models.pieChart()
.x(function(d) { return d.theLabel })
.y(function(d) { return d.theValue })
.showLabels(true);
d3.select("#vulnerabilitySummary svg")
.datum(sums)
.transition().duration(1200)
.call(chart);
});
},
error: function (xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
});
$.ajax({
type: "GET",
dataType: "json",
accept: "application/json",
data: {
session_id: String($.session.get('sessionID'))
},
crfossDomain: true,
url: serverIP + "/api/summary/dimension/threat/environment/" + encodeURIComponent(envName),
success: function (sums) {
nv.addGraph(function() {
var chart = nv.models.pieChart()
.x(function(d) { return d.theLabel })
.y(function(d) { return d.theValue })
.showLabels(true);
d3.select("#threatSummary svg")
.datum(sums)
.transition().duration(1200)
.call(chart);
});
},
error: function (xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
});
$.ajax({
type: "GET",
dataType: "json",
accept: "application/json",
data: {
session_id: String($.session.get('sessionID'))
},
crfossDomain: true,
url: serverIP + "/api/summary/dimension/risk/environment/" + encodeURIComponent(envName),
success: function (sums) {
nv.addGraph(function() {
var chart = nv.models.pieChart()
.x(function(d) { return d.theLabel })
.y(function(d) { return d.theValue })
.showLabels(true);
d3.select("#riskSummary svg")
.datum(sums)
.transition().duration(1200)
.call(chart);
});
},
error: function (xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
});
});
28 changes: 27 additions & 1 deletion cairis/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<link href="plugins/jquery-contextmenu/jquery.contextMenu.min.css" rel="stylesheet" type="text/css"/>
<script src="plugins/bootstrap-validator/js/validator.js"></script>
<script src="plugins/js-cookie/js.cookie.js"></script>
<link href="plugins/d3/nv.d3.min.css" rel="stylesheet">
<script src="plugins/d3/d3.min.js"></script>
<script src="plugins/d3/nv.d3.min.js"></script>



Expand Down Expand Up @@ -351,8 +354,31 @@
<tbody>
</tbody>
</table>
<div id="homePanel"></div>
<div id="svgViewer"></div>
<div id="homePanel">
<div id="filtersummarytables" class="extraContent row form-group">
<div class="col-md-1">
<label class="topCombobox control-label" for="summaryenvironmentsbox">Environment</label>
</div>
<div class="col-md-2">
<select class="topCombobox form-control" id="summaryenvironmentsbox"></select>
</div>
</div>
<div class="row">
<div id="vulnerabilitySummary" class="col-md-4">
<label class="control-label">Vulnerability Summary</label>
<svg style="height:400px"></svg>
</div>
<div id="threatSummary" class="col-md-4">
<label class="control-label">Threat Summary</label>
<svg style="height:400px"></svg>
</div>
<div id="riskSummary" class="col-md-4">
<label class="control-label">Risk Summary</label>
<svg style="height:400px"></svg>
</div>
</div>
</div>
<div id="objectViewer" class="no-print"></div>
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
Expand Down
5 changes: 5 additions & 0 deletions cairis/web/plugins/d3/d3.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions cairis/web/plugins/d3/nv.d3.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8098d61

Please sign in to comment.