Service app incorrectly display an app panel

Started by ChrisPlak, March 17, 2021, 02:51:44 AM

Previous topic - Next topic

ChrisPlak

My understanding of a service is that it is supposed to run in the background with no UI.

I have the following service app.  I believe I have done everything I am supposed to do.  I have turned off "Debug Mode" in the "Developer Options" of preference. 

I assigned this app to the "Favorites" panel so that I can either just click on it or use a hotkey.  When I click on the icon in the favorites panel for this app, I get an app window that pops up in the "App Viewer 1" panel.  It is empty and has just my app title "CSP Add Seq Service"

How can I prevent the app window from showing up when I click on the app in Favorites?

Thanks
Chris

Here is my code

{
  "type": "service",
  "id": "94FB9D80-057A-4726-BDD1-F68D6B4E571F",
  "version": "1.0",
  "author": [
    "CSP"
  ],
  "name": {
    "": "CSP Add Seq Service"
  },
  "description": {
    "": "As a Service - Adds all selected files to the category PicSet/PicSet_NNN using the next highest sequence number"
  },
  "defaultDocument": "index.html",
  "icon": {
    "": "app.png"
  }
}


And here is the app
  <!DOCTYPE html>
   <html>
   
   <head>
      <meta charset="utf-8">
      <title>CSP Add Seq: Service</title>
   </head>

   <!-- jQuery and Bootstrap -->
   <script src="/system/jquery/dist/jquery.min.js"></script>
   <script src="/system/bootstrap-4/js/bootstrap.bundle.min.js"></script>
   
   <!-- The IMatch and IMWS helper libraries - they make access to IMWS and IMatch very easy -->
   <script src="/system/imws/imwslib.js"></script>
   <script src="/system/imatch/imatchlib.js"></script>

   <body>

   <script>
      $(document).ready(function () {

         // Update appInfo in the UI
         IMatch.appInfo({
            instanceid: IMatch.instanceId()
         }).then(function (response) {
            console.log('Running ' + response.app.localName);
         });

         RunMe();

         function RunMe() {
            console.log('Did run me');
         }
      });
   </script>

</body>

</html>



David_H

Quote from: ChrisPlak on March 17, 2021, 02:51:44 AM
My understanding of a service is that it is supposed to run in the background with no UI.

Service apps are run at startup by IMatch and shutdown when it goes away; they're meant to do something in the background (listen for events over the websocket connection, then do something - like if a file has been added to a particular folder, get it copied elsewhere, etc).
If you put it on a favourite, IMatch will open another copy of it when you run it....

A Modal one might be better for what you're trying to do (not used them, so can't really say!)

Mario

#2
Service apps are automatically run by IMatch in the background (no UI!) after IMatch has started and should shut-down when they did their job.
You don't add service apps to Favorites or start them manually - except maybe for debugging purposes.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ChrisPlak

Understood.  The only reason why I assigned it a favorite was so that I could get a hotkey for that service/app.

Is there any functionality then that would allow me to write my own app/service that is activated by a hotkey and does not have any sort of UI?

Basically, what I am attempting to do is to assign a category that is built up dynamically from other data to a selection of pictures.  I would prefer to have this bound to a hotkey/keystroke as opposed to having an App/service taking up screen real estate.  And to get the speed of using a hotkey where I don't have to move my hand off of the keyboard.

Mario

That's a typical task for a normal app. The UI of your app is what you make it.
Make it a modal app (runs in a dialog). Then just call IMatch.modalClose() when your app is done. If it is fast, you may not even see the modal window.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook