Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a30f9eb3
authored
Jul 02, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: basic store
parent
7af38cf1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
121 additions
and
3 deletions
+121
-3
circle/circle/settings/base.py
+0
-1
circle/dashboard/store_api.py
+0
-2
circle/dashboard/templates/dashboard/store/list.html
+81
-0
circle/dashboard/templatetags/store_tags.py
+22
-0
circle/dashboard/urls.py
+4
-0
circle/dashboard/views.py
+14
-0
No files found.
circle/circle/settings/base.py
View file @
a30f9eb3
...
@@ -271,7 +271,6 @@ LOCAL_APPS = (
...
@@ -271,7 +271,6 @@ LOCAL_APPS = (
'dashboard'
,
'dashboard'
,
'manager'
,
'manager'
,
'acl'
,
'acl'
,
'cloudstore'
,
)
)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
...
...
circle/
cloudstore
/store_api.py
→
circle/
dashboard
/store_api.py
View file @
a30f9eb3
...
@@ -82,8 +82,6 @@ def listfolder(neptun, path):
...
@@ -82,8 +82,6 @@ def listfolder(neptun, path):
r
=
post_request
(
url
,
payload
)
r
=
post_request
(
url
,
payload
)
if
r
.
status_code
==
requests
.
codes
.
ok
:
if
r
.
status_code
==
requests
.
codes
.
ok
:
tupplelist
=
json
.
loads
(
r
.
content
)
tupplelist
=
json
.
loads
(
r
.
content
)
for
item
in
tupplelist
:
item
[
'MTIME'
]
=
time
.
ctime
(
item
[
'MTIME'
])
return
tupplelist
return
tupplelist
else
:
else
:
raise
Http404
raise
Http404
...
...
circle/dashboard/templates/dashboard/store/list.html
0 → 100644
View file @
a30f9eb3
{% extends "dashboard/base.html" %}
{% load i18n %}
{% load store_tags %}
{% block title-page %}{% trans "Virtual machines" %}{% endblock %}
{% block content %}
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<ul
id=
"store-list-list"
>
{% for f in root %}
<li
class=
"store-list-item"
>
<div
class=
"store-list-item-icon"
>
<i
class=
"icon-{% if f.TYPE == "
D
"
%}
folder-open-alt
{%
else
%}
file-alt
{%
endif
%}"
></i>
</div>
{{ f.NAME }}
<div
class=
"store-list-item-size"
>
{% if f.TYPE == "D" %}{% trans "directory" %}{% else %}{% bytes_to_megabytes f.SIZE %}MB{% endif %}
</div>
<div
class=
"store-list-item-actions"
>
<span
title=
"{% trans "
Last
modified:
"
%}
{%
timestamp_to_date
f
.
MTIME
%}"
class=
"btn btn-default btn-xs"
>
<i
class=
"icon-time"
></i>
</span>
<span
class=
"btn btn-default btn-xs"
>
<i
class=
"icon-cloud-download"
></i>
</span>
</div>
<div
class=
"clearfix"
></div>
</li>
{% endfor %}
</ul>
</div>
</div>
<style>
#store-list-list
{
list-style
:
none
;
}
.store-list-item
{
padding
:
0
8px
0
8px
;
cursor
:
pointer
;
line-height
:
35px
;
height
:
35px
;
}
.store-list-item
:hover
{
background
:
rgba
(
0
,
0
,
0
,
0.1
);
}
.store-list-item-icon
{
width
:
20px
;
display
:
inline-block
;
text-align
:
center
;
}
.store-list-item-size
{
display
:
inline-block
;
width
:
70px
;
text-align
:
right
;
float
:
right
;
}
.store-list-item-actions
{
display
:
inline-block
;
width
:
100px
;
text-align
:
center
;
float
:
right
;
}
</style>
{% endblock %}
{% block extra_js %}
<script
src=
"{{ STATIC_URL}}dashboard/store.js"
></script>
{% endblock %}
circle/dashboard/templatetags/store_tags.py
0 → 100644
View file @
a30f9eb3
from
datetime
import
datetime
from
django
import
template
from
django.utils.timesince
import
timesince
register
=
template
.
Library
()
@register.simple_tag
(
name
=
"bytes_to_megabytes"
)
def
bytes_to_megabytes
(
size
):
if
size
:
return
size
/
(
1024
*
1024
)
else
:
return
0
@register.simple_tag
(
name
=
"timestamp_to_date"
)
def
timestamp_to_date
(
timestamp
):
date
=
datetime
.
fromtimestamp
(
float
(
timestamp
))
if
(
datetime
.
now
()
-
date
)
.
days
<
1
:
date
=
timesince
(
date
)
return
date
circle/dashboard/urls.py
View file @
a30f9eb3
...
@@ -37,6 +37,7 @@ from .views import (
...
@@ -37,6 +37,7 @@ from .views import (
get_vm_screenshot
,
get_vm_screenshot
,
ProfileView
,
toggle_use_gravatar
,
UnsubscribeFormView
,
ProfileView
,
toggle_use_gravatar
,
UnsubscribeFormView
,
UserKeyDelete
,
UserKeyDetail
,
UserKeyCreate
,
UserKeyDelete
,
UserKeyDetail
,
UserKeyCreate
,
StoreList
)
)
urlpatterns
=
patterns
(
urlpatterns
=
patterns
(
...
@@ -169,4 +170,7 @@ urlpatterns = patterns(
...
@@ -169,4 +170,7 @@ urlpatterns = patterns(
url
(
r'^sshkey/create/$'
,
url
(
r'^sshkey/create/$'
,
UserKeyCreate
.
as_view
(),
UserKeyCreate
.
as_view
(),
name
=
"dashboard.views.userkey-create"
),
name
=
"dashboard.views.userkey-create"
),
url
(
r"^store/list/$"
,
StoreList
.
as_view
(),
name
=
"dashboard.views.store-list"
)
)
)
circle/dashboard/views.py
View file @
a30f9eb3
...
@@ -75,6 +75,8 @@ from storage.models import Disk
...
@@ -75,6 +75,8 @@ from storage.models import Disk
from
firewall.models
import
Vlan
,
Host
,
Rule
from
firewall.models
import
Vlan
,
Host
,
Rule
from
.models
import
Favourite
,
Profile
,
GroupProfile
from
.models
import
Favourite
,
Profile
,
GroupProfile
from
dashboard
import
store_api
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
...
@@ -2931,3 +2933,15 @@ class UserKeyCreate(LoginRequiredMixin, SuccessMessageMixin, CreateView):
...
@@ -2931,3 +2933,15 @@ class UserKeyCreate(LoginRequiredMixin, SuccessMessageMixin, CreateView):
kwargs
=
super
(
UserKeyCreate
,
self
)
.
get_form_kwargs
()
kwargs
=
super
(
UserKeyCreate
,
self
)
.
get_form_kwargs
()
kwargs
[
'user'
]
=
self
.
request
.
user
kwargs
[
'user'
]
=
self
.
request
.
user
return
kwargs
return
kwargs
class
StoreList
(
LoginRequiredMixin
,
TemplateView
):
template_name
=
"dashboard/store/list.html"
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
context
=
super
(
StoreList
,
self
)
.
get_context_data
(
*
args
,
**
kwargs
)
files
=
store_api
.
listfolder
(
"test"
,
"/"
)
dirs_first
=
sorted
(
files
,
key
=
lambda
k
:
k
[
'TYPE'
])
context
[
'root'
]
=
dirs_first
return
context
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment