~devcamcar/horizon/trunk

« back to all changes in this revision

Viewing changes to django-openstack/src/django_openstack/templates/django_openstack/nova/instances/index.html

  • Committer: Devin Carlen
  • Date: 2011-06-18 05:59:37 UTC
  • Revision ID: devin.carlen@gmail.com-20110618055937-aobwm0buvviijz3o
Moved codebase to GitHub

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{% extends "django_openstack/nova/instances/base.html" %}
2
 
{% load i18n %}
3
 
 
4
 
{% block title %} - {{ project.projectname|capfirst }} Instances{% endblock %}
5
 
{% block pageclass %}instances{% endblock %}
6
 
 
7
 
{% block content %}
8
 
  <div id="page_head">
9
 
    <div id="spinner"></div>
10
 
 
11
 
    <h2 id="page_heading">{% trans "Instances" %}</h2>
12
 
    <p id="page_description">{% trans "Instances are virtual servers launched from images. You can launch instances from the" %} <a href="{% url nova_images project.projectname %}">images tab</a>.</p>
13
 
  </div>
14
 
 
15
 
  {% include "django_openstack/_messages.html" %}
16
 
 
17
 
  <div id="instances">
18
 
    {% include "django_openstack/nova/instances/_instances_list.html" %}
19
 
  </div>
20
 
 
21
 
  <div id="dlg_confirm" title="Confirm Termination" style="display:none;">
22
 
    <p>{% trans "Are you sure you wish to terminate instance" %} <span id="spn_terminate"></span>?</p>
23
 
  </div>
24
 
 
25
 
  <div id="connection_error" style="display:none;" title="Connection Error">
26
 
    <p><span class="ui-icon ui-icon-alert"></span>{% trans "A connection error has occurred. Please ensure you are still connected to VPN." %}</p>
27
 
  </div>
28
 
{% endblock %}
29
 
 
30
 
{% block footerjs %}
31
 
{{ block.super }}
32
 
<script type="text/javascript">
33
 
 
34
 
  $(function() {
35
 
    setInterval(function() {
36
 
      $('#spinner').show();
37
 
      {% if detail %}
38
 
        $('#instances').load('{% url nova_instances_refresh_detail project.projectname selected_instance.id %}', onInstancesUpdated);
39
 
      {% else %}
40
 
        $('#instances').load('{% url nova_instances_refresh project.projectname %}', onInstancesUpdated);
41
 
      {% endif %}
42
 
    }, 15000);
43
 
 
44
 
    initInstanceForms();
45
 
 
46
 
    $('#dlg_confirm').dialog({
47
 
      buttons: {
48
 
        'Ok': onConfirmOK,
49
 
        'Cancel': function() { $(this).dialog('close'); }
50
 
      },
51
 
      autoOpen: false,
52
 
      resizable: false,
53
 
      width: 500,
54
 
      height: 200
55
 
    });
56
 
  });
57
 
 
58
 
  var _terminateID = null;
59
 
 
60
 
  function initInstanceForms() {
61
 
    $('.form-terminate').submit(function() {
62
 
      _terminateID = $(this).children(':first').val()
63
 
      $('#spn_terminate').text(_terminateID);
64
 
      $('#dlg_confirm').dialog('open');
65
 
      return false;
66
 
    });
67
 
  }
68
 
 
69
 
  var counter = 0;
70
 
 
71
 
  function onInstancesUpdated(response, status, xhr) {
72
 
    $('#spinner').hide();
73
 
 
74
 
    switch(xhr.status) {
75
 
      case 200:
76
 
        initInstanceForms();
77
 
        break;
78
 
 
79
 
      case 403:
80
 
        document.location = '{% url auth_login %}';
81
 
        break;
82
 
 
83
 
      default:
84
 
        if (counter >= 1) {
85
 
          $('#connection_error').dialog({
86
 
            dialogClass: 'alert',
87
 
            modal: true,
88
 
            closeOnEscape: true,
89
 
            buttons:{ "Close": function() { $(this).dialog("close"); } },
90
 
          });
91
 
          $('#connection_error').dialog('open');
92
 
          counter = 0;
93
 
        } else {
94
 
          counter++;
95
 
        }
96
 
        break;
97
 
    }
98
 
  }
99
 
 
100
 
  function onConfirmOK() {
101
 
    $(this).dialog('close');
102
 
    form = document.getElementById('form_terminate_' + _terminateID);
103
 
    if(form) form.submit();
104
 
  }
105
 
</script>
106
 
{% endblock %}