Skip to content

Commit

Permalink
Merge pull request #22 from solocommand/reporting
Browse files Browse the repository at this point in the history
Do not query on load
  • Loading branch information
zarathustra323 committed Jun 20, 2019
2 parents 4df7c96 + 11ac501 commit deb3115
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 113 deletions.
13 changes: 12 additions & 1 deletion services/manage/app/controllers/manage/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ export default Controller.extend(ActionMixin, ObjectQueryManager, {
});
},

hasResults: computed('model.rows.length', function() {
const length = this.get('model.rows.length');
return length && length > 1;
}),

isDownloadDisabled: computed('isActionRunning', 'hasResults', function() {
const isActionRunning = this.get('isActionRunning');
const hasResults = this.get('hasResults');
return isActionRunning || !hasResults;
}),

downloadInput: computed('start', 'end', 'publishers', 'deployments', 'adunits', 'advertisers', 'orders', 'lineitems', function() {
return JSON.stringify(this.getInput());
}),
Expand Down Expand Up @@ -71,8 +82,8 @@ export default Controller.extend(ActionMixin, ObjectQueryManager, {
advertisers: [],
orders: [],
lineitems: [],
model: null,
});
this.execute();
},
update() {
this.execute();
Expand Down
26 changes: 0 additions & 26 deletions services/manage/app/routes/manage/reports.js

This file was deleted.

173 changes: 87 additions & 86 deletions services/manage/app/templates/manage/reports.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -74,97 +74,98 @@
</button>
</div>

<div class="card-body">
{{#if model.rows}}
<div class="card-body">

<div class="table-responsive mt-3">
<table class="table table-hover table-sm">
<thead>
<tr>
<th>Publisher</th>
<th>Deployment</th>
<th class="text-nowrap">Ad Unit</th>
<th class="text-nowrap">Ad Unit Size</th>
<th>Advertiser</th>
<th>Order</th>
<th>Line Item</th>
<th>Ad</th>
<th>Ad Size</th>
<th>Impressions</th>
<th>Clicks</th>
<th>CTR</th>
</tr>
</thead>
<tbody>
{{#each model.rows as |item|}}
<div class="table-responsive mt-3">
<table class="table table-hover table-sm">
<thead>
<tr>
<td>
{{#link-to "manage.publishers.edit" item.publisher.id}}
{{item.publisher.name}}
{{/link-to}}
</td>
<td>
{{#link-to "manage.deployments.edit" item.deployment.id}}
{{item.deployment.name}}
{{/link-to}}
</td>
<td>
{{#link-to "manage.adunits.edit" item.adunit.id}}
{{item.adunit.name}}
{{/link-to}}
</td>
<td>{{item.adunit.size}}</td>
<td>
{{#link-to "manage.advertisers.edit" item.advertiser.id}}
{{item.advertiser.name}}
{{/link-to}}
</td>
<td>
{{#link-to "manage.orders.edit" item.order.id}}
{{item.order.name}}
{{/link-to}}
</td>
<td>
{{#link-to "manage.orders.edit.lineitems.edit" item.order.id item.lineitem.id}}
{{item.lineitem.name}}
{{/link-to}}
</td>
<td>
{{#link-to
"manage.orders.edit.lineitems.edit.ads.edit"
item.order.id
item.lineitem.id
item.ad.id
}}
{{item.ad.name}}
{{/link-to}}
</td>
<td>{{item.ad.size}}</td>
<td title="Total Views: {{item.impressions}}">{{number-format item.impressions "0,0"}}</td>
<td title="Total Clicks: {{item.clicks}}">{{number-format item.clicks "0,0"}}</td>
<td title={{item.ctr}}>{{number-format item.ctr "0.00%"}}</td>
<th>Publisher</th>
<th>Deployment</th>
<th class="text-nowrap">Ad Unit</th>
<th class="text-nowrap">Ad Unit Size</th>
<th>Advertiser</th>
<th>Order</th>
<th>Line Item</th>
<th>Ad</th>
<th>Ad Size</th>
<th>Impressions</th>
<th>Clicks</th>
<th>CTR</th>
</tr>
{{else}}
<tr><td class="text-muted">No results</td></tr>
{{/each}}
</tbody>
</table>
</thead>
<tbody>
{{#each model.rows as |item|}}
<tr>
<td>
{{#link-to "manage.publishers.edit" item.publisher.id}}
{{item.publisher.name}}
{{/link-to}}
</td>
<td>
{{#link-to "manage.deployments.edit" item.deployment.id}}
{{item.deployment.name}}
{{/link-to}}
</td>
<td>
{{#link-to "manage.adunits.edit" item.adunit.id}}
{{item.adunit.name}}
{{/link-to}}
</td>
<td>{{item.adunit.size}}</td>
<td>
{{#link-to "manage.advertisers.edit" item.advertiser.id}}
{{item.advertiser.name}}
{{/link-to}}
</td>
<td>
{{#link-to "manage.orders.edit" item.order.id}}
{{item.order.name}}
{{/link-to}}
</td>
<td>
{{#link-to "manage.orders.edit.lineitems.edit" item.order.id item.lineitem.id}}
{{item.lineitem.name}}
{{/link-to}}
</td>
<td>
{{#link-to
"manage.orders.edit.lineitems.edit.ads.edit"
item.order.id
item.lineitem.id
item.ad.id
}}
{{item.ad.name}}
{{/link-to}}
</td>
<td>{{item.ad.size}}</td>
<td title="Total Views: {{item.impressions}}">{{number-format item.impressions "0,0"}}</td>
<td title="Total Clicks: {{item.clicks}}">{{number-format item.clicks "0,0"}}</td>
<td title={{item.ctr}}>{{number-format item.ctr "0.00%"}}</td>
</tr>
{{else}}
<tr><td class="text-muted">No results</td></tr>
{{/each}}
</tbody>
</table>
</div>
</div>
</div>

<div class="card-footer d-flex justify-content-end">
<form action="/reporting" method="post">
<input type="hidden" name="input" value={{downloadInput}}>
<button
type="submit"
class="btn btn-success"
disabled={{isActionRunning}}
title="Download Results"
>
{{entypo-icon "download"}} Download
</button>
</form>
</div>

<div class="card-footer d-flex justify-content-end">
<form action="/reporting" method="post">
<input type="hidden" name="input" value={{downloadInput}}>
<button
type="submit"
class="btn btn-success"
disabled={{isDownloadDisabled}}
title="Download Results"
>
{{entypo-icon "download"}} Download
</button>
</form>
</div>
{{/if}}
</div>
</div>
</div>

0 comments on commit deb3115

Please sign in to comment.