mirror of
https://github.com/documize/community.git
synced 2025-07-23 15:19:42 +02:00
select which boards and date since, individual board not working yet
This commit is contained in:
parent
16bf5237b9
commit
1e37c68d99
7 changed files with 166 additions and 87 deletions
|
@ -50,7 +50,8 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
||||||
token: "",
|
token: "",
|
||||||
user: null,
|
user: null,
|
||||||
board: null,
|
board: null,
|
||||||
lists: []
|
lists: [],
|
||||||
|
boards: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +102,12 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
||||||
|
|
||||||
this.set('noBoards', false);
|
this.set('noBoards', false);
|
||||||
|
|
||||||
|
if (is.undefined(self.get('initDateTimePicker'))) {
|
||||||
|
$.datetimepicker.setLocale('en');
|
||||||
|
$('#trello-since').datetimepicker();
|
||||||
|
self.set('initDateTimePicker', "Done");
|
||||||
|
}
|
||||||
|
|
||||||
if (is.null(board) || is.undefined(board)) {
|
if (is.null(board) || is.undefined(board)) {
|
||||||
if (boards.length) {
|
if (boards.length) {
|
||||||
board = boards[0];
|
board = boards[0];
|
||||||
|
@ -150,6 +157,15 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onBoardCheckbox(id) {
|
||||||
|
let boards = this.get('config.boards');
|
||||||
|
let board = boards.findBy('id', id);
|
||||||
|
|
||||||
|
if (board !== null) {
|
||||||
|
Ember.set(board, 'included', !board.included);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
auth() {
|
auth() {
|
||||||
if (this.get('appKey') === "") {
|
if (this.get('appKey') === "") {
|
||||||
$("#trello-appkey").addClass('error').focus();
|
$("#trello-appkey").addClass('error').focus();
|
||||||
|
|
|
@ -3,44 +3,70 @@
|
||||||
isDirty=(action 'isDirty') onCancel=(action 'onCancel') onAction=(action 'onAction')}}
|
isDirty=(action 'isDirty') onCancel=(action 'onCancel') onAction=(action 'onAction')}}
|
||||||
|
|
||||||
{{#if authenticated}}
|
{{#if authenticated}}
|
||||||
|
{{#if noBoards}}
|
||||||
<div class="pull-left width-50">
|
<div class="input-control">
|
||||||
<div class="input-form">
|
<div class="color-error">You have no team boards to share - personal boards are never shown.</div>
|
||||||
<div class="heading">
|
|
||||||
<div class="title">Select Board & Lists</div>
|
|
||||||
<div class="tip">Choose lists to include from board</div>
|
|
||||||
</div>
|
</div>
|
||||||
{{#if noBoards}}
|
{{else}}
|
||||||
<div class="input-control">
|
|
||||||
<div class="color-error">You have no team boards to share - personal boards are never shown.</div>
|
<div class="pull-left width-50">
|
||||||
</div>
|
<div class="input-form">
|
||||||
{{else}}
|
<div class="heading">
|
||||||
<div class="input-control">
|
<div class="title">Select Board & Lists</div>
|
||||||
<label>Board</label>
|
<div class="tip">Choose lists to include from board</div>
|
||||||
<div class="tip">Select board</div>
|
|
||||||
{{ui-select id="boards-dropdown" content=boards action=(action 'onBoardChange') optionValuePath="id" optionLabelPath="name" selection=config.board}}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="input-control">
|
<div class="input-control">
|
||||||
<label>Lists</label>
|
<label>Show summary from (default 7 days ago)</label>
|
||||||
<div class="tip">Select lists to include</div>
|
{{input id="trello-since" value=config.since type="text" }}<br>
|
||||||
<div class="section-trello-board" style= {{boardStyle}}>
|
</div>
|
||||||
<div class="section-trello-board-title">{{config.board.name}}</div>
|
|
||||||
{{#each config.lists as |list|}}
|
<div class="input-control">
|
||||||
<div class="section-trello-list" {{action 'onListCheckbox' list.id}}>
|
<label>Select which boards you want to see</label>
|
||||||
{{#if list.included}}
|
<div class="tip">All boards are selectd by default</div>
|
||||||
<i class="material-icons widget-checkbox checkbox-gray section-trello-list-checkbox">check_box</i>
|
<div class="github-board">
|
||||||
{{else}}
|
{{#each config.boards as |board|}}
|
||||||
<i class="material-icons widget-checkbox checkbox-gray section-trello-list-checkbox">check_box_outline_blank</i>
|
<div class="github-list" {{action 'onBoardCheckbox' board.id}}>
|
||||||
{{/if}}
|
{{#if board.included}}
|
||||||
<span class="trello-list-title">{{list.name}}</span>
|
<i class="material-icons widget-checkbox checkbox-gray github-list-checkbox">check_box</i>
|
||||||
</div>
|
{{else}}
|
||||||
{{/each}}
|
<i class="material-icons widget-checkbox checkbox-gray github-list-checkbox">check_box_outline_blank</i>
|
||||||
<div class="clearfix" />
|
{{/if}}
|
||||||
|
<span style="background-color: {{board.prefs.backgroundColor}}">{{board.name}}</span>
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
<div class="clearfix" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="pull-right width-50">
|
||||||
|
<div class="input-form">
|
||||||
|
<div class="input-control">
|
||||||
|
<label>Individual Board</label>
|
||||||
|
<div class="tip">Select board</div>
|
||||||
|
{{ui-select id="boards-dropdown" content=boards action=(action 'onBoardChange') optionValuePath="id" optionLabelPath="name" selection=config.board}}
|
||||||
|
</div>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>Lists</label>
|
||||||
|
<div class="tip">Select lists to include</div>
|
||||||
|
<div class="section-trello-board" style= {{boardStyle}}>
|
||||||
|
<div class="section-trello-board-title">{{config.board.name}}</div>
|
||||||
|
{{#each config.lists as |list|}}
|
||||||
|
<div class="section-trello-list" {{action 'onListCheckbox' list.id}}>
|
||||||
|
{{#if list.included}}
|
||||||
|
<i class="material-icons widget-checkbox checkbox-gray section-trello-list-checkbox">check_box</i>
|
||||||
|
{{else}}
|
||||||
|
<i class="material-icons widget-checkbox checkbox-gray section-trello-list-checkbox">check_box_outline_blank</i>
|
||||||
|
{{/if}}
|
||||||
|
<span class="trello-list-title">{{list.name}}</span>
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
<div class="clearfix" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
</div>
|
||||||
</div>
|
{{/if}}
|
||||||
</div>
|
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
||||||
|
|
|
@ -12,17 +12,21 @@
|
||||||
package trello
|
package trello
|
||||||
|
|
||||||
const graphsTemplate = `
|
const graphsTemplate = `
|
||||||
<b>Single Boards (graphs)</b><br>
|
{{if false}}
|
||||||
{{range $b := .Boards}}
|
|
||||||
<div>
|
<b>Single Boards (graphs)</b><br>
|
||||||
<p>There are {{ $b.CardCount }} cards across {{ $b.ListCount }} lists for board <a href="{{ $b.Board.URL }}">{{$b.Board.Name}}.</a></p>
|
{{range $b := .Boards}}
|
||||||
<div>
|
<div>
|
||||||
{{range $data := $b.Data}}
|
<p>There are {{ $b.CardCount }} cards across {{ $b.ListCount }} lists for board <a href="{{ $b.Board.URL }}">{{$b.Board.Name}}.</a></p>
|
||||||
<div style="background-color: {{$b.Board.Prefs.BackgroundColor}}">
|
<div>
|
||||||
<progress value="{{len $data.Cards}}" max="{{ $b.CardCount }}"></progress> {{ $data.List.Name }}
|
{{range $data := $b.Data}}
|
||||||
</div>
|
<div style="background-color: {{$b.Board.Prefs.BackgroundColor}}">
|
||||||
{{end}}
|
<progress value="{{len $data.Cards}}" max="{{ $b.CardCount }}"></progress> {{ $data.List.Name }}
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{{end}}
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
`
|
`
|
||||||
|
|
|
@ -15,7 +15,7 @@ const renderTemplate = `
|
||||||
<h3>Header for Trello Multi-Board Test (in master_template.go)</h3>
|
<h3>Header for Trello Multi-Board Test (in master_template.go)</h3>
|
||||||
` + labelsTemplate +
|
` + labelsTemplate +
|
||||||
boardsTemplate +
|
boardsTemplate +
|
||||||
// graphsTemplate +
|
graphsTemplate +
|
||||||
membersTemplate +
|
membersTemplate +
|
||||||
archiveTemplate +
|
archiveTemplate +
|
||||||
tradTemplate +
|
tradTemplate +
|
||||||
|
|
|
@ -11,18 +11,23 @@
|
||||||
|
|
||||||
package trello
|
package trello
|
||||||
|
|
||||||
import "strings"
|
import (
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type secrets struct {
|
type secrets struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type trelloConfig struct {
|
type trelloConfig struct {
|
||||||
AppKey string `json:"appKey"`
|
AppKey string `json:"appKey"`
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
Board trelloBoard `json:"board"` // TODO review
|
Board trelloBoard `json:"board"`
|
||||||
Lists []trelloList `json:"lists"` // TODO review
|
Lists []trelloList `json:"lists"`
|
||||||
Boards []trelloBoard `json:"boards"`
|
Boards []trelloBoard `json:"boards"`
|
||||||
|
Since string `json:"since,omitempty"`
|
||||||
|
SincePtr *time.Time `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *trelloConfig) Clean() {
|
func (c *trelloConfig) Clean() {
|
||||||
|
@ -162,6 +167,7 @@ type trelloBoard struct {
|
||||||
Blue string `json:"blue"`
|
Blue string `json:"blue"`
|
||||||
Purple string `json:"purple"`
|
Purple string `json:"purple"`
|
||||||
} `json:"labelNames"`
|
} `json:"labelNames"`
|
||||||
|
Included bool `json:"included"` // indicates whether we display this board
|
||||||
}
|
}
|
||||||
|
|
||||||
type trelloBoardBackground struct {
|
type trelloBoardBackground struct {
|
||||||
|
@ -258,6 +264,8 @@ type trelloBoardAssign struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type trelloRender struct {
|
type trelloRender struct {
|
||||||
|
Config trelloConfig
|
||||||
|
|
||||||
Boards []trelloRenderBoard
|
Boards []trelloRenderBoard
|
||||||
|
|
||||||
Since string
|
Since string
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
package trello
|
package trello
|
||||||
|
|
||||||
const tradTemplate = `
|
const tradTemplate = `
|
||||||
{{if eq 1 (len .Boards)}}
|
{{if false}}
|
||||||
<h3>#Board Name</h3>
|
|
||||||
{{range $b := .Boards}}
|
{{range $b := .Boards}}
|
||||||
<p class="non-printable-message">Non-printable</p>
|
<p class="non-printable-message">Non-printable</p>
|
||||||
<div class="section-trello-render non-printable">
|
<div class="section-trello-render non-printable">
|
||||||
|
|
|
@ -183,45 +183,67 @@ func (*Provider) Render(ctx *provider.Context, config, data string) string {
|
||||||
// Refresh just sends back data as-is.
|
// Refresh just sends back data as-is.
|
||||||
func (*Provider) Refresh(ctx *provider.Context, config, data string) string {
|
func (*Provider) Refresh(ctx *provider.Context, config, data string) string {
|
||||||
var c = trelloConfig{}
|
var c = trelloConfig{}
|
||||||
json.Unmarshal([]byte(config), &c)
|
log.IfErr(json.Unmarshal([]byte(config), &c))
|
||||||
|
|
||||||
save := trelloRender{}
|
save := trelloRender{}
|
||||||
|
save.Config = c
|
||||||
save.Boards = make([]trelloRenderBoard, 0, len(c.Boards))
|
save.Boards = make([]trelloRenderBoard, 0, len(c.Boards))
|
||||||
|
|
||||||
for _, board := range c.Boards {
|
if len(c.Since) >= len("yyyy/mm/dd hh:ss") {
|
||||||
|
var since time.Time
|
||||||
var payload = trelloRenderBoard{}
|
tt := []byte("yyyy-mm-ddThh:mm:00Z")
|
||||||
|
for _, i := range []int{0, 1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15} {
|
||||||
c.Board = board
|
tt[i] = c.Since[i]
|
||||||
c.AppKey = request.ConfigString(meta.ConfigHandle(), "appKey")
|
|
||||||
|
|
||||||
lsts, err := getLists(c)
|
|
||||||
log.IfErr(err)
|
|
||||||
if err == nil {
|
|
||||||
c.Lists = lsts
|
|
||||||
}
|
}
|
||||||
|
err := since.UnmarshalText(tt)
|
||||||
for l := range c.Lists {
|
if err != nil {
|
||||||
c.Lists[l].Included = true
|
log.ErrorString("Date unmarshall '" + c.Since + "'->'" + string(tt) + "' error: " + err.Error())
|
||||||
|
} else {
|
||||||
|
c.SincePtr = &since
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshed, err := getCards(c)
|
|
||||||
log.IfErr(err)
|
|
||||||
|
|
||||||
payload.Board = c.Board
|
|
||||||
payload.Data = refreshed
|
|
||||||
payload.ListCount = len(refreshed)
|
|
||||||
|
|
||||||
for _, list := range refreshed {
|
|
||||||
payload.CardCount += len(list.Cards)
|
|
||||||
}
|
|
||||||
|
|
||||||
payload.Actions, payload.Archived = fetchBoardActions(&c, &save, board.ID, nil) // TODO pass in date
|
|
||||||
|
|
||||||
save.Boards = append(save.Boards, payload)
|
|
||||||
}
|
}
|
||||||
|
dateMessage := ""
|
||||||
|
if c.SincePtr == nil {
|
||||||
|
dateMessage = " (the last 7 days)"
|
||||||
|
since := time.Now().AddDate(0, 0, -7)
|
||||||
|
c.SincePtr = &since
|
||||||
|
c.Since = (*c.SincePtr).Format("2006/01/02 ")
|
||||||
|
}
|
||||||
|
save.Since = (*c.SincePtr).Format("January 2, 2006") + dateMessage
|
||||||
|
|
||||||
save.Since = "# 1 Aug 2016 #"
|
for _, board := range c.Boards {
|
||||||
|
if board.Included {
|
||||||
|
var payload = trelloRenderBoard{}
|
||||||
|
|
||||||
|
c.Board = board
|
||||||
|
c.AppKey = request.ConfigString(meta.ConfigHandle(), "appKey")
|
||||||
|
|
||||||
|
lsts, err := getLists(c)
|
||||||
|
log.IfErr(err)
|
||||||
|
if err == nil {
|
||||||
|
c.Lists = lsts
|
||||||
|
}
|
||||||
|
|
||||||
|
for l := range c.Lists {
|
||||||
|
c.Lists[l].Included = true
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshed, err := getCards(c)
|
||||||
|
log.IfErr(err)
|
||||||
|
|
||||||
|
payload.Board = c.Board
|
||||||
|
payload.Data = refreshed
|
||||||
|
payload.ListCount = len(refreshed)
|
||||||
|
|
||||||
|
for _, list := range refreshed {
|
||||||
|
payload.CardCount += len(list.Cards)
|
||||||
|
}
|
||||||
|
|
||||||
|
payload.Actions, payload.Archived = fetchBoardActions(&c, &save, board.ID, c.Since)
|
||||||
|
|
||||||
|
save.Boards = append(save.Boards, payload)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
j, err := json.Marshal(save)
|
j, err := json.Marshal(save)
|
||||||
|
|
||||||
|
@ -268,6 +290,10 @@ func getBoards(config trelloConfig) (boards []trelloBoard, err error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for bx := range boards {
|
||||||
|
boards[bx].Included = true // include boards by default
|
||||||
|
}
|
||||||
|
|
||||||
return boards, nil
|
return boards, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,9 +413,9 @@ func fetchMember(config *trelloConfig, render *trelloRender, memberID string) (m
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchBoardActions(config *trelloConfig, render *trelloRender, boardID string, since *time.Time) (actions []trelloAction, archived []trelloCard) {
|
func fetchBoardActions(config *trelloConfig, render *trelloRender, boardID string, since string) (actions []trelloAction, archived []trelloCard) {
|
||||||
|
|
||||||
sinceString := "2016-08-01" // TODO
|
sinceString := since[:10]
|
||||||
|
|
||||||
if len(config.AppKey) == 0 {
|
if len(config.AppKey) == 0 {
|
||||||
config.AppKey = request.ConfigString(meta.ConfigHandle(), "appKey")
|
config.AppKey = request.ConfigString(meta.ConfigHandle(), "appKey")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue