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

select which boards and date since, individual board not working yet

This commit is contained in:
Elliott Stoneham 2016-09-09 16:28:51 +01:00
parent 16bf5237b9
commit 1e37c68d99
7 changed files with 166 additions and 87 deletions

View file

@ -50,7 +50,8 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
token: "",
user: null,
board: null,
lists: []
lists: [],
boards: []
};
}
@ -101,6 +102,12 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
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 (boards.length) {
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() {
if (this.get('appKey') === "") {
$("#trello-appkey").addClass('error').focus();

View file

@ -3,44 +3,70 @@
isDirty=(action 'isDirty') onCancel=(action 'onCancel') onAction=(action 'onAction')}}
{{#if authenticated}}
<div class="pull-left width-50">
<div class="input-form">
<div class="heading">
<div class="title">Select Board & Lists</div>
<div class="tip">Choose lists to include from board</div>
{{#if noBoards}}
<div class="input-control">
<div class="color-error">You have no team boards to share - personal boards are never shown.</div>
</div>
{{#if noBoards}}
<div class="input-control">
<div class="color-error">You have no team boards to share - personal boards are never shown.</div>
</div>
{{else}}
<div class="input-control">
<label>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}}
{{else}}
<div class="pull-left width-50">
<div class="input-form">
<div class="heading">
<div class="title">Select Board & Lists</div>
<div class="tip">Choose lists to include from board</div>
</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" />
<label>Show summary from (default 7 days ago)</label>
{{input id="trello-since" value=config.since type="text" }}<br>
</div>
<div class="input-control">
<label>Select which boards you want to see</label>
<div class="tip">All boards are selectd by default</div>
<div class="github-board">
{{#each config.boards as |board|}}
<div class="github-list" {{action 'onBoardCheckbox' board.id}}>
{{#if board.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 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>
{{/if}}
</div>
</div>
</div>
{{/if}}
{{else}}

View file

@ -12,17 +12,21 @@
package trello
const graphsTemplate = `
<b>Single Boards (graphs)</b><br>
{{range $b := .Boards}}
<div>
<p>There are {{ $b.CardCount }} cards across {{ $b.ListCount }} lists for board <a href="{{ $b.Board.URL }}">{{$b.Board.Name}}.</a></p>
{{if false}}
<b>Single Boards (graphs)</b><br>
{{range $b := .Boards}}
<div>
{{range $data := $b.Data}}
<div style="background-color: {{$b.Board.Prefs.BackgroundColor}}">
<progress value="{{len $data.Cards}}" max="{{ $b.CardCount }}"></progress> {{ $data.List.Name }}
</div>
{{end}}
<p>There are {{ $b.CardCount }} cards across {{ $b.ListCount }} lists for board <a href="{{ $b.Board.URL }}">{{$b.Board.Name}}.</a></p>
<div>
{{range $data := $b.Data}}
<div style="background-color: {{$b.Board.Prefs.BackgroundColor}}">
<progress value="{{len $data.Cards}}" max="{{ $b.CardCount }}"></progress> {{ $data.List.Name }}
</div>
{{end}}
</div>
</div>
</div>
{{end}}
{{end}}
`

View file

@ -15,7 +15,7 @@ const renderTemplate = `
<h3>Header for Trello Multi-Board Test (in master_template.go)</h3>
` + labelsTemplate +
boardsTemplate +
// graphsTemplate +
graphsTemplate +
membersTemplate +
archiveTemplate +
tradTemplate +

View file

@ -11,18 +11,23 @@
package trello
import "strings"
import (
"strings"
"time"
)
type secrets struct {
Token string `json:"token"`
}
type trelloConfig struct {
AppKey string `json:"appKey"`
Token string `json:"token"`
Board trelloBoard `json:"board"` // TODO review
Lists []trelloList `json:"lists"` // TODO review
Boards []trelloBoard `json:"boards"`
AppKey string `json:"appKey"`
Token string `json:"token"`
Board trelloBoard `json:"board"`
Lists []trelloList `json:"lists"`
Boards []trelloBoard `json:"boards"`
Since string `json:"since,omitempty"`
SincePtr *time.Time `json:"-"`
}
func (c *trelloConfig) Clean() {
@ -162,6 +167,7 @@ type trelloBoard struct {
Blue string `json:"blue"`
Purple string `json:"purple"`
} `json:"labelNames"`
Included bool `json:"included"` // indicates whether we display this board
}
type trelloBoardBackground struct {
@ -258,6 +264,8 @@ type trelloBoardAssign struct {
}
type trelloRender struct {
Config trelloConfig
Boards []trelloRenderBoard
Since string

View file

@ -12,8 +12,7 @@
package trello
const tradTemplate = `
{{if eq 1 (len .Boards)}}
<h3>#Board Name</h3>
{{if false}}
{{range $b := .Boards}}
<p class="non-printable-message">Non-printable</p>
<div class="section-trello-render non-printable">

View file

@ -183,45 +183,67 @@ func (*Provider) Render(ctx *provider.Context, config, data string) string {
// Refresh just sends back data as-is.
func (*Provider) Refresh(ctx *provider.Context, config, data string) string {
var c = trelloConfig{}
json.Unmarshal([]byte(config), &c)
log.IfErr(json.Unmarshal([]byte(config), &c))
save := trelloRender{}
save.Config = c
save.Boards = make([]trelloRenderBoard, 0, len(c.Boards))
for _, board := range c.Boards {
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
if len(c.Since) >= len("yyyy/mm/dd hh:ss") {
var since time.Time
tt := []byte("yyyy-mm-ddThh:mm:00Z")
for _, i := range []int{0, 1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15} {
tt[i] = c.Since[i]
}
for l := range c.Lists {
c.Lists[l].Included = true
err := since.UnmarshalText(tt)
if err != nil {
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)
@ -268,6 +290,10 @@ func getBoards(config trelloConfig) (boards []trelloBoard, err error) {
return nil, err
}
for bx := range boards {
boards[bx].Included = true // include boards by default
}
return boards, nil
}
@ -387,9 +413,9 @@ func fetchMember(config *trelloConfig, render *trelloRender, memberID string) (m
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 {
config.AppKey = request.ConfigString(meta.ConfigHandle(), "appKey")