Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
3pia
VISPA
VISPA web
Commits
94dd4664
Commit
94dd4664
authored
Jan 12, 2016
by
Fabian-Andree Heidemann
Browse files
[workspaceview] add duplicate button
[ajax controller] add editworkspace on server side, client side TODO
parent
85ac26a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
vispa/controller/ajax.py
View file @
94dd4664
...
...
@@ -121,6 +121,31 @@ class AjaxController(AbstractController):
command
=
cmd
)
return
self
.
_root
.
workspace_data
(
workspace
)
@
cherrypy
.
expose
@
cherrypy
.
tools
.
method
(
accept
=
"POST"
)
def
editworkspace
(
self
,
wid
,
name
=
None
,
host
=
None
,
login
=
None
,
key
=
None
,
cmd
=
None
):
if
not
vispa
.
config
(
"workspace"
,
"add"
,
True
):
raise
AjaxException
(
"No permission to edit a Workspace!"
)
db
=
cherrypy
.
request
.
db
# can the user edit the workspace?
workspace
=
Workspace
.
get_by_id
(
db
,
wid
)
if
not
isinstance
(
workspace
,
Workspace
):
raise
AjaxException
(
"Unknown Workspace!"
)
if
not
workspace
.
can_edit
(
self
.
get
(
"user_id"
)):
raise
AjaxException
(
"No permission to edit this Workspace!"
)
if
workspace
.
user_id
is
None
:
raise
AjaxException
(
"No permission to edit this Workspace!"
)
# edit it
workspace
.
name
=
name
or
workspace
.
name
workspace
.
host
=
host
or
workspace
.
host
workspace
.
login
=
login
or
workspace
.
login
workspace
.
key
=
key
or
workspace
.
key
workspace
.
command
=
cmd
or
workspace
.
command
return
self
.
_root
.
workspace_data
(
workspace
)
@
cherrypy
.
expose
@
cherrypy
.
tools
.
method
(
accept
=
"POST"
)
def
deleteworkspace
(
self
,
wid
):
...
...
vispa/static/html/index/workspaceview/content.html
View file @
94dd4664
...
...
@@ -41,6 +41,9 @@
<button
role=
"button"
class=
"btn btn-sm btn-danger"
id=
"global-delete"
>
Delete
</button>
<button
role=
"button"
class=
"btn btn-sm btn-default"
id=
"duplicate"
>
Duplicate
</button>
</h3>
<div
data-bind=
"lvl3-list"
>
<div
class=
"lvl3-container"
data-bind=
"lvl3-element"
>
...
...
vispa/static/js/workspaces.js
View file @
94dd4664
...
...
@@ -1570,6 +1570,10 @@ define([
return
;
}
if
(
self
.
isVisible
())
{
self
.
reload
();
}
setAddStatus
(
$footer
,
2
);
setTimeout
(
function
()
{
dialog
.
close
();
...
...
@@ -1701,16 +1705,40 @@ define([
return
null
;
}
var
workspaceId
=
this
.
workspaceId
;
$
(
"
button#global-delete
"
,
data
.
element
).
off
();
$
(
"
button#global-delete
"
,
data
.
element
).
click
(
function
(
event
)
{
var
workspace
=
vispa
.
workspaces
.
getWorkspace
(
workspaceId
);
if
(
workspace
)
{
workspace
.
remove
(
function
(
err
)
{
if
(
err
)
return
workspace
.
logger
.
error
(
err
);
self
.
reload
();
});
vispa
.
messenger
.
confirm
(
"
Do you want to delete the workspace
\"
"
+
workspace
.
getName
()
+
"
\"
?
"
,
function
(
confirmed
)
{
if
(
confirmed
)
{
if
(
workspace
)
{
workspace
.
remove
(
function
(
err
)
{
if
(
err
)
return
workspace
.
logger
.
error
(
err
);
self
.
reload
();
});
}
}
}
);
});
$
(
"
button#duplicate
"
,
data
.
element
).
off
();
$
(
"
button#duplicate
"
,
data
.
element
).
click
(
function
(
event
)
{
var
workspace
=
vispa
.
workspaces
.
getWorkspace
(
workspaceId
);
self
.
showAddDialog
();
var
addDialog
=
$
(
"
.workspace-add-dialog
"
);
$
(
"
input#name
"
,
addDialog
).
val
(
workspace
.
model
.
name
);
$
(
"
input#host
"
,
addDialog
).
val
(
workspace
.
model
.
host
);
$
(
"
input#login
"
,
addDialog
).
val
(
workspace
.
model
.
login
);
if
(
workspace
.
model
.
command
)
{
$
(
"
input#cmd
"
,
addDialog
).
val
(
workspace
.
model
.
command
);
$
(
"
button#advanced
"
).
click
();
}
event
.
preventDefault
();
});
$
(
"
button#edit
"
,
data
.
element
).
off
();
$
(
"
button#edit
"
,
data
.
element
).
click
(
function
(
event
)
{
var
workspace
=
vispa
.
workspaces
.
getWorkspace
(
workspaceId
);
self
.
showEditDialog
(
workspace
);
});
};
var
directives
=
{
...
...
@@ -1741,7 +1769,9 @@ define([
callbacks
.
fire
();
$
.
when
.
apply
(
$
,
dfds
).
done
(
function
()
{
$
(
"
button#refresh
"
,
content
).
off
();
$
(
"
button#refresh
"
,
content
).
click
(
self
.
reload
.
bind
(
self
));
$
(
"
button#add
"
,
content
).
off
();
$
(
"
button#add
"
,
content
).
click
(
self
.
showAddDialog
.
bind
(
self
));
content
.
scrollspy
({
...
...
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