Skip to content
This repository has been archived by the owner on Sep 17, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/0_1_2_test_1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Kelley committed Aug 11, 2014
2 parents ae7c2ff + 4e02a0c commit 13bf64a
Show file tree
Hide file tree
Showing 42 changed files with 986 additions and 465 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
library revisions_controller;
library security_monkey.search_bar_component;

import 'package:angular/angular.dart';
import 'dart:js'; // select2 is still in JavaScript
import 'dart:html';
import 'package:js/js.dart' as js; // select2 is still in JavaScript
import 'dart:async';
import 'dart:js';
import 'package:angular/routing/module.dart';

import 'package:SecurityMonkey/service/revisions_service.dart';
import 'package:SecurityMonkey/routing/securitymonkey_router.dart' show param_from_url, param_to_url, map_from_url, map_to_url;


@Controller(
selector: '[revisions]',
publishAs: 'revisions_ctrl')
class RevisionsController {
@Component(
selector: 'search-bar',
templateUrl: 'packages/SecurityMonkey/component/search_bar_component/search_bar_component.html',
publishAs: 'cmp',
useShadowDom: false)
class SearchBarComponent {

String searchconfig = "";
String active_filter_value = "null";
String result_type_binded = "items";
Router router;
RouteProvider routeProvider;
RevisionsService rs;

Map<String, String> filter_params = {
'filterregions': '',
Expand All @@ -30,13 +32,10 @@ class RevisionsController {
'count': '25'
};

// Constructor
RevisionsController(this.rs, this.router, this.routeProvider) { // this.bs
js.context['getFilterString'] = getFilterString;
js.context['pushFilterRoutes'] = pushFilterRoutes;
this.current_result_type = this.routeProvider.route.parent.name;
this.result_type_binded = current_result_type;
print("ROUTE NAME: $current_result_type");
SearchBarComponent(this.router, this.routeProvider) {
context['getFilterString'] = getFilterString;
context['pushFilterRoutes'] = pushFilterRoutes;
this.result_type_binded = this.routeProvider.route.parent.name;
if (routeProvider != null) {
filter_params = map_from_url(filter_params, this.routeProvider);
this.runbootstrap();
Expand All @@ -61,9 +60,10 @@ class RevisionsController {
filter = Uri.decodeComponent(filter);
List<String> thelist = filter.split(',');
var json = new JsObject.jsify(thelist);
var select_box = js.context.jQuery(querySelector(s2id));
select_box.select2("val", json);
js.context.jQuery(querySelector(hidd)).val(select_box.val());
var select_box = context.callMethod('jQuery', [s2id]);
select_box.callMethod('select2', ["val", json]);
var hidden_field = context.callMethod('jQuery', [hidd]);
hidden_field.callMethod('val', [select_box.callMethod('val')]);
}
}

Expand Down Expand Up @@ -107,10 +107,4 @@ class RevisionsController {
}
return "$param_url_name=$param_value";
}

String active_filter_value = "null";
String searchconfig = "";
String current_result_type = "items";
String result_type_binded = "items";

}
}
76 changes: 76 additions & 0 deletions dart/lib/component/search_bar_component/search_bar_component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<div class="panel panel-info">
<div class="panel-heading">Search<i class="glyphicon glyphicon-search pull-right"></i></div>
<div class="panel-body">
<div>
<h6>Region</h6>
<input type="hidden" id="filterregions"></input>
<input type="hidden"
class="bigdrop select2-offscreen populate placeholder"
multiple="multiple" id="s2_regions" style="width: 100%">
</div>
<div>
<h6>Tech</h6>
<input type="hidden" id="filtertechnologies"></input>
<input type="hidden"
class="bigdrop select2-offscreen populate placeholder"
multiple="multiple" id="s2_technologies" style="width: 100%">
</div>
<div>
<h6>Account</h6>
<input type="hidden" id="filteraccounts"></input>
<input type="hidden"
class="bigdrop select2-offscreen populate placeholder"
multiple="multiple" id="s2_accounts" style="width: 100%">
<!-- Foundation -->
</div>
<div>
<h6>Name</h6>
<input type="hidden" id="filternames"></input>
<input type="hidden"
class="bigdrop select2-offscreen populate placeholder"
multiple="multiple" id="s2_names" style="width: 100%">
</div>

<hr>

<div>
<h6>Search Config</h6>
<input id="searchconfig" class="form-control" ng-model="cmp.searchconfig"></input>
</div>

<div>
<h6>Status</h6>
<select ng-model="cmp.active_filter_value" class="form-control">
<option value="null">None (Return Both)</option>
<option value="True">Active</option>
<option value="False">Inactive (Deleted)</option>
</select>
</div>

<div>
<h6>Type</h6>
<select ng-model="cmp.result_type_binded" class="form-control">
<option value="items">Items</option>
<option value="revisions">Items + Historical Changes</option>
<option value="issues">Audit Issues</option>
</select>
</div>

<div>
<hr>
<div class="row">
<div class="col-md-4">
<button class="btn btn-sm btn-primary"
ng-click="cmp.pushFilterRoutes()">Search</button>
</div>
<div class="col-md-8">
</div>
</div>
</div>
</div>
</div> <!-- end left-sidebar -->

<!-- Setup the select2 autocomplete boxes -->
<!-- Need to make this CSP compatible -->
<script src="js/searchpage.js">
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
library security_monkey.search_page_component;

import 'package:angular/angular.dart';

@Component(
selector: 'search-page',
templateUrl: 'packages/SecurityMonkey/component/search_page_component/search_page_component.html',
publishAs: 'cmp',
useShadowDom: false) // Because a Search-Page contains a Search-Bar,
// and a Search-Bar uses JavaScript and is not shadow-dom Compatible,
// the Search-Page cannot use shadow-dom.
class SearchPageComponent {
RouteProvider routeProvider;
String current_result_type;

SearchPageComponent(this.routeProvider) {
this.current_result_type = this.routeProvider.route.parent.name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div>
<div class="col-lg-3">
<search-bar></search-bar>
</div>

<!-- right sidebar -->
<div class="col-lg-9" ng-switch="cmp.current_result_type">
<revision-table ng-switch-when="revisions"></revision-table>
<item-table ng-switch-when="items"></item-table>
<issue-table ng-switch-when="issues"></issue-table>
<h1 ng-switch-when="null">Enter a search on the left.</h1>
</div> <!-- end right-sidebar -->
</div>
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
library security_monkey.settings_controller;
library security_monkey.settings_component;

import 'package:angular/angular.dart';
import 'package:SecurityMonkey/service/account_service.dart';
import 'package:SecurityMonkey/service/user_settings_service.dart';
import 'package:SecurityMonkey/model/Account.dart';

@Controller(
selector: '[settings]',
@Component(
selector: 'settings-cmp',
templateUrl: 'packages/SecurityMonkey/component/settings_component/settings_component.html',
cssUrl: const ['css/bootstrap.min.css'],
publishAs: 'cmp')
class SettingsController {
class SettingsComponent {
AccountService as;
UserSettingsService uss;
Router router;
List<Account> accounts;

SettingsController(this.as, this.uss, this.router) {
SettingsComponent(this.as, this.uss, this.router) {
this.as.listAccounts().then((List<Account> new_accounts) {
this.accounts = new_accounts;
});
Expand Down Expand Up @@ -67,5 +69,4 @@ class SettingsController {
get user_setting => uss.user_setting;
get isLoaded => uss.isLoaded && as.isLoaded;
get isError => uss.isError || as.isError;

}
92 changes: 92 additions & 0 deletions dart/lib/component/settings_component/settings_component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<div>
<div class="col-lg-3">
<div class="panel panel-info" ng-switch="cmp.isLoaded">
<div class="panel-heading">Notification Settings <i class="glyphicon glyphicon-pencil pull-right"></i></div>
<div class="panel-body" ng-switch-when="false">
<p>Loading . . .</p>
</div>
<div class="panel-body" ng-switch-when="true">
<div>
<h6>Change Emails</h6>
<select ng-model="cmp.user_setting.change_report_setting" class="form-control">
<option value="ALL">All</option>
<option value="ISSUES">With Issues</option>
<option value="NONE">None</option>
</select>
<h6>Daily Email</h6>
<input type="checkbox" ng-model="cmp.user_setting.daily_audit_email" />
</div>

<div>
<hr>
<div class="row">
<div class="col-md-4 text-center">

<button class="btn btn-sm btn-primary"
ng-click="cmp.saveSettings()"">Save</button>
</div>
<div class="col-md-8">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-9" ng-switch="cmp.isLoaded">
<div class="panel panel-info">
<div class="panel-heading">Accounts <span class="badge pull-right">{{cmp.accounts.length}} of {{cmp.accounts.length}}</span></div>
<div class="panel-body" ng-switch-when="false">
<p>Loading . . .</p>
</div>
<div class="panel-body" ng-switch-when="true">
<table class="table table-striped">
<tr>
<th>Notify</th>
<th>Active</th>
<th>Third Party</th>
<th>Name</th>
<th>S3 Name</th>
<th>Account Number</th>
<th>Notes</th>
<th><button ng-click="cmp.createAccount()" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-plus"></i></button></th>
</tr>
<tr ng-repeat="account in cmp.accounts">
<td>
<input ng-if="!cmp.enabledValueForAccount(account.active, account.third_party)" disabled="disabled" type="checkbox">
<input ng-if="cmp.enabledValueForAccount(account.active, account.third_party) && cmp.notificationValueForAccount(account.id)" type='checkbox' checked ng-click="cmp.toggleNotificationForAccount(account.id)">
<input ng-if="cmp.enabledValueForAccount(account.active, account.third_party) && !cmp.notificationValueForAccount(account.id)" type='checkbox' ng-click="cmp.toggleNotificationForAccount(account.id)">
</td>
<td ng-if="account.active"><div class="text-center"><i class="glyphicon glyphicon-ok"></i></div></td>
<td ng-if="!account.active"><div class="text-center"><i class="glyphicon glyphicon-remove"></i></div></td>
<td ng-if="account.third_party"><div class="text-center"><i class="glyphicon glyphicon-ok"></i></div></td>
<td ng-if="!account.third_party"><div class="text-center"><i class="glyphicon glyphicon-remove"></i></div></td>
<td><a href="#/viewaccount/{{account.id}}">{{account.name}}</a></td>
<td>{{account.s3_name}}</td>
<td>{{account.number}}</td>
<td>{{account.notes}}</td>
<td></td>
</tr>
</table>

</div>
<div class="panel-footer">
<!-- Pagination is not net enabled for user-setting accounts
<div class="pull-left">
<ul style="margin-top: 5px; margin-bottom: 5px;" class="pagination">
<li class="disabled"><a href="#">&laquo;</a></li>
<li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
</ul>
</div>
<div class="pull-right">
<select class="form-control">
<option>10</option>
<option>25</option>
<option>50</option>
</select>
</div>
-->
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
library signout_controller;
library security_monkey.signout_component;
import 'package:angular/angular.dart';
import 'package:SecurityMonkey/util/constants.dart';


@Controller(
selector: '[signout]',
publishAs: 'signout_ctrl')
class SignoutController {
// On init, make a call to /logout on API
@Component(
selector: 'signout',
templateUrl: 'packages/SecurityMonkey/component/signout_component/signout_component.html',
cssUrl: const ['css/bootstrap.min.css'],
publishAs: 'cmp')
class SignoutComponent {
final Http _http;
Scope scope;
bool complete = false;
bool error = false;
bool loading = true;

SignoutController(this._http, this.scope) {
SignoutComponent(this._http, this.scope) {
String url = '$API_HOST/logout';
print("Signing Out...");
_http.get(url, withCredentials:true)
.then((HttpResponse response) {
print("Sign Out Complete");
complete = true;
loading = false;
// scope.emit("username-change", "emit");
// scope.broadcast("username-change", "broadcast");
// scope.parentScope.broadcast("username-change", "parent-broadcast");
scope.rootScope.broadcast("username-change", "");
})
.catchError((error) {
Expand All @@ -33,4 +30,4 @@ class SignoutController {
loading = false;
});
}
}
}
25 changes: 25 additions & 0 deletions dart/lib/component/signout_component/signout_component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div>
<div ng-switch="cmp.loading">
<div ng-switch-when="true">
<div class="page-header">
<h1>Signing Out <small>(Just a second.)</small></h1>
</div>
</div>
<div ng-switch-when="false">
<div ng-if="cmp.complete">
<div class="page-header">
<h1>Signed Out <small>Your Security Monkey session has ended.</small></h1>
</div>
<div class="row">
<p>To continue using Security Monkey, please proceed to the <a href="/">Login page</a>.</p>
</div>
</div>
<div ng-if="cmp.error">
<div class="page-header">
<h1>Error Signing Out <small>The bad thing about monkeys is when they fling poo. :(</small></h1>
</div>
</div>
</div>
</div>

</div>
Loading

0 comments on commit 13bf64a

Please sign in to comment.