Statistics
| Branch: | Tag: | Revision:

root / ui / views.py @ 8b471ee6

History | View | Annotate | Download (3.9 kB)

1 a5bc3755 Vangelis Koukis
# Copyright 2011 GRNET S.A. All rights reserved.
2 8950a78f Christodoulos Psaltis
#
3 a5bc3755 Vangelis Koukis
# Redistribution and use in source and binary forms, with or
4 a5bc3755 Vangelis Koukis
# without modification, are permitted provided that the following
5 a5bc3755 Vangelis Koukis
# conditions are met:
6 8950a78f Christodoulos Psaltis
#
7 a5bc3755 Vangelis Koukis
#   1. Redistributions of source code must retain the above
8 a5bc3755 Vangelis Koukis
#      copyright notice, this list of conditions and the following
9 a5bc3755 Vangelis Koukis
#      disclaimer.
10 8950a78f Christodoulos Psaltis
#
11 a5bc3755 Vangelis Koukis
#   2. Redistributions in binary form must reproduce the above
12 a5bc3755 Vangelis Koukis
#      copyright notice, this list of conditions and the following
13 a5bc3755 Vangelis Koukis
#      disclaimer in the documentation and/or other materials
14 a5bc3755 Vangelis Koukis
#      provided with the distribution.
15 8950a78f Christodoulos Psaltis
#
16 a5bc3755 Vangelis Koukis
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 a5bc3755 Vangelis Koukis
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 a5bc3755 Vangelis Koukis
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 a5bc3755 Vangelis Koukis
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 a5bc3755 Vangelis Koukis
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 a5bc3755 Vangelis Koukis
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 a5bc3755 Vangelis Koukis
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 a5bc3755 Vangelis Koukis
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 a5bc3755 Vangelis Koukis
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 a5bc3755 Vangelis Koukis
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 a5bc3755 Vangelis Koukis
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 a5bc3755 Vangelis Koukis
# POSSIBILITY OF SUCH DAMAGE.
28 8950a78f Christodoulos Psaltis
#
29 a5bc3755 Vangelis Koukis
# The views and conclusions contained in the software and
30 a5bc3755 Vangelis Koukis
# documentation are those of the authors and should not be
31 a5bc3755 Vangelis Koukis
# interpreted as representing official policies, either expressed
32 a5bc3755 Vangelis Koukis
# or implied, of GRNET S.A.
33 8950a78f Christodoulos Psaltis
#
34 edda4d30 Markos Gogoulos
import os
35 abf90954 Markos Gogoulos
from django.conf import settings
36 edda4d30 Markos Gogoulos
from django.utils.translation import gettext_lazy as _
37 b303ba05 Christodoulos Psaltis
from django.template import Context, loader
38 cc7c5902 Dimitris Moraitis
from django.http import HttpResponse
39 ec06b07c Dimitris Moraitis
from django.utils.translation import get_language
40 9c901aec Markos Gogoulos
from django.utils import simplejson as json
41 f533f224 Vangelis Koukis
from django.shortcuts import render_to_response
42 cc7c5902 Dimitris Moraitis
43 abf90954 Markos Gogoulos
TIMEOUT = settings.TIMEOUT
44 7b03c69d Dimitris Moraitis
UPDATE_INTERVAL = settings.UPDATE_INTERVAL
45 f533f224 Vangelis Koukis
IMAGE_ICONS = settings.IMAGE_ICONS
46 e646ebe5 Dimitris Moraitis
47 cc7c5902 Dimitris Moraitis
def template(name, context):
48 e646ebe5 Dimitris Moraitis
    template_path = os.path.join(os.path.dirname(__file__), "templates/")
49 b303ba05 Christodoulos Psaltis
    current_template = template_path + name + '.html'
50 b303ba05 Christodoulos Psaltis
    t = loader.get_template(current_template)
51 b303ba05 Christodoulos Psaltis
    return HttpResponse(t.render(Context(context)))
52 cc7c5902 Dimitris Moraitis
53 cc7c5902 Dimitris Moraitis
def home(request):
54 e646ebe5 Dimitris Moraitis
    context = {'timeout': TIMEOUT,
55 a226ff9f Christodoulos Psaltis
               'project': '+nefo',
56 e646ebe5 Dimitris Moraitis
               'request': request,
57 f533f224 Vangelis Koukis
               'current_lang': get_language() or 'en',
58 7b03c69d Dimitris Moraitis
               'update_interval': UPDATE_INTERVAL,
59 f533f224 Vangelis Koukis
               'image_icons': IMAGE_ICONS,}
60 cc7c5902 Dimitris Moraitis
    return template('home', context)
61 cc7c5902 Dimitris Moraitis
62 43df43aa Markos Gogoulos
def machines(request):
63 f533f224 Vangelis Koukis
    context = {'default_keywords': settings.DEFAULT_KEYWORDS}
64 43df43aa Markos Gogoulos
    return template('machines', context)
65 42f67a2a Dimitris Moraitis
66 f533f224 Vangelis Koukis
def machines_icon(request):
67 f533f224 Vangelis Koukis
    context = {'default_keywords': settings.DEFAULT_KEYWORDS}
68 f533f224 Vangelis Koukis
    return template('machines_icon', context)
69 f533f224 Vangelis Koukis
70 f533f224 Vangelis Koukis
def machines_list(request):
71 f533f224 Vangelis Koukis
    context = {'default_keywords': settings.DEFAULT_KEYWORDS}
72 f533f224 Vangelis Koukis
    return template('machines_list', context)
73 f533f224 Vangelis Koukis
74 f533f224 Vangelis Koukis
def machines_single(request):
75 f533f224 Vangelis Koukis
    context = {'default_keywords': settings.DEFAULT_KEYWORDS}
76 f533f224 Vangelis Koukis
    return template('machines_single', context)
77 f533f224 Vangelis Koukis
78 f533f224 Vangelis Koukis
def machines_console(request):
79 473d37cc Markos Gogoulos
    host, port, password = ('','','')
80 6912c72b Markos Gogoulos
    host = request.GET.get('host','')
81 6912c72b Markos Gogoulos
    port = request.GET.get('port','')
82 6912c72b Markos Gogoulos
    password = request.GET.get('password','')
83 f533f224 Vangelis Koukis
    machine = request.GET.get('machine','')
84 f533f224 Vangelis Koukis
    host_ip = request.GET.get('host_ip','')
85 f533f224 Vangelis Koukis
    context = {'host': host, 'port': port, 'password': password, 'machine': machine, 'host_ip': host_ip}
86 f533f224 Vangelis Koukis
    return template('machines_console', context)
87 e646ebe5 Dimitris Moraitis
88 e646ebe5 Dimitris Moraitis
def images(request):
89 ec06b07c Dimitris Moraitis
    context = {}
90 cc7c5902 Dimitris Moraitis
    return template('images', context)
91 cc7c5902 Dimitris Moraitis
92 cc7c5902 Dimitris Moraitis
def disks(request):
93 ec06b07c Dimitris Moraitis
    context = {}
94 cc7c5902 Dimitris Moraitis
    return template('disks', context)
95 cc7c5902 Dimitris Moraitis
96 cc7c5902 Dimitris Moraitis
def networks(request):
97 ec06b07c Dimitris Moraitis
    context = {}
98 cc7c5902 Dimitris Moraitis
    return template('networks', context)
99 0dedf601 Christodoulos Psaltis
100 f533f224 Vangelis Koukis
def files(request):
101 0dedf601 Christodoulos Psaltis
    context = {}
102 0dedf601 Christodoulos Psaltis
    return template('files', context)
103 0dedf601 Christodoulos Psaltis
104 0dedf601 Christodoulos Psaltis
def desktops(request):
105 0dedf601 Christodoulos Psaltis
    context = {}
106 0dedf601 Christodoulos Psaltis
    return template('desktops', context)
107 0dedf601 Christodoulos Psaltis
108 0dedf601 Christodoulos Psaltis
def apps(request):
109 0dedf601 Christodoulos Psaltis
    context = {}
110 0dedf601 Christodoulos Psaltis
    return template('apps', context)