-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Drone io widget #1037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Drone io widget #1037
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9a70d1c
Added Widget for drone.io
m42e 71510ee
Added info for Drone Widget
m42e f0a5c24
New Window + update support
m42e 97ccdd4
Use `drone-io` in config and minor doc improvement for drone-io
m42e f14eaf5
WIP: updated drone
m42e f43966f
Rename DroneIo to DroneCi
m42e 120c351
Add update function for DroneCi Widget
m42e 0948a3f
updated Format and allow single repo listing
m42e db8abb2
Added skipped icon, use correct status
m42e File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
<template> | ||
<div class="droneio-builds-wrapper" v-if="builds"> | ||
<div | ||
class="build-row" | ||
v-for="build in builds" :key="build.id" | ||
v-tooltip="infoTooltip(build)" | ||
> | ||
<div class="status"> | ||
<p :class="build.build.status">{{ build.build.status | formatStatus }}</p> | ||
</div> | ||
<div class="info"> | ||
<p class="build-name"><a :href="build.git_http_url" target="_blank">{{ build.name }}</a></p> | ||
<p class="build-desc"><a :href="build.baseurl + '/' + build.slug + '/' +build.build.number" target="_blank">{{ build.build.number }}</a></p> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import WidgetMixin from '@/mixins/WidgetMixin'; | ||
import { timestampToDateTime } from '@/utils/MiscHelpers'; | ||
|
||
export default { | ||
mixins: [WidgetMixin], | ||
components: {}, | ||
data() { | ||
return { | ||
builds: null, | ||
}; | ||
}, | ||
filters: { | ||
formatStatus(status) { | ||
let symbol = ''; | ||
if (status === 'success') symbol = '✔'; | ||
if (status === 'failure' || status === 'error') symbol = '✘'; | ||
if (status === 'running') symbol = '❖'; | ||
return `${symbol}`; | ||
}, | ||
formatDate(timestamp) { | ||
return timestampToDateTime(timestamp); | ||
}, | ||
}, | ||
computed: { | ||
/* API endpoint, either for self-hosted or managed instance */ | ||
endpoint() { | ||
if (this.options.host) return `${this.options.host}/api/user/builds`; | ||
this.error('Drone.io Host is required'); | ||
}, | ||
apiKey() { | ||
if (!this.options.apiKey) { | ||
this.error('An API key is required, please see the docs for more info'); | ||
} | ||
return this.options.apiKey; | ||
}, | ||
}, | ||
methods: { | ||
update() { | ||
this.startLoading(); | ||
this.fetchData(); | ||
this.finishLoading(); | ||
}, | ||
/* Make GET request to CoinGecko API endpoint */ | ||
fetchData() { | ||
this.overrideProxyChoice = true; | ||
const authHeaders = { 'Authorization': `Bearer ${this.apiKey}` }; | ||
this.makeRequest(this.endpoint, authHeaders).then( | ||
(response) => { this.processData(response); }, | ||
); | ||
}, | ||
/* Assign data variables to the returned data */ | ||
processData(data) { | ||
const results = data.slice(0, this.options.limit).map(obj => { | ||
return {...obj, baseurl: this.options.host}; | ||
}); | ||
this.builds = results; | ||
}, | ||
infoTooltip(build) { | ||
const content = `<b>Trigger:</b> ${build.build.event} by ${build.build.trigger}<br>` | ||
+ `<b>Repo:</b> ${build.slug}<br>` | ||
+ `<b>Branch:</b> ${build.build.target}<br>` | ||
return { | ||
content, html: true, trigger: 'hover focus', delay: 250, classes: 'build-info-tt', | ||
}; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.droneio-builds-wrapper { | ||
color: var(--widget-text-color); | ||
.build-row { | ||
display: flex; | ||
justify-content: left; | ||
align-items: center; | ||
padding: 0.25rem 0; | ||
.status { | ||
min-width: 5rem; | ||
font-size: 1rem; | ||
font-weight: bold; | ||
p { | ||
margin: 0; | ||
color: var(--info); | ||
&.success { color: var(--success); } | ||
&.failure { color: var(--danger); } | ||
&.error { color: var(--danger); } | ||
&.running { color: var(--neutral); } | ||
} | ||
} | ||
.info { | ||
p.build-name { | ||
margin: 0.25rem 0; | ||
font-weight: bold; | ||
color: var(--widget-text-color); | ||
a, a:hover, a:visited, a:active { | ||
color: inherit; | ||
text-decoration: none; | ||
} | ||
} | ||
p.build-desc { | ||
margin: 0; | ||
color: var(--widget-text-color); | ||
opacity: var(--dimming-factor); | ||
a, a:hover, a:visited, a:active { | ||
color: inherit; | ||
text-decoration: none; | ||
} | ||
} | ||
p.build-desc::before { | ||
content: "#"; | ||
} | ||
} | ||
&:not(:last-child) { | ||
border-bottom: 1px dashed var(--widget-text-color); | ||
} | ||
} | ||
} | ||
|
||
</style> | ||
|
||
<style lang="scss"> | ||
.build-info-tt { | ||
min-width: 20rem; | ||
} | ||
</style> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.