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
45b30b6b
Commit
45b30b6b
authored
May 11, 2016
by
Benjamin Fischer
Browse files
SessionManager: implemented session loading
parent
faa215b1
Changes
7
Hide whitespace changes
Inline
Side-by-side
vispa/controller/root.py
View file @
45b30b6b
...
...
@@ -119,6 +119,7 @@ class RootController(AbstractController):
user
=
cherrypy
.
request
.
user
prefs
=
JSONData
.
get_values_by_key
(
db
,
user
.
id
,
key
=
"preferences"
)
sess
=
JSONData
.
get_value
(
db
,
user
.
id
,
key
=
"session"
,
workspace_id
=-
1
)
try
:
if
vispa
.
config
(
"usermanagement"
,
"autosetup"
,
False
):
...
...
@@ -153,6 +154,7 @@ class RootController(AbstractController):
"extensions"
:
JSON
.
dumps
(
extensions
),
"cache_bust"
:
self
.
cache_bust
,
"preferences"
:
JSON
.
dumps
(
prefs
),
"session"
:
JSON
.
dumps
(
sess
),
}
return
data
...
...
vispa/static/js/jsondata.js
View file @
45b30b6b
...
...
@@ -27,7 +27,7 @@ define([
* is stored.
*/
var
JSONData
=
Emitter
.
_extend
({
init
:
function
(
key
,
workspace
,
_initFrom
)
{
init
:
function
(
key
,
workspace
)
{
key
=
String
(
key
);
var
wid
=
Workspace
.
_members
.
getId
(
workspace
,
-
1
);
var
root
=
this
.
_class
.
_members
;
...
...
@@ -64,11 +64,6 @@ define([
// push and pull flags
this
.
_pushRequested
=
undefined
;
this
.
_pullRequested
=
undefined
;
// initalize from already present data (for internal use only)
if
(
_initFrom
)
{
this
.
_pullProcess
(
null
,
_initFrom
);
}
},
/** indent: 1
...
...
@@ -205,7 +200,7 @@ define([
*/
loadKey
:
function
(
key
,
JSONDataInfos
)
{
for
(
var
wid
in
JSONDataInfos
)
{
new
this
.
_class
.
_instanceClass
(
key
,
wid
,
JSONDataInfos
[
wid
]);
this
.
getInst
(
key
,
wid
).
_pullProcess
(
null
,
JSONDataInfos
[
wid
]);
}
},
...
...
vispa/static/js/session.js
View file @
45b30b6b
...
...
@@ -37,24 +37,12 @@ define([
},
}
});
},
load
:
function
(
callback
)
{
return
callback
(
null
);
// blind this
var
self
=
this
;
vispa
.
POST
(
"
ajax/whatever
"
,
{
},
function
(
err
,
data
){
if
(
!
err
)
{
self
.
_loadedSession
=
data
;
}
callback
(
err
);
});
this
.
_jsondata
=
vispa
.
jsondata
.
getInst
(
"
session
"
);
},
run
:
function
(
callback
)
{
if
(
!
this
.
_load
edSession
)
return
this
.
plain
(
callback
);
if
(
!
this
.
stor
edSession
)
return
this
.
plain
(
callback
);
switch
(
this
.
prefs
.
get
(
"
restoreLast
"
))
{
case
"
always
"
:
...
...
@@ -62,8 +50,7 @@ define([
case
"
never
"
:
return
this
.
plain
(
callback
);
case
"
ask
"
:
var
self
=
this
;
var
ds
=
this
.
_loadedSession
.
time
;
var
ds
=
this
.
storedSession
.
time
;
if
(
ds
)
{
ds
=
"
(from
"
+
Utils
.
formatDate
(
new
Date
(
ds
))
+
"
)
"
;
}
else
{
...
...
@@ -83,10 +70,10 @@ define([
label
:
"
Don't restore
"
,
callback
:
function
()
{
if
(
this
.
remember
)
{
self
.
prefs
.
set
(
"
restoreLast
"
,
"
never
"
);
this
.
prefs
.
set
(
"
restoreLast
"
,
"
never
"
);
}
self
.
plain
(
callback
);
},
this
.
plain
(
callback
);
}
.
bind
(
this
)
,
},
yes
:
{
pos
:
2
,
...
...
@@ -94,10 +81,10 @@ define([
label
:
"
Restore
"
,
callback
:
function
()
{
if
(
this
.
remember
)
{
self
.
prefs
.
set
(
"
restoreLast
"
,
"
always
"
);
this
.
prefs
.
set
(
"
restoreLast
"
,
"
always
"
);
}
self
.
restore
(
callback
);
},
this
.
restore
(
callback
);
}
.
bind
(
this
)
,
},
},
closable
:
true
,
...
...
@@ -112,10 +99,10 @@ define([
},
restore
:
function
(
callback
)
{
if
(
!
this
.
_load
edSession
)
return
this
.
plain
(
callback
);
if
(
!
this
.
stor
edSession
)
return
this
.
plain
(
callback
);
// main view restore
vispa
.
mainViewManager
.
loadState
(
this
.
_load
edSession
.
mainView
);
vispa
.
mainViewManager
.
loadState
(
this
.
stor
edSession
.
mainView
);
Utils
.
callback
(
callback
)(
null
);
},
...
...
@@ -157,15 +144,8 @@ define([
}
// actual save process
var
self
=
this
;
vispa
.
POST
(
"
ajax/whatever
"
,
{
data
:
this
.
currentSession
,
},
function
(
err
){
if
(
err
)
{
self
.
logger
.
error
(
"
saving state failed:
"
,
err
);
return
;
}
});
this
.
_jsondata
.
data
=
this
.
currentSession
;
this
.
_jsondata
.
push
();
},
currentSession
:
{
...
...
@@ -177,6 +157,13 @@ define([
};
}
},
storedSession
:
{
descriptor
:
true
,
get
:
function
()
{
return
this
.
_jsondata
.
data
;
},
},
});
return
SessionManager
;
...
...
vispa/static/js/ui/split.js
View file @
45b30b6b
...
...
@@ -291,7 +291,7 @@ define([
loadState
:
function
(
tree
,
inst
)
{
this
.
direction
=
tree
[
0
];
for
(
var
i
=
1
;
i
<
tree
.
length
;
i
+=
2
)
{
var
instance
=
new
(
require
(
"
vispa/
"
+
tree
[
i
+
1
][
0
]))();
var
instance
=
new
(
require
(
"
vispa/
ui/
"
+
tree
[
i
+
1
][
0
]))();
this
.
attach
(
instance
,
undefined
,
undefined
,
tree
[
i
]);
instance
.
loadState
(
tree
[
i
+
1
].
slice
(
1
),
inst
);
}
...
...
vispa/static/js/views/main.js
View file @
45b30b6b
...
...
@@ -569,7 +569,6 @@ define([
// check whether we have everything
var
ws
=
Workspace
.
_members
.
byId
(
data
[
2
]);
if
(
!
ws
)
return
;
var
ext
=
Extension
.
_members
.
byName
(
data
[
3
]);
if
(
!
ext
)
return
;
var
view
=
ext
.
getView
(
data
[
4
]);
...
...
@@ -580,7 +579,7 @@ define([
focusIndex
:
data
[
0
],
activeIndex
:
data
[
1
],
};
if
(
ws
.
state
===
"
connected
"
)
{
if
(
ws
===
null
||
ws
.
state
===
"
connected
"
)
{
view
.
_members
.
spawn
(
data
[
5
],
viewArgs
,
{
workspace
:
ws
,
});
...
...
vispa/static/js/vispa.js
View file @
45b30b6b
...
...
@@ -353,7 +353,6 @@ define([
// now start all the loading
async
.
parallel
([
this
.
sessionManager
.
load
.
bind
(
this
.
sessionManager
),
Extension
.
_members
.
load
.
bind
(
Extension
.
_members
),
async
.
series
.
bind
(
async
,
[
// the workspaces need the socket for status communication
this
.
setupSocket
.
bind
(
this
),
...
...
@@ -361,13 +360,13 @@ define([
])
],
function
(
err
)
{
if
(
err
)
{
self
.
logger
.
error
(
"
error during startup
"
,
err
);
this
.
logger
.
error
(
"
error during startup
"
,
err
);
return
;
}
self
.
logger
.
info
(
"
everything loaded
"
);
this
.
logger
.
info
(
"
everything loaded
"
);
// needs workspaces
self
.
jsondata
.
loadKey
(
"
preferences
"
,
vispa
.
args
.
preferences
);
this
.
jsondata
.
loadKey
(
"
preferences
"
,
vispa
.
args
.
preferences
);
// we may need to add workspaces
if
(
!
Workspace
.
_members
.
workspaceCount
)
{
...
...
@@ -377,9 +376,9 @@ define([
}
}
self
.
sessionManager
.
run
(
);
// we could state the session now
});
this
.
sessionManager
.
_jsondata
.
_pullProcess
(
null
,
vispa
.
args
.
session
);
this
.
sessionManager
.
run
();
}
.
bind
(
this
)
);
},
...
...
vispa/templates/sites/index.mako
View file @
45b30b6b
...
...
@@ -47,6 +47,7 @@
extensions : ${extensions},
},
preferences: ${preferences},
session : ${session},
};
requirejs(['${base_static}js/config.js?'+urlArgs], function () {
...
...
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