diff --git a/Gemfile b/Gemfile index 03750100f4..539bc0d34c 100644 --- a/Gemfile +++ b/Gemfile @@ -25,8 +25,6 @@ else gem 'seed-fu', '~> 2.3.3' end -gem 'actionpack-action_caching' - # Rails 4.1.6+ will relax the mail gem version requirement to `~> 2.5, >= 2.5.4`. # However, mail gem 2.6.x currently does not work with discourse because of the # reference to `Mail::RFC2822Parser` in `lib/email.rb`. This ensure discourse diff --git a/Gemfile.lock b/Gemfile.lock index 154d660bc2..abbaf8458c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,8 +15,6 @@ GEM activesupport (= 4.1.10) rack (~> 1.5.2) rack-test (~> 0.6.2) - actionpack-action_caching (1.1.1) - actionpack (>= 4.0.0, < 5.0) actionview (4.1.10) activesupport (= 4.1.10) builder (~> 3.1) @@ -208,7 +206,7 @@ GEM omniauth-twitter (1.0.1) multi_json (~> 1.3) omniauth-oauth (~> 1.0) - onebox (1.5.20) + onebox (1.5.21) moneta (~> 0.7) multi_json (~> 1.7) mustache (~> 0.99) @@ -392,7 +390,6 @@ PLATFORMS ruby DEPENDENCIES - actionpack-action_caching active_model_serializers (~> 0.8.3) annotate aws-sdk diff --git a/app/assets/javascripts/admin/controllers/admin-customize-css-html.js.es6 b/app/assets/javascripts/admin/controllers/admin-customize-css-html.js.es6 index 266f06c3e8..be6834333d 100644 --- a/app/assets/javascripts/admin/controllers/admin-customize-css-html.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-customize-css-html.js.es6 @@ -1,3 +1,5 @@ +import showModal from 'discourse/lib/show-modal'; + /** This controller supports interface for creating custom CSS skins in Discourse. @@ -21,6 +23,10 @@ export default Ember.ArrayController.extend({ this.set('selectedItem', item); }, + importModal: function() { + showModal('upload-customization'); + }, + /** Select a given style diff --git a/app/assets/javascripts/admin/controllers/admin-reports.js.es6 b/app/assets/javascripts/admin/controllers/admin-reports.js.es6 index 6bb36989b7..0430e8a180 100644 --- a/app/assets/javascripts/admin/controllers/admin-reports.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-reports.js.es6 @@ -4,24 +4,26 @@ export default Ember.ObjectController.extend({ viewingBarChart: Em.computed.equal('viewMode', 'barChart'), startDate: null, endDate: null, + categoryId: null, refreshing: false, actions: { - refreshReport: function() { - var self = this; - this.set('refreshing', true); - Discourse.Report.find(this.get('type'), this.get('startDate'), this.get('endDate')).then(function(r) { - self.set('model', r); - }).finally(function() { - self.set('refreshing', false); - }); + refreshReport() { + this.set("refreshing", true); + Discourse.Report.find( + this.get("type"), + this.get("startDate"), + this.get("endDate"), + this.get("categoryId") + ).then(m => this.set("model", m) + ).finally(() => this.set("refreshing", false)); }, - viewAsTable: function() { + viewAsTable() { this.set('viewMode', 'table'); }, - viewAsBarChart: function() { + viewAsBarChart() { this.set('viewMode', 'barChart'); } } diff --git a/app/assets/javascripts/admin/models/report.js b/app/assets/javascripts/admin/models/report.js.es6 similarity index 83% rename from app/assets/javascripts/admin/models/report.js rename to app/assets/javascripts/admin/models/report.js.es6 index 6f8bfdfff3..ebb63486d2 100644 --- a/app/assets/javascripts/admin/models/report.js +++ b/app/assets/javascripts/admin/models/report.js.es6 @@ -1,9 +1,11 @@ -Discourse.Report = Discourse.Model.extend({ +import round from "discourse/lib/round"; + +const Report = Discourse.Model.extend({ reportUrl: function() { return("/admin/reports/" + this.get('type')); }.property('type'), - valueAt: function(numDaysAgo) { + valueAt(numDaysAgo) { if (this.data) { var wantedDate = moment().subtract(numDaysAgo, 'days').format('YYYY-MM-DD'); var item = this.data.find( function(d) { return d.x === wantedDate; } ); @@ -14,7 +16,7 @@ Discourse.Report = Discourse.Model.extend({ return 0; }, - sumDays: function(startDaysAgo, endDaysAgo) { + sumDays(startDaysAgo, endDaysAgo) { if (this.data) { var earliestDate = moment().subtract(endDaysAgo, 'days').startOf('day'); var latestDate = moment().subtract(startDaysAgo, 'days').startOf('day'); @@ -25,7 +27,7 @@ Discourse.Report = Discourse.Model.extend({ sum += datum.y; } }); - return sum; + return round(sum, -2); } }, @@ -100,7 +102,7 @@ Discourse.Report = Discourse.Model.extend({ } }.property('type'), - percentChangeString: function(val1, val2) { + percentChangeString(val1, val2) { var val = ((val1 - val2) / val2) * 100; if( isNaN(val) || !isFinite(val) ) { return null; @@ -111,7 +113,7 @@ Discourse.Report = Discourse.Model.extend({ } }, - changeTitle: function(val1, val2, prevPeriodString) { + changeTitle(val1, val2, prevPeriodString) { var title = ''; var percentChange = this.percentChangeString(val1, val2); if( percentChange ) { @@ -139,26 +141,29 @@ Discourse.Report = Discourse.Model.extend({ }); -Discourse.Report.reopenClass({ - find: function(type, startDate, endDate) { +Report.reopenClass({ - return Discourse.ajax("/admin/reports/" + type, {data: { - start_date: startDate, - end_date: endDate - }}).then(function (json) { + find(type, startDate, endDate, categoryId) { + return Discourse.ajax("/admin/reports/" + type, { + data: { + start_date: startDate, + end_date: endDate, + category_id: categoryId + } + }).then(json => { // Add a percent field to each tuple - var maxY = 0; - json.report.data.forEach(function (row) { + let maxY = 0; + json.report.data.forEach(row => { if (row.y > maxY) maxY = row.y; }); if (maxY > 0) { - json.report.data.forEach(function (row) { - row.percentage = Math.round((row.y / maxY) * 100); - }); + json.report.data.forEach(row => row.percentage = Math.round((row.y / maxY) * 100)); } - var model = Discourse.Report.create({type: type}); + const model = Discourse.Report.create({ type: type }); model.setProperties(json.report); return model; }); } }); + +export default Report; diff --git a/app/assets/javascripts/admin/models/site_customization.js b/app/assets/javascripts/admin/models/site_customization.js index 27b6ddbdd9..f7b6346a95 100644 --- a/app/assets/javascripts/admin/models/site_customization.js +++ b/app/assets/javascripts/admin/models/site_customization.js @@ -78,13 +78,18 @@ Discourse.SiteCustomization = Discourse.Model.extend({ siteCustomization.set('savingStatus', I18n.t('saved')); siteCustomization.set('saving',false); siteCustomization.startTrackingChanges(); + return siteCustomization; }); }, destroy: function() { if (!this.id) return; return Discourse.ajax("/admin/site_customizations/" + this.id, { type: 'DELETE' }); - } + }, + + download_url: function() { + return Discourse.getURL('/admin/site_customizations/' + this.id); + }.property('id') }); var SiteCustomizations = Ember.ArrayProxy.extend({ diff --git a/app/assets/javascripts/admin/routes/admin-dashboard.js.es6 b/app/assets/javascripts/admin/routes/admin-dashboard.js.es6 index bbe4c79845..5f2c6abd8e 100644 --- a/app/assets/javascripts/admin/routes/admin-dashboard.js.es6 +++ b/app/assets/javascripts/admin/routes/admin-dashboard.js.es6 @@ -12,8 +12,9 @@ export default Discourse.Route.extend({ if (versionChecks) { c.set('versionCheck', Discourse.VersionCheck.create(d.version_check)); } - _.each(d.reports,function(report){ - c.set(report.type, Discourse.Report.create(report)); + + ['global_reports', 'page_view_reports', 'private_message_reports', 'http_reports', 'user_reports'].forEach(name => { + c.set(name, d[name].map(r => Discourse.Report.create(r))); }); var topReferrers = d.top_referrers; diff --git a/app/assets/javascripts/admin/templates/customize_css_html.hbs b/app/assets/javascripts/admin/templates/customize_css_html.hbs index 004318e1eb..e2cc7951a0 100644 --- a/app/assets/javascripts/admin/templates/customize_css_html.hbs +++ b/app/assets/javascripts/admin/templates/customize_css_html.hbs @@ -8,12 +8,14 @@ + {{d-button action="importModal" icon="upload" label="admin.customize.import"}} {{#if selectedItem}}
{{text-field class="style-name" value=selectedItem.name}} + {{fa-icon "download"}} {{i18n 'admin.export_json.button_text'}}