Permalink
Browse files

New branch for v0.9 beta work - new framework

  • Loading branch information...
Mark Troyer
Mark Troyer committed Apr 18, 2014
1 parent 2b5e522 commit b06908ba4f1338eedf8b09af6527ba29098e0ae9
Showing with 16,913 additions and 359 deletions.
  1. +2 −3 app/.htaccess
  2. +18 −0 app/Widgets/ExampleWidget/ExampleWidget.json
  3. +3 −0 app/Widgets/ExampleWidget/css/sw.examplewidget.css
  4. +245 −0 app/Widgets/ExampleWidget/js/sw.examplewidget.js
  5. +73 −0 app/Widgets/OpenTSDBWidget/Controller/GraphWidgetController.php
  6. +23 −0 app/Widgets/OpenTSDBWidget/OpenTSDBWidget.json
  7. +24 −0 app/Widgets/OpenTSDBWidget/config.rb
  8. +600 −0 app/Widgets/OpenTSDBWidget/css/sw.opentsdbwidget.css
  9. +2,805 −0 app/Widgets/OpenTSDBWidget/js/sw.opentsdbwidget.js
  10. +542 −0 app/Widgets/OpenTSDBWidget/sass/sw.opentsdbwidget.scss
  11. +147 −25 app/index.php
  12. +24 −0 app/static/config.rb
  13. +123 −0 app/static/constants/Constants.php
  14. +82 −0 app/static/css/dashboard.css
  15. +5 −0 app/static/css/ie.css
  16. +94 −0 app/static/css/login.css
  17. +3 −0 app/static/css/print.css
  18. +68 −0 app/static/css/screen.css
  19. +1,405 −0 app/static/css/sw_dark.css
  20. BIN app/static/fonts/ElegantIcons.eot
  21. +1,832 −0 app/static/fonts/ElegantIcons.svg
  22. BIN app/static/fonts/ElegantIcons.ttf
  23. BIN app/static/fonts/ElegantIcons.woff
  24. +42 −0 app/static/img/SW-White.svg
  25. +45 −0 app/static/img/StatusWolf2-White.svg
  26. BIN app/static/img/Status_Wolf2.png
  27. +45 −0 app/static/img/Status_Wolf2.svg
  28. +1,424 −0 app/static/js/lib/bootstrap-datetimepicker.js
  29. +6 −0 app/static/js/lib/jquery-ui-1.10.4.custom.min.js
  30. +1 −0 app/static/js/lib/jquery-ui.js
  31. +190 −0 app/static/js/lib/md5.js
  32. +271 −0 app/static/js/status_wolf_colors.js
  33. +65 −0 app/static/js/sw_lib.js
  34. +129 −0 app/static/js/sw_upgrade_0.9.js
  35. +24 −0 app/static/sass/_animations.scss
  36. +1,037 −0 app/static/sass/_base.scss
  37. +42 −0 app/static/sass/_colors_dark.scss
  38. +1,159 −0 app/static/sass/_elegant_icons_reference.css
  39. +95 −0 app/static/sass/_fonts.scss
  40. +95 −0 app/static/sass/_mixins.scss
  41. +75 −0 app/static/sass/dashboard.scss
  42. +5 −0 app/static/sass/ie.scss
  43. +75 −0 app/static/sass/login.scss
  44. +3 −0 app/static/sass/print.scss
  45. +6 −0 app/static/sass/sw_dark.scss
  46. +208 −0 app/sw.php
  47. +89 −0 app/templates/dashboard.html
  48. +481 −0 app/templates/dashboard_js.twig
  49. +26 −0 app/templates/dashboard_menu.twig
  50. +18 −0 app/templates/footer.twig
  51. +29 −0 app/templates/header.twig
  52. +42 −0 app/templates/login.html
  53. +18 −0 app/templates/navbar.twig
  54. +84 −0 app/templates/no_upgrade.html
  55. +37 −0 app/templates/sw_config.twig
  56. +119 −0 app/templates/upgrade.html
  57. +44 −0 composer.json
  58. +0 −74 conf/example_auth.conf
  59. +0 −25 conf/example_datasource.conf
  60. +0 −44 conf/example_statuswolf.conf
  61. +0 −12 conf/saved_dashboards.sql
  62. +0 −134 conf/statuswolf.sql
  63. +0 −41 conf/sw_073_update.sql
  64. +0 −1 conf/sw_080_update.sql
  65. +22 −0 phpunit.xml
  66. +15 −0 src/StatusWolf/Config/ConfigReaderInterface.php
  67. +75 −0 src/StatusWolf/Config/ConfigReaderService.php
  68. +32 −0 src/StatusWolf/Config/ConfigReaderServiceProvider.php
  69. +16 −0 src/StatusWolf/Config/ConfigWriterInterface.php
  70. +59 −0 src/StatusWolf/Config/ConfigWriterService.php
  71. +28 −0 src/StatusWolf/Config/ConfigWriterServiceProvider.php
  72. +49 −0 src/StatusWolf/Config/JsonConfigReader.php
  73. +37 −0 src/StatusWolf/Config/JsonConfigWriter.php
  74. +55 −0 src/StatusWolf/Controllers/ApiAnomalyController.php
  75. +40 −0 src/StatusWolf/Controllers/ApiController.php
  76. +123 −0 src/StatusWolf/Controllers/ApiDashboardController.php
  77. +28 −0 src/StatusWolf/Controllers/ApiDatasourceController.php
  78. +155 −0 src/StatusWolf/Controllers/ApiOpenTSDBController.php
  79. +36 −0 src/StatusWolf/Controllers/ApiSessionController.php
  80. +85 −0 src/StatusWolf/Controllers/DashboardController.php
  81. +15 −0 src/StatusWolf/Exception/ApiNetworkFetchException.php
  82. +14 −0 src/StatusWolf/Exception/ConfigWriterException.php
  83. +14 −0 src/StatusWolf/Exception/InvalidConfigurationException.php
  84. +554 −0 src/StatusWolf/Model/OpenTSDBDataSource.php
  85. +26 −0 src/StatusWolf/Model/TimeSeriesDataInterface.php
  86. +206 −0 src/StatusWolf/Model/TimeSeriesDownsample.php
  87. +80 −0 src/StatusWolf/Network/Curl.php
  88. +219 −0 src/StatusWolf/Security/Authentication/Provider/SWChainAuthProvider.php
  89. +64 −0 src/StatusWolf/Security/Authentication/Token/SWChainAuthToken.php
  90. +95 −0 src/StatusWolf/Security/Firewall/SWChainAuthListener.php
  91. +107 −0 src/StatusWolf/Security/User/SWUser.php
  92. +93 −0 src/StatusWolf/Security/User/SWUserProvider.php
  93. +47 −0 src/StatusWolf/Utility/SWLegacyConfig.php
  94. +159 −0 src/StatusWolf/Utility/StatusWolfDBUpgrade.php
  95. +63 −0 tests/StatusWolf/Tests/Config/ConfigServiceProviderTest.php
  96. +4 −0 tests/StatusWolf/Tests/Config/Fixtures/sw_config_broken.json
  97. 0 tests/StatusWolf/Tests/Config/Fixtures/sw_config_empty.json
  98. +5 −0 tests/StatusWolf/Tests/Config/Fixtures/sw_config_good.json
  99. +83 −0 tests/StatusWolf/Tests/Security/User/SWUserProviderTest.php
  100. +25 −0 tests/StatusWolf/Tests/StatusWolfApplicationTest.php
  101. +34 −0 tests/StatusWolf/Tests/StatusWolfApplicationWebTest.php
  102. +4 −0 tests/bootstrap.php
View
@@ -1,6 +1,5 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
RewriteRule ^ index.php [QSA,L]
</IfModule>
@@ -0,0 +1,18 @@
{
"name": "sw.examplewidget"
,"title": "Example Widget"
,"description": "Empty Widget Base"
,"version": "1.0"
,"author": {
"name": "StatusWolf Project"
,"url": "http://wwww.statuswolf.com/"
}
,"maintainers": [
{
"name": "Mark Troyer"
,"email": "disco@box.com"
}
]
,"license": "Apache v2.0",
"enabled": false
}
@@ -0,0 +1,3 @@
.widget-container {
height: 350px;
}
@@ -0,0 +1,245 @@
/**
*
* Author: Mark Troyer <disco@box.com>
* Date Created: 15 July 2013
*
*/
(function($, undefined) {
var sw_examplewidget_classes = 'widget';
$.widget('sw.examplewidget', {
version: "1.0",
defaultElement: "<div>",
options: {
disabled: null,
label: null,
}, _create: function() {
var that = this,
options = this.options,
sw_examplewidget,
sw_examplewidget_container,
sw_examplewidget_containerid,
sw_examplewidget_front,
sw_examplewidget_back,
sw_examplewidget_close,
sw_examplewidget_backtitle,
sw_examplewidget_backfooter,
sw_examplewidget_frontmain,
sw_examplewidget_backmain,
sw_examplewidget_form,
sw_examplewidget_action,
sw_examplewidget_querycancelbutton,
sw_examplewidget_gobutton;
// If this is the first OpenTSDB widget added, load the
// widget-specific CSS file
if ($('link[href*="opentsdb"]').length === 0) {
var widget_css = document.createElement('link');
widget_css.setAttribute('rel', 'stylesheet');
widget_css.setAttribute('href', window.location.origin + '/Widgets/OpenTSDBWidget/css/sw.examplewidget.css');
document.getElementsByTagName('head')[0].appendChild(widget_css);
}
sw_examplewidget_container = (this.sw_examplewidget_container = $(this.element));
$(sw_examplewidget_container).addClass('transparent');
sw_examplewidget = (this.sw_examplewidget = $('<div>'))
.addClass(sw_examplewidget_classes)
.appendTo(this.element);
sw_examplewidget_containerid = (this.sw_examplewidget_containerid = '#' + $(this.sw_examplewidget_container).attr('id'));
// The Example widget has a front and back face
sw_examplewidget_front = (this.sw_examplewidget_front = $('<div>'))
.addClass('widget-front')
.appendTo(sw_examplewidget);
sw_examplewidget_back = (this.sw_examplewidget_back = $('<div>'))
.addClass('widget-back')
.appendTo(sw_examplewidget);
// Each face has a title bar, a main content area,
// and a footer bar
sw_examplewidget_frontmain = (this.sw_examplewidget_frontmain = $('<div>'))
.addClass('widget-main')
.addClass('front')
.appendTo(sw_examplewidget_front);
sw_examplewidget_backtitle = (this.sw_examplewidget_backtitle = $('<div>'))
.addClass('widget-title')
.appendTo(sw_examplewidget_back);
sw_examplewidget_backmain = (this.sw_examplewidget_backmain = $('<div>'))
.addClass('widget-main')
.addClass('back')
.appendTo(sw_examplewidget_back);
sw_examplewidget_backfooter = (this.sw_examplewidget_backfooter = $('<div>'))
.addClass('widget-footer')
.appendTo(sw_examplewidget_back);
sw_examplewidget_action = (this.sw_examplewidget_action = $('<div>'))
.addClass('widget-action dropdown')
.append('<span data-toggle="dropdown">' +
'<span class="elegant-icons icon-cog"></span></span>' +
'<ul class="dropdown-menu sub-menu-item widget-action-options" role="menu">' +
'<li data-menu-action="maximize_widget"><span class="maximize-me">Maximize</span></li>' +
'<li data-menu-action="edit_params"><span>Edit Parameters</span></li>' +
'<li class="clone-widget" data-parent="' + that.element.attr('id') + '"><span>Clone Widget</span></li>' +
'<li class="dropdown"><span>Options</span><span class="elegant-icons arrow-triangle-right"></span>' +
'<ul class="dropdown-menu sub-menu examplewidget-options-menu">' +
'<li data-menu-action="example_action"><span>Sub Menu Option Choice</span></li></ul>')
.appendTo(sw_examplewidget_frontmain);
$('li.clone-widget').click(function(event) {
event.stopImmediatePropagation();
that.clone_widget($(this).attr('data-parent'));
});
sw_examplewidget_close = (this.sw_examplewidget_close = $('<div>'))
.addClass('widget-close')
.click(function(event) {
event.preventDefault();
$(sw_examplewidget_container).addClass('transparent');
var that_id = sw_examplewidget_containerid;
setTimeout(function() {
that.destroy(event);
sw_examplewidget_container.remove();
}, 600);
})
.append('<span class="elegant-icons icon-close">')
.appendTo(sw_examplewidget_frontmain);
// Buttons that will go in the footer bar
sw_examplewidget_querycancelbutton = (this.sw_examplewidget_querycancelbutton = $('<div>'))
.addClass("widget-footer-button left-button query_cancel")
.click(function() {
that.flip_to_front();
})
.append('<span class="iconic iconic-x-alt"><span class="font-reset"> Cancel</span></span>')
.appendTo(sw_examplewidget_backfooter);
sw_examplewidget_gobutton = (this.sw_examplewidget_gobutton = $('<div>'))
.addClass("widget-footer-button right-button go-button")
.click(function(event) {
that.go_click_handler(event);
})
.append('<span class="iconic iconic-bolt"><span class="font-reset"> Go</span></span>')
.appendTo(sw_examplewidget_backfooter);
// Define the div for the search form
sw_examplebwidget_form = (this.sw_examplewidget_form = $('<div>'))
.addClass('example-widget-form')
.appendTo(sw_examplewidget_backmain);
setTimeout(function() {
that.edit_params();
}, 250);
$(sw_examplewidget).on('click', 'li[data-menu-action]', function(event) {
event.preventDefault();
var action = $(this).attr('data-menu-action');
that[action](this, that);
});
}, _destroy: function() {
console.log('_destroy called');
if (typeof this.autoupdate_timer !== "undefined") {
clearTimeout(this.autoupdate_timer);
}
if (typeof this.ajax_request !== "undefined") {
this.ajax_request.abort();
}
this.sw_examplewidget_gobutton.remove();
this.sw_examplewidget_querycancelbutton.remove();
this.sw_examplewidget_form.remove();
this.sw_examplewidget_backfooter.remove();
this.sw_examplewidget_backmain.remove();
this.sw_examplewidget_backtitle.remove();
this.sw_examplewidget_action.remove();
this.sw_examplewidget_close.remove();
this.sw_examplewidget_frontmain.remove();
this.sw_examplewidget_front.remove();
this.sw_examplewidget_back.remove();
this.sw_examplewidget.remove();
}, dropdown_menu_handler: function(item) {
var widget = this;
var button = $(item).parent().parent().children('span');
var action = $(item).attr('data-action');
$(button).children('.graph-widget-button-label').text($(item).text());
$(button).children('div.ds-interval').attr('data-value', $(item).children('span').attr('data-value'));
if ($(item).parent().attr('id') === "time-span-options" + widget.uuid) {
$(button).children('div#time-span' + widget.uuid).attr('data-ms', $(item).children('span').attr('data-ms')).text();
}
}, edit_params: function() {
var widget = this;
$(window).scrollTop(0);
widget.start_height = widget.sw_examplewidget_container.height();
widget.start_width = widget.sw_examplewidget_container.width();
widget.widget_position = widget.sw_examplewidget_container.position();
widget.sw_examplewidget.addClass('flipped');
$('div.container').after('<div class="bodyshade transparent">');
setTimeout(function() {
widget.sw_examplewidget_container.css({position: 'absolute', height: widget.start_height + 'px', width: widget.start_width + 'px', top: widget.widget_position.top, left: widget.widget_position.left, 'z-index': '500'})
.after('<div class="spacer-box" style="display: inline-block; width: ' + widget.start_width +
'px; height: ' + widget.start_height +
'px; margin: ' + widget.sw_examplewidget.parent().css('margin') + '"></div>');
widget.sw_examplewidget_container.css({top: '15%', left: '15%', height: '70%', width: '65%'});
$('div.bodyshade').removeClass('transparent');
}, 700);
}, flip_to_front: function() {
var widget = this;
if ($('div.bodyshade').length > 0) {
$('div.bodyshade').addClass('transparent');
widget.sw_examplewidget_container.css({width: widget.start_width, height: '', top: widget.widget_position.top, left: widget.widget_position.left});
setTimeout(function() {
widget.sw_examplewidget_container.css({position: '', top: '', left: '', 'z-index': '', height: '', width: ''})
.siblings('div.spacer-box').remove();
$('div.bodyshade').remove();
}, 600);
setTimeout(function() {
if (typeof widget.svg !== "undefined") {
widget.resize_graph();
}
widget.sw_examplewidget.removeClass('flipped');
}, 700);
}
else {
widget.sw_examplewidget.removeClass('flipped');
if ($('#' + widget.element.attr('id')).hasClass('transparent')) {
$('#' + widget.element.attr('id')).removeClass('transparent');
}
}
}, maximize_widget: function() {
var widget = this;
if ($(widget.sw_examplewidget_container).hasClass('maximize-widget')) {
$(widget.sw_examplewidget_container).removeClass('maximize-widget');
$(widget.sw_examplewidget_container).addClass('cols-' + document._session.dashboard_columns);
$('body').removeClass('no-overflow');
$('.menubar').removeClass('hidden');
$(widget.sw_examplewidget_containerid + ' span.maximize-me').text('Maximize');
}
else {
$(window).scrollTop(0);
$(widget.sw_examplewidget_container).removeClass('cols-' + document._session.dashboard_columns);
$(widget.sw_examplewidget_container).addClass('maximize-widget');
$('.menubar').addClass('hidden');
$('body').addClass('no-overflow');
$(widget.sw_examplewidget_containerid + ' span.maximize-me').text('Minimize');
}
}, clone_widget: function(widget_id) {
// Add a new widget as a duplicate of the selected widget
var widget = $('#' + widget_id).data('sw-opentsdbwidget');
console.log('Cloning widget ' + widget.element.attr('id'));
var username = document._session.dashboard_username;
var new_widget_id = "widget" + md5(username + new Date.now().getTime());
console.log('Adding new widget ' + new_widget_id);
$('#dash-container').append('<div class="widget-container" id="' + new_widget_id + '" data-widget-type="opentsdbwidget">');
var new_widget = $('div#' + new_widget_id).opentsdbwidget(widget.options);
new_widget.addClass('cols-' + document._session.dashboard_columns);
new_widget_object = $(new_widget).data('sw-opentsdbwidget');
new_widget_object.populate_search_form(widget.query_data, 'clone');
$('#search-title' + new_widget_object.uuid).css('width', $('#search-title' + widget.uuid).width());
$('#' + new_widget_object.element.attr('id')).removeClass('transparent');
}
})
}(jQuery));
@@ -0,0 +1,73 @@
<?php
/**
* GraphWidgetController
*
* Describe your class here
*
* Author: Mark Troyer <disco@box.com>
* Date Created: 15 July 2013
*
* @package StatusWolf.Widets.GraphWidget
*/
class GraphWidgetController extends SWController
{
public function __construct($url_path)
{
parent::__construct();
// Init logging for the class
if(SWConfig::read_values('statuswolf.debug'))
{
$this->loggy = new KLogger(ROOT . 'app/log/', KLogger::DEBUG);
}
else
{
$this->loggy = new KLogger(ROOT . 'app/log/', KLogger::INFO);
}
$this->log_tag = '(' . $_SESSION['_sw_authsession']['username'] . '|' . $_SESSION['_sw_authsession']['sessionip'] . ') ';
$this->loggy->logDebug($this->log_tag . 'Looking for Widget function ' . $url_path[0]);
if (!empty($url_path[0]))
{
$widget_action = array_shift($url_path);
switch($widget_action)
{
case 'api':
if (!empty($url_path[0]))
{
$_api_function = array_shift($url_path);
$this->loggy->logDebug($this->log_tag . 'calling function ' . $_api_function);
$this->$_api_function($url_path);
}
else
{
throw new SWException ('No API function specified');
}
}
}
else
{
throw new SWException ('No action specified for widget');
}
}
protected function datasource_form($form)
{
if (!empty($form) && $form[0])
{
$this->loggy->logDebug($this->log_tag . 'Loading data source form for ' . $form[0]);
ob_start();
include WIDGETS . 'GraphWidget' . DS . 'Views' . DS . $form[0] . '.php';
$raw_form = ob_get_contents();
$form_data = array('form_source' => $raw_form);
ob_end_clean();
echo json_encode($form_data);
}
else
{
throw new SWException('No datasource form found');
}
}
}
@@ -0,0 +1,23 @@
{
"name": "sw.opentsdbwidget"
,"title": "OpenTSDB Widget"
,"description": "Widget for displaying graphs for OpenTSDB Data"
,"version": "1.1"
,"author": {
"name": "StatusWolf Project"
,"url": "http://wwww.statuswolf.com/"
}
,"maintainers": [
{
"name": "Mark Troyer"
,"email": "disco@box.com"
}
]
,"license": "Apache v2.0",
"enabled": true,
"dependencies": {
"js": [
"bootstrap-datetimepicker.js"
]
}
}
Oops, something went wrong.

0 comments on commit b06908b

Please sign in to comment.