Highlighted

Close NodeJS panel when the UI panel is closed

New Here ,
Jun 26, 2020

Copy link to clipboard

Copied

Hi everybody,

 

Glad to work on my first Adobe Panel (for Premiere Pro). The main idea behind this panel is basically to download one or more fils and import them in a custom bin as soon as they re completed. Looks pretty stright forward and for this I have choosen to have 2 panels:
1. The UI Panel where users see all the files (some aws hosted files) and it s based on ReactJS and CSInterface v9.4.0.

2. The NodeJS panel that holds the server which basically handles all the download part (it exposes some endpoints that i trigger from UI, nothignt fancy, just /download, /progress /cancel):

 

The problem is that even if the user closes the UI Panel, the server still running (i can still check it by debugging using cefclient) and so the downloads.
Is there a way to close both extensions as soon as the ui one is closed?


This is how i trigger the NodeJS extension from the UI panel:

try {
csinterface.requestOpenExtension('com.foo.baz.localserver', '');
} catch (e) {
console.warn(e.message);
}


and this is the manifest file:

<?xml version='1.0' encoding='UTF-8'?>
<ExtensionManifest
Version="7.0"
ExtensionBundleId="com.foo.baz"
ExtensionBundleVersion="12.0"
ExtensionBundleName="Foo Bazz"
>
<ExtensionList>
<Extension Id="com.foo.baz.panel" Version="1.0.0"/>
<Extension Id="com.foo.baz.localserver" Version="1.0.1"/>
</ExtensionList>
<ExecutionEnvironment>
<HostList>
<Host Name="PPRO" Version="14"/>
</HostList>
<LocaleList>
<Locale Code="All"/>
</LocaleList>
<RequiredRuntimeList>
<RequiredRuntime Name="CSXS" Version="9.0"/>
</RequiredRuntimeList>
</ExecutionEnvironment>
<DispatchInfoList>
<Extension Id="com.foo.baz.panel">
<DispatchInfo>
<Resources>
<MainPath>./client/build/index.html</MainPath>
<ScriptPath>./host/index.jsx</ScriptPath>
<CEFCommandLine>
<Parameter>--allow-file-access</Parameter>
<Parameter>--allow-file-access-from-files</Parameter>
</CEFCommandLine>
</Resources>
<Lifecycle>
<AutoVisible>true</AutoVisible>
</Lifecycle>
<UI>
<Type>Panel</Type>
<Menu>Ownzones Connect</Menu>
<Geometry>
<Size>
<Height>720</Height>
<Width>960</Width>
</Size>
<MinSize>
<Height>460</Height>
<Width>600</Width>
</MinSize>
</Geometry>
<Icons/>
</UI>
</DispatchInfo>
</Extension>
<Extension Id="com.foo.baz.localserver">
<DispatchInfo>
<Resources>
<MainPath>./server/index.html</MainPath>
<CEFCommandLine>
<Parameter>--enable-nodejs</Parameter>
<Parameter>--mixed-context</Parameter>
</CEFCommandLine>
</Resources>
<Lifecycle>
<AutoVisible>false</AutoVisible>
</Lifecycle>
<UI>
<Type>Custom</Type>
<Geometry>
<Size>
<Height>1</Height>
<Width>1</Width>
</Size>
</Geometry>
</UI>
</DispatchInfo>
</Extension>
</DispatchInfoList>
</ExtensionManifest>

 


Note: I have tried to stop the closing action by using 'onbeforeunload' JS event, but it s pretty tricky and actually can not be done. Is there any other adobe event that could prevent the user closing the panel by showing an alert or something? Would really glad to have this approach, but I guess is a way to complex (if at least is doable).

Thank you,

There's no way to prevent the user from closing the panel's UI, but you _can_ prevent the panel from being unloaded.


 

 

Topics

Anywhere, How to, SDK

Views

65

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Close NodeJS panel when the UI panel is closed

New Here ,
Jun 26, 2020

Copy link to clipboard

Copied

Hi everybody,

 

Glad to work on my first Adobe Panel (for Premiere Pro). The main idea behind this panel is basically to download one or more fils and import them in a custom bin as soon as they re completed. Looks pretty stright forward and for this I have choosen to have 2 panels:
1. The UI Panel where users see all the files (some aws hosted files) and it s based on ReactJS and CSInterface v9.4.0.

2. The NodeJS panel that holds the server which basically handles all the download part (it exposes some endpoints that i trigger from UI, nothignt fancy, just /download, /progress /cancel):

 

The problem is that even if the user closes the UI Panel, the server still running (i can still check it by debugging using cefclient) and so the downloads.
Is there a way to close both extensions as soon as the ui one is closed?


This is how i trigger the NodeJS extension from the UI panel:

try {
csinterface.requestOpenExtension('com.foo.baz.localserver', '');
} catch (e) {
console.warn(e.message);
}


and this is the manifest file:

<?xml version='1.0' encoding='UTF-8'?>
<ExtensionManifest
Version="7.0"
ExtensionBundleId="com.foo.baz"
ExtensionBundleVersion="12.0"
ExtensionBundleName="Foo Bazz"
>
<ExtensionList>
<Extension Id="com.foo.baz.panel" Version="1.0.0"/>
<Extension Id="com.foo.baz.localserver" Version="1.0.1"/>
</ExtensionList>
<ExecutionEnvironment>
<HostList>
<Host Name="PPRO" Version="14"/>
</HostList>
<LocaleList>
<Locale Code="All"/>
</LocaleList>
<RequiredRuntimeList>
<RequiredRuntime Name="CSXS" Version="9.0"/>
</RequiredRuntimeList>
</ExecutionEnvironment>
<DispatchInfoList>
<Extension Id="com.foo.baz.panel">
<DispatchInfo>
<Resources>
<MainPath>./client/build/index.html</MainPath>
<ScriptPath>./host/index.jsx</ScriptPath>
<CEFCommandLine>
<Parameter>--allow-file-access</Parameter>
<Parameter>--allow-file-access-from-files</Parameter>
</CEFCommandLine>
</Resources>
<Lifecycle>
<AutoVisible>true</AutoVisible>
</Lifecycle>
<UI>
<Type>Panel</Type>
<Menu>Ownzones Connect</Menu>
<Geometry>
<Size>
<Height>720</Height>
<Width>960</Width>
</Size>
<MinSize>
<Height>460</Height>
<Width>600</Width>
</MinSize>
</Geometry>
<Icons/>
</UI>
</DispatchInfo>
</Extension>
<Extension Id="com.foo.baz.localserver">
<DispatchInfo>
<Resources>
<MainPath>./server/index.html</MainPath>
<CEFCommandLine>
<Parameter>--enable-nodejs</Parameter>
<Parameter>--mixed-context</Parameter>
</CEFCommandLine>
</Resources>
<Lifecycle>
<AutoVisible>false</AutoVisible>
</Lifecycle>
<UI>
<Type>Custom</Type>
<Geometry>
<Size>
<Height>1</Height>
<Width>1</Width>
</Size>
</Geometry>
</UI>
</DispatchInfo>
</Extension>
</DispatchInfoList>
</ExtensionManifest>

 


Note: I have tried to stop the closing action by using 'onbeforeunload' JS event, but it s pretty tricky and actually can not be done. Is there any other adobe event that could prevent the user closing the panel by showing an alert or something? Would really glad to have this approach, but I guess is a way to complex (if at least is doable).

Thank you,

There's no way to prevent the user from closing the panel's UI, but you _can_ prevent the panel from being unloaded.


 

 

Topics

Anywhere, How to, SDK

Views

66

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 26, 2020 0
Adobe Employee ,
Jul 06, 2020

Copy link to clipboard

Copied

There's no way to prevent the user from closing the panel's UI, but you _can_ prevent the panel from being unloaded.


 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 06, 2020 0
New Here ,
Jul 08, 2020

Copy link to clipboard

Copied

Hmm, didn t know about this function. I ll give it a try soon. Thanks a lot for your help

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 08, 2020 0