Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

✨ Simplifies options for github stats widget

Alicia Sykesf9e821755cb9
diff --git a/docs/widgets.md b/docs/widgets.md
index 09aad081..e3394ee5 100644
--- a/docs/widgets.md
+++ b/docs/widgets.md
@@ -1189,31 +1189,46 @@ Displays currently trending projects on GitHub. Optionally specify a language an
### GitHub Profile Stats
-Displays a summary of a GitHub profile and its repositories, fetched directly from the [GitHub REST API](https://docs.github.com/en/rest). Shows a profile card (avatar, name and headline stats), followed by a card for each listed repository with its star, fork and issue counts.
+Shows GitHub user stats (if `username`) and repos stats (for each repo in `repos`). Fetched from the GitHub API.
-<p align="center"><img width="380" src="https://pixelflare.cc/alicia/dashy/github-stats" /></p>
+<p align="center"><img width="600" src="https://pixelflare.cc/alicia/dashy/github-stats-widget" /></p>
#### Options
**Field** | **Type** | **Required** | **Description**
--- | --- | --- | ---
-**`username`** | `string` | _Optional_ | The GitHub username to show the profile card for, e.g. `lissy93`. Required, unless `hideProfileCard` is set to `true`
-**`hideProfileCard`** | `boolean` | _Optional_ | If set to `true`, the profile card is hidden, and only repositories are shown. Defaults to `false`
+**`username`** | `string` | _Optional_ | A GitHub username, e.g. `lissy93`. If this is set, a profile card is shown, if it's unset the card isn't shown
**`repos`** | `array` | _Optional_ | A list of repositories to show stats for, each specified as `[owner]/[repo]`, e.g. `lissy93/dashy`
-**`token`** | `string` | _Optional_ | An optional [GitHub personal access token](https://github.com/settings/tokens). Used to raise the API rate limit from 60 to 5,000 requests per hour. Can be set directly, or as an environment variable
+**`token`** | `string` | _Optional_ | An optional [GitHub token](https://github.com/settings/tokens). Used to raise the API rate limit from 60 to 5,000 requests per hour (can be set directly, or as an environment variable)
#### Example
```yaml
- type: github-profile-stats
options:
- username: Lissy93
+ username: lissy93
repos:
- lissy93/dashy
- - lissy93/personal-security-checklist
- - lissy93/twitter-sentiment-visualisation
+ - lissy93/portainer-templates
+ - lissy93/web-check
```
+Or just show the user's profile card:
+```yaml
+- type: github-profile-stats
+ options:
+ username: octocat
+```
+
+Or just show repo(s)
+```yaml
+- type: github-profile-stats
+ options:
+ repos:
+ - lissy93/dashy
+```
+
+
#### Info
- **CORS**: 🟒 Enabled
diff --git a/src/components/Widgets/GitHubProfile.vue b/src/components/Widgets/GitHubProfile.vue
index b20aacbc..db61cf78 100644
--- a/src/components/Widgets/GitHubProfile.vue
+++ b/src/components/Widgets/GitHubProfile.vue
@@ -72,9 +72,6 @@ export default {
};
},
computed: {
- hideProfileCard() {
- return !!this.options.hideProfileCard;
- },
username() {
return this.options.username;
},
@@ -94,17 +91,12 @@ export default {
methods: {
/* Validate options, then dispatch a request for the profile and each repo */
fetchData() {
- if (!this.hideProfileCard && !this.username) {
- this.error('You must specify a GitHub username');
- this.finishLoading();
- return;
- }
- if (this.hideProfileCard && !this.repos.length) {
+ if (!this.username && !this.repos.length) {
this.error('Nothing to display, set a username or add repos');
this.finishLoading();
return;
}
- if (!this.hideProfileCard) this.fetchProfile();
+ if (this.username) this.fetchProfile();
if (this.repos.length) this.fetchRepos();
},
/* Fetch the users profile for the top card */