Author Topic: Service app incorrectly display an app panel  (Read 157 times)

ChrisPlak

  • New Members
  • *
  • Posts: 21
Service app incorrectly display an app panel
« 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.

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

Code: [Select]
{
  "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
Code: [Select]
  <!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

  • Jr. Member
  • *
  • Posts: 95
Re: Service app incorrectly display an app panel
« Reply #1 on: March 17, 2021, 08:11:02 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

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 27956
Re: Service app incorrectly display an app panel
« Reply #2 on: March 17, 2021, 08:48:34 AM »
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.
« Last Edit: March 17, 2021, 08:54:04 AM by Mario »

ChrisPlak

  • New Members
  • *
  • Posts: 21
Re: Service app incorrectly display an app panel
« Reply #3 on: March 18, 2021, 05:25:52 AM »
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

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 27956
Re: Service app incorrectly display an app panel
« Reply #4 on: March 18, 2021, 08:15:31 AM »
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.