mirror of
https://github.com/documize/community.git
synced 2025-07-21 22:29:41 +02:00
github for single repos only, with selectable sub-sections
This commit is contained in:
parent
7bf9901c9a
commit
6e362c0eac
10 changed files with 104 additions and 28 deletions
|
@ -41,6 +41,9 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
||||||
branchLines: "100",
|
branchLines: "100",
|
||||||
userId: "",
|
userId: "",
|
||||||
pageId: page.get('id'),
|
pageId: page.get('id'),
|
||||||
|
showMilestones: false,
|
||||||
|
showIssues: false,
|
||||||
|
showCommits: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -50,6 +53,9 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
||||||
config.branchSince = metaConfig.branchSince;
|
config.branchSince = metaConfig.branchSince;
|
||||||
config.userId = metaConfig.userId;
|
config.userId = metaConfig.userId;
|
||||||
config.pageId = metaConfig.pageId;
|
config.pageId = metaConfig.pageId;
|
||||||
|
config.showMilestones = metaConfig.showMilestones;
|
||||||
|
config.showIssues = metaConfig.showIssues;
|
||||||
|
config.showCommits = metaConfig.showCommits;
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
self.set('config', config);
|
self.set('config', config);
|
||||||
|
@ -168,12 +174,16 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
||||||
return this.get('isDirty');
|
return this.get('isDirty');
|
||||||
},
|
},
|
||||||
|
|
||||||
onListCheckbox(id) {
|
onListCheckbox(id) { // select one repository only
|
||||||
let lists = this.get('config.lists');
|
let lists = this.get('config.lists');
|
||||||
let list = lists.findBy('id', id);
|
let list = lists.findBy('id', id);
|
||||||
|
|
||||||
|
lists.forEach(function (entry) {
|
||||||
|
Ember.set(entry, 'included', false);
|
||||||
|
});
|
||||||
|
|
||||||
if (list !== null) {
|
if (list !== null) {
|
||||||
Ember.set(list, 'included', !list.included);
|
Ember.set(list, 'included', true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -7,18 +7,30 @@
|
||||||
<div class="pull-left width-45">
|
<div class="pull-left width-45">
|
||||||
<div class="input-form">
|
<div class="input-form">
|
||||||
<div class="heading">
|
<div class="heading">
|
||||||
<div class="title">Select Repositories</div>
|
<div class="title">Select Repository</div>
|
||||||
<div class="tip">Choose source of code information to be displayed</div>
|
<div class="tip">Choose source of code information to be displayed</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-control">
|
<div class="input-control">
|
||||||
<label>Organization or User</label>
|
<label>Organization or User</label>
|
||||||
<div class="tip">Select organization or username whose repositories you want to show</div>
|
<div class="tip">Select organization or username whose repository you want to show</div>
|
||||||
{{ui-select id="owners-dropdown" content=owners action=(action 'onOwnerChange') optionValuePath="id" optionLabelPath="name" selection=config.owner}}
|
{{ui-select id="owners-dropdown" content=owners action=(action 'onOwnerChange') optionValuePath="id" optionLabelPath="name" selection=config.owner}}
|
||||||
</div>
|
</div>
|
||||||
<div class="input-control">
|
<div class="input-control">
|
||||||
<label>Show items since (default 7 days ago)</label>
|
<label>Show items since (default 7 days ago)</label>
|
||||||
{{input id="branch-since" value=config.branchSince type="text" }}<br>
|
{{input id="branch-since" value=config.branchSince type="text" }}<br>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>Show Milestones</label>
|
||||||
|
{{input id="show-milestone" checked=config.showMilestones type="checkbox"}}<br>
|
||||||
|
</div>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>Show Issues</label>
|
||||||
|
{{input id="show-issues" checked=config.showIssues type="checkbox"}}<br>
|
||||||
|
</div>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>Show Commits</label>
|
||||||
|
{{input id="show-commits" checked=config.showCommits type="checkbox" }}<br>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -28,7 +40,7 @@
|
||||||
<div class="input-form">
|
<div class="input-form">
|
||||||
<div class="input-control">
|
<div class="input-control">
|
||||||
<label>Repositories</label>
|
<label>Repositories</label>
|
||||||
<div class="tip">Select the repositories to show</div>
|
<div class="tip">Select the repository to show</div>
|
||||||
<div class="github-board">
|
<div class="github-board">
|
||||||
{{#each config.lists as |list|}}
|
{{#each config.lists as |list|}}
|
||||||
<div class="github-list" {{action 'onListCheckbox' list.id}}>
|
<div class="github-list" {{action 'onListCheckbox' list.id}}>
|
||||||
|
|
|
@ -90,6 +90,10 @@ const tagCommitsData = "commitsData"
|
||||||
|
|
||||||
func getCommits(client *gogithub.Client, config *githubConfig) ([]githubCommit, []githubAuthorStats, error) {
|
func getCommits(client *gogithub.Client, config *githubConfig) ([]githubCommit, []githubAuthorStats, error) {
|
||||||
|
|
||||||
|
if !config.ShowCommits {
|
||||||
|
return nil, nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
// first make sure we've got all the branches
|
// first make sure we've got all the branches
|
||||||
for _, orb := range config.Lists {
|
for _, orb := range config.Lists {
|
||||||
if orb.Included {
|
if orb.Included {
|
||||||
|
@ -253,6 +257,11 @@ func getCommits(client *gogithub.Client, config *githubConfig) ([]githubCommit,
|
||||||
}
|
}
|
||||||
|
|
||||||
func refreshCommits(gr *githubRender, config *githubConfig, client *gogithub.Client) (err error) {
|
func refreshCommits(gr *githubRender, config *githubConfig, client *gogithub.Client) (err error) {
|
||||||
|
|
||||||
|
if !config.ShowCommits {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
gr.BranchCommits, gr.AuthorStats, err = getCommits(client, config)
|
gr.BranchCommits, gr.AuthorStats, err = getCommits(client, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("github refreshCommits:", err)
|
log.Error("github refreshCommits:", err)
|
||||||
|
@ -262,6 +271,11 @@ func refreshCommits(gr *githubRender, config *githubConfig, client *gogithub.Cli
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderCommits(payload *githubRender, c *githubConfig) error {
|
func renderCommits(payload *githubRender, c *githubConfig) error {
|
||||||
|
|
||||||
|
if !c.ShowCommits {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
payload.CommitCount = 0
|
payload.CommitCount = 0
|
||||||
for range payload.BranchCommits {
|
for range payload.BranchCommits {
|
||||||
payload.CommitCount++
|
payload.CommitCount++
|
||||||
|
|
|
@ -13,6 +13,7 @@ package github
|
||||||
|
|
||||||
const commitsTemplate = `
|
const commitsTemplate = `
|
||||||
<div class="section-github-render">
|
<div class="section-github-render">
|
||||||
|
<!--
|
||||||
{{if .HasAuthorStats}}
|
{{if .HasAuthorStats}}
|
||||||
<div class="heading">Contributors</div>
|
<div class="heading">Contributors</div>
|
||||||
<p>
|
<p>
|
||||||
|
@ -58,12 +59,13 @@ const commitsTemplate = `
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
-->
|
||||||
|
|
||||||
{{if .HasCommits}}
|
{{if .HasCommits}}
|
||||||
<div class="heading">Commits</div>
|
<div class="heading">Commits</div>
|
||||||
<p>There are {{len .BranchCommits}} commits by {{.NumContributors}} contributors across {{.RepoCount}}
|
<!-- <p>There are {{len .BranchCommits}} commits by {{.NumContributors}} contributors across {{.RepoCount}}
|
||||||
{{if eq 1 .RepoCount}} repository. {{else}} repositories. {{end}}
|
{{if eq 1 .RepoCount}} repository. {{else}} repositories. {{end}}
|
||||||
</p>
|
</p> -->
|
||||||
<div class="margin-top-20"></div>
|
<div class="margin-top-20"></div>
|
||||||
<table class="github-table">
|
<table class="github-table">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
|
@ -106,6 +106,10 @@ func wrapLabels(labels []gogithub.Label) (l string, labelNames []string, labelCo
|
||||||
|
|
||||||
func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, error) {
|
func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, error) {
|
||||||
|
|
||||||
|
if !config.ShowIssues {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
ret := []githubIssue{}
|
ret := []githubIssue{}
|
||||||
|
|
||||||
hadRepo := make(map[string]bool)
|
hadRepo := make(map[string]bool)
|
||||||
|
@ -183,6 +187,11 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er
|
||||||
}
|
}
|
||||||
|
|
||||||
func refreshIssues(gr *githubRender, config *githubConfig, client *gogithub.Client) (err error) {
|
func refreshIssues(gr *githubRender, config *githubConfig, client *gogithub.Client) (err error) {
|
||||||
|
|
||||||
|
if !config.ShowIssues {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
gr.Issues, err = getIssues(client, config)
|
gr.Issues, err = getIssues(client, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("unable to get github issues (cmd)", err)
|
log.Error("unable to get github issues (cmd)", err)
|
||||||
|
|
|
@ -30,14 +30,14 @@ const (
|
||||||
<div class="section-github-render">
|
<div class="section-github-render">
|
||||||
{{if .HasIssues}}
|
{{if .HasIssues}}
|
||||||
<div class="heading">Issues</div>
|
<div class="heading">Issues</div>
|
||||||
<p>
|
<!-- <p>
|
||||||
There are {{.ClosedIssues}} closed
|
There are {{.ClosedIssues}} closed
|
||||||
{{if eq 1 .ClosedIssues}}issue{{else}}issues{{end}}
|
{{if eq 1 .ClosedIssues}}issue{{else}}issues{{end}}
|
||||||
and {{.OpenIssues}} open
|
and {{.OpenIssues}} open
|
||||||
{{if eq 1 .OpenIssues}}issue{{else}}issues{{end}}
|
{{if eq 1 .OpenIssues}}issue{{else}}issues{{end}}
|
||||||
across {{.RepoCount}}
|
across {{.RepoCount}}
|
||||||
{{if eq 1 .RepoCount}} repository. {{else}} repositories. {{end}}
|
{{if eq 1 .RepoCount}} repository. {{else}} repositories. {{end}}
|
||||||
</p>
|
</p> -->
|
||||||
|
|
||||||
<div class="margin-top-20"></div>
|
<div class="margin-top-20"></div>
|
||||||
<table class="github-table">
|
<table class="github-table">
|
||||||
|
|
|
@ -79,6 +79,10 @@ func init() {
|
||||||
|
|
||||||
func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMilestone, error) {
|
func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMilestone, error) {
|
||||||
|
|
||||||
|
if !config.ShowMilestones {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
ret := []githubMilestone{}
|
ret := []githubMilestone{}
|
||||||
|
|
||||||
hadRepo := make(map[string]bool)
|
hadRepo := make(map[string]bool)
|
||||||
|
@ -156,6 +160,10 @@ func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMiles
|
||||||
|
|
||||||
func refreshMilestones(gr *githubRender, config *githubConfig, client *gogithub.Client) (err error) {
|
func refreshMilestones(gr *githubRender, config *githubConfig, client *gogithub.Client) (err error) {
|
||||||
|
|
||||||
|
if !config.ShowMilestones {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
gr.Milestones, err = getMilestones(client, config)
|
gr.Milestones, err = getMilestones(client, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("unable to get github milestones", err)
|
log.Error("unable to get github milestones", err)
|
||||||
|
@ -176,6 +184,11 @@ func refreshMilestones(gr *githubRender, config *githubConfig, client *gogithub.
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderMilestones(payload *githubRender, c *githubConfig) error {
|
func renderMilestones(payload *githubRender, c *githubConfig) error {
|
||||||
|
|
||||||
|
if !c.ShowMilestones {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
hadRepo := make(map[string]bool)
|
hadRepo := make(map[string]bool)
|
||||||
payload.RepoCount = 0
|
payload.RepoCount = 0
|
||||||
for _, orb := range payload.List {
|
for _, orb := range payload.List {
|
||||||
|
|
|
@ -31,7 +31,7 @@ const (
|
||||||
<div class="section-github-render">
|
<div class="section-github-render">
|
||||||
{{if .HasMilestones}}
|
{{if .HasMilestones}}
|
||||||
<div class="heading">Milestones</div>
|
<div class="heading">Milestones</div>
|
||||||
<p>
|
<!-- <p>
|
||||||
There are
|
There are
|
||||||
{{.ClosedMS}}
|
{{.ClosedMS}}
|
||||||
{{if eq 1 .ClosedMS}} milestone {{else}} milestones {{end}}
|
{{if eq 1 .ClosedMS}} milestone {{else}} milestones {{end}}
|
||||||
|
@ -39,7 +39,7 @@ const (
|
||||||
{{if eq 1 .OpenMS}} milestone {{else}} milestones {{end}}
|
{{if eq 1 .OpenMS}} milestone {{else}} milestones {{end}}
|
||||||
open across {{.RepoCount}}
|
open across {{.RepoCount}}
|
||||||
{{if eq 1 .RepoCount}} repository. {{else}} repositories. {{end}}
|
{{if eq 1 .RepoCount}} repository. {{else}} repositories. {{end}}
|
||||||
</p>
|
</p> -->
|
||||||
<div class="margin-top-20"></div>
|
<div class="margin-top-20"></div>
|
||||||
<table class="github-table">
|
<table class="github-table">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
|
@ -84,21 +84,24 @@ type githubLabel struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type githubConfig struct {
|
type githubConfig struct {
|
||||||
Token string `json:"-"` // NOTE very important that the secret Token is not leaked to the client side, so "-"
|
Token string `json:"-"` // NOTE very important that the secret Token is not leaked to the client side, so "-"
|
||||||
UserID string `json:"userId"`
|
UserID string `json:"userId"`
|
||||||
PageID string `json:"pageId"`
|
PageID string `json:"pageId"`
|
||||||
Owner string `json:"owner_name"`
|
Owner string `json:"owner_name"`
|
||||||
BranchSince string `json:"branchSince,omitempty"`
|
BranchSince string `json:"branchSince,omitempty"`
|
||||||
SincePtr *time.Time `json:"-"`
|
SincePtr *time.Time `json:"-"`
|
||||||
Since string `json:"-"`
|
Since string `json:"-"`
|
||||||
BranchLines int `json:"branchLines,omitempty,string"`
|
BranchLines int `json:"branchLines,omitempty,string"`
|
||||||
OwnerInfo githubOwner `json:"owner"`
|
OwnerInfo githubOwner `json:"owner"`
|
||||||
ClientID string `json:"clientId"`
|
ClientID string `json:"clientId"`
|
||||||
CallbackURL string `json:"callbackUrl"`
|
CallbackURL string `json:"callbackUrl"`
|
||||||
Lists []githubBranch `json:"lists,omitempty"`
|
Lists []githubBranch `json:"lists,omitempty"`
|
||||||
ReportOrder []string `json:"-"`
|
ReportOrder []string `json:"-"`
|
||||||
DateMessage string `json:"-"`
|
DateMessage string `json:"-"`
|
||||||
UserNames map[string]string `json:"UserNames"`
|
UserNames map[string]string `json:"UserNames"`
|
||||||
|
ShowMilestones bool `json:"showMilestones,omitempty"`
|
||||||
|
ShowIssues bool `json:"showIssues,omitempty"`
|
||||||
|
ShowCommits bool `json:"showCommits,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *githubConfig) Clean() {
|
func (c *githubConfig) Clean() {
|
||||||
|
@ -125,7 +128,18 @@ func (c *githubConfig) Clean() {
|
||||||
}
|
}
|
||||||
c.Since = (*c.SincePtr).Format(issuesTimeFormat)
|
c.Since = (*c.SincePtr).Format(issuesTimeFormat)
|
||||||
|
|
||||||
c.ReportOrder = []string{tagSummaryData, tagMilestonesData, tagIssuesData, tagCommitsData}
|
c.ReportOrder = []string{tagSummaryData}
|
||||||
|
|
||||||
|
if c.ShowMilestones {
|
||||||
|
c.ReportOrder = append(c.ReportOrder, tagMilestonesData)
|
||||||
|
}
|
||||||
|
if c.ShowIssues {
|
||||||
|
c.ReportOrder = append(c.ReportOrder, tagIssuesData)
|
||||||
|
}
|
||||||
|
if c.ShowCommits {
|
||||||
|
c.ReportOrder = append(c.ReportOrder, tagCommitsData)
|
||||||
|
}
|
||||||
|
|
||||||
c.BranchLines = 100 // overide any existing value with maximum allowable in one call
|
c.BranchLines = 100 // overide any existing value with maximum allowable in one call
|
||||||
|
|
||||||
sort.Sort(branchesToSort(c.Lists)) // get the configured branches in a sensible order for display
|
sort.Sort(branchesToSort(c.Lists)) // get the configured branches in a sensible order for display
|
||||||
|
|
|
@ -13,7 +13,7 @@ package github
|
||||||
|
|
||||||
const summaryTemplate = `
|
const summaryTemplate = `
|
||||||
<div class="section-github-render">
|
<div class="section-github-render">
|
||||||
<p>Activity since {{.Config.Since}}{{.Config.DateMessage}} for {{.Config.Owner}} repositories:
|
<p>Activity since {{.Config.Since}}{{.Config.DateMessage}} for {{.Config.Owner}} repository
|
||||||
{{range $data := .Config.Lists}}
|
{{range $data := .Config.Lists}}
|
||||||
{{if $data.Included}}
|
{{if $data.Included}}
|
||||||
<a class="link" href="{{$data.URL}}">
|
<a class="link" href="{{$data.URL}}">
|
||||||
|
@ -23,6 +23,7 @@ const summaryTemplate = `
|
||||||
{{end}}
|
{{end}}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<!--
|
||||||
{{if .HasSharedLabels}}
|
{{if .HasSharedLabels}}
|
||||||
<div class="heading">Labels</div>
|
<div class="heading">Labels</div>
|
||||||
<p>There
|
<p>There
|
||||||
|
@ -42,5 +43,6 @@ const summaryTemplate = `
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
-->
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue