{
  "title": "Albums",
  "icon": "rectangle.stack",
  "sidebar": false,
  "sources": {
    "albums": {
      "url": "http://192.0.2.40:2283",
      "secret": "immich",
      "auth": {
        "type": "header",
        "name": "x-api-key"
      },
      "every": "15m",
      "requests": {
        "albums": "/api/albums"
      },
      "derive": [
        {
          "name": "album_count",
          "value": {
            "count": "albums",
            "default": 0
          }
        }
      ]
    }
  },
  "cards": [
    {
      "id": "albums",
      "type": "list",
      "image_shape": "square",
      "max_items": 15,
      "items": [],
      "source": {
        "ref": "albums",
        "empty": {
          "text": "No albums yet",
          "when": {
            "path": "album_count",
            "equals": 0
          }
        },
        "map": {
          "items": {
            "each": "albums",
            "sort": {
              "by": "lastModifiedAssetTimestamp",
              "order": "desc"
            },
            "fields": {
              "text": "albumName",
              "detail": {
                "if": {
                  "path": "assetCount",
                  "equals": 1
                },
                "then": {
                  "if": {
                    "path": "endDate",
                    "exists": true
                  },
                  "then": {
                    "template": "1 item · {endDate|day}"
                  },
                  "else": {
                    "template": "1 item"
                  }
                },
                "else": {
                  "if": {
                    "path": "endDate",
                    "exists": true
                  },
                  "then": {
                    "template": "{assetCount} items · {endDate|day}"
                  },
                  "else": {
                    "template": "{assetCount} items"
                  }
                }
              },
              "image": {
                "if": {
                  "path": "albumThumbnailAssetId",
                  "exists": true
                },
                "then": {
                  "template": "/api/assets/{albumThumbnailAssetId|raw}/thumbnail?size=thumbnail"
                },
                "else": {
                  "template": ""
                }
              },
              "icon": {
                "template": "photo.on.rectangle"
              },
              "url": {
                "template": "http://192.0.2.40:2283/albums/{id|raw}"
              }
            }
          }
        }
      }
    }
  ]
}
