Using the same widget twice

Issue #122 new
FrankJ created an issue

Is there a way to use the same widget in different configurations twice? If I try something like that

"widgets": [
      {
        "row": 1,
        "col": 5,
        "width": 2,
        "height": 2,
        "widget": "calendar",
        "job": "calendar-aggregator",
        "config": "calendar-aggregator1"
      },
      {
        "row": 1,
        "col": 5,
        "width": 2,
        "height": 2,
        "widget": "calendar",
        "job": "calendar-aggregator",
        "config": "calendar-aggregator2"
      }
    ]

both widgets get the same data-widget-id and will display the same values.

Background: I'd like to implement a widget, which aggregates multiple widgets on the same grid position and cycles the display through the widgets every x seconds. Maybe there is already such an option?

Comments (12)

  1. gnomishperson

    In the board that I've created, I use the same widget multiple times and pass it different config values (a date/clock + weather based on config location) without issues of same values, I can't say offhand as to the data-widget-id without reviewing my board when I get to the office, but depending on how your widget and job is configured I can't say as to why you're receiving duplicate values.

    As to your background, I can't say much to that either.

  2. Iván Loire

    You are positioning both widgets in the same location. Using different values for row and col will solve your problem (the client id gets generated based on those)

  3. FrankJ reporter

    yes, my initial idea was to place multiple widgets on one location and reveal them round-robin to emulate a "rotate multiple widgets"-widget.

  4. Brad

    Since they're the same type of component, you could try having a single component and just having the job alternate which set of data it returns (possibly to include things like title).

  5. FrankJ reporter

    yes, I did this in the end. Thanks a lot.

    btw. does anybody know whether it is possible to send the data of a single job execution to multiple widgets? (in my case there is a rather expensive job collecting data and 3 widgets providing different views on it)

  6. Iván Loire

    It would make sense that if you define a few widgets sharing the same job and config key Atlasboard would run the job just once and broadcast the results to the widgets wouldn't it?

  7. FrankJ reporter

    I agree, but I'm not sure how to interpret these log entries:

    -------------------------------------------
    Atlasboard listening at port 3000
    -------------------------------------------
    
    [dashboard: tolina] [job: build-status] 2016-02-19T07:54:48+0100 <log> scheduler.js:74 (handleSuccess) executed OK
    [dashboard: tolina] [job: build-status] 2016-02-19T07:54:49+0100 <log> scheduler.js:74 (handleSuccess) executed OK
    [dashboard: tolina] [job: build-status] 2016-02-19T07:54:51+0100 <log> scheduler.js:74 (handleSuccess) executed OK
    [dashboard: tolina] [job: calendar-aggregator] 2016-02-19T07:54:55+0100 <log> scheduler.js:74 (handleSuccess) executed OK
    [dashboard: tolina] [job: room-occupation] 2016-02-19T07:54:55+0100 <log> scheduler.js:74 (handleSuccess) executed OK
    [dashboard: tolina] [job: dilbert-of-the-day] 2016-02-19T07:54:58+0100 <log> scheduler.js:74 (handleSuccess) executed OK
    [dashboard: tolina] [job: wiki-status] 2016-02-19T07:54:59+0100 <log> scheduler.js:74 (handleSuccess) executed OK
    

    It seems to me that the job build-status is executed thrice. The configuration is as you suggested

        "widgets": [
          {
            "row": 1,
            "col": 1,
            "width": 3,
            "height": 4,
            "widget": "build-status",
            "job": "build-status",
            "config": "build-status"
          },
          {
            "row": 1,
            "col": 4,
            "width": 1,
            "height": 2,
            "widget": "build-health",
            "job": "build-status",
            "config": "build-status"
          },
          {
            "row": 3,
            "col": 4,
            "width": 1,
            "height": 2,
            "widget": "build-picture",
            "job": "build-status",
            "config": "build-status"
          },
    

    Is this jus not logging as one would expect (one log entry per job execution) or is the job really executed multiple times?

  8. Ivan Loire Account Deactivated

    Yes, it is being executed multiple times at the moment (one for each widget). I was just resonating with the idea that it would be a good improvement to broadcast one single job execution to multiple widgets.

  9. FrankJ reporter

    I tried as a workaround to use memory-cache in the job, which works mostly, but I think that jobs are executed in parallel, so the cached items are sometimes hit, sometimes not. Am I right in my assumption and / or is there anything else to try for now? (I really need this feature shortly)

  10. Mathieu Baumgartner

    @fjakop Did you manage to have your widget-cycling feature emulated somehow? I would be very interested to achieve the same thing. Could you tell me more?

  11. FrankJ reporter

    No, I did not manage to do this. After looking at the code it seems that there's some need to refactor core atlasboard code. My workaround is using different widgets with one job where the data is of map structure and I'm using a cache for the key of current displayed data.

  12. Log in to comment