1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-09 07:25:23 +02:00

improve issue display

This commit is contained in:
Elliott Stoneham 2016-06-29 21:26:28 +01:00
parent afaf19f3c5
commit b9ec7b9e51
4 changed files with 117 additions and 125 deletions

View file

@ -28,9 +28,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
showLabels: false, showLabels: false,
didReceiveAttrs() { didReceiveAttrs() {
$.datetimepicker.setLocale('en');
$('#branch-since').datetimepicker();
let self = this; let self = this;
let page = this.get('page'); let page = this.get('page');
@ -53,7 +50,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
branchURL: "", branchURL: "",
branchSince: "", branchSince: "",
branchLines: "30", branchLines: "30",
issueNum: "1"
}; };
try { try {
@ -64,7 +60,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
config.lists = metaConfig.lists; config.lists = metaConfig.lists;
config.branchSince = metaConfig.branchSince; config.branchSince = metaConfig.branchSince;
config.branchLines = metaConfig.branchLines; config.branchLines = metaConfig.branchLines;
config.issueNum = metaConfig.issueNum;
} catch (e) {} } catch (e) {}
self.set('config', config); self.set('config', config);
@ -161,11 +156,7 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
}; };
reports[1] = { reports[1] = {
id: "issues_data", // used as method for fetching Go data id: "issues_data", // used as method for fetching Go data
name: "Open Issues" name: "Issues"
};
reports[2] = {
id: "issuenum_data", // used as method for fetching Go data
name: "Individual issue activity"
}; };
this.set("reports", reports); this.set("reports", reports);
@ -187,6 +178,9 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
renderSwitch(thisReport) { renderSwitch(thisReport) {
$.datetimepicker.setLocale('en');
$('#branch-since').datetimepicker();
let bl = this.get('config.branchLines'); let bl = this.get('config.branchLines');
if (is.undefined(bl) || bl === "" || bl <= 0) { if (is.undefined(bl) || bl === "" || bl <= 0) {
this.set('config.branchLines', "30"); this.set('config.branchLines', "30");
@ -194,7 +188,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
this.set('showCommits', false); this.set('showCommits', false);
this.set('showLabels', false); this.set('showLabels', false);
this.set('showIssueNum', false);
switch (thisReport.id) { switch (thisReport.id) {
case 'commits_data': case 'commits_data':
this.set('showCommits', true); this.set('showCommits', true);
@ -204,10 +197,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
this.set('showLabels', true); this.set('showLabels', true);
this.getLabelLists(); this.getLabelLists();
break; break;
case "issuenum_data":
this.set('showIssueNum', true);
this.set('busy', false);
break;
} }
}, },
@ -315,11 +304,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
let lists = this.get('config.lists'); let lists = this.get('config.lists');
let list = lists.findBy('id', id); let list = lists.findBy('id', id);
// restore the list of branches to the default state
// lists.forEach(function(lst) {
// Ember.set(lst, 'included', false);
// });
if (list !== null) { if (list !== null) {
Ember.set(list, 'included', !list.included); Ember.set(list, 'included', !list.included);
} }
@ -379,10 +363,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
this.getReportLists(); this.getReportLists();
}, },
checkLinesChange(thisLines) {
console.log("onLinesChange", thisLines);
},
onCancel() { onCancel() {
this.attrs.onCancel(); this.attrs.onCancel();
}, },

View file

@ -36,9 +36,6 @@
</div> </div>
Show items since {{input id="branch-since" value=config.branchSince type="text" }}<br> Show items since {{input id="branch-since" value=config.branchSince type="text" }}<br>
Number of items to show {{input id="branch-lines" value=config.branchLines type="number" min="1" step="1" max="100" }}<br> Number of items to show {{input id="branch-lines" value=config.branchLines type="number" min="1" step="1" max="100" }}<br>
{{#if showIssueNum}}
Issue Number: {{input id="issue-number" value=config.issueNum type="number" min="1" step="1" }}
{{/if}}
{{#if showCommits}} {{#if showCommits}}
<div class="input-control"> <div class="input-control">
<label>Branches</label> <label>Branches</label>
@ -62,6 +59,8 @@
<div class="input-control"> <div class="input-control">
<label>Labels</label> <label>Labels</label>
<div class="tip">Select labels - an issue must have all labels to be shown, if no label is selected all issues are shown.</div> <div class="tip">Select labels - an issue must have all labels to be shown, if no label is selected all issues are shown.</div>
TODO: Open/Closed<br>
TODO: Issue Numbers<br>
<div class="github-board"> <div class="github-board">
{{#each config.lists as |list|}} {{#each config.lists as |list|}}
<div class="github-list" {{action 'onLabelCheckbox' list.id}} > <div class="github-list" {{action 'onLabelCheckbox' list.id}} >

View file

@ -142,7 +142,7 @@ func (t *Provider) Command(w http.ResponseWriter, r *http.Request) {
provider.WriteJSON(w, render) provider.WriteJSON(w, render)
case "issuenum_data": /*case "issuenum_data":
render, err := t.getIssueNum(client, config) render, err := t.getIssueNum(client, config)
if err != nil { if err != nil {
@ -151,7 +151,7 @@ func (t *Provider) Command(w http.ResponseWriter, r *http.Request) {
return return
} }
provider.WriteJSON(w, render) provider.WriteJSON(w, render)*/
case "owners": case "owners":
@ -290,6 +290,7 @@ func (*Provider) githubClient(config githubConfig) *gogithub.Client {
return gogithub.NewClient(tc) return gogithub.NewClient(tc)
} }
/*
func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]githubIssueActivity, error) { func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]githubIssueActivity, error) {
ret := []githubIssueActivity{} ret := []githubIssueActivity{}
@ -301,8 +302,8 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
a := "" a := ""
p := issue.User p := issue.User
if p != nil { if p != nil {
if p.Name != nil { if p.Login != nil {
n = *p.Name n = *p.Login
} }
if p.AvatarURL != nil { if p.AvatarURL != nil {
a = *p.AvatarURL a = *p.AvatarURL
@ -310,24 +311,24 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
} }
ret = append(ret, githubIssueActivity{ ret = append(ret, githubIssueActivity{
Name: n, Name: n,
Event: "TITLE", Event: "created",
Message: template.HTML(*issue.Title), Message: template.HTML(*issue.Title),
Date: issue.UpdatedAt.Format("January 2 2006, 15:04"), Date: "on " + issue.UpdatedAt.Format("January 2 2006, 15:04"),
Avatar: a, Avatar: a,
URL: template.URL(*issue.HTMLURL), URL: template.URL(*issue.HTMLURL),
}) })
ret = append(ret, githubIssueActivity{ ret = append(ret, githubIssueActivity{
Name: n, Name: n,
Event: "DESCRIPTION", Event: "described",
Message: template.HTML(*issue.Body), Message: template.HTML(*issue.Body),
Date: issue.UpdatedAt.Format("January 2 2006, 15:04"), Date: "on " + issue.UpdatedAt.Format("January 2 2006, 15:04"),
Avatar: a, Avatar: a,
URL: template.URL(*issue.HTMLURL), URL: template.URL(*issue.HTMLURL),
}) })
ret = append(ret, githubIssueActivity{ ret = append(ret, githubIssueActivity{
Name: "", Name: "",
Event: "NOTE", Event: "Note",
Message: template.HTML("Issue timeline below is in reverse order"), Message: template.HTML("the issue timeline below is in reverse order"),
Date: "", Date: "",
Avatar: githubGravatar, Avatar: githubGravatar,
URL: template.URL(*issue.HTMLURL), URL: template.URL(*issue.HTMLURL),
@ -371,8 +372,8 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
u = *ic.HTMLURL u = *ic.HTMLURL
p := ic.User p := ic.User
if p != nil { if p != nil {
if p.Name != nil { if p.Login != nil {
n = *p.Name n = *p.Login
} }
if p.AvatarURL != nil { if p.AvatarURL != nil {
a = *p.AvatarURL a = *p.AvatarURL
@ -385,7 +386,7 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
Name: n, Name: n,
Event: *v.Event, Event: *v.Event,
Message: template.HTML(m), Message: template.HTML(m),
Date: v.CreatedAt.Format("January 2 2006, 15:04"), Date: "on " + v.CreatedAt.Format("January 2 2006, 15:04"),
Avatar: a, Avatar: a,
URL: template.URL(u), URL: template.URL(u),
}) })
@ -395,11 +396,12 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
return ret, nil return ret, nil
} }
*/
func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]githubIssue, error) { func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]githubIssue, error) {
opts := &gogithub.IssueListByRepoOptions{ opts := &gogithub.IssueListByRepoOptions{
Sort: "created", Sort: "updated",
ListOptions: gogithub.ListOptions{PerPage: config.BranchLines}} ListOptions: gogithub.ListOptions{PerPage: config.BranchLines}}
if config.SincePtr != nil { if config.SincePtr != nil {
@ -436,9 +438,11 @@ func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]gith
Name: n, Name: n,
Message: *v.Title, Message: *v.Title,
Date: v.CreatedAt.Format("January 2 2006, 15:04"), Date: v.CreatedAt.Format("January 2 2006, 15:04"),
Updated: v.UpdatedAt.Format("January 2 2006, 15:04"),
URL: template.URL(*v.HTMLURL), URL: template.URL(*v.HTMLURL),
Labels: template.HTML(l), Labels: template.HTML(l),
ID: *v.Number, ID: *v.Number,
IsOpen: v.ClosedAt == nil,
}) })
} }
@ -537,7 +541,7 @@ func (t *Provider) Refresh(configJSON, data string) string {
c.Clean() c.Clean()
switch c.ReportInfo.ID { switch c.ReportInfo.ID {
case "issuenum_data": /*case "issuenum_data":
refreshed, err := t.getIssueNum(t.githubClient(c), c) refreshed, err := t.getIssueNum(t.githubClient(c), c)
if err != nil { if err != nil {
log.Error("unable to get github issue number activity", err) log.Error("unable to get github issue number activity", err)
@ -548,7 +552,7 @@ func (t *Provider) Refresh(configJSON, data string) string {
log.Error("unable to marshall github issue number activity", err) log.Error("unable to marshall github issue number activity", err)
return data return data
} }
return string(j) return string(j)*/
case "issues_data": case "issues_data":
refreshed, err := t.getIssues(t.githubClient(c), c) refreshed, err := t.getIssues(t.githubClient(c), c)
@ -602,7 +606,7 @@ func (p *Provider) Render(config, data string) string {
} }
switch c.ReportInfo.ID { switch c.ReportInfo.ID {
case "issuenum_data": /* case "issuenum_data":
payload.IssueNum = c.IssueNum payload.IssueNum = c.IssueNum
raw := []githubIssueActivity{} raw := []githubIssueActivity{}
@ -626,7 +630,7 @@ func (p *Provider) Render(config, data string) string {
} }
} }
} }
payload.IssueNumActivity = raw payload.IssueNumActivity = raw */
case "issues_data": case "issues_data":
raw := []githubIssue{} raw := []githubIssue{}

View file

@ -27,8 +27,8 @@ type githubRender struct {
BranchCommits []githubBranchCommits BranchCommits []githubBranchCommits
CommitCount int CommitCount int
Issues []githubIssue Issues []githubIssue
IssueNum int //IssueNum int
IssueNumActivity []githubIssueActivity //IssueNumActivity []githubIssueActivity
Limit int Limit int
DateMessage string DateMessage string
} }
@ -86,14 +86,20 @@ var renderTemplates = map[string]string{
<li class="github-commit-item"> <li class="github-commit-item">
<a class="link" href="{{$data.URL}}"> <a class="link" href="{{$data.URL}}">
<div class="issue-avatar"> <div class="issue-avatar">
{{if $data.IsOpen}}
<span aria-label="Open issue"> <span aria-label="Open issue">
<svg aria-hidden="true" class="octicon octicon-issue-opened open" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg> <svg aria-hidden="true" class="octicon octicon-issue-opened open" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
</span> </span>
{{else}}
<span aria-label="Closed issue">
<svg aria-hidden="true" class="octicon octicon-issue-closed closed" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M7 10h2v2H7v-2zm2-6H7v5h2V4zm1.5 1.5l-1 1L12 9l4-4.5-1-1L12 7l-1.5-1.5zM8 13.7A5.71 5.71 0 0 1 2.3 8c0-3.14 2.56-5.7 5.7-5.7 1.83 0 3.45.88 4.5 2.2l.92-.92A6.947 6.947 0 0 0 8 1C4.14 1 1 4.14 1 8s3.14 7 7 7 7-3.14 7-7l-1.52 1.52c-.66 2.41-2.86 4.19-5.48 4.19v-.01z"></path></svg>
</span>
{{end}}
</div> </div>
<div class="github-commit-body"> <div class="github-commit-body">
<div class="github-commit-title"><span class="label-name">{{$data.Message}}</span> {{$data.Labels}}</div> <div class="github-commit-title"><span class="label-name">{{$data.Message}}</span> {{$data.Labels}}</div>
<div class="github-commit-meta"> <div class="github-commit-meta">
#{{$data.ID}} opened on {{$data.Date}} by {{$data.Name}} #{{$data.ID}} opened on {{$data.Date}} by {{$data.Name}}, last updated {{$data.Updated}}
</div> </div>
</div> </div>
</a> </a>
@ -104,7 +110,7 @@ var renderTemplates = map[string]string{
</div> </div>
</div> </div>
`, `,
"issuenum_data": ` /* "issuenum_data": `
<div class="section-github-render"> <div class="section-github-render">
<p> <p>
Activity for issue #{{.IssueNum}} in repository <a href="{{ .Repo.URL }}/issues">{{.Repo.Name}}.</a> Activity for issue #{{.IssueNum}} in repository <a href="{{ .Repo.URL }}/issues">{{.Repo.Name}}.</a>
@ -117,14 +123,13 @@ var renderTemplates = map[string]string{
<div class="github-avatar"> <div class="github-avatar">
<img alt="@{{$data.Name}}" src="{{$data.Avatar}}" height="36" width="36"> <img alt="@{{$data.Name}}" src="{{$data.Avatar}}" height="36" width="36">
</div> </div>
<div class="github-commit-meta">
{{$data.Name}} <a class="link" href="{{$data.URL}}">{{$data.Event}}</a> {{$data.Date}}
</div>
<div class="github-commit-body"> <div class="github-commit-body">
<div class="github-commit-title"> <div class="github-commit-title">
<a class="link" href="{{$data.URL}}">
{{$data.Event}}:
</a>
{{$data.Message}} {{$data.Message}}
</div> </div>
<div class="github-commit-meta">{{$data.Name}} committed on {{$data.Date}}</div>
</div> </div>
<div class="clearfix" /> <div class="clearfix" />
</li> </li>
@ -132,7 +137,7 @@ var renderTemplates = map[string]string{
</ul> </ul>
</div> </div>
</div> </div>
`, `,*/
} }
type githubReport struct { type githubReport struct {
@ -180,13 +185,16 @@ type githubCommit struct {
type githubIssue struct { type githubIssue struct {
ID int `json:"id"` ID int `json:"id"`
Date string `json:"date"` Date string `json:"date"`
Updated string `json:"dated"`
Message string `json:"message"` Message string `json:"message"`
URL template.URL `json:"url"` URL template.URL `json:"url"`
Name string `json:"name"` Name string `json:"name"`
Avatar string `json:"avatar"` Avatar string `json:"avatar"`
Labels template.HTML `json:"labels"` Labels template.HTML `json:"labels"`
IsOpen bool `json:"isopen"`
} }
/*
type githubIssueActivity struct { type githubIssueActivity struct {
Date string `json:"date"` Date string `json:"date"`
Event string `json:"event"` Event string `json:"event"`
@ -195,6 +203,7 @@ type githubIssueActivity struct {
Name string `json:"name"` Name string `json:"name"`
Avatar string `json:"avatar"` Avatar string `json:"avatar"`
} }
*/
type githubConfig struct { type githubConfig struct {
AppKey string `json:"appKey"` // TODO keep? AppKey string `json:"appKey"` // TODO keep?