Matteo Scandolo | fd564fb | 2015-10-26 14:08:10 +0100 | [diff] [blame] | 1 | <div class="row-fluid">
|
| 2 | <div class="span12 text-right">
|
| 3 | <a href="core/dashboardview/add/" class="btn btn-success">
|
| 4 | <i class="icon icon-plus"></i> Add
|
| 5 | </a>
|
| 6 | </div>
|
| 7 | </div>
|
| 8 | <form>
|
Scott Baker | 2c3cb64 | 2014-05-19 17:55:56 -0700 | [diff] [blame] | 9 | <div class="customize_row">
|
Matteo Scandolo | fd564fb | 2015-10-26 14:08:10 +0100 | [diff] [blame] | 10 | <div class="customize_column">
|
| 11 | <div>Available Dashboard Views</div>
|
| 12 | <select name="selectfrom" id="select-from" multiple size="5">
|
| 13 | {% for cp in unusedDashboards %}
|
| 14 | <option value="{{ cp }}">{{ cp }}</option>
|
| 15 | {% endfor %}
|
| 16 | </select>
|
| 17 | </div>
|
| 18 | <div class="customize_column">
|
| 19 | <br>
|
| 20 | <div class="btn btn-success" id="customize-btn-add">Add »</div>
|
| 21 | <br>
|
| 22 | <br>
|
| 23 | <div class="btn btn-success" id="customize-btn-remove">« Remove</div>
|
| 24 | </div>
|
| 25 | <div class="customize_column">
|
| 26 | <div>Selected Dashboard Views</div>
|
| 27 | <select name="selectto" id="select-to" multiple size="5">
|
| 28 | {% for cp in dashboards %}
|
| 29 | <option value="{{ cp }}">{{ cp }}</option>
|
| 30 | {% endfor %}
|
| 31 | </select>
|
| 32 | <br>
|
| 33 | <div class="btn btn-high btn-info" id="customize-btn-save">Save</div>
|
| 34 | <div style="display: none" id="customize-msg-saving">Saving...</div>
|
| 35 | </div>
|
| 36 | <div class="customize_column">
|
| 37 | <br>
|
| 38 | <div class="btn btn-success" id="customize-btn-up">Up</div>
|
| 39 | <br>
|
| 40 | <br>
|
| 41 | <div class="btn btn-success" id="customize-btn-down">Down</div>
|
| 42 | </div>
|
Scott Baker | 2c3cb64 | 2014-05-19 17:55:56 -0700 | [diff] [blame] | 43 | </div>
|
| 44 | </form>
|
Matteo Scandolo | fd564fb | 2015-10-26 14:08:10 +0100 | [diff] [blame] | 45 |
|
| 46 | <script>
|
| 47 | $(document).ready(function() {
|
Scott Baker | ea41779 | 2014-05-21 17:52:44 -0700 | [diff] [blame] | 48 | $('#customize-btn-add').click(function(){
|
Scott Baker | 2c3cb64 | 2014-05-19 17:55:56 -0700 | [diff] [blame] | 49 | $('#select-from option:selected').each( function() {
|
| 50 | $('#select-to').append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option>");
|
| 51 | $(this).remove();
|
| 52 | });
|
| 53 | });
|
Scott Baker | ea41779 | 2014-05-21 17:52:44 -0700 | [diff] [blame] | 54 | $('#customize-btn-remove').click(function(){
|
Scott Baker | 2c3cb64 | 2014-05-19 17:55:56 -0700 | [diff] [blame] | 55 | $('#select-to option:selected').each( function() {
|
| 56 | $('#select-from').append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option>");
|
| 57 | $(this).remove();
|
| 58 | });
|
| 59 | });
|
Scott Baker | ea41779 | 2014-05-21 17:52:44 -0700 | [diff] [blame] | 60 | $('#customize-btn-up').bind('click', function() {
|
Scott Baker | 2c3cb64 | 2014-05-19 17:55:56 -0700 | [diff] [blame] | 61 | $('#select-to option:selected').each( function() {
|
| 62 | var newPos = $('#select-to option').index(this) - 1;
|
| 63 | if (newPos > -1) {
|
| 64 | $('#select-to option').eq(newPos).before("<option value='"+$(this).val()+"' selected='selected'>"+$(this).text()+"</option>");
|
| 65 | $(this).remove();
|
| 66 | }
|
| 67 | });
|
| 68 | });
|
Scott Baker | ea41779 | 2014-05-21 17:52:44 -0700 | [diff] [blame] | 69 | $('#customize-btn-down').bind('click', function() {
|
Scott Baker | 2c3cb64 | 2014-05-19 17:55:56 -0700 | [diff] [blame] | 70 | var countOptions = $('#select-to option').size();
|
| 71 | $('#select-to option:selected').each( function() {
|
| 72 | var newPos = $('#select-to option').index(this) + 1;
|
| 73 | if (newPos < countOptions) {
|
| 74 | $('#select-to option').eq(newPos).after("<option value='"+$(this).val()+"' selected='selected'>"+$(this).text()+"</option>");
|
| 75 | $(this).remove();
|
| 76 | }
|
| 77 | });
|
| 78 | });
|
Scott Baker | ea41779 | 2014-05-21 17:52:44 -0700 | [diff] [blame] | 79 | $('#customize-btn-save').bind('click', function() {
|
| 80 | $("#customize-btn-save").hide();
|
| 81 | $("#customize-msg-saving").show();
|
Scott Baker | 2c3cb64 | 2014-05-19 17:55:56 -0700 | [diff] [blame] | 82 | var items=[];
|
| 83 | $("#select-to option").each(function() { items.push($(this).val()); });
|
| 84 | $.ajax({
|
Matteo Scandolo | fd564fb | 2015-10-26 14:08:10 +0100 | [diff] [blame] | 85 | url: '/customize/',
|
| 86 | dataType: 'json',
|
| 87 | data: {
|
| 88 | dashboards: items.join(","),
|
| 89 | csrfmiddlewaretoken: "{{ csrf_token }}" // < here
|
| 90 | },
|
| 91 | type: 'POST',
|
| 92 | error: function (jqXHR, textStatus, errorThrown) {
|
| 93 | errorDialog("Error", textStatus + " " + jqXHR.responseText);
|
| 94 | $("#customize-btn-save").show();
|
| 95 | $("#customize-msg-saving").hide();
|
| 96 | },
|
| 97 | success: function () {
|
| 98 | location.reload();
|
| 99 | }
|
Scott Baker | 2c3cb64 | 2014-05-19 17:55:56 -0700 | [diff] [blame] | 100 | });
|
Matteo Scandolo | fd564fb | 2015-10-26 14:08:10 +0100 | [diff] [blame] | 101 | });
|
| 102 | });
|
| 103 | </script> |