Permalink
Browse files

major shit

  • Loading branch information...
Sergey Vyushkov
Sergey Vyushkov committed Apr 4, 2016
1 parent c77e69b commit c5efaa4887220b371a24407e6d3b559da6a3174f
@@ -0,0 +1,22 @@
import Ember from 'ember';
export default Ember.Controller.extend({
filteredModel: Ember.computed('model.[]', 'searchQuery', function() {
let searchQuery = this.get('searchQuery');
if(searchQuery) {
return DS.PromiseArray.create({
promise: Ember.RSVP.filter(this.get('model').toArray(), entity => {
return entity.get('assetIps').then( assetIps => {
return assetIps.filterBy('ipNumber', "79.62.194.89");
// return assetIps.filter( (assetIp) => {
// return assetIp.get('ipNumber').toLowerCase().indexOf( searchQuery.toLowerCase() ) !== -1;
// });
});
})
});
} else {
return this.get('model');
}
})
});
@@ -1,15 +1,65 @@
import Ember from 'ember';
export default Ember.Controller.extend({
selectedAssetIps: [],
selectedAssetIpIds: [],
entityId: null,
isLaunching: null,
availableIps: function() {
if(this.get('entityId')) {
return this.get('model.entities').findBy('id', this.get('entityId')).get('assetIps');
}
}.property('entityId'),
actions: {
selectEntity(entityId) {
this.get('model.assetIp').set('entityId', this.store.peekRecord('entity', entityId));
this.setProperties({
'entityId': entityId,
'selectedAssetIpIds': null
});
Ember.$("#new-scan-select").val(null).trigger("change");
},
selectAssetIps(event) {
const selectedAssetIps = Ember.$(event.target).val();
this.set('selectedAssetIps', selectedAssetIps || []);
this.set('selectedAssetIpIds', selectedAssetIps || []);
},
launchScan() {
this.set('isLaunching', true);
$.ajax({
type: "POST",
url: this.store.adapterFor('application').namespace + '/asv/scans',
data: JSON.stringify({
entityId: this.get('entityId'),
assetIpIds: this.get('selectedAssetIpIds')
}),
contentType: 'application/json'
}).then((response) => {
this.set('isLaunching', false);
if(response.success) {
$('body').pgNotification({
"style": "bar",
"position": "top",
"message": "Scan launched succesfully.",
"type": "success"
}).show();
window.history.go(-1);
} else {
$('body').pgNotification({
"style": "bar",
"position": "top",
"message": "Oh no..",
"type": "danger"
}).show();
}
}).fail(()=>{
this.set('isLaunching', false);
$('body').pgNotification({
"style": "bar",
"position": "top",
"message": "Oh no..",
"type": "danger"
}).show();
});
}
}
});
View
@@ -12,6 +12,30 @@ export default DS.Model.extend({
totalVulnerabilities: DS.attr('number'),
totalPCIVulnerabilities: DS.attr('number'),
status: DS.attr('string'),
humanStatus: Ember.computed('status', function() {
switch(this.get('status')) {
case "PASS":
return "Not Scanned";
case "NOT_SCANNED":
return "Not Scanned";
case "FAIL":
return "Fail";
default:
return "Unknown";
}
}),
PCIStatus: DS.attr('string'),
humanPCIStatus: Ember.computed('status', function() {
switch(this.get('status')) {
case "PASS":
return "pass";
case "NOT_SCANNED":
return "not scanned";
case "FAIL":
return "fail";
default:
return "unknown";
}
}),
isNotExpired: DS.attr('boolean')
});
View
@@ -8,6 +8,9 @@ export default DS.Model.extend({
scanEnd: DS.attr('date'),
scanReference: DS.attr('string'),
statusAsString: DS.attr('string'),
humanStatus: Ember.computed('statusAsString', function() {
return this.get('statusAsString').toLowerCase();
}),
riskAverage: DS.attr('number'),
riskCoverage: DS.attr('number'),
totalVulnerabilities: DS.attr('number'),
View
@@ -14,6 +14,10 @@ Router.map(function() {
this.route('ips', function() {
this.route('new');
});
this.route('scan', function() {
this.route('results');
});
});
export default Router;
View
@@ -3,10 +3,6 @@ import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-rout
export default Ember.Route.extend(AuthenticatedRouteMixin, {
model() {
// return Ember.RSVP.hash({
// entities: this.store.findAll('entity'),
// assetIps: this.store.findAll('asset-ip')
// });
return this.store.findAll('entity');
},
afterModel() {
@@ -0,0 +1,4 @@
import Ember from 'ember';
export default Ember.Route.extend({
});
View
@@ -9,7 +9,7 @@ export default Ember.Route.extend({
},
model() {
return Ember.RSVP.hash({
assetIp: this.store.findAll('asset-ip'),
assetIps: this.store.findAll('asset-ip'),
entities: this.store.findAll('entity'),
scan: this.store.createRecord('scan'),
});
View
@@ -20,6 +20,13 @@ body > .ember-view:first-child, :not(.ember-view) + .ember-view {
.full-page-wrapper {
@extend .login-wrapper;
}
/* Login */
.login-wrapper {
background-color: #176E8E;
.bg-pic > img {
opacity: 0.2;
}
}
/* Navigation */
.navbar {
@@ -69,11 +76,29 @@ body > .ember-view:first-child, :not(.ember-view) + .ember-view {
}
}
/* Login */
.login-wrapper {
background-color: #176E8E;
.bg-pic > img {
opacity: 0.3;
}
/* Forms */
//Select2
.select2-container-multi .select2-choices .select2-search-field input {
padding-left: 12px;
padding-top: 8px;
}
/* Labels */
.label {
text-transform: uppercase;
}
.label-NOT_SCANNED, .label-PAUSED, .label-STOPPED, label-QUEUED {
@extend .label-default;
}
.label-FINISHED {
@extend .label-info;
}
.label-PASS, .label-NEW, .label-STARTED {
@extend .label-success;
}
.label-FAIL, .label-FAILED {
@extend .label-important;
}
.label-PENDING {
@extend .label-warning;
}
@@ -25,13 +25,14 @@
<div class="">
<div class="container-fluid container-fixed-lg p-l-35 sm-p-r-35 p-t-15 p-b-15" style="border-bottom: 1px solid #e6e6e6;">
<div class="row">
<div class="col-sm-6 col-md-height col-middle pull-left">
<div class="col-sm-6 col-sm-height col-middle pull-left hide-sm">
<span class="hint-text">You have <b>7</b> IPs, 5 of them are not PCI compliant</span>
</div>
<div class="col-sm-6 col-md-height col-middle pull-right">
<div class="col-sm-6 col-sm-height col-middle pull-right">
<div class="full-width">
<div class="input-group p-l-0 transparent b-b b-transparent pull-right" style="border-color: rgba(0, 0, 0, 0.03);">
<input type="text" class="form-control bg-master no-border p-l-0 transparent" placeholder="Search IPs" style="background-color: transparent; ">
{{!-- <input type="text" value={{searchQuery}} class="form-control bg-master no-border p-l-0 transparent" placeholder="Search IPs" style="background-color: transparent; "> --}}
{{input type="text" value=searchQuery class="form-control bg-transparent no-border p-l-0 transparent" placeholder="Search IPs"}}
<span class="input-group-addon no-border">
<i class="pg-search"></i>
</span>
@@ -52,12 +53,12 @@
<th class="sorting">Hostname</th>
<th class="sorting">IP</th>
<th class="sorting">Tag</th>
<th>Description</th>
<th class="sorting">Status</th>
<th></th>
</tr>
</thead>
<tbody>
{{#each model as |entity|}}
{{#each filteredModel as |entity|}}
<tr>
<td colspan=5 style="padding: 0px; background: transparent; border: none;">
<ul class="nav nav-tabs nav-tabs-linetriangle">
@@ -73,7 +74,7 @@
<td>{{assetIp.hostName}}</td>
<td>{{assetIp.ipNumber}}</td>
<td><span class="label label-default">{{assetIp.tag}}</span></td>
<td>{{assetIp.description}}</td>
<td><span class="label label-{{assetIp.status}}">{{assetIp.humanStatus}}</span></td>
<td style="padding: 12px; width: 180px; text-align: center;">
<div class="btn-group">
<div class="btn-group dropdown-default">
@@ -0,0 +1 @@
{{outlet}}
@@ -31,10 +31,9 @@
<table class="table ips-table dataTable">
<thead>
<tr>
<th class="sorting">Hostname</th>
<th>IP</th>
<th>Tag</th>
<th>Description</th>
<th class="sorting">Reference</th>
<th class="sorting">Status</th>
<th class="sorting">Finished</th>
<th></th>
</tr>
</thead>
@@ -50,30 +49,35 @@
</ul>
</td>
</tr>
{{#each entity.scans as |scan|}}
<tr>
<td>{{assetIp.scanReference}}</td>
<td>{{assetIp.scanReference}}</td>
<td><span class="label label-default">{{assetIp.scanReference}}</span></td>
<td>{{assetIp.scanReference}}</td>
<td style="padding: 12px; width: 180px; text-align: center;">
<div class="btn-group">
{{#if entity.scans}}
{{#each entity.scans as |scan|}}
<tr>
<td>{{scan.scanReference}}</td>
<td><span class="label label-{{scan.statusAsString}}">{{scan.humanStatus}}</span></td>
<td>{{#if scan.scanEnd}}{{moment-to-now scan.scanEnd}}{{/if}}</td>
<td style="padding: 12px; width: 180px; text-align: center;">
<div class="btn-group dropdown-default">
<button type="button" class="btn btn-default"><i class="fa fa-bolt"></i>&nbsp; Scan</button>
<button type="button" class="btn btn-default dropdown-toggle p-l-15 p-r-15" data-toggle="dropdown" aria-expanded="false">
<i class="fa fa-caret-down"></i>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Schedule Scan</a></li>
<li class="divider"></li>
<li><a href="#">Edit</a></li>
<li><a href="#">Disable</a></li>
</ul>
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> Actions <span class="caret"></span> </a>
<ul class="dropdown-menu ">
<li><a href="#">Relaunch</a>
</li>
<li class="divider"></li>
{{!-- <li>{{#link-to 'scan.results' scan.scanReportId}}View Report{{/link-to}} --}}
{{!-- </li> --}}
<li><a href="#">Download Report</a>
</li>
</ul>
</div>
</div>
</td>
</tr>
{{/each}}
{{else}}
<tr>
<td colspan=4>
aa
</td>
</tr>
{{/each}}
{{/if}}
{{/each}}
</tbody>
</table>
@@ -9,39 +9,35 @@
<div class="row clearfix">
<div class="col-sm-12">
<div class="form-group form-group-default form-group-default-select2">
<label>IP(s) to scan</label>
<select class="full-width select2-offscreen" onchange={{action "selectAssetIps"}} data-init-plugin="select2" multiple="" placeholder="Choose what IPs to scan"tabindex="-1">
<label class="">Merchant</label>
<select onchange={{action "selectEntity" value="target.value"}} id="entity-select" data-init-plugin="select2" class="full-width select2-offscreen" data-placeholder="Select Merchant" tabindex="-1" title="">
{{#each model.entities as |entity|}}
<optgroup label="Merchant {{entity.companyName}}">
{{#each entity.assetIps as |assetIp|}}
<option value="{{assetIp.id}}"><b>{{assetIp.hostName}}</b> {{assetIp.ipNumber}}</option>
{{/each}}
</optgroup>
<option value="{{entity.id}}">{{entity.companyName}}</option>
{{/each}}
</select>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-12">
<div class="form-group form-group-default form-group-default-select2">
<label class="">Merchant</label>
<select onchange={{action "selectEntity" value="target.value"}} id="entity-select" data-init-plugin="select2" class="full-width select2-offscreen" data-placeholder="Select Merchant" tabindex="-1" title="">
{{#each model.entities as |entity|}}
<option value="{{entity.id}}">{{entity.companyName}}</option>
<label>IP(s) to scan</label>
<select id="new-scan-select" class="full-width select2-offscreen" onchange={{action "selectAssetIps"}} data-init-plugin="select2" multiple="" placeholder="Choose what IPs to scan"tabindex="-1">
{{#each availableIps as |assetIp|}}
<option value="{{assetIp.id}}"><b>{{assetIp.hostName}}</b> {{assetIp.ipNumber}}</option>
{{/each}}
</select>
</div>
</div>
</div>
</div>
<p class="pull-left hint-text p-l-5">
I agree to the <a href="#">ZeroRisk Terms</a> and <a href="#">Privacy</a>.
</p>
<div class="clearfix"></div>
<button {{action "saveIp"}} class="btn btn-complete pull-right" type="submit">Launch scan</button>
<button {{action "launchScan"}} class="btn btn-complete pull-right" type="submit" disabled={{isLaunching}}>{{{if isLaunching '<i class="fa fa-circle-o-notch fa-spin"></i>&nbsp; Launching, please wait' 'Launch scan'}}}</button>
</form>
</div>
</div>
View
@@ -29,6 +29,7 @@
"ember-cli-htmlbars": "^1.0.1",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-inject-live-reload": "^1.3.1",
"ember-cli-moment-shim": "1.1.0",
"ember-cli-qunit": "^1.2.1",
"ember-cli-release": "0.2.8",
"ember-cli-sass": "5.3.1",
@@ -38,6 +39,7 @@
"ember-disable-proxy-controllers": "^1.0.1",
"ember-export-application-global": "^1.0.4",
"ember-load-initializers": "^0.5.0",
"ember-moment": "6.1.0",
"ember-resolver": "^2.0.3",
"ember-simple-auth": "1.1.0-beta.2",
"loader.js": "^4.0.0"
Binary file not shown.
Oops, something went wrong.

0 comments on commit c5efaa4

Please sign in to comment.