From bceba3a4706759a1b37d74503748600f9cd2b20c Mon Sep 17 00:00:00 2001 From: MartinBB360 Date: Mon, 26 Feb 2024 10:35:49 +0100 Subject: [PATCH] feat: monitor work in urgency --- index.html | 3 + scripts/trello/lists.js | 4 + scripts/trelloEngWorkInUrgencyDashboard.js | 90 +++++++++++++ trelloEngWorkInUrgencyDashboard.html | 141 +++++++++++++++++++++ 4 files changed, 238 insertions(+) create mode 100644 scripts/trelloEngWorkInUrgencyDashboard.js create mode 100644 trelloEngWorkInUrgencyDashboard.html diff --git a/index.html b/index.html index cc0ba26..16190ac 100644 --- a/index.html +++ b/index.html @@ -25,6 +25,9 @@

List of tools

  • Trello comments dashboard
  • +
  • + Trello engineering work in urgency dashboard +
  • diff --git a/scripts/trello/lists.js b/scripts/trello/lists.js index 94f7d42..ee3ad57 100644 --- a/scripts/trello/lists.js +++ b/scripts/trello/lists.js @@ -1,3 +1,7 @@ async function fetchCardsInList(listId, { trelloApiKey, trelloOAuth1 } = {}) { return new TrelloClient({ trelloApiKey, trelloOAuth1 }).get(`lists/${listId}/cards`); } + +async function fetchList(listId, { trelloApiKey, trelloOAuth1 } = {}) { + return new TrelloClient({ trelloApiKey, trelloOAuth1 }).get(`lists/${listId}`); +} diff --git a/scripts/trelloEngWorkInUrgencyDashboard.js b/scripts/trelloEngWorkInUrgencyDashboard.js new file mode 100644 index 0000000..ee337f3 --- /dev/null +++ b/scripts/trelloEngWorkInUrgencyDashboard.js @@ -0,0 +1,90 @@ +const TRELLO_BASE_URL = "https://trello.com"; +const TRELLO_CREDENTIALS_HELPER_FILE = "https://docs.google.com/document/d/1HwaedNa861gkj93TaradW5n0MID8cbeamiU5SXCvX64/edit#heading=h.ijjo2dol5z6v" + +const LIST_IDS = [ + "65d8c6c2bdf8fb6ece5c3288" +] + +new Vue({ + el: '#app', + data: { + options: { + quarter: "", + squad: "" + }, + error: null, + loading: false, + trelloCredentialsHelperFile: TRELLO_CREDENTIALS_HELPER_FILE, + credentials: { + trelloApiKey: "", + trelloOAuth1: "" + }, + urgencyCardsBySquadName: {}, + squadNames: null, + listIdBySquadName: {}, + reportBuilt: false, + reportBuildForAllSquads: false + }, + computed: { + areCredentialsValid() { + return !! this.credentials.trelloApiKey && !! this.credentials.trelloOAuth1; + }, + isAccessButtonDisabled() { + return ! this.areCredentialsValid || this.loading; + }, + isSubmitButtonDisabled() { + return ! this.areCredentialsValid || this.loading || ! this.options.squad || ! this.options.quarter; + } + }, + methods: { + async buildReport() { + this.resetReport(); + this.error = null; + this.loading = true; + const selectedSquadNames = this.getSelectedSquadNames(); + try { + for (const selectedSquadName of selectedSquadNames) { + await this.buildReportForSquad(selectedSquadName); + } + this.reportBuilt = true; + this.reportBuildForAllSquads = (this.options.squad === "*"); + } catch (error) { + this.error = error.message; + } finally { + this.loading = false; + } + }, + async buildReportForSquad(squadName) { + const listId = this.listIdBySquadName[squadName]; + const cards = await fetchCardsInList(listId, this.credentials); + const filteredCards = cards.filter(card => ! card.isTemplate && card.labels.map(label => label.name).includes(this.options.quarter)); + this.urgencyCardsBySquadName[squadName] = filteredCards.map(({name, url}) => ({ name, url })); + }, + async fetchSquadNames() { + this.error = null; + this.loading = true; + try { + this.squadNames = await Promise.all(LIST_IDS.map(this.getSquadNameFromListId)); + } + catch (error) { + this.error = error.message; + } finally { + this.loading = false; + } + }, + getSelectedSquadNames() { + return this.options.squad === "*" ? this.squadNames : [this.options.squad]; + }, + async getSquadNameFromListId(listId) { + const list = await fetchList(listId, this.credentials); + const squadName = list.name.match(/[^[]+(?=\])/g).pop(); + this.listIdBySquadName[squadName] = listId; + return squadName; + }, + resetReport() { + this.reportBuilt = false; + this.reportBuildForAllSquads = false; + this.urgencyCardsBySquadName = {}; + } + } +}); diff --git a/trelloEngWorkInUrgencyDashboard.html b/trelloEngWorkInUrgencyDashboard.html new file mode 100644 index 0000000..0cc53be --- /dev/null +++ b/trelloEngWorkInUrgencyDashboard.html @@ -0,0 +1,141 @@ + + + + + 360Tools - Trello engineering work in urgency dashboard + + + + +
    + +
    +

    Trello engineering work in urgency dashboard

    + +
    + + Platform squads sometimes need to work in urgency a/o out of usual development process. 🏃 🚧 +
    This dashboard will help you to get some metrics about it. + +
    + +
    To get started, get your Trello API information and make sure to have your API key and authentication token. + +
    + +
    +
    + + +
    +
    + + +
    + +
    + +
    + +
    + +

    Settings

    + +
    + + +
    +
    + + +
    + +
    + +
    +
    +
    + + + + +
    +
    +
    +
    + + + + + + + +