{"id":19151436,"url":"https://github.com/sc5/mozaik-ext-sheets","last_synced_at":"2025-06-27T08:33:02.289Z","repository":{"id":29755125,"uuid":"33298789","full_name":"SC5/mozaik-ext-sheets","owner":"SC5","description":"Show Google Sheets in Mozaïk dashboard","archived":false,"fork":false,"pushed_at":"2018-03-19T21:00:52.000Z","size":87,"stargazers_count":6,"open_issues_count":0,"forks_count":6,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-19T19:05:03.695Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SC5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-02T08:44:30.000Z","updated_at":"2022-01-04T05:15:32.000Z","dependencies_parsed_at":"2022-08-02T19:31:01.975Z","dependency_job_id":null,"html_url":"https://github.com/SC5/mozaik-ext-sheets","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SC5%2Fmozaik-ext-sheets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SC5%2Fmozaik-ext-sheets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SC5%2Fmozaik-ext-sheets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SC5%2Fmozaik-ext-sheets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SC5","download_url":"https://codeload.github.com/SC5/mozaik-ext-sheets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252819555,"owners_count":21809038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T08:14:43.238Z","updated_at":"2025-05-07T05:24:30.975Z","avatar_url":"https://github.com/SC5.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mozaik-ext-sheets\n\nList rows from Google Sheets in Mozaïk dashboard. The extension can be handy for various\nuse cases where data is maintained in Google Sheets:\n\n- List events (including dates etc)\n- Show game results\n- Show event participants, company vacation listing\n- Etc.\n\n![preview](https://raw.githubusercontent.com/SC5/mozaik-ext-sheets/master/preview.png)\n\n- The widget tries to provide a generic but easy-to-use way to show content in dashboard.\n- You can also utilise the Sheets functions as the outcome is shown in widget\n- Use format functions to format some cell data\n- Use filter function to leave out some results\n\n## Setup\n\n- Install module\n\n    ```bash\n    npm install --save mozaik-ext-sheets\n    ```\n\n- Create a project and service account in Google Developer Console\n- Enable API: Drive API\n- Collect service email and .p12 file\n- Convert .p12 file into .PEM\n- Configure service key and .PEM file into dashboard ``config.js`` file and\n  environment variables / ``.env`` file:\n\n    ```javascript\n    api: {\n      sheets: {\n        googleServiceEmail: process.env.GOOGLE_SERVICE_EMAIL,\n        googleServiceKeypath: process.env.GOOGLE_SERVICE_KEYPATH\n      }\n    }\n    ```\n\n- Done.\n\n\n## Widget: List\n\nShow cell contents in a listing. Use dashboard theme to customize the outcome to match with your requirements.\n\n### parameters\n\nkey           | required | description\n--------------|----------|---------------\n`documentId`  | yes      | *Sheets document id, taken form web UI*\n`sheetNo`     | no       | *Sheet order number, starting from 0. Defaults to first: `0`*\n`range`       | no       | *Range from where to list data. Example: `A2:C10` or `A2:`. Defaults to full sheet*\n`style`       | no       | *Show results as bullet list or table-like. Valid values: `list` (default) or `table`*\n`styles`      | no       | *Inline style defintions in React supported style format. Sub-elements: list, listItem`*\n`fields`      | no       | *Columns to list, using advanced formatting*\n`random`      | no       | *Pick and show random number entries, defined by the value. Zero means no random is used (Default). Example: `random: 1`*\n`fontSize`    | no       | *Use default (``), fixed  (`12px`) or auto scaled fontsize (`auto`)*\n`format`      | no       | *Custom formating functions in object, where key is name of the formatter and used like {COLUMNLETTER!formatter}. See usage for examples*\n`filter`      | no       | *Filter some rows out of the outcome by implementing the function. See usage for examples*\n\n\n### usage\n\nImaginary example of Google Sheet document cells:\n\n```\n    |      A     |       B       |       C       |  D  |\n 1  | 2015-01-28 | React.js Conf | Facebook HQ   |     |\n 2  | 2015-07-02 | ReactEurope   | Paris, France |     |\n```\n\nOne widget in dashboard config:\n\n```javascript\n// widget in config.js\n{\n  type: 'sheets.list',\n  // You can find the documentId in sheet URL\n  documentId: 'abasdfsdfafsd123123',\n  range: 'A1:D10',\n  // Use either 'list' or 'table'\n  // Table shows every other row with different bg color\n  style: 'list',\n  fontSize: 'auto', // Use default, fixed or auto-scaled font size\n  // Customize the list or list item styles\n  styles: {\n    list: {\n      listStyle: 'none'\n    },\n    listItem: {\n      textAlign: 'center'\n    }\n  },\n  // Values (cells) to show on each row. Use one or multiple column letters:\n  // Uses https://www.npmjs.com/package/string-format for formatting\n  // NOTE: The both `['{A} {B} {C}']` and `['{A}', '{B}', '{C}']` work, but\n  // latter makes it possible to style each field / show the values in different\n  // cells in table format\n  fields: [\n    'Event date: {A!date}',\n    '{B!uppercase}',\n    '{C} {D}'\n  ],\n  // Show two random entries (after optional filtering)\n  // Handy for picking random quote of the day etc.\n  random: 2,\n  // Custom formatter functions, name must match with the usage: !method\n  // NOTE: Call method.toString() to every function!\n  // NOTE: `moment` is available\n  format: {\n    // !date formatter\n    date: function(s){\n      return new moment(s).format('YYYY-MM-DD');\n    }.toString(),\n    // !uppercase formatter\n    uppercase: function(s) {\n      return s.toUpperCase();\n    }.toString()\n  },\n  // Custom function to filter some results rows\n  // If defined, each row is processed through it.\n  // Return `false` if you want to filter the row out and `true`\n  // for inclusion.\n  // NOTE: Only one variable is passed, containing all columns from current row\n  // NOTE: Variable `columns` does not contain the columns out of the range\n  // NOTE: Call method.toString() to every function!\n  filter: function(columns, index){\n    // Filter out first two lines\n    if (index \u003c 2) {\n      return false;\n    }\n\n    // Filter out the results that are in past\n    var eventStart = moment(columns.B, ['YYYY-MM-DD']);\n    if (eventStart.isBefore(new moment())) {\n      return false;\n    }\n\n    // Otherwise show the fields from that row\n    return true;\n  }.toString(),\n  columns: 1, rows: 2,\n  x: 0, y: 0\n}\n```\n\n## Changelog\n\n### Release 0.6.0\n\n- Added support showing `random` number (0-n) of entries\n- Added support for styling elements with widget arguments\n\n### Release 0.5.0\n\n- Added support for table -styled listing\n\n### Release 0.4.1\n\n- Fixed missing module: src/client\n\n### Release 0.4.0\n\n- Replaced Gulp + Karma with Ava testing\n- Started using Eslint\n- Fixed dependencies\n- Fixed format support\n\n### Release 0.3.0\n\n- Updated support to Mozaik 1.4\n\n### Release 0.2.0\n\n- Added support for filtering\n\n### Release 0.1.0\n\n- Initial release\n\n## License\n\nModule is MIT -licensed\n\n## Credit\n\nModule is backed by: [SC5](http://sc5.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsc5%2Fmozaik-ext-sheets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsc5%2Fmozaik-ext-sheets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsc5%2Fmozaik-ext-sheets/lists"}