Fossil

Check-in [e35b9cb74c]
Login

Check-in [e35b9cb74c]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Click on the column labels to sort on the /brlist page.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e35b9cb74cbf0de3f577529487f768b38be772d3
User & Date: drh 2015-01-04 00:28:21.883
Context
2015-01-04
20:54
Enhance the /brlist output to show a count of the number of check-ins on each branch, and to separate the "Status" and "Resolution" into separate columns, with the "Status" column being sortable. Enhance the SortableTable() javascript to always sort ASC on initial click and only go to DESC on a second click of the same column. ... (check-in: 965905c884 user: drh tags: trunk)
00:28
Click on the column labels to sort on the /brlist page. ... (check-in: e35b9cb74c user: drh tags: trunk)
2015-01-03
23:54
New design for the /brlist webpage that shows the branches in age order and shows their current status. ... (check-in: 12fb5d04e3 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/branch.c.
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362

363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382

383
384
385
386
387
388
389
  if( !g.perm.Read ){ login_needed(); return; }
  style_header("Branches");
  login_anonymous_available();
  
  assert( orderByMtime==0 || orderByMtime==1 );
  db_prepare(&q, brlistQuery/*works-like:"%d"*/, 2-orderByMtime);
  rNow = db_double(0.0, "SELECT julianday('now')");
  @ <div class="brlist"><table>
  @ <tr>
  @ <th>Branch Name</th>
  @ <th>Age</th>
  @ <th>Status</th>
  @ </tr>
  while( db_step(&q)==SQLITE_ROW ){
    const char *zBranch = db_column_text(&q, 0);
    double rMtime = db_column_double(&q, 1);
    int isClosed = db_column_int(&q, 2);
    const char *zMergeTo = db_column_text(&q, 3);
    char *zAge = human_readable_age(rNow - rMtime);

    if( zMergeTo && zMergeTo[0]==0 ) zMergeTo = 0;
    @ <tr>
    @ <td>%z(href("%R/timeline?n=100&r=%T",zBranch))%h(zBranch)</a>
    @ <td>%s(zAge)
    fossil_free(zAge);
    if( isClosed && zMergeTo ){
      @ <td>closed,
    }else if( isClosed ){
      @ <td>closed
    }else{
      @ <td>
    }
    if( zMergeTo ){
      @ merged into %z(href("%R/timeline?r=%T",zMergeTo))%h(zMergeTo)</a>
    }
    @ </tr>
  }
  @ </table></div>

  db_finalize(&q);

  style_footer();
}

/*
** WEBPAGE: brlist
** Show a list of branches
** Query parameters:







|
|



|






>



|













|
<

>







344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381

382
383
384
385
386
387
388
389
390
  if( !g.perm.Read ){ login_needed(); return; }
  style_header("Branches");
  login_anonymous_available();
  
  assert( orderByMtime==0 || orderByMtime==1 );
  db_prepare(&q, brlistQuery/*works-like:"%d"*/, 2-orderByMtime);
  rNow = db_double(0.0, "SELECT julianday('now')");
  @ <div class="brlist"><table id="branchlisttable">
  @ <thead><tr>
  @ <th>Branch Name</th>
  @ <th>Age</th>
  @ <th>Status</th>
  @ </tr></thead><tbody>
  while( db_step(&q)==SQLITE_ROW ){
    const char *zBranch = db_column_text(&q, 0);
    double rMtime = db_column_double(&q, 1);
    int isClosed = db_column_int(&q, 2);
    const char *zMergeTo = db_column_text(&q, 3);
    char *zAge = human_readable_age(rNow - rMtime);
    sqlite3_int64 iMtime = (sqlite3_int64)(rMtime*86400.0);
    if( zMergeTo && zMergeTo[0]==0 ) zMergeTo = 0;
    @ <tr>
    @ <td>%z(href("%R/timeline?n=100&r=%T",zBranch))%h(zBranch)</a>
    @ <td data-sortkey="%016llx(iMtime)">%s(zAge)
    fossil_free(zAge);
    if( isClosed && zMergeTo ){
      @ <td>closed,
    }else if( isClosed ){
      @ <td>closed
    }else{
      @ <td>
    }
    if( zMergeTo ){
      @ merged into %z(href("%R/timeline?r=%T",zMergeTo))%h(zMergeTo)</a>
    }
    @ </tr>
  }
  @ </tbody></table></div>

  db_finalize(&q);
  output_table_sorting_javascript("branchlisttable","tkx");
  style_footer();
}

/*
** WEBPAGE: brlist
** Show a list of branches
** Query parameters:
Changes to src/report.c.
936
937
938
939
940
941
942
943






944
945
946
947
948
949
950
*/
void output_table_sorting_javascript(const char *zTableId, const char *zColumnTypes){
  @ <script>
  @ function SortableTable(tableEl,columnTypes){
  @   this.tbody = tableEl.getElementsByTagName('tbody');
  @   this.sort = function (cell) {
  @     var column = cell.cellIndex;
  @     var sortFn = cell.sortType=="n" ? this.sortNumeric : this.sortText;






  @     this.sortIndex = column;
  @     var newRows = new Array();
  @     for (j = 0; j < this.tbody[0].rows.length; j++) {
  @        newRows[j] = this.tbody[0].rows[j];
  @     }
  @     newRows.sort(sortFn);
  @     if (cell.getAttribute("sortdir") == 'down') {







|
>
>
>
>
>
>







936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
*/
void output_table_sorting_javascript(const char *zTableId, const char *zColumnTypes){
  @ <script>
  @ function SortableTable(tableEl,columnTypes){
  @   this.tbody = tableEl.getElementsByTagName('tbody');
  @   this.sort = function (cell) {
  @     var column = cell.cellIndex;
  @     var sortFn;
  @     switch( cell.sortType ){
  @       case "n":  sortFn = this.sortNumeric;  break;
  @       case "t":  sortFn = this.sortText;     break;
  @       case "k":  sortFn = this.sortKey;      break;
  @       case "x":  return;
  @     }
  @     this.sortIndex = column;
  @     var newRows = new Array();
  @     for (j = 0; j < this.tbody[0].rows.length; j++) {
  @        newRows[j] = this.tbody[0].rows[j];
  @     }
  @     newRows.sort(sortFn);
  @     if (cell.getAttribute("sortdir") == 'down') {
968
969
970
971
972
973
974








975
976
977
978
979
980
981
  @   this.sortNumeric = function(a,b) {
  @     var i = thisObject.sortIndex;
  @     aa = parseFloat(a.cells[i].textContent);
  @     if (isNaN(aa)) aa = 0;
  @     bb = parseFloat(b.cells[i].textContent);
  @     if (isNaN(bb)) bb = 0;
  @     return aa-bb;








  @   }
  @   var thisObject = this;
  @   var x = tableEl.getElementsByTagName('thead');
  @   if(!(this.tbody && this.tbody[0].rows && this.tbody[0].rows.length>0)){
  @     return;
  @   }
  @   if(x && x[0].rows && x[0].rows.length > 0) {







>
>
>
>
>
>
>
>







974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
  @   this.sortNumeric = function(a,b) {
  @     var i = thisObject.sortIndex;
  @     aa = parseFloat(a.cells[i].textContent);
  @     if (isNaN(aa)) aa = 0;
  @     bb = parseFloat(b.cells[i].textContent);
  @     if (isNaN(bb)) bb = 0;
  @     return aa-bb;
  @   }
  @   this.sortKey = function(a,b) {
  @     var i = thisObject.sortIndex;
  @     aa = a.cells[i].getAttribute("data-sortkey");
  @     bb = b.cells[i].getAttribute("data-sortkey");
  @     if(aa==bb) return 0;
  @     if(aa<bb) return -1;
  @     return 1;
  @   }
  @   var thisObject = this;
  @   var x = tableEl.getElementsByTagName('thead');
  @   if(!(this.tbody && this.tbody[0].rows && this.tbody[0].rows.length>0)){
  @     return;
  @   }
  @   if(x && x[0].rows && x[0].rows.length > 0) {