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
7a60a40d
Commit
7a60a40d
authored
May 11, 2016
by
Benjamin Fischer
Browse files
JSONData: consistently use None/null for global (no workspace)
parent
ce702868
Changes
4
Hide whitespace changes
Inline
Side-by-side
vispa/controller/ajax.py
View file @
7a60a40d
...
...
@@ -81,11 +81,9 @@ class AjaxController(AbstractController):
# json
@
cherrypy
.
expose
@
cherrypy
.
tools
.
method
(
accept
=
"POST"
)
def
setjson
(
self
,
key
,
value
,
wid
=
-
1
):
def
setjson
(
self
,
key
,
value
,
wid
=
None
):
db
=
cherrypy
.
request
.
db
user_id
=
self
.
get
(
"user_id"
)
wid
=
int
(
wid
)
wid
=
None
if
wid
==
-
1
else
wid
JSONData
.
set_value
(
db
,
user_id
=
user_id
,
key
=
key
,
...
...
@@ -95,11 +93,10 @@ class AjaxController(AbstractController):
@
cherrypy
.
expose
@
cherrypy
.
tools
.
method
(
accept
=
"POST"
)
def
getjson
(
self
,
key
,
wid
=
-
1
):
def
getjson
(
self
,
key
,
wid
=
None
):
db
=
cherrypy
.
request
.
db
user_id
=
self
.
get
(
"user_id"
)
wid
=
int
(
wid
)
wid
=
None
if
wid
==
-
1
else
wid
return
JSON
.
dumps
(
JSONData
.
get_value
(
db
,
user_id
=
user_id
,
key
=
key
,
...
...
vispa/static/js/jsondata.js
View file @
7a60a40d
...
...
@@ -29,7 +29,7 @@ define([
var
JSONData
=
Emitter
.
_extend
({
init
:
function
(
key
,
workspace
)
{
key
=
String
(
key
);
var
wid
=
Workspace
.
_members
.
getId
(
workspace
,
-
1
);
var
wid
=
Workspace
.
_members
.
getId
(
workspace
,
null
);
var
root
=
this
.
_class
.
_members
;
if
(
root
.
_instances
[
key
]
&&
root
.
_instances
[
key
][
wid
])
{
...
...
@@ -107,6 +107,8 @@ define([
_pullProcess
:
function
(
err
,
info
)
{
if
(
err
)
throw
err
;
if
(
!
info
)
return
;
// apply changes
this
.
data
=
JSON
.
parse
(
info
.
data
);
this
.
_time
=
info
.
time
;
...
...
@@ -221,7 +223,7 @@ define([
getInst
:
function
(
key
,
workspace
)
{
var
inst
=
this
.
_instances
[
key
];
if
(
inst
)
{
inst
=
inst
[
Workspace
.
_members
.
getId
(
workspace
,
-
1
)];
inst
=
inst
[
Workspace
.
_members
.
getId
(
workspace
,
null
)];
if
(
inst
)
{
return
inst
;
}
...
...
vispa/static/js/prefs/manager.js
View file @
7a60a40d
...
...
@@ -77,16 +77,16 @@ define([
// prefs value interaction functions
get
:
function
(
path
,
ws
,
user
)
{
ws
=
parseInt
(
ws
);
ws
=
isNaN
(
ws
)
||
ws
<
0
?
-
1
:
ws
;
ws
=
isNaN
(
ws
)
||
ws
<
0
?
null
:
ws
;
if
(
user
===
undefined
)
{
// ws = Workspace._members.getId(ws);
// user settings come first
var
r
;
if
(
ws
>=
0
&&
((
r
=
this
.
get
(
path
,
ws
,
true
))
!==
undefined
))
return
r
;
if
(
((
r
=
this
.
get
(
path
,
-
1
,
true
))
!==
undefined
))
return
r
;
if
(
ws
>=
0
&&
((
r
=
this
.
get
(
path
,
ws
,
true
))
!==
undefined
))
return
r
;
if
(
((
r
=
this
.
get
(
path
,
null
,
true
))
!==
undefined
))
return
r
;
// now seversettings
if
(
ws
>=
0
&&
((
r
=
this
.
get
(
path
,
ws
,
false
))
!==
undefined
))
return
r
;
if
(
((
r
=
this
.
get
(
path
,
-
1
,
false
))
!==
undefined
))
return
r
;
if
(
ws
>=
0
&&
((
r
=
this
.
get
(
path
,
ws
,
false
))
!==
undefined
))
return
r
;
if
(
((
r
=
this
.
get
(
path
,
null
,
false
))
!==
undefined
))
return
r
;
// extension default has to be folded in at a later point in time
}
else
{
var
d
=
this
.
data
;
...
...
@@ -102,8 +102,9 @@ define([
},
set
:
function
(
path
,
ws
,
value
)
{
ws
=
parseInt
(
ws
);
ws
=
isNaN
(
ws
)
||
ws
<
0
?
-
1
:
ws
;
this
.
$set
(
"
data.user[
"
+
ws
+
"
].
"
+
path
,
value
);
ws
=
isNaN
(
ws
)
||
ws
<
0
?
null
:
ws
;
ws
=
ws
===
null
?
"
.null.
"
:
"
[
"
+
ws
+
"
].
"
;
this
.
$set
(
"
data.user
"
+
ws
+
path
,
value
);
},
del
:
function
(
path
,
ws
)
{
this
.
set
(
path
,
ws
,
undefined
);
...
...
@@ -112,18 +113,22 @@ define([
wsList
:
function
(
path
)
{
var
ks
=
[];
for
(
var
i
in
this
.
data
.
user
)
{
if
(
i
<
0
)
continue
;
if
(
i
<
0
)
continue
;
if
(
i
===
null
)
continue
;
if
(
i
===
"
null
"
)
continue
;
if
(
this
.
get
(
path
,
i
,
true
)
!==
undefined
)
ks
.
push
(
i
);
}
for
(
var
i
in
(
this
.
data
.
server
||
{}))
{
if
(
i
<
0
)
continue
;
if
(
i
<
0
)
continue
;
if
(
i
===
null
)
continue
;
if
(
i
===
"
null
"
)
continue
;
if
(
~
ks
.
indexOf
(
i
))
continue
;
if
(
this
.
get
(
path
,
i
,
false
)
!==
undefined
)
ks
.
push
(
i
);
}
ks
.
sort
();
ks
.
unshift
(
-
1
);
ks
.
unshift
(
null
);
return
ks
;
},
},
...
...
vispa/static/js/prefs/manipulator.js
View file @
7a60a40d
...
...
@@ -45,7 +45,7 @@ define([
if
(
this
.
isWs
)
r
=
this
.
$parent
.
get
(
this
.
wsId
,
false
);
if
(
r
===
undefined
)
r
=
this
.
$parent
.
get
(
-
1
,
false
);
r
=
this
.
$parent
.
get
(
null
,
false
);
if
(
r
===
undefined
)
r
=
this
.
data
.
value
;
return
r
;
...
...
@@ -127,7 +127,7 @@ define([
},
},
isWs
:
function
()
{
return
this
.
wsId
>=
0
;
return
this
.
wsId
!==
null
&&
!
isNaN
(
this
.
wsId
)
;
},
label
:
function
()
{
return
this
.
isWs
?
Workspace
.
_members
.
byId
(
this
.
wsId
).
name
:
"
Global
"
;
...
...
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