1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-21 22:29:41 +02:00

1st cut rejigged edit page, unused code commented out for now

This commit is contained in:
Elliott Stoneham 2016-08-23 17:11:31 +01:00
parent 603db6fc15
commit b42fc1f84d
5 changed files with 221 additions and 143 deletions

View file

@ -112,10 +112,10 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
getOwnerLists() { getOwnerLists() {
this.set('busy', true); this.set('busy', true);
let self = this; //let self = this;
let owners = this.get('owners'); let owners = this.get('owners');
let thisOwner = this.get('config.owner'); let thisOwner = this.get('config.owner');
let page = this.get('page'); //let page = this.get('page');
if (is.null(thisOwner) || is.undefined(thisOwner)) { if (is.null(thisOwner) || is.undefined(thisOwner)) {
if (owners.length) { if (owners.length) {
@ -128,6 +128,7 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
this.set('owner', thisOwner); this.set('owner', thisOwner);
/*
this.get('sectionService').fetch(page, "repos", self.get('config')) this.get('sectionService').fetch(page, "repos", self.get('config'))
.then(function (lists) { .then(function (lists) {
self.set('busy', false); self.set('busy', false);
@ -139,8 +140,18 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
self.showNotification("Unable to fetch repositories"); self.showNotification("Unable to fetch repositories");
console.log(error); console.log(error);
}); });
*/
this.getOrgReposLists();
if (is.undefined(this.get('initDateTimePicker'))) {
$.datetimepicker.setLocale('en');
$('#branch-since').datetimepicker();
this.set('initDateTimePicker', "Done");
}
}, },
/*
getRepoLists() { getRepoLists() {
this.set('busy', true); this.set('busy', true);
@ -266,7 +277,53 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
console.log(error); console.log(error);
}); });
}, },
*/
getOrgReposLists() {
this.set('busy', true);
let self = this;
let page = this.get('page');
this.get('sectionService').fetch(page, "orgrepos", self.get('config'))
.then(function (lists) {
let savedLists = self.get('config.lists');
if (savedLists === null) {
savedLists = [];
}
if (lists.length > 0) {
let noIncluded = true;
lists.forEach(function (list) {
let included = false;
var saved;
if (is.not.undefined(savedLists)) {
saved = savedLists.findBy("id", list.id);
}
if (is.not.undefined(saved)) {
included = saved.included;
noIncluded = false;
}
list.included = included;
});
if (noIncluded) {
lists[0].included = true; // make the first entry the default
}
}
self.set('config.lists', lists);
self.set('busy', false);
}, function (error) { //jshint ignore: line
self.set('busy', false);
self.set('authenticated', false);
self.showNotification("Unable to fetch repository branches");
console.log(error);
});
},
/*
getLabelLists() { getLabelLists() {
this.set('busy', true); this.set('busy', true);
@ -330,6 +387,7 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
console.log(error); console.log(error);
}); });
}, },
*/
actions: { actions: {
isDirty() { isDirty() {
@ -341,15 +399,16 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
let list = lists.findBy('id', id); let list = lists.findBy('id', id);
// restore the list of branches to the default state // restore the list of branches to the default state
lists.forEach(function (lst) { //lists.forEach(function (lst) {
Ember.set(lst, 'included', false); // Ember.set(lst, 'included', false);
}); //});
if (list !== null) { if (list !== null) {
Ember.set(list, 'included', !list.included); Ember.set(list, 'included', !list.included);
} }
}, },
/*
onLabelCheckbox(id) { onLabelCheckbox(id) {
let lists = this.get('config.lists'); let lists = this.get('config.lists');
let list = lists.findBy('id', id); let list = lists.findBy('id', id);
@ -358,6 +417,7 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
Ember.set(list, 'included', !list.included); Ember.set(list, 'included', !list.included);
} }
}, },
*/
authStage2() { authStage2() {
let self = this; let self = this;
@ -399,6 +459,7 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
this.getOwnerLists(); this.getOwnerLists();
}, },
/*
onRepoChange(thisRepo) { onRepoChange(thisRepo) {
this.set('isDirty', true); this.set('isDirty', true);
this.set('config.repo', thisRepo); this.set('config.repo', thisRepo);
@ -411,6 +472,7 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
this.set('config.report', thisReport); this.set('config.report', thisReport);
this.getReportLists(); this.getReportLists();
}, },
*/
onStateChange(thisState) { onStateChange(thisState) {
this.set('config.state', thisState); this.set('config.state', thisState);

View file

@ -7,12 +7,12 @@
<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 Repository</div> <div class="title">Select Repositories</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>Organizations and User</label> <label>Organization or User</label>
<div class="tip">Select organization or username</div> <div class="tip">Select organization or username whose repositories 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>
{{#if noRepos}} {{#if noRepos}}
@ -21,22 +21,8 @@
</div> </div>
{{else}} {{else}}
<div class="input-control"> <div class="input-control">
<label>Repositories</label> <label>Show items since (default 7 days ago)</label>
<div class="tip">Select repository</div> {{input id="branch-since" value=config.branchSince type="text" }}<br>
{{ui-select id="repos-dropdown" content=repos action=(action 'onRepoChange') optionValuePath="id" optionLabelPath="name" selection=config.repo}}
</div>
<div class="input-control">
<label>Report</label>
<div class="tip">Select report type</div>
{{ui-select id="report-dropdown" content=reports action=(action 'onReportChange') optionValuePath="id" optionLabelPath="name" selection=config.report}}
</div>
<div class="input-control">
<label>Show items since</label>
{{input id="branch-since" value=config.branchSince type="text" }}
</div>
<div class="input-control">
<label>Number of items to show</label>
{{input id="branch-lines" value=config.branchLines type="number" min="1" step="1" max="100" }}
</div> </div>
{{/if}} {{/if}}
</div> </div>
@ -46,10 +32,9 @@
<div class="pull-left width-45"> <div class="pull-left width-45">
<div class="input-form"> <div class="input-form">
{{#if showCommits}}
<div class="input-control"> <div class="input-control">
<label>Branches</label> <label>Repositories</label>
<div class="tip">Select branch</div> <div class="tip">Select the repositories 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}}>
@ -58,42 +43,12 @@
{{else}} {{else}}
<i class="material-icons widget-checkbox checkbox-gray github-list-checkbox">check_box_outline_blank</i> <i class="material-icons widget-checkbox checkbox-gray github-list-checkbox">check_box_outline_blank</i>
{{/if}} {{/if}}
<span class="github-list-title">{{list.name}}</span> <span class="github-list-title">{{list.repo}} {{#if list.private}}(private){{/if}}</span>
</div> </div>
{{/each}} {{/each}}
<div class="clearfix" /> <div class="clearfix" />
</div> </div>
</div> </div>
{{/if}}
{{#if showLabels}}
<div class="input-control">
<label>State</label>
<div class="tip">Open, Closed or All issues</div>
{{ui-select id="issue-state-dropdown" content=states action=(action 'onStateChange') optionValuePath="id" optionLabelPath="name" selection=config.state}}
</div>
<div class="input-control">
<label>Issue numbers</label>
<div class="tip">A comma separated list of issue numbers e.g. 42, 1066, 1966 (other selection criteria are ignored)</div>
{{input id="github-issues" value=config.issues type="text" }}
</div>
<div class="input-control">
<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="github-board">
{{#each config.lists as |list|}}
<div class="github-list" {{action 'onLabelCheckbox' list.id}} >
{{#if list.included}}
<i class="material-icons widget-checkbox checkbox-gray github-list-checkbox">check_box</i>
{{else}}
<i class="material-icons widget-checkbox checkbox-gray github-list-checkbox">check_box_outline_blank</i>
{{/if}}
<span class="github-list-title"><span class="github-issue-label" style="background-color:#{{list.color}}">{{list.name}}</span></span>
</div>
{{/each}}
<div class="clearfix" />
</div>
</div>
{{/if}}
</div> </div>
</div> </div>

View file

@ -52,6 +52,7 @@ func listFailed(method string, config githubConfig, client *gogithub.Client, w h
provider.WriteJSON(w, owners) provider.WriteJSON(w, owners)
/*
case "repos": case "repos":
var render []githubRepo var render []githubRepo
@ -124,7 +125,52 @@ func listFailed(method string, config githubConfig, client *gogithub.Client, w h
} }
provider.WriteJSON(w, render) provider.WriteJSON(w, render)
*/
case "orgrepos":
var render []githubBranch
if config.Owner != "" {
me, _, err := client.Users.Get("")
if err != nil {
log.Error("github get user details:", err)
provider.WriteError(w, "github", err)
return
}
var repos []*gogithub.Repository
if config.Owner == *me.Login {
repos, _, err = client.Repositories.List(config.Owner, nil)
} else {
opt := &gogithub.RepositoryListByOrgOptions{
ListOptions: gogithub.ListOptions{PerPage: 100},
}
repos, _, err = client.Repositories.ListByOrg(config.Owner, opt)
}
if err != nil {
log.Error("github get user/org repositories:", err)
provider.WriteError(w, "github", err)
return
}
for _, vr := range repos {
render = append(render,
githubBranch{
Name: "master",
ID: fmt.Sprintf("%s:%s", config.Owner, *vr.Name),
Owner: config.Owner,
Repo: *vr.Name,
Private: *vr.Private,
Included: false,
URL: *vr.HTMLURL,
})
}
}
render = sortBranches(render)
provider.WriteJSON(w, render)
/*
case "labels": case "labels":
if config.Owner == "" || config.Repo == "" { if config.Owner == "" || config.Repo == "" {
@ -149,6 +195,7 @@ func listFailed(method string, config githubConfig, client *gogithub.Client, w h
} }
provider.WriteJSON(w, render) provider.WriteJSON(w, render)
*/
default: default:
return true // failed to get a list return true // failed to get a list

View file

@ -12,7 +12,6 @@
package github package github
import ( import (
"fmt"
"sort" "sort"
"strings" "strings"
"time" "time"
@ -86,6 +85,7 @@ type githubBranch struct {
URL string `json:"url"` URL string `json:"url"`
Color string `json:"color,omitempty"` Color string `json:"color,omitempty"`
Comma bool `json:"comma"` Comma bool `json:"comma"`
Private bool `json:"private"`
} }
type githubLabel struct { type githubLabel struct {
@ -155,6 +155,7 @@ func (c *githubConfig) Clean() {
c.Since = (*c.SincePtr).Format(issuesTimeFormat) c.Since = (*c.SincePtr).Format(issuesTimeFormat)
// TEST DATA INSERTION DEBUG ONLY! // TEST DATA INSERTION DEBUG ONLY!
/*
debugList := map[string][]string{ debugList := map[string][]string{
"community": []string{"master"}, "community": []string{"master"},
"enterprise": []string{"master"}, "enterprise": []string{"master"},
@ -176,16 +177,22 @@ func (c *githubConfig) Clean() {
c.Lists = append(c.Lists, render...) c.Lists = append(c.Lists, render...)
} }
c.Owner = "documize" c.Owner = "documize"
*/
c.ReportOrder = []string{tagSummaryData, tagMilestonesData, tagIssuesData /*, tagPullRequestData*/, tagCommitsData} c.ReportOrder = []string{tagSummaryData, tagMilestonesData, tagIssuesData /*, tagPullRequestData*/, tagCommitsData}
c.BranchLines = 100 // overide js default of 30 with maximum allowable in one call c.BranchLines = 100 // overide js default of 30 with maximum allowable in one call
sort.Stable(branchesToSort(c.Lists)) // get the configured branches in a sensible order for printing sort.Stable(branchesToSort(c.Lists)) // get the configured branches in a sensible order for printing
for i := range c.Lists {
if i != len(c.Lists)-1 {
c.Lists[i].Comma = true // put the commas in the right places
}
}
lastItem := 0
for i := range c.Lists {
c.Lists[i].Comma = true
if c.Lists[i].Included {
lastItem = i
}
}
if lastItem < len(c.Lists) {
c.Lists[lastItem].Comma = false
}
} }
type githubCallbackT struct { type githubCallbackT struct {

View file

@ -42,3 +42,10 @@ func sortOwners(in []githubOwner) []githubOwner {
sort.Sort(sts) sort.Sort(sts)
return []githubOwner(sts) return []githubOwner(sts)
} }
// sort branches in order that that should be presented.
func sortBranches(in []githubBranch) []githubBranch {
sts := branchesToSort(in)
sort.Sort(sts)
return []githubBranch(sts)
}