-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow to filter reports by scmid
Signed-off-by: Olivier Vernin <[email protected]>
- Loading branch information
Showing
3 changed files
with
191 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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,125 @@ | ||
<template> | ||
<v-container | ||
class="py-8 px-6" | ||
fluid | ||
> | ||
<v-form v-model="filterForm" @submit.prevent="applyFilter"> | ||
<!-- Repository Dropdown --> | ||
<v-select | ||
label="Git Repository" | ||
:items="repositories" | ||
:rules="[v => !!v || 'Git repository is required']" | ||
v-model="repository" | ||
></v-select> | ||
|
||
<v-select | ||
label="Git Branch" | ||
:items="branches" | ||
:rules="[v => !!v || 'Git branch is required']" | ||
v-model="branch" | ||
></v-select> | ||
|
||
<!-- Filter repository--> | ||
<!--<v-btn type="submit" color="primary" :disabled="!filterForm">Filter</v-btn>--> | ||
</v-form> | ||
|
||
</v-container> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'PipelineSCMS', | ||
props: { | ||
scmid: {}, | ||
}, | ||
data: () => ({ | ||
isLoading: true, | ||
filterForm: false, | ||
scms: [], | ||
repository: "", | ||
repositories : [], | ||
branches: [], | ||
branch : "", | ||
}), | ||
beforeUnmount() { | ||
this.cancelAutoUpdate(); | ||
}, | ||
computed: { | ||
}, | ||
methods: { | ||
async getSCMSData() { | ||
const token = await this.$auth0.getAccessTokenSilently(); | ||
const response = await fetch('/api/pipeline/scms', { | ||
headers: { | ||
Authorization: `Bearer ${token}` | ||
} | ||
}); | ||
const data = await response.json(); | ||
this.isLoading = false | ||
this.scms = data.scms | ||
this.repositories = this.scms.map(scm => scm.URL) | ||
if (this.repositories.length > 0) { | ||
this.repository = this.repositories[0] | ||
} | ||
}, | ||
getScmID(url, branch) { | ||
return this.scms.find(scm => scm.URL === url && scm.Branch === branch).ID | ||
}, | ||
applyFilter() { | ||
var scmid = this.getScmID(this.repository, this.branch) | ||
this.$emit('update-scmid', scmid) | ||
}, | ||
cancelAutoUpdate() { | ||
clearInterval(this.timer); | ||
}, | ||
}, | ||
watch: { | ||
isLoading (val) { | ||
val && setTimeout(() => { | ||
this.isLoading = false | ||
}, 3000) | ||
}, | ||
repository (val) { | ||
var b = [] | ||
for (var i =0 ; i < this.scms.length; i++) { | ||
if (this.scms[i].URL == val) { | ||
if (this.scms[i].Branch == "main") { | ||
this.branch = "main" | ||
} | ||
if (this.scms[i].Branch == "master" && this.branch == "" ){ | ||
this.branch = "master" | ||
} | ||
b.push(this.scms[i].Branch) | ||
} | ||
} | ||
this.branches = b | ||
this.applyFilter() | ||
}, | ||
branch () { | ||
this.applyFilter() | ||
}, | ||
}, | ||
async created() { | ||
try { | ||
this.getSCMSData() | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}, | ||
} | ||
</script> |
This file contains 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,52 @@ | ||
<template> | ||
<v-card> | ||
<v-card-title | ||
class="text-center" | ||
> | ||
<h2>{{ sanitizeURL(data.URL) }} - {{ data.Branch }}</h2> | ||
</v-card-title> | ||
</v-card> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "SCMSummary", | ||
props: { | ||
scmid: {}, | ||
}, | ||
data: () => ({ | ||
data: {}, | ||
}), | ||
methods: { | ||
sanitizeURL: function(url) { | ||
if (url === undefined) { | ||
return ""; | ||
} | ||
url = url.replace(/https?:\/\//, ''); | ||
url = url.replace(/http?:\/\//, ''); | ||
url = url.replace(/\/$/, ''); | ||
url = url.replace(/\.git$/, ''); | ||
return url; | ||
}, | ||
}, | ||
async created() { | ||
try { | ||
const token = await this.$auth0.getAccessTokenSilently(); | ||
const response = await fetch(`/api/pipeline/scms?scmid=${this.scmid}`, { | ||
headers: { | ||
Authorization: `Bearer ${token}` | ||
} | ||
}); | ||
const data = await response.json(); | ||
this.data = data.scms[0]; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}, | ||
} | ||
</script> |
This file contains 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