Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
078facad
Commit
078facad
authored
Apr 15, 2018
by
serapath
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor this2self + adapt passing of compiler
parent
40805653
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
10 deletions
+14
-10
pluginManager.js
src/app/plugin/pluginManager.js
+12
-8
plugin-tab.js
src/app/tabs/plugin-tab.js
+2
-2
No files found.
src/app/plugin/pluginManager.js
View file @
078facad
...
@@ -40,11 +40,12 @@
...
@@ -40,11 +40,12 @@
module
.
exports
=
class
PluginManager
{
module
.
exports
=
class
PluginManager
{
constructor
(
api
=
{},
events
=
{},
opts
=
{})
{
constructor
(
api
=
{},
events
=
{},
opts
=
{})
{
const
self
=
this
const
self
=
this
self
.
_opts
=
opts
self
.
_api
=
api
self
.
_api
=
api
self
.
_events
=
events
self
.
_events
=
events
self
.
plugins
=
{}
self
.
plugins
=
{}
self
.
inFocus
self
.
inFocus
var
allowedapi
=
{
'setConfig'
:
1
,
'getConfig'
:
1
,
'removeConfig'
:
1
}
self
.
allowedapi
=
{
'setConfig'
:
1
,
'getConfig'
:
1
,
'removeConfig'
:
1
}
self
.
_events
.
compiler
.
register
(
'compilationFinished'
,
(
success
,
data
,
source
)
=>
{
self
.
_events
.
compiler
.
register
(
'compilationFinished'
,
(
success
,
data
,
source
)
=>
{
if
(
self
.
inFocus
)
{
if
(
self
.
inFocus
)
{
// trigger to the current focus
// trigger to the current focus
...
@@ -54,6 +55,7 @@ module.exports = class PluginManager {
...
@@ -54,6 +55,7 @@ module.exports = class PluginManager {
}))
}))
}
}
})
})
self
.
_events
.
app
.
register
(
'tabChanged'
,
(
tabName
)
=>
{
self
.
_events
.
app
.
register
(
'tabChanged'
,
(
tabName
)
=>
{
if
(
self
.
inFocus
&&
self
.
inFocus
!==
tabName
)
{
if
(
self
.
inFocus
&&
self
.
inFocus
!==
tabName
)
{
// trigger unfocus
// trigger unfocus
...
@@ -69,7 +71,7 @@ module.exports = class PluginManager {
...
@@ -69,7 +71,7 @@ module.exports = class PluginManager {
self
.
inFocus
=
tabName
self
.
inFocus
=
tabName
self
.
post
(
tabName
,
JSON
.
stringify
({
self
.
post
(
tabName
,
JSON
.
stringify
({
type
:
'compilationData'
,
type
:
'compilationData'
,
value
:
self
.
_api
.
getCompilationResult
()
value
:
api
.
compiler
.
getCompilationResult
()
}))
}))
}
}
})
})
...
@@ -83,10 +85,10 @@ module.exports = class PluginManager {
...
@@ -83,10 +85,10 @@ module.exports = class PluginManager {
result
:
result
result
:
result
}))
}))
}
}
if
(
event
.
type
===
'message'
&&
this
.
inFocus
&&
this
.
plugins
[
this
.
inFocus
]
&&
this
.
plugins
[
this
.
inFocus
].
origin
===
event
.
origin
)
{
if
(
event
.
type
===
'message'
&&
self
.
inFocus
&&
self
.
plugins
[
self
.
inFocus
]
&&
self
.
plugins
[
self
.
inFocus
].
origin
===
event
.
origin
)
{
var
data
=
JSON
.
parse
(
event
.
data
)
var
data
=
JSON
.
parse
(
event
.
data
)
data
.
arguments
.
unshift
(
this
.
inFocus
)
data
.
arguments
.
unshift
(
self
.
inFocus
)
if
(
allowedapi
[
data
.
type
])
{
if
(
self
.
allowedapi
[
data
.
type
])
{
data
.
arguments
.
push
((
error
,
result
)
=>
{
data
.
arguments
.
push
((
error
,
result
)
=>
{
response
(
data
.
type
,
data
.
id
,
error
,
result
)
response
(
data
.
type
,
data
.
id
,
error
,
result
)
})
})
...
@@ -96,11 +98,13 @@ module.exports = class PluginManager {
...
@@ -96,11 +98,13 @@ module.exports = class PluginManager {
},
false
)
},
false
)
}
}
register
(
desc
,
content
)
{
register
(
desc
,
content
)
{
this
.
plugins
[
desc
.
title
]
=
{
content
,
origin
:
desc
.
url
}
const
self
=
this
self
.
plugins
[
desc
.
title
]
=
{
content
,
origin
:
desc
.
url
}
}
}
post
(
name
,
value
)
{
post
(
name
,
value
)
{
if
(
this
.
plugins
[
name
])
{
const
self
=
this
this
.
plugins
[
name
].
content
.
querySelector
(
'iframe'
).
contentWindow
.
postMessage
(
value
,
this
.
plugins
[
name
].
origin
)
if
(
self
.
plugins
[
name
])
{
self
.
plugins
[
name
].
content
.
querySelector
(
'iframe'
).
contentWindow
.
postMessage
(
value
,
self
.
plugins
[
name
].
origin
)
}
}
}
}
}
}
src/app/tabs/plugin-tab.js
View file @
078facad
...
@@ -8,10 +8,10 @@ module.exports = class plugintab {
...
@@ -8,10 +8,10 @@ module.exports = class plugintab {
constructor
(
api
=
{},
events
=
{},
opts
=
{})
{
constructor
(
api
=
{},
events
=
{},
opts
=
{})
{
const
self
=
this
const
self
=
this
self
.
event
=
new
EventManager
()
self
.
event
=
new
EventManager
()
self
.
_opts
=
opts
self
.
_api
=
api
self
.
_api
=
api
self
.
_events
=
events
self
.
_events
=
events
self
.
_view
=
{
el
:
null
}
self
.
_view
=
{
el
:
null
}
self
.
data
=
{
url
:
opts
.
url
}
self
.
_components
=
{}
self
.
_components
=
{}
}
}
render
()
{
render
()
{
...
@@ -19,7 +19,7 @@ module.exports = class plugintab {
...
@@ -19,7 +19,7 @@ module.exports = class plugintab {
if
(
self
.
_view
.
el
)
return
self
.
_view
.
el
if
(
self
.
_view
.
el
)
return
self
.
_view
.
el
self
.
_view
.
el
=
yo
`
self
.
_view
.
el
=
yo
`
<div class="
${
css
.
pluginTabView
}
" id="pluginView">
<div class="
${
css
.
pluginTabView
}
" id="pluginView">
<iframe class="
${
css
.
iframe
}
" src="
${
self
.
data
.
url
}
/index.html"></iframe>
<iframe class="
${
css
.
iframe
}
" src="
${
self
.
_opts
.
url
}
/index.html"></iframe>
</div>`
</div>`
return
self
.
_view
.
el
return
self
.
_view
.
el
}
}
...
...
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