diff --git a/circle/dashboard/static/dashboard/dashboard.css b/circle/dashboard/static/dashboard/dashboard.css index 1df1b34..452490c 100644 --- a/circle/dashboard/static/dashboard/dashboard.css +++ b/circle/dashboard/static/dashboard/dashboard.css @@ -186,42 +186,6 @@ html { text-decoration: none !important; } -.slider { - display: inline-block; -} -.slider .track { - height: 20px; - top: 50%; -} -.slider > .dragger, .slider > .dragger:hover { - border-radius: 0px; - -moz-border-radius: 0px; - -webkit-border-radius: 0px; - width: 8px; - height: 24px; - margin-top: -12px!important; - text-shadow: 0 1px 0 #fff; - background-image: -webkit-gradient(linear, left 0%, left 100%, from(#428bca), to(#3071a9)); - background-image: -webkit-linear-gradient(top, #428bca, 0%, #3071a9, 100%); - background-image: -moz-linear-gradient(top, #428bca 0%, #3071a9 100%); - background-image: linear-gradient(to bottom, #428bca 0%, #3071a9 100%); - background-repeat: repeat-x; - border-color: #2d6ca2; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff3071a9', GradientType=0); -} -.slider > .dragger:hover { - background-color: #3071a9; - background-image: none; - border-color: #2d6ca2; -} - -.slider > .highlight-track { - height: 20px; - top: 50%; -} -.slider + .output { - -} .rule-table tr >:nth-child(1) { text-align: right; } @@ -751,3 +715,7 @@ textarea[name="list-new-namelist"] { #group-detail-permissions input[type="submit"]{ margin-top: -6px; } + +.vm-resources-sliders .row { + margin-bottom: 15px; +} diff --git a/circle/dashboard/static/dashboard/dashboard.js b/circle/dashboard/static/dashboard/dashboard.js index b88eb2b..f2eaba7 100644 --- a/circle/dashboard/static/dashboard/dashboard.js +++ b/circle/dashboard/static/dashboard/dashboard.js @@ -432,27 +432,59 @@ function compareVmByFav(a, b) { } function addSliderMiscs() { - $('.vm-slider').each(function() { - $("").addClass("output").html($(this).val()).insertAfter($(this)); - }); - - $('.vm-slider').slider() - .on('slide', function(e) { - $(this).val(e.value); - $(this).parent('div').nextAll("span").html(e.value) + $(".vm-slider").simpleSlider(); + $(".cpu-priority-slider").bind("slider:changed", function (event, data) { + value = data.value + 0; + switch(value) { + case 30: type = 1; break; + case 80: type = 2; break; + case 100: type = 3; break; + default: type = 0; + } + + $(".cpu-priority-input option:eq(" + type + ")").attr("selected", "selected"); }); - refreshSliders(); -} + var ram_fire = false; + $(".cpu-priority-input").change(function() { + var val = $(":selected", $(this)).val(); + var slider_value = [10, 30, 80, 100][val] + $(".cpu-priority-slider").simpleSlider("setValue", slider_value); + }); -// ehhh -function refreshSliders() { - $('.vm-slider').each(function() { - $(this).val($(this).slider().data('slider').getValue()); - $(this).parent('div').nextAll("span").html($(this).val()); + $(".cpu-count-slider").bind("slider:changed", function (event, data) { + var value = data.value + 0; + $(".cpu-count-input").val(value); }); + + $(".cpu-count-input").bind("input", function() { + var val = $(this).val(); + $(".cpu-count-slider").simpleSlider("setValue", val); + }); + + + $(".ram-slider").bind("slider:changed", function (event, data) { + if(ram_fire) { + ram_fire = false; + return; + } + + var value = data.value + 0; + $(".ram-input").val(value); + }); + + $(".ram-input").bind("input", function() { + var val = $(this).val(); + ram_fire = true; + $(".ram-slider").simpleSlider("setValue", parseInt(val)); + }); + + + $(".cpu-priority-input").trigger("change"); + $(".cpu-count-input, .ram-input").trigger("input"); } + /* deletes the VM with the pk * if dir is true, then redirect to the dashboard landing page * else it adds a success message */ diff --git a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/README.md b/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/README.md deleted file mode 100644 index 1ab4e1c..0000000 --- a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/README.md +++ /dev/null @@ -1,27 +0,0 @@ -jQuery Simple Slider: Unobtrusive Numerical Slider -================================================== - -SimpleSlider is a jQuery plugin for turning your text inputs into draggable -numerical sliders. - -It has no external dependencies other than jQuery, and you don't need to write -a single line of JavaScript to get it to work. - - -How to Use ------------ - -Include the javascript file in your page: - - - -Turn your text input into a slider: - - - - -Documentation, Features and Demos ---------------------------------- -Full details and documentation can be found on the project page here: - - \ No newline at end of file diff --git a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/demo.html b/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/demo.html deleted file mode 100644 index 1bf42ec..0000000 --- a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/demo.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - -

jQuery Simple Slider Examples

-

- Here are a few examples of the functionality available in Simple Slider. -

- - -

Basic Example

- - -

Basic Example (Themed)

- - -

Predefined Value

- - -

Steps

- - -

Range

- - -

Range & Steps

- - -

Range, Steps & Snap

- - -

Predefined List of Values

- - -

Predefined List & Snap

- - -

Predefined List, Equal Steps & Snap

- - -

Highlighted

- - -

Highlighted (Themed)

- - - - - diff --git a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/grunt.js b/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/grunt.js deleted file mode 100644 index eea6217..0000000 --- a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/grunt.js +++ /dev/null @@ -1,68 +0,0 @@ -module.exports = function(grunt) { - grunt.initConfig({ - pkg: '', - - meta: { - banner: - '/*\n' + - ' * <%= pkg.title || pkg.name %>: <%= pkg.description %>\n' + - ' * Version <%= pkg.version %>\n' + - ' *\n' + - ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> (<%= pkg.author.url %>)\n' + - ' *\n' + - ' * Licensed under the <%= pkg.licenses[0].type %> license (<%= pkg.licenses[0].url %>)\n' + - ' *\n' + - ' */\n' - }, - - coffee: { - compile: { - files: { - 'js/<%= pkg.name %>.js': 'js/*.coffee' - }, - - options: { - bare: true - } - } - }, - - watch: { - coffee: { - files: ['js/*.coffee'], - tasks: 'coffee growl:coffee' - } - }, - - growl: { - coffee: { - title: 'CoffeeScript', - message: 'Compiled successfully' - } - }, - - min: { - dist: { - src: ['', 'js/<%= pkg.name %>.js'], - dest: 'js/<%= pkg.name %>.min.js' - } - }, - - compress: { - zip: { - files: { - "<%= pkg.name %>-<%= pkg.version %>.zip": ["js/**", "demo.html", "README.md"] - } - } - } - }); - - // Lib tasks. - grunt.loadNpmTasks('grunt-contrib'); - grunt.loadNpmTasks('grunt-growl'); - - // Default task. - grunt.registerTask('build', 'coffee min'); - grunt.registerTask('serve', 'server watch:coffee'); - grunt.registerTask('default', 'build'); -}; \ No newline at end of file diff --git a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/package.json b/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/package.json deleted file mode 100644 index c1918f3..0000000 --- a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name" : "simple-slider", - "title" : "jQuery Simple Slider", - "description" : "Unobtrusive Numerical Slider", - "version" : "1.0.0", - "homepage" : "http://loopj.com/jquery-simple-slider", - "keywords" : [], - "author" : { - "name" : "James Smith", - "email" : "james@loopj.com", - "url" : "http://loopj.com" - }, - "repository" : { - "type" : "git", - "url" : "https://github.com/loopj/jquery-simple-slider.git" - }, - "bugs" : { - "url" : "https://github.com/loopj/jquery-simple-slider/issues" - }, - "licenses": [{ - "type": "MIT", - "url" : "http://mit-license.org/" - }], - "devDependencies" : { - "grunt" : "0.3.x", - "grunt-contrib": "0.2.x", - "grunt-growl": "git://github.com/loopj/grunt-growl.git#master" - }, - "scripts": { - "test": "grunt" - } -} \ No newline at end of file diff --git a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/.gitignore b/circle/dashboard/static/dashboard/loopj-jquery-simple-slider/.gitignore similarity index 100% rename from circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/.gitignore rename to circle/dashboard/static/dashboard/loopj-jquery-simple-slider/.gitignore diff --git a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/css/simple-slider.css b/circle/dashboard/static/dashboard/loopj-jquery-simple-slider/css/simple-slider.css similarity index 67% rename from circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/css/simple-slider.css rename to circle/dashboard/static/dashboard/loopj-jquery-simple-slider/css/simple-slider.css index ca9bf6b..953ebf2 100644 --- a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/css/simple-slider.css +++ b/circle/dashboard/static/dashboard/loopj-jquery-simple-slider/css/simple-slider.css @@ -53,3 +53,50 @@ border-color: #496805; } + + +.slider { + display: inline-block; +} +.slider .track { + height: 20px; + top: 50%; +} +.slider > .dragger, .slider > .dragger:hover { + border-radius: 0px; + -moz-border-radius: 0px; + -webkit-border-radius: 0px; + width: 8px; + height: 24px; + margin-top: -12px!important; + text-shadow: 0 1px 0 #fff; + background-image: -webkit-gradient(linear, left 0%, left 100%, from(#428bca), to(#3071a9)); + background-image: -webkit-linear-gradient(top, #428bca, 0%, #3071a9, 100%); + background-image: -moz-linear-gradient(top, #428bca 0%, #3071a9 100%); + background-image: linear-gradient(to bottom, #428bca 0%, #3071a9 100%); + background-repeat: repeat-x; + border-color: #2d6ca2; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff3071a9', GradientType=0); +} +.slider > .dragger:hover { + background-color: #3071a9; + background-image: none; + border-color: #2d6ca2; +} + +.slider > .highlight-track { + height: 20px; + top: 50%; +} +.slider + .output { + +} + +.slider > .track, .slider > .highlight-track { +border-radius: 5px; +} + +/* review this later */ +.slider { + width: 100%; +} diff --git a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/js/simple-slider.coffee b/circle/dashboard/static/dashboard/loopj-jquery-simple-slider/js/simple-slider.coffee similarity index 100% rename from circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/js/simple-slider.coffee rename to circle/dashboard/static/dashboard/loopj-jquery-simple-slider/js/simple-slider.coffee diff --git a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/js/simple-slider.js b/circle/dashboard/static/dashboard/loopj-jquery-simple-slider/js/simple-slider.js similarity index 80% rename from circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/js/simple-slider.js rename to circle/dashboard/static/dashboard/loopj-jquery-simple-slider/js/simple-slider.js index 1b917f6..5426cbd 100644 --- a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/js/simple-slider.js +++ b/circle/dashboard/static/dashboard/loopj-jquery-simple-slider/js/simple-slider.js @@ -1,7 +1,10 @@ /* jQuery Simple Slider - Copyright (c) 2012 James Smith (http://loopj.com) + Copyright (c) 2012, 2013 James Smith (http://loopj.com) + Copyright (c) 2013 Maarten van Grootel (http://maatenvangrootel.nl) + Copyright (c) 2013 Nathan Hunzaker (http://natehunzaker.com) + Copyright (c) 2013 Erik J. Nedwidek (http://github.com/nedwidek) Licensed under the MIT license (http://mit-license.org/) */ @@ -23,8 +26,12 @@ var __slice = [].slice, classPrefix: null, classSuffix: null, theme: null, - highlight: false + highlight: false, + showScale: false }; + if(typeof options == 'undefined') { + options = this.loadDataOptions(); + } this.settings = $.extend({}, this.defaultOptions, options); if (this.settings.theme) { this.settings.classSuffix = "-" + this.settings.theme; @@ -106,6 +113,20 @@ var __slice = [].slice, } this.setSliderPositionFromValue(this.value); ratio = this.valueToRatio(this.value); + if (this.settings.showScale) { + this.scale = this.createDivElement("scale"); + this.minScale = this.createSpanElement("min-scale", this.scale); + this.maxScale = this.createSpanElement("max-scale", this.scale); + + range = this.getRange(); + + this.minScale.html(range.min); + this.maxScale.html(range.max); + + this.scale.css('marginTop', function(index, currentValue) { + return (parseInt(currentValue, 10) + this.previousSibling.offsetHeight / 2) + 'px'; + }); + } this.input.trigger("slider:ready", { value: this.value, ratio: ratio, @@ -114,6 +135,44 @@ var __slice = [].slice, }); } + SimpleSlider.prototype.loadDataOptions = function() { + var options = {}; + allowedValues = this.input.data("slider-values"); + if (allowedValues) { + options.allowedValues = (function() { + var _i, _len, _ref, _results; + _ref = allowedValues.split(","); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + x = _ref[_i]; + _results.push(parseFloat(x)); + } + return _results; + })(); + } + if (this.input.data("slider-range")) { + options.range = this.input.data("slider-range").split(","); + } + if (this.input.data("slider-step")) { + options.step = this.input.data("slider-step"); + } + options.snap = this.input.data("slider-snap"); + options.equalSteps = this.input.data("slider-equal-steps"); + if (this.input.data("slider-theme")) { + options.theme = this.input.data("slider-theme"); + } + if (this.input.attr("data-slider-highlight")) { + options.highlight = this.input.data("slider-highlight"); + } + if (this.input.data("slider-animate") != null) { + options.animate = this.input.data("slider-animate"); + } + if (this.input.data("slider-showscale") != null) { + options.showScale = this.input.data("slider-showscale"); + } + return options; + } + SimpleSlider.prototype.createDivElement = function(classname) { var item; item = $("
").addClass(classname).css({ @@ -125,6 +184,12 @@ var __slice = [].slice, return item; }; + SimpleSlider.prototype.createSpanElement = function(classname, parent) { + var item; + item = $("").addClass(classname).appendTo(parent); + return item; + }; + SimpleSlider.prototype.setRatio = function(ratio) { var value; ratio = Math.min(1, ratio); @@ -322,42 +387,14 @@ var __slice = [].slice, }); } }); + + /* return $(function() { return $("[data-slider]").each(function() { var $el, allowedValues, settings, x; $el = $(this); - settings = {}; - allowedValues = $el.data("slider-values"); - if (allowedValues) { - settings.allowedValues = (function() { - var _i, _len, _ref, _results; - _ref = allowedValues.split(","); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - x = _ref[_i]; - _results.push(parseFloat(x)); - } - return _results; - })(); - } - if ($el.data("slider-range")) { - settings.range = $el.data("slider-range").split(","); - } - if ($el.data("slider-step")) { - settings.step = $el.data("slider-step"); - } - settings.snap = $el.data("slider-snap"); - settings.equalSteps = $el.data("slider-equal-steps"); - if ($el.data("slider-theme")) { - settings.theme = $el.data("slider-theme"); - } - if ($el.attr("data-slider-highlight")) { - settings.highlight = $el.data("slider-highlight"); - } - if ($el.data("slider-animate") != null) { - settings.animate = $el.data("slider-animate"); - } - return $el.simpleSlider(settings); + return $el.simpleSlider(); }); }); + */ })(this.jQuery || this.Zepto, this); diff --git a/circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/js/simple-slider.min.js b/circle/dashboard/static/dashboard/loopj-jquery-simple-slider/js/simple-slider.min.js similarity index 100% rename from circle/dashboard/static/dashboard/loopj-jquery-simple-slider-fa64f59/js/simple-slider.min.js rename to circle/dashboard/static/dashboard/loopj-jquery-simple-slider/js/simple-slider.min.js diff --git a/circle/dashboard/templates/base.html b/circle/dashboard/templates/base.html index 2061471..ab5f2f2 100644 --- a/circle/dashboard/templates/base.html +++ b/circle/dashboard/templates/base.html @@ -68,6 +68,7 @@ + {% include 'autocomplete_light/static.html' %} diff --git a/circle/dashboard/templates/dashboard/base.html b/circle/dashboard/templates/dashboard/base.html index 3deaaff..fc54eed 100644 --- a/circle/dashboard/templates/dashboard/base.html +++ b/circle/dashboard/templates/dashboard/base.html @@ -5,7 +5,7 @@ {% block extra_link %} - + {% endblock %} @@ -56,6 +56,5 @@ {% block extra_script %} - {% endblock %} diff --git a/circle/dashboard/templates/dashboard/vm-detail/resources.html b/circle/dashboard/templates/dashboard/vm-detail/resources.html index 77f0d49..4299f4a 100644 --- a/circle/dashboard/templates/dashboard/vm-detail/resources.html +++ b/circle/dashboard/templates/dashboard/vm-detail/resources.html @@ -2,6 +2,79 @@ {% load sizefieldtags %} {% load crispy_forms_tags %} +
+ +
+ +
+
+ {% trans "CPU priority" %} +
+
+ +
+
+
+ + + + +
+
+
+ +
+
+ {% trans "CPU count" %} +
+
+ +
+
+
+ + + + +
+
+
+ +
+
+ {% trans "RAM amount" %} +
+
+ +
+
+
+ + + MiB + + + +
+
+
+
+ +
+ +
+
{% csrf_token %}