Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Michal Malý
Molstar
Commits
958654d6
Commit
958654d6
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
ability to hide controls by default in Viewer app
parent
04e87205
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/apps/viewer/index.ts
+32
-7
32 additions, 7 deletions
src/apps/viewer/index.ts
src/mol-plugin/index.ts
+0
-20
0 additions, 20 deletions
src/mol-plugin/index.ts
src/mol-plugin/layout.ts
+1
-1
1 addition, 1 deletion
src/mol-plugin/layout.ts
src/mol-plugin/spec.ts
+1
-1
1 addition, 1 deletion
src/mol-plugin/spec.ts
with
34 additions
and
29 deletions
src/apps/viewer/index.ts
+
32
−
7
View file @
958654d6
...
...
@@ -6,14 +6,39 @@
import
{
createPlugin
,
DefaultPluginSpec
}
from
'
mol-plugin
'
;
import
'
./index.html
'
import
{
PluginContext
}
from
'
mol-plugin/context
'
;
import
{
PluginCommands
}
from
'
mol-plugin/command
'
;
require
(
'
mol-plugin/skin/light.scss
'
)
createPlugin
(
document
.
getElementById
(
'
app
'
)
!
,
{
...
DefaultPluginSpec
,
layout
:
{
initial
:
{
isExpanded
:
true
,
showControls
:
true
function
getParam
(
name
:
string
,
regex
:
string
):
string
{
let
r
=
new
RegExp
(
`
${
name
}
=(
${
regex
}
)[&]?`
,
'
i
'
);
return
decodeURIComponent
(((
window
.
location
.
search
||
''
).
match
(
r
)
||
[])[
1
]
||
''
);
}
const
hideControls
=
getParam
(
'
hide-controls
'
,
`[^&]+`
)
===
'
1
'
;
function
init
()
{
const
plugin
=
createPlugin
(
document
.
getElementById
(
'
app
'
)
!
,
{
...
DefaultPluginSpec
,
layout
:
{
initial
:
{
isExpanded
:
true
,
showControls
:
!
hideControls
}
}
});
trySetSnapshot
(
plugin
);
}
async
function
trySetSnapshot
(
ctx
:
PluginContext
)
{
try
{
const
snapshotUrl
=
getParam
(
'
snapshot-url
'
,
`[^&]+`
);
if
(
!
snapshotUrl
)
return
;
await
PluginCommands
.
State
.
Snapshots
.
Fetch
.
dispatch
(
ctx
,
{
url
:
snapshotUrl
})
}
catch
(
e
)
{
ctx
.
log
.
error
(
'
Failed to load snapshot.
'
);
console
.
warn
(
'
Failed to load snapshot
'
,
e
);
}
});
\ No newline at end of file
}
init
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-plugin/index.ts
+
0
−
20
View file @
958654d6
...
...
@@ -9,7 +9,6 @@ import { PluginContext } from './context';
import
{
Plugin
}
from
'
./ui/plugin
'
import
*
as
React
from
'
react
'
;
import
*
as
ReactDOM
from
'
react-dom
'
;
import
{
PluginCommands
}
from
'
./command
'
;
import
{
PluginSpec
}
from
'
./spec
'
;
import
{
StateTransforms
}
from
'
./state/transforms
'
;
import
{
PluginBehaviors
}
from
'
./behavior
'
;
...
...
@@ -18,11 +17,6 @@ import { StateActions } from './state/actions';
import
{
InitVolumeStreaming
}
from
'
./behavior/dynamic/volume-streaming/transformers
'
;
import
{
StructureRepresentationInteraction
}
from
'
./behavior/dynamic/selection/structure-representation-interaction
'
;
function
getParam
(
name
:
string
,
regex
:
string
):
string
{
let
r
=
new
RegExp
(
`
${
name
}
=(
${
regex
}
)[&]?`
,
'
i
'
);
return
decodeURIComponent
(((
window
.
location
.
search
||
''
).
match
(
r
)
||
[])[
1
]
||
''
);
}
export
const
DefaultPluginSpec
:
PluginSpec
=
{
actions
:
[
PluginSpec
.
Action
(
StateActions
.
Structure
.
DownloadStructure
),
...
...
@@ -71,19 +65,5 @@ export const DefaultPluginSpec: PluginSpec = {
export
function
createPlugin
(
target
:
HTMLElement
,
spec
?:
PluginSpec
):
PluginContext
{
const
ctx
=
new
PluginContext
(
spec
||
DefaultPluginSpec
);
ReactDOM
.
render
(
React
.
createElement
(
Plugin
,
{
plugin
:
ctx
}),
target
);
trySetSnapshot
(
ctx
);
return
ctx
;
}
async
function
trySetSnapshot
(
ctx
:
PluginContext
)
{
try
{
const
snapshotUrl
=
getParam
(
'
snapshot-url
'
,
`[^&]+`
);
if
(
!
snapshotUrl
)
return
;
await
PluginCommands
.
State
.
Snapshots
.
Fetch
.
dispatch
(
ctx
,
{
url
:
snapshotUrl
})
}
catch
(
e
)
{
ctx
.
log
.
error
(
'
Failed to load snapshot.
'
);
console
.
warn
(
'
Failed to load snapshot
'
,
e
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-plugin/layout.ts
+
1
−
1
View file @
958654d6
...
...
@@ -58,7 +58,7 @@ export class PluginLayout extends PluginComponent<PluginLayoutStateProps> {
private
rootState
:
RootState
|
undefined
=
void
0
;
private
expandedViewport
:
HTMLMetaElement
;
setProps
(
props
:
PluginLayoutStateProps
)
{
setProps
(
props
:
Partial
<
PluginLayoutStateProps
>
)
{
this
.
updateState
(
props
);
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/spec.ts
+
1
−
1
View file @
958654d6
...
...
@@ -17,7 +17,7 @@ interface PluginSpec {
animations
?:
PluginStateAnimation
[],
customParamEditors
?:
[
StateAction
|
StateTransformer
,
StateTransformParameters
.
Class
][],
layout
?:
{
initial
?:
PluginLayoutStateProps
,
initial
?:
Partial
<
PluginLayoutStateProps
>
,
controls
?:
{
left
?:
React
.
ComponentClass
|
'
none
'
,
right
?:
React
.
ComponentClass
|
'
none
'
,
...
...
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