Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iobserve-ui-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iobserve-ui
iobserve-ui-frontend
Commits
b9307bf5
"gitlab@git.se.informatik.uni-kiel.de:she/theodolite.git" did not exist on "67423b5fb2a25840d346848251dbd818295695aa"
Commit
b9307bf5
authored
8 years ago
by
Mathis Neumann
Browse files
Options
Downloads
Patches
Plain Diff
save visualisation settings to localstorage
parent
583ae1c3
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/services/visualisation-settings.js
+44
-2
44 additions, 2 deletions
app/services/visualisation-settings.js
app/templates/deployments/index.hbs
+1
-1
1 addition, 1 deletion
app/templates/deployments/index.hbs
with
45 additions
and
3 deletions
app/services/visualisation-settings.js
+
44
−
2
View file @
b9307bf5
import
Ember
from
'
ember
'
;
import
Themes
from
'
../utils/visualisation-themes
'
;
const
{
Service
,
computed
,
assign
}
=
Ember
;
const
{
Service
,
computed
,
assign
,
observer
}
=
Ember
;
/**
* Stores the settings for visualisations for a user.
* Stores the settings for visualisations for a user.
Synchronizes with `localStorage` if possible
*
* @class VisualisationSettingsService
* @extends Ember.Service
*/
export
default
Service
.
extend
({
// TODO: load and save to localstorage
/**
* Initializes the service by loading the settings from `localStorage` (if possible)
* @method init
*/
init
()
{
// load from local storage
if
(
window
.
localStorage
)
{
const
settingsString
=
window
.
localStorage
.
getItem
(
'
visualisationSettings
'
);
// user might visit the first time
if
(
settingsString
)
{
const
settings
=
JSON
.
parse
(
settingsString
);
// themes/layouts may be deleted
if
(
Themes
[
settings
.
theme
])
{
this
.
set
(
'
theme
'
,
settings
.
theme
);
}
if
(
this
.
get
(
'
layoutAlgorithms
'
).
indexOf
(
settings
.
layoutAlgorithm
)
>=
0
)
{
this
.
set
(
'
layoutAlgorithm
'
,
settings
.
layoutAlgorithm
);
}
}
}
this
.
_super
(...
arguments
);
},
/**
* Observer of theme and layoutAlgorithm that stores the current settings to `localStorage` (if possible)
* @method saveToStorage
* @private
*/
saveToStorage
:
observer
(
'
theme
'
,
'
layoutAlgorithm
'
,
function
()
{
if
(
window
.
localStorage
)
{
const
toSave
=
JSON
.
stringify
({
theme
:
this
.
get
(
'
theme
'
),
layoutAlgorithm
:
this
.
get
(
'
layoutAlgorithm
'
)
});
this
.
debug
(
'
saving settings to localStorage
'
,
toSave
);
window
.
localStorage
.
setItem
(
'
visualisationSettings
'
,
toSave
);
}
else
{
this
.
debug
(
'
could not save to localStorage as it is not accessible
'
);
}
}),
/**
* the layout to use for the visualisation
*
...
...
This diff is collapsed.
Click to expand it.
app/templates/deployments/index.hbs
+
1
−
1
View file @
b9307bf5
...
...
@@ -8,7 +8,7 @@
{{
system
.
name
}}
</div>
<div
class=
"panel-body"
>
<div
class=
"btn-group"
role=
"group"
aria-label=
"..."
>
<div
class=
"btn-group"
role=
"group"
>
{{#
link-to
'deployments.single'
system
.
id
class
=
'btn btn-default'
}}
Deployments
{{/
link-to
}}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment