diff --git a/index.js b/index.js index 0a3b424..1756a06 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,11 @@ nunjucks.configure({ const httpServer = express(); httpServer.use(handleWebhooks); +httpServer.engine("njk", nunjucks.render); + +httpServer.set("views", "./views"); +httpServer.set("view engine", "njk"); + httpServer.get("/", (request, response) => { const db = new TowtruckDatabase(); const persistedRepoData = db.getAllRepositories(); @@ -22,14 +27,16 @@ httpServer.get("/", (request, response) => { const { sortDirection, sortBy } = request.query; - const template = nunjucks.render("index.njk", { + return response.render("org-dashboard", { sortBy, sortDirection, ...reposForUi, repos: sortByType(reposForUi.repos, sortDirection, sortBy), }); +}); - return response.end(template); +httpServer.all("*path", (request, response) => { + return response.status(404).render("404", { url: request.path }); }); const PORT = process.env.PORT || 3000; diff --git a/index.njk b/index.njk deleted file mode 100644 index 184a09a..0000000 --- a/index.njk +++ /dev/null @@ -1,220 +0,0 @@ -{% import "./macros.njk" as macros %} - - - -
- - -- {% if totalRepos === 1 %} - There is 1 repository - {% else %} - There are {{ totalRepos }} repositories - {% endif %} - that Towtruck is tracking for {{ org }}. -
-Repository | - {{macros.sortableTableHeader("Open issues count", "openIssues", sortDirection, sortBy)}} - {{macros.sortableTableHeader("Open bot PR count", "openBotPrCount", sortDirection, sortBy)}} - {{macros.sortableTableHeader("Open PR count", "openPrCount", sortDirection, sortBy)}} - {{macros.sortableTableHeader("Updated at", "updatedAt", sortDirection, sortBy)}} - {{macros.sortableTableHeader("Most recent PR opened", "mostRecentPrOpenedAt", sortDirection, sortBy)}} - {{macros.sortableTableHeader("Oldest open PR opened", "oldestOpenPrOpenedAt", sortDirection, sortBy)}} - {{macros.sortableTableHeader("Most recent issue opened", "mostRecentIssueOpenedAt", sortDirection, sortBy)}} - {{macros.sortableTableHeader("Oldest open issue opened", "oldestOpenIssueOpenedAt", sortDirection, sortBy)}} -||||||||
---|---|---|---|---|---|---|---|---|
-
- {{ repo.name }}
- {% if repo.language %}
- {{ repo.language }}
- {% endif %}
- {% if repo.totalOpenAlerts !== undefined %}
-
-
- {% set id = [repo.name, "alerts", "critical"] | join("-") %}
- {% set mainText = ["", repo.criticalSeverityAlerts, ""] | join('') | safe %}
-
- {% else %}
- Dependabot alerts have been disabled for this repository.
- {% endif %}
- {{macros.tooltip(id, mainText, "Critical severity alerts")}}
- {% set id = [repo.name, "alerts", "high"] | join("-") %}
- {% set mainText = ["", repo.highSeverityAlerts, ""] | join('') | safe %}
- {{macros.tooltip(id, mainText, "High severity alerts")}}
- {% set id = [repo.name, "alerts", "medium"] | join("-") %}
- {% set mainText = ["", repo.mediumSeverityAlerts, ""] | join('') | safe %}
- {{macros.tooltip(id, mainText, "Medium severity alerts")}}
- {% set id = [repo.name, "alerts", "low"] | join("-") %}
- {% set mainText = ["", repo.lowSeverityAlerts, ""] | join('') | safe %}
- {{macros.tooltip(id, mainText, "Low severity alerts")}}
- {{ repo.description }} - - {% if repo.topics.length %} -
- {% for topic in repo.topics %}
- {{ topic }}
- {% endfor %}
-
- {% endif %}
-
- - -
- {% if repo.dependencies.length %}
-
-
-
- {% else %}
-
- No dependencies have been discovered.
- - {% if repo.dependencies.length === 1 %} - There is 1 dependency: - {% else %} - There are {{ repo.dependencies.length }} dependencies: - {% endif %} - - - -- Please make sure that Renovate has been configured on the repository to produce a dependency dashboard. - - {% endif %} - |
-
- - - - {{ repo.openIssues }} - - - | -- - - {{ repo.openBotPrCount }} - - - | -- - - {{ repo.openPrCount }} - - - | -- - - {{ repo.updatedAt }} - - - | -- - - {{ repo.mostRecentPrOpenedAt }} - - - | -- - - {{ repo.oldestOpenPrOpenedAt }} - - - | -- - - {{ repo.mostRecentIssueOpenedAt }} - - - | -- - - {{ repo.oldestOpenIssueOpenedAt }} - - - | - -
No repositories found. | -
+ {% if orgs.length === 1 %} + There is 1 organisation + {% else %} + There are {{ orgs.length }} organisations + {% endif %} + using Towtruck that you are a member of. +
++ You are not a member of any organisations that are using Towtruck. +
+ {% endif %} ++ {% if totalRepos === 1 %} + There is 1 repository + {% else %} + There are {{ totalRepos }} repositories + {% endif %} + that Towtruck is tracking for {{ org }}. +
+Repository | + {{macros.sortableTableHeader("Open issues count", "openIssues", sortDirection, sortBy)}} + {{macros.sortableTableHeader("Open bot PR count", "openBotPrCount", sortDirection, sortBy)}} + {{macros.sortableTableHeader("Open PR count", "openPrCount", sortDirection, sortBy)}} + {{macros.sortableTableHeader("Updated at", "updatedAt", sortDirection, sortBy)}} + {{macros.sortableTableHeader("Most recent PR opened", "mostRecentPrOpenedAt", sortDirection, sortBy)}} + {{macros.sortableTableHeader("Oldest open PR opened", "oldestOpenPrOpenedAt", sortDirection, sortBy)}} + {{macros.sortableTableHeader("Most recent issue opened", "mostRecentIssueOpenedAt", sortDirection, sortBy)}} + {{macros.sortableTableHeader("Oldest open issue opened", "oldestOpenIssueOpenedAt", sortDirection, sortBy)}} +||||||||
---|---|---|---|---|---|---|---|---|
+
+ {{ repo.name }}
+ {% if repo.language %}
+ {{ repo.language }}
+ {% endif %}
+ {% if repo.totalOpenAlerts !== undefined %}
+
+
+ {% set id = [repo.name, "alerts", "critical"] | join("-") %}
+ {% set mainText = ["", repo.criticalSeverityAlerts, ""] | join('') | safe %}
+
+ {% else %}
+ Dependabot alerts have been disabled for this repository.
+ {% endif %}
+ {{macros.tooltip(id, mainText, "Critical severity alerts")}}
+ {% set id = [repo.name, "alerts", "high"] | join("-") %}
+ {% set mainText = ["", repo.highSeverityAlerts, ""] | join('') | safe %}
+ {{macros.tooltip(id, mainText, "High severity alerts")}}
+ {% set id = [repo.name, "alerts", "medium"] | join("-") %}
+ {% set mainText = ["", repo.mediumSeverityAlerts, ""] | join('') | safe %}
+ {{macros.tooltip(id, mainText, "Medium severity alerts")}}
+ {% set id = [repo.name, "alerts", "low"] | join("-") %}
+ {% set mainText = ["", repo.lowSeverityAlerts, ""] | join('') | safe %}
+ {{macros.tooltip(id, mainText, "Low severity alerts")}}
+ {{ repo.description }} + + {% if repo.topics.length %} +
+ {% for topic in repo.topics %}
+ {{ topic }}
+ {% endfor %}
+
+ {% endif %}
+
+ + +
+ {% if repo.dependencies.length %}
+
+
+
+ {% else %}
+
+ No dependencies have been discovered.
+ + {% if repo.dependencies.length === 1 %} + There is 1 dependency: + {% else %} + There are {{ repo.dependencies.length }} dependencies: + {% endif %} + + + ++ Please make sure that Renovate has been configured on the repository to produce a dependency dashboard. + + {% endif %} + |
+
+ + + + {{ repo.openIssues }} + + + | ++ + + {{ repo.openBotPrCount }} + + + | ++ + + {{ repo.openPrCount }} + + + | ++ + + {{ repo.updatedAt }} + + + | ++ + + {{ repo.mostRecentPrOpenedAt }} + + + | ++ + + {{ repo.oldestOpenPrOpenedAt }} + + + | ++ + + {{ repo.mostRecentIssueOpenedAt }} + + + | ++ + + {{ repo.oldestOpenIssueOpenedAt }} + + + | + +
No repositories found. | +