From 2f46c1c6326c83b63112bb6dd01bf2edd1a2c9d1 Mon Sep 17 00:00:00 2001 From: Tendrid Date: Wed, 25 Jul 2012 16:32:22 -0400 Subject: [PATCH] adding csv and excel export --- .../app/collections/filtercollection.coffee | 23 +++++++++++++------ SimpleSeer/static/app/styles/main.less | 2 +- .../static/app/views/framelist_view.coffee | 23 +++++++++++++++---- .../static/app/views/templates/framelist.hbs | 3 +++ 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/SimpleSeer/static/app/collections/filtercollection.coffee b/SimpleSeer/static/app/collections/filtercollection.coffee index 324413b9..718d9d82 100644 --- a/SimpleSeer/static/app/collections/filtercollection.coffee +++ b/SimpleSeer/static/app/collections/filtercollection.coffee @@ -38,19 +38,24 @@ module.exports = class FilterCollection extends Collection @sortParams.sortkey = sortkey @sortParams.sortorder = sortorder @sortParams.sorttype = sorttype - @fetch() return - - fetch: (params={}) => + + getUrl: (total=false)=> #todo: map .error to params.error _json = [] for o in @filters val = o.toJson() if val _json.push val + if total + skip = 0 + limit = @skip+@limit + else + skip=@skip + limit=@limit _json = - skip:@skip - limit:@limit + skip:skip + limit:limit query:_json sortkey: @sortParams.sortkey || 'capturetime' sortorder: @sortParams.sortorder || -1 @@ -58,9 +63,13 @@ module.exports = class FilterCollection extends Collection type: @sortParams.sorttype || '' name: @sortParams.sortkey || 'capturetime' order: @sortParams.sortorder || -1 - url = @url+"/"+JSON.stringify _json + "/"+JSON.stringify _json + + fetch: (params={}) => #console.dir _json - $.getJSON(url, (data) => + if params.before + params.before() + $.getJSON(@url+@getUrl(), (data) => @.totalavail = data.total_frames if @skip == 0 @reset data.frames diff --git a/SimpleSeer/static/app/styles/main.less b/SimpleSeer/static/app/styles/main.less index 6924bfe4..c9c148be 100644 --- a/SimpleSeer/static/app/styles/main.less +++ b/SimpleSeer/static/app/styles/main.less @@ -477,7 +477,7 @@ a.video{ #second-tier-footer{ color:#0090d6; border-top:#e0dede solid 1px; - height:30px; + height:45px; text-align:center; padding-top:10px; } diff --git a/SimpleSeer/static/app/views/framelist_view.coffee b/SimpleSeer/static/app/views/framelist_view.coffee index 261f0bbf..abedd0bc 100644 --- a/SimpleSeer/static/app/views/framelist_view.coffee +++ b/SimpleSeer/static/app/views/framelist_view.coffee @@ -34,8 +34,17 @@ module.exports = class FramelistView extends View 'click #data-tab' : 'tabData' 'click #image-tab' : 'tabImage' + preFetch:()=> + $('#loadThrob').modal "show" + + postFetch:()=> + $('#loadThrob').modal "hide" + url = @filtercollection.getUrl(true) + $('#csvlink').attr('href','/downloadFrames/csv'+url) + $('#excellink').attr('href','/downloadFrames/excel'+url) + + tabData: ()=> - $('#loadThrob').modal("show"); $('#data-view').show() $('#data-tab').removeClass('unselected') $('#image-view').hide() @@ -46,12 +55,13 @@ module.exports = class FramelistView extends View @filtercollection.limit = 65536 @filtercollection.skip = 0 @filtercollection.fetch + before: @preFetch success: () => - $('#loadThrob').modal("hide"); $('#data-views-controls').show() $('#views-contain').addClass('wide scroll') $('#views').addClass('wide') $('#content').addClass('wide') + @postFetch() tabImage: () => $('#loadThrob').modal("show"); @@ -64,11 +74,13 @@ module.exports = class FramelistView extends View @filtercollection.limit = @filtercollection._defaults.limit @filtercollection.skip = @filtercollection._defaults.skip @filtercollection.fetch + before: @preFetch success: () => $('#loadThrob').modal("hide"); $('#data-views-controls').hide() $('#views-controls').show() $('#views-contain').removeClass('wide') + @postFetch() toggleMenu: ()=> @@ -88,6 +100,7 @@ module.exports = class FramelistView extends View sortComboVals: @updateFilterCombo(false) metakeys: application.settings.ui_metadata_keys featurekeys: application.settings.ui_feature_keys + filter_url:@filtercollection.getUrl() render: => @filtercollection.limit = @filtercollection._defaults.limit @@ -109,14 +122,14 @@ module.exports = class FramelistView extends View if !application.settings.showMenu? application.settings.showMenu = true @$el.find("#stage").css('margin-left','252px') - @filtercollection.fetch() + @filtercollection.fetch({before: @preFetch,success:@postFetch}) @$el.find('#sortCombo').combobox selected: (event, ui) => if ui.item v = ui.item.value v = v.split(',') @filtercollection.sortList(v[0],v[1],v[2]) - #set sort order and key + @filtercollection.fetch({before: @preFetch,success:@postFetch}) width:"50px" @$el.find("#tabDataTable").tablesorter() @@ -132,7 +145,7 @@ module.exports = class FramelistView extends View @$el.find('#loading_message').fadeIn('fast') @loading=true @filtercollection.skip += @filtercollection._defaults.limit - @filtercollection.fetch() + @filtercollection.fetch({before: @preFetch,success:@postFetch}) clearLoading: (callback=->)=> @loading = false diff --git a/SimpleSeer/static/app/views/templates/framelist.hbs b/SimpleSeer/static/app/views/templates/framelist.hbs index 74ef5f64..c092a013 100644 --- a/SimpleSeer/static/app/views/templates/framelist.hbs +++ b/SimpleSeer/static/app/views/templates/framelist.hbs @@ -14,6 +14,9 @@