DEV: apply new coding standards (#10592)

This commit is contained in:
Joffrey JAFFEUX 2020-09-04 13:42:47 +02:00 committed by GitHub
parent 80dfaeb0d2
commit 52672b9eab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1473 changed files with 9386 additions and 9958 deletions

View File

@ -1,23 +1,18 @@
// discourse-skip-module // discourse-skip-module
(function() { (function () {
setTimeout(function() { setTimeout(function () {
const $activateButton = $("#activate-account-button"); const $activateButton = $("#activate-account-button");
$activateButton.on("click", function() { $activateButton.on("click", function () {
$activateButton.prop("disabled", true); $activateButton.prop("disabled", true);
const hpPath = document.getElementById("data-activate-account").dataset const hpPath = document.getElementById("data-activate-account").dataset
.path; .path;
$.ajax(hpPath) $.ajax(hpPath)
.then(function(hp) { .then(function (hp) {
$("#password_confirmation").val(hp.value); $("#password_confirmation").val(hp.value);
$("#challenge").val( $("#challenge").val(hp.challenge.split("").reverse().join(""));
hp.challenge
.split("")
.reverse()
.join("")
);
$("#activate-account-form").submit(); $("#activate-account-form").submit();
}) })
.fail(function() { .fail(function () {
$activateButton.prop("disabled", false); $activateButton.prop("disabled", false);
}); });
}); });

View File

@ -9,5 +9,5 @@ export default RESTAdapter.extend({
apiNameFor() { apiNameFor() {
return "key"; return "key";
} },
}); });

View File

@ -6,6 +6,6 @@ export default function buildPluginAdapter(pluginName) {
return ( return (
"/admin/plugins/" + pluginName + this._super(store, type, findArgs) "/admin/plugins/" + pluginName + this._super(store, type, findArgs)
); );
} },
}); });
} }

View File

@ -3,5 +3,5 @@ import RestAdapter from "discourse/adapters/rest";
export default RestAdapter.extend({ export default RestAdapter.extend({
basePath() { basePath() {
return "/admin/customize/"; return "/admin/customize/";
} },
}); });

View File

@ -3,5 +3,5 @@ import RestAdapter from "discourse/adapters/rest";
export default RestAdapter.extend({ export default RestAdapter.extend({
pathFor() { pathFor() {
return "/admin/customize/email_style"; return "/admin/customize/email_style";
} },
}); });

View File

@ -3,5 +3,5 @@ import RestAdapter from "discourse/adapters/rest";
export default RestAdapter.extend({ export default RestAdapter.extend({
pathFor() { pathFor() {
return "/admin/customize/embedding"; return "/admin/customize/embedding";
} },
}); });

View File

@ -3,5 +3,5 @@ import RestAdapter from "discourse/adapters/rest";
export default RestAdapter.extend({ export default RestAdapter.extend({
basePath() { basePath() {
return "/admin/logs/"; return "/admin/logs/";
} },
}); });

View File

@ -1,5 +1,5 @@
import RestAdapter from "discourse/adapters/rest"; import RestAdapter from "discourse/adapters/rest";
export default RestAdapter.extend({ export default RestAdapter.extend({
jsonMode: true jsonMode: true,
}); });

View File

@ -7,20 +7,20 @@ export default RestAdapter.extend({
afterFindAll(results) { afterFindAll(results) {
let map = {}; let map = {};
results.forEach(theme => { results.forEach((theme) => {
map[theme.id] = theme; map[theme.id] = theme;
}); });
results.forEach(theme => { results.forEach((theme) => {
let mapped = theme.get("child_themes") || []; let mapped = theme.get("child_themes") || [];
mapped = mapped.map(t => map[t.id]); mapped = mapped.map((t) => map[t.id]);
theme.set("childThemes", mapped); theme.set("childThemes", mapped);
let mappedParents = theme.get("parent_themes") || []; let mappedParents = theme.get("parent_themes") || [];
mappedParents = mappedParents.map(t => map[t.id]); mappedParents = mappedParents.map((t) => map[t.id]);
theme.set("parentThemes", mappedParents); theme.set("parentThemes", mappedParents);
}); });
return results; return results;
}, },
jsonMode: true jsonMode: true,
}); });

View File

@ -3,5 +3,5 @@ import RESTAdapter from "discourse/adapters/rest";
export default RESTAdapter.extend({ export default RESTAdapter.extend({
basePath() { basePath() {
return "/admin/api/"; return "/admin/api/";
} },
}); });

View File

@ -3,5 +3,5 @@ import RESTAdapter from "discourse/adapters/rest";
export default RESTAdapter.extend({ export default RESTAdapter.extend({
basePath() { basePath() {
return "/admin/api/"; return "/admin/api/";
} },
}); });

View File

@ -37,7 +37,7 @@ export default Component.extend({
placeholderChanged() { placeholderChanged() {
if (this._editor) { if (this._editor) {
this._editor.setOptions({ this._editor.setOptions({
placeholder: this.placeholder placeholder: this.placeholder,
}); });
} }
}, },
@ -54,13 +54,13 @@ export default Component.extend({
editor.setOptions({ editor.setOptions({
readOnly: disabled, readOnly: disabled,
highlightActiveLine: !disabled, highlightActiveLine: !disabled,
highlightGutterLine: !disabled highlightGutterLine: !disabled,
}); });
editor.container.parentNode.setAttribute("data-disabled", disabled); editor.container.parentNode.setAttribute("data-disabled", disabled);
} }
}, },
_destroyEditor: on("willDestroyElement", function() { _destroyEditor: on("willDestroyElement", function () {
if (this._editor) { if (this._editor) {
this._editor.destroy(); this._editor.destroy();
this._editor = null; this._editor = null;
@ -82,7 +82,7 @@ export default Component.extend({
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
loadScript("/javascripts/ace/ace.js?v=1.4.12").then(() => { loadScript("/javascripts/ace/ace.js?v=1.4.12").then(() => {
window.ace.require(["ace/ace"], loadedAce => { window.ace.require(["ace/ace"], (loadedAce) => {
loadedAce.config.set("loadWorkerFromBlob", false); loadedAce.config.set("loadWorkerFromBlob", false);
loadedAce.config.set("workerPath", getURL("/javascripts/ace")); // Do not use CDN for workers loadedAce.config.set("workerPath", getURL("/javascripts/ace")); // Do not use CDN for workers
@ -129,6 +129,6 @@ export default Component.extend({
this._editor.focus(); this._editor.focus();
this._editor.navigateFileEnd(); this._editor.navigateFileEnd();
} }
} },
} },
}); });

View File

@ -35,7 +35,7 @@ export default Component.extend({
@on("init") @on("init")
@observes("logs.[]") @observes("logs.[]")
_updateFormattedLogs: discourseDebounce(function() { _updateFormattedLogs: discourseDebounce(function () {
const logs = this.logs; const logs = this.logs;
if (logs.length === 0) return; if (logs.length === 0) return;
@ -49,7 +49,7 @@ export default Component.extend({
// update the formatted logs & cache index // update the formatted logs & cache index
this.setProperties({ this.setProperties({
formattedLogs: formattedLogs, formattedLogs: formattedLogs,
index: logs.length index: logs.length,
}); });
// force rerender // force rerender
this.renderLogs(); this.renderLogs();
@ -70,5 +70,5 @@ export default Component.extend({
} else { } else {
this.set("showLoadingSpinner", false); this.set("showLoadingSpinner", false);
} }
} },
}); });

View File

@ -19,6 +19,6 @@ export default Component.extend({
save() { save() {
// Action has to toggle 'editing' property. // Action has to toggle 'editing' property.
this.action(this.buffer); this.action(this.buffer);
} },
} },
}); });

View File

@ -1,4 +1,4 @@
import Component from "@ember/component"; import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
classNames: ["row"] classNames: ["row"],
}); });

View File

@ -11,15 +11,15 @@ export default Component.extend({
const rawData = this.get("model.data"); const rawData = this.get("model.data");
var data = { var data = {
labels: rawData.map(r => r.x), labels: rawData.map((r) => r.x),
datasets: [ datasets: [
{ {
data: rawData.map(r => r.y), data: rawData.map((r) => r.y),
label: model.get("title"), label: model.get("title"),
backgroundColor: `rgba(200,220,240,${this.type === "bar" ? 1 : 0.3})`, backgroundColor: `rgba(200,220,240,${this.type === "bar" ? 1 : 0.3})`,
borderColor: "#08C" borderColor: "#08C",
} },
] ],
}; };
const config = { const config = {
@ -29,21 +29,21 @@ export default Component.extend({
responsive: true, responsive: true,
tooltips: { tooltips: {
callbacks: { callbacks: {
title: context => title: (context) =>
moment(context[0].xLabel, "YYYY-MM-DD").format("LL") moment(context[0].xLabel, "YYYY-MM-DD").format("LL"),
} },
}, },
scales: { scales: {
yAxes: [ yAxes: [
{ {
display: true, display: true,
ticks: { ticks: {
stepSize: 1 stepSize: 1,
} },
} },
] ],
} },
} },
}; };
this._chart = new window.Chart(ctx, config); this._chart = new window.Chart(ctx, config);
@ -53,5 +53,5 @@ export default Component.extend({
loadScript("/javascripts/Chart.min.js").then(() => loadScript("/javascripts/Chart.min.js").then(() =>
this.refreshChart.apply(this) this.refreshChart.apply(this)
); );
} },
}); });

View File

@ -1,4 +1,4 @@
import Component from "@ember/component"; import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
tagName: "" tagName: "",
}); });

View File

@ -59,13 +59,13 @@ export default Component.extend({
model.get("prevChartData") || model.get("prev_data") model.get("prevChartData") || model.get("prev_data")
); );
const labels = chartData.map(d => d.x); const labels = chartData.map((d) => d.x);
const data = { const data = {
labels, labels,
datasets: [ datasets: [
{ {
data: chartData.map(d => Math.round(parseFloat(d.y))), data: chartData.map((d) => Math.round(parseFloat(d.y))),
backgroundColor: prevChartData.length backgroundColor: prevChartData.length
? "transparent" ? "transparent"
: model.secondary_color, : model.secondary_color,
@ -73,19 +73,19 @@ export default Component.extend({
pointRadius: 3, pointRadius: 3,
borderWidth: 1, borderWidth: 1,
pointBackgroundColor: model.primary_color, pointBackgroundColor: model.primary_color,
pointBorderColor: model.primary_color pointBorderColor: model.primary_color,
} },
] ],
}; };
if (prevChartData.length) { if (prevChartData.length) {
data.datasets.push({ data.datasets.push({
data: prevChartData.map(d => Math.round(parseFloat(d.y))), data: prevChartData.map((d) => Math.round(parseFloat(d.y))),
borderColor: model.primary_color, borderColor: model.primary_color,
borderDash: [5, 5], borderDash: [5, 5],
backgroundColor: "transparent", backgroundColor: "transparent",
borderWidth: 1, borderWidth: 1,
pointRadius: 0 pointRadius: 0,
}); });
} }
@ -110,41 +110,41 @@ export default Component.extend({
options: { options: {
tooltips: { tooltips: {
callbacks: { callbacks: {
title: tooltipItem => title: (tooltipItem) =>
moment(tooltipItem[0].xLabel, "YYYY-MM-DD").format("LL") moment(tooltipItem[0].xLabel, "YYYY-MM-DD").format("LL"),
} },
}, },
legend: { legend: {
display: false display: false,
}, },
responsive: true, responsive: true,
maintainAspectRatio: false, maintainAspectRatio: false,
responsiveAnimationDuration: 0, responsiveAnimationDuration: 0,
animation: { animation: {
duration: 0 duration: 0,
}, },
layout: { layout: {
padding: { padding: {
left: 0, left: 0,
top: 0, top: 0,
right: 0, right: 0,
bottom: 0 bottom: 0,
} },
}, },
scales: { scales: {
yAxes: [ yAxes: [
{ {
display: true, display: true,
ticks: { ticks: {
userCallback: label => { userCallback: (label) => {
if (Math.floor(label) === label) return label; if (Math.floor(label) === label) return label;
}, },
callback: label => number(label), callback: (label) => number(label),
sampleSize: 5, sampleSize: 5,
maxRotation: 25, maxRotation: 25,
minRotation: 25 minRotation: 25,
} },
} },
], ],
xAxes: [ xAxes: [
{ {
@ -152,17 +152,17 @@ export default Component.extend({
gridLines: { display: false }, gridLines: { display: false },
type: "time", type: "time",
time: { time: {
unit: this._unitForGrouping(options) unit: this._unitForGrouping(options),
}, },
ticks: { ticks: {
sampleSize: 5, sampleSize: 5,
maxRotation: 50, maxRotation: 50,
minRotation: 50 minRotation: 50,
} },
} },
] ],
} },
} },
}; };
}, },
@ -192,11 +192,11 @@ export default Component.extend({
const transformedData = [ const transformedData = [
{ {
x: currentStart.format("YYYY-MM-DD"), x: currentStart.format("YYYY-MM-DD"),
y: 0 y: 0,
} },
]; ];
data.forEach(d => { data.forEach((d) => {
let date = moment(d.x, "YYYY-MM-DD"); let date = moment(d.x, "YYYY-MM-DD");
if (!date.isBetween(currentStart, currentEnd)) { if (!date.isBetween(currentStart, currentEnd)) {
@ -210,7 +210,7 @@ export default Component.extend({
} else { } else {
transformedData[currentIndex] = { transformedData[currentIndex] = {
x: d.x, x: d.x,
y: d.y y: d.y,
}; };
} }
}); });
@ -231,5 +231,5 @@ export default Component.extend({
default: default:
return "day"; return "day";
} }
} },
}); });

View File

@ -2,5 +2,5 @@ import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
classNames: ["admin-report-counters"], classNames: ["admin-report-counters"],
attributeBindings: ["model.description:title"] attributeBindings: ["model.description:title"],
}); });

View File

@ -7,5 +7,5 @@ export default Component.extend({
"report.type", "report.type",
/^(time_to_first_response|topics_with_no_response)$/ /^(time_to_first_response|topics_with_no_response)$/
), ),
classNameBindings: ["reverseColors"] classNameBindings: ["reverseColors"],
}); });

View File

@ -1,4 +1,4 @@
import Component from "@ember/component"; import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
classNames: ["admin-report-inline-table"] classNames: ["admin-report-inline-table"],
}); });

View File

@ -1,4 +1,4 @@
import Component from "@ember/component"; import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
tagName: "tr" tagName: "tr",
}); });

View File

@ -56,14 +56,14 @@ export default Component.extend({
const data = { const data = {
labels: chartData[0].data.mapBy("x"), labels: chartData[0].data.mapBy("x"),
datasets: chartData.map(cd => { datasets: chartData.map((cd) => {
return { return {
label: cd.label, label: cd.label,
stack: "pageviews-stack", stack: "pageviews-stack",
data: cd.data.map(d => Math.round(parseFloat(d.y))), data: cd.data.map((d) => Math.round(parseFloat(d.y))),
backgroundColor: cd.color backgroundColor: cd.color,
}; };
}) }),
}; };
loadScript("/javascripts/Chart.min.js").then(() => { loadScript("/javascripts/Chart.min.js").then(() => {
@ -83,30 +83,30 @@ export default Component.extend({
responsiveAnimationDuration: 0, responsiveAnimationDuration: 0,
hover: { mode: "index" }, hover: { mode: "index" },
animation: { animation: {
duration: 0 duration: 0,
}, },
tooltips: { tooltips: {
mode: "index", mode: "index",
intersect: false, intersect: false,
callbacks: { callbacks: {
beforeFooter: tooltipItem => { beforeFooter: (tooltipItem) => {
let total = 0; let total = 0;
tooltipItem.forEach( tooltipItem.forEach(
item => (total += parseInt(item.yLabel || 0, 10)) (item) => (total += parseInt(item.yLabel || 0, 10))
); );
return `= ${total}`; return `= ${total}`;
}, },
title: tooltipItem => title: (tooltipItem) =>
moment(tooltipItem[0].xLabel, "YYYY-MM-DD").format("LL") moment(tooltipItem[0].xLabel, "YYYY-MM-DD").format("LL"),
} },
}, },
layout: { layout: {
padding: { padding: {
left: 0, left: 0,
top: 0, top: 0,
right: 0, right: 0,
bottom: 0 bottom: 0,
} },
}, },
scales: { scales: {
yAxes: [ yAxes: [
@ -114,15 +114,15 @@ export default Component.extend({
stacked: true, stacked: true,
display: true, display: true,
ticks: { ticks: {
userCallback: label => { userCallback: (label) => {
if (Math.floor(label) === label) return label; if (Math.floor(label) === label) return label;
}, },
callback: label => number(label), callback: (label) => number(label),
sampleSize: 5, sampleSize: 5,
maxRotation: 25, maxRotation: 25,
minRotation: 25 minRotation: 25,
} },
} },
], ],
xAxes: [ xAxes: [
{ {
@ -132,17 +132,17 @@ export default Component.extend({
offset: true, offset: true,
time: { time: {
parser: "YYYY-MM-DD", parser: "YYYY-MM-DD",
minUnit: "day" minUnit: "day",
}, },
ticks: { ticks: {
sampleSize: 5, sampleSize: 5,
maxRotation: 50, maxRotation: 50,
minRotation: 50 minRotation: 50,
} },
} },
] ],
} },
} },
}; };
}, },
@ -151,5 +151,5 @@ export default Component.extend({
this._chart.destroy(); this._chart.destroy();
this._chart = null; this._chart = null;
} }
} },
}); });

View File

@ -39,5 +39,5 @@ export default Component.extend({
@discourseComputed("uploadStats.free_bytes") @discourseComputed("uploadStats.free_bytes")
freeUploadSpace(bytes) { freeUploadSpace(bytes) {
return I18n.toHumanSize(bytes); return I18n.toHumanSize(bytes);
} },
}); });

View File

@ -16,5 +16,5 @@ export default Component.extend({
type: alias("label.type"), type: alias("label.type"),
property: alias("label.mainProperty"), property: alias("label.mainProperty"),
formatedValue: alias("computedLabel.formatedValue"), formatedValue: alias("computedLabel.formatedValue"),
value: alias("computedLabel.value") value: alias("computedLabel.value"),
}); });

View File

@ -15,5 +15,5 @@ export default Component.extend({
@discourseComputed("currentSortDirection") @discourseComputed("currentSortDirection")
sortIcon(currentSortDirection) { sortIcon(currentSortDirection) {
return currentSortDirection === 1 ? "caret-up" : "caret-down"; return currentSortDirection === 1 ? "caret-up" : "caret-down";
} },
}); });

View File

@ -2,5 +2,5 @@ import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
tagName: "tr", tagName: "tr",
classNames: ["admin-report-table-row"], classNames: ["admin-report-table-row"],
options: null options: null,
}); });

View File

@ -26,7 +26,7 @@ export default Component.extend({
showTotalForSample(totalsForSample, total, datesFiltering) { showTotalForSample(totalsForSample, total, datesFiltering) {
// check if we have at least one cell which contains a value // check if we have at least one cell which contains a value
const sum = totalsForSample const sum = totalsForSample
.map(t => t.value) .map((t) => t.value)
.compact() .compact()
.reduce((s, v) => s + v, 0); .reduce((s, v) => s + v, 0);
@ -64,7 +64,7 @@ export default Component.extend({
@discourseComputed("totalsForSampleRow", "model.computedLabels") @discourseComputed("totalsForSampleRow", "model.computedLabels")
totalsForSample(row, labels) { totalsForSample(row, labels) {
return labels.map(label => { return labels.map((label) => {
const computedLabel = label.compute(row); const computedLabel = label.compute(row);
computedLabel.type = label.type; computedLabel.type = label.type;
computedLabel.property = label.mainProperty; computedLabel.property = label.mainProperty;
@ -78,7 +78,7 @@ export default Component.extend({
let totalsRow = {}; let totalsRow = {};
labels.forEach(label => { labels.forEach((label) => {
const reducer = (sum, row) => { const reducer = (sum, row) => {
const computedLabel = label.compute(row); const computedLabel = label.compute(row);
const value = computedLabel.value; const value = computedLabel.value;
@ -137,11 +137,11 @@ export default Component.extend({
pagesIndexes.push(i); pagesIndexes.push(i);
} }
let pages = pagesIndexes.map(v => { let pages = pagesIndexes.map((v) => {
return { return {
page: v + 1, page: v + 1,
index: v, index: v,
class: v === page ? "is-current" : null class: v === page ? "is-current" : null,
}; };
}); });
@ -165,6 +165,6 @@ export default Component.extend({
} else { } else {
this.set("sortLabel", label); this.set("sortLabel", label);
} }
} },
} },
}); });

View File

@ -1,4 +1,4 @@
import Component from "@ember/component"; import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
tagName: "tr" tagName: "tr",
}); });

View File

@ -16,7 +16,7 @@ const TABLE_OPTIONS = {
perPage: 8, perPage: 8,
total: true, total: true,
limit: 20, limit: 20,
formatNumbers: true formatNumbers: true,
}; };
const CHART_OPTIONS = {}; const CHART_OPTIONS = {};
@ -46,7 +46,7 @@ export default Component.extend({
"isVisible", "isVisible",
"isEnabled", "isEnabled",
"isLoading", "isLoading",
"dasherizedDataSourceName" "dasherizedDataSourceName",
], ],
classNames: ["admin-report"], classNames: ["admin-report"],
isEnabled: true, isEnabled: true,
@ -75,14 +75,14 @@ export default Component.extend({
this._reports = []; this._reports = [];
}, },
isHidden: computed("siteSettings.dashboard_hidden_reports", function() { isHidden: computed("siteSettings.dashboard_hidden_reports", function () {
return (this.siteSettings.dashboard_hidden_reports || "") return (this.siteSettings.dashboard_hidden_reports || "")
.split("|") .split("|")
.filter(Boolean) .filter(Boolean)
.includes(this.dataSourceName); .includes(this.dataSourceName);
}), }),
startDate: computed("filters.startDate", function() { startDate: computed("filters.startDate", function () {
if (this.filters && isPresent(this.filters.startDate)) { if (this.filters && isPresent(this.filters.startDate)) {
return moment(this.filters.startDate, "YYYY-MM-DD"); return moment(this.filters.startDate, "YYYY-MM-DD");
} else { } else {
@ -90,7 +90,7 @@ export default Component.extend({
} }
}), }),
endDate: computed("filters.endDate", function() { endDate: computed("filters.endDate", function () {
if (this.filters && isPresent(this.filters.endDate)) { if (this.filters && isPresent(this.filters.endDate)) {
return moment(this.filters.endDate, "YYYY-MM-DD"); return moment(this.filters.endDate, "YYYY-MM-DD");
} else { } else {
@ -139,7 +139,7 @@ export default Component.extend({
@action @action
changeGrouping(grouping) { changeGrouping(grouping) {
this.send("refreshReport", { this.send("refreshReport", {
chartGrouping: grouping chartGrouping: grouping,
}); });
}, },
@ -147,14 +147,14 @@ export default Component.extend({
displayedModes(currentMode, reportModes, forcedModes) { displayedModes(currentMode, reportModes, forcedModes) {
const modes = forcedModes ? forcedModes.split(",") : reportModes; const modes = forcedModes ? forcedModes.split(",") : reportModes;
return makeArray(modes).map(mode => { return makeArray(modes).map((mode) => {
const base = `btn-default mode-btn ${mode}`; const base = `btn-default mode-btn ${mode}`;
const cssClass = currentMode === mode ? `${base} is-current` : base; const cssClass = currentMode === mode ? `${base} is-current` : base;
return { return {
mode, mode,
cssClass, cssClass,
icon: mode === "table" ? "table" : "signal" icon: mode === "table" ? "table" : "signal",
}; };
}); });
}, },
@ -187,10 +187,10 @@ export default Component.extend({
customFilters customFilters
? JSON.stringify(customFilters, (k, v) => (k ? `${v}` : v)) ? JSON.stringify(customFilters, (k, v) => (k ? `${v}` : v))
: null, : null,
SCHEMA_VERSION SCHEMA_VERSION,
] ]
.filter(x => x) .filter((x) => x)
.map(x => x.toString()) .map((x) => x.toString())
.join(":"); .join(":");
return reportKey; return reportKey;
@ -200,11 +200,11 @@ export default Component.extend({
chartGroupings(chartGrouping) { chartGroupings(chartGrouping) {
chartGrouping = chartGrouping || "daily"; chartGrouping = chartGrouping || "daily";
return ["daily", "weekly", "monthly"].map(id => { return ["daily", "weekly", "monthly"].map((id) => {
return { return {
id, id,
label: `admin.dashboard.reports.${id}`, label: `admin.dashboard.reports.${id}`,
class: `chart-grouping ${chartGrouping === id ? "active" : "inactive"}` class: `chart-grouping ${chartGrouping === id ? "active" : "inactive"}`,
}; };
}); });
}, },
@ -213,7 +213,7 @@ export default Component.extend({
onChangeDateRange(range) { onChangeDateRange(range) {
this.send("refreshReport", { this.send("refreshReport", {
startDate: range.from, startDate: range.from,
endDate: range.to endDate: range.to,
}); });
}, },
@ -228,7 +228,7 @@ export default Component.extend({
} }
this.send("refreshReport", { this.send("refreshReport", {
filters: customFilters filters: customFilters,
}); });
}, },
@ -250,7 +250,7 @@ export default Component.extend({
filters: filters:
typeof options.filters === "undefined" typeof options.filters === "undefined"
? this.get("filters.customFilters") ? this.get("filters.customFilters")
: options.filters : options.filters,
}); });
}, },
@ -259,7 +259,7 @@ export default Component.extend({
const args = { const args = {
name: this.get("model.type"), name: this.get("model.type"),
start_date: this.startDate.toISOString(true).split("T")[0], start_date: this.startDate.toISOString(true).split("T")[0],
end_date: this.endDate.toISOString(true).split("T")[0] end_date: this.endDate.toISOString(true).split("T")[0],
}; };
const customFilters = this.get("filters.customFilters"); const customFilters = this.get("filters.customFilters");
@ -275,7 +275,7 @@ export default Component.extend({
this.set("currentMode", mode); this.set("currentMode", mode);
this.send("refreshReport", { this.send("refreshReport", {
chartGrouping: null chartGrouping: null,
}); });
}, },
@ -295,7 +295,7 @@ export default Component.extend({
let filteredReports = this._reports.uniqBy("report_key"); let filteredReports = this._reports.uniqBy("report_key");
let report; let report;
const sort = r => { const sort = (r) => {
if (r.length > 1) { if (r.length > 1) {
return r.findBy("type", this.dataSourceName); return r.findBy("type", this.dataSourceName);
} else { } else {
@ -307,7 +307,7 @@ export default Component.extend({
report = sort(filteredReports)[0]; report = sort(filteredReports)[0];
} else { } else {
report = sort( report = sort(
filteredReports.filter(r => r.report_key.includes(this.reportKey)) filteredReports.filter((r) => r.report_key.includes(this.reportKey))
)[0]; )[0];
if (!report) return; if (!report) return;
@ -327,7 +327,7 @@ export default Component.extend({
this.setProperties({ this.setProperties({
model: report, model: report,
currentMode, currentMode,
options: this._buildOptions(currentMode) options: this._buildOptions(currentMode),
}); });
}, },
@ -339,7 +339,7 @@ export default Component.extend({
next(() => { next(() => {
let payload = this._buildPayload(["prev_period"]); let payload = this._buildPayload(["prev_period"]);
const callback = response => { const callback = (response) => {
if (!this.element || this.isDestroying || this.isDestroyed) { if (!this.element || this.isDestroying || this.isDestroyed) {
return; return;
} }
@ -399,7 +399,7 @@ export default Component.extend({
const chartOptions = JSON.parse(JSON.stringify(CHART_OPTIONS)); const chartOptions = JSON.parse(JSON.stringify(CHART_OPTIONS));
return EmberObject.create( return EmberObject.create(
Object.assign(chartOptions, this.get("reportOptions.chart") || {}, { Object.assign(chartOptions, this.get("reportOptions.chart") || {}, {
chartGrouping: this.get("reportOptions.chartGrouping") chartGrouping: this.get("reportOptions.chartGrouping"),
}) })
); );
} }
@ -409,13 +409,13 @@ export default Component.extend({
Report.fillMissingDates(jsonReport, { filledField: "chartData" }); Report.fillMissingDates(jsonReport, { filledField: "chartData" });
if (jsonReport.chartData && jsonReport.modes[0] === "stacked_chart") { if (jsonReport.chartData && jsonReport.modes[0] === "stacked_chart") {
jsonReport.chartData = jsonReport.chartData.map(chartData => { jsonReport.chartData = jsonReport.chartData.map((chartData) => {
if (chartData.length > 40) { if (chartData.length > 40) {
return { return {
data: collapseWeekly(chartData.data), data: collapseWeekly(chartData.data),
req: chartData.req, req: chartData.req,
label: chartData.label, label: chartData.label,
color: chartData.color color: chartData.color,
}; };
} else { } else {
return chartData; return chartData;
@ -433,7 +433,7 @@ export default Component.extend({
filledField: "prevChartData", filledField: "prevChartData",
dataField: "prev_data", dataField: "prev_data",
starDate: jsonReport.prev_startDate, starDate: jsonReport.prev_startDate,
endDate: jsonReport.prev_endDate endDate: jsonReport.prev_endDate,
}); });
if (jsonReport.prevChartData && jsonReport.prevChartData.length > 40) { if (jsonReport.prevChartData && jsonReport.prevChartData.length > 40) {
@ -445,5 +445,5 @@ export default Component.extend({
} }
return Report.create(jsonReport); return Report.create(jsonReport);
} },
}); });

View File

@ -7,7 +7,7 @@ import { fmt } from "discourse/lib/computed";
export default Component.extend({ export default Component.extend({
@discourseComputed("theme.targets", "onlyOverridden", "showAdvanced") @discourseComputed("theme.targets", "onlyOverridden", "showAdvanced")
visibleTargets(targets, onlyOverridden, showAdvanced) { visibleTargets(targets, onlyOverridden, showAdvanced) {
return targets.filter(target => { return targets.filter((target) => {
if (target.advanced && !showAdvanced) { if (target.advanced && !showAdvanced) {
return false; return false;
} }
@ -22,7 +22,7 @@ export default Component.extend({
visibleFields(targetName, onlyOverridden, fields) { visibleFields(targetName, onlyOverridden, fields) {
fields = fields[targetName]; fields = fields[targetName];
if (onlyOverridden) { if (onlyOverridden) {
fields = fields.filter(field => field.edited); fields = fields.filter((field) => field.edited);
} }
return fields; return fields;
}, },
@ -50,7 +50,7 @@ export default Component.extend({
set(value, fieldName, target, model) { set(value, fieldName, target, model) {
model.setField(target, fieldName, value); model.setField(target, fieldName, value);
return value; return value;
} },
}, },
editorId: fmt("fieldName", "currentTargetName", "%@|%@"), editorId: fmt("fieldName", "currentTargetName", "%@|%@"),
@ -62,7 +62,7 @@ export default Component.extend({
@discourseComputed("currentTargetName", "theme.targets") @discourseComputed("currentTargetName", "theme.targets")
showAddField(currentTargetName, targets) { showAddField(currentTargetName, targets) {
return targets.find(t => t.name === currentTargetName).customNames; return targets.find((t) => t.name === currentTargetName).customNames;
}, },
@discourseComputed( @discourseComputed(
@ -95,13 +95,13 @@ export default Component.extend({
this.fieldAdded(this.currentTargetName, name); this.fieldAdded(this.currentTargetName, name);
}, },
toggleMaximize: function() { toggleMaximize: function () {
this.toggleProperty("maximized"); this.toggleProperty("maximized");
next(() => this.appEvents.trigger("ace:resize")); next(() => this.appEvents.trigger("ace:resize"));
}, },
onlyOverriddenChanged(value) { onlyOverriddenChanged(value) {
this.onlyOverriddenChanged(value); this.onlyOverriddenChanged(value);
} },
} },
}); });

View File

@ -10,7 +10,7 @@ import { propertyEqual } from "discourse/lib/computed";
import { i18n } from "discourse/lib/computed"; import { i18n } from "discourse/lib/computed";
import discourseComputed, { import discourseComputed, {
observes, observes,
on on,
} from "discourse-common/utils/decorators"; } from "discourse-common/utils/decorators";
export default Component.extend(bufferedProperty("userField"), { export default Component.extend(bufferedProperty("userField"), {
@ -103,6 +103,6 @@ export default Component.extend(bufferedProperty("userField"), {
this.rollbackBuffer(); this.rollbackBuffer();
this.set("editing", false); this.set("editing", false);
} }
} },
} },
}); });

View File

@ -19,12 +19,12 @@ export default Component.extend({
.then(() => { .then(() => {
this.action(this.word); this.action(this.word);
}) })
.catch(e => { .catch((e) => {
bootbox.alert( bootbox.alert(
I18n.t("generic_error_with_reason", { I18n.t("generic_error_with_reason", {
error: `http: ${e.status} - ${e.body}` error: `http: ${e.status} - ${e.body}`,
}) })
); );
}); });
} },
}); });

View File

@ -19,7 +19,7 @@ export default Component.extend({
@discourseComputed("model.[]", "typeName") @discourseComputed("model.[]", "typeName")
eventTypeExists(eventTypes, typeName) { eventTypeExists(eventTypes, typeName) {
return eventTypes.any(event => event.name === typeName); return eventTypes.any((event) => event.name === typeName);
}, },
@discourseComputed("eventTypeExists") @discourseComputed("eventTypeExists")
@ -36,12 +36,12 @@ export default Component.extend({
model.addObject(type); model.addObject(type);
} else { } else {
model.removeObjects( model.removeObjects(
model.filter(eventType => eventType.name === type.name) model.filter((eventType) => eventType.name === type.name)
); );
} }
} }
return value; return value;
} },
} },
}); });

View File

@ -54,7 +54,7 @@ export default Component.extend({
I18n.t("admin.web_hooks.events.redeliver_confirm"), I18n.t("admin.web_hooks.events.redeliver_confirm"),
I18n.t("no_value"), I18n.t("no_value"),
I18n.t("yes_value"), I18n.t("yes_value"),
result => { (result) => {
if (result) { if (result) {
ajax( ajax(
`/admin/api/web_hooks/${this.get( `/admin/api/web_hooks/${this.get(
@ -62,7 +62,7 @@ export default Component.extend({
)}/events/${this.get("model.id")}/redeliver`, )}/events/${this.get("model.id")}/redeliver`,
{ type: "POST" } { type: "POST" }
) )
.then(json => { .then((json) => {
this.set("model", json.web_hook_event); this.set("model", json.web_hook_event);
}) })
.catch(popupAjaxError); .catch(popupAjaxError);
@ -78,7 +78,7 @@ export default Component.extend({
let headers = Object.assign( let headers = Object.assign(
{ {
"Request URL": this.get("model.request_url"), "Request URL": this.get("model.request_url"),
"Request method": "POST" "Request method": "POST",
}, },
ensureJSON(this.get("model.headers")) ensureJSON(this.get("model.headers"))
); );
@ -86,7 +86,7 @@ export default Component.extend({
headers: plainJSON(headers), headers: plainJSON(headers),
body: prettyJSON(this.get("model.payload")), body: prettyJSON(this.get("model.payload")),
expandDetails: expandDetailsKey, expandDetails: expandDetailsKey,
bodyLabel: I18n.t("admin.web_hooks.events.payload") bodyLabel: I18n.t("admin.web_hooks.events.payload"),
}); });
} else { } else {
this.set("expandDetails", null); this.set("expandDetails", null);
@ -101,11 +101,11 @@ export default Component.extend({
headers: plainJSON(this.get("model.response_headers")), headers: plainJSON(this.get("model.response_headers")),
body: this.get("model.response_body"), body: this.get("model.response_body"),
expandDetails: expandDetailsKey, expandDetails: expandDetailsKey,
bodyLabel: I18n.t("admin.web_hooks.events.body") bodyLabel: I18n.t("admin.web_hooks.events.body"),
}); });
} else { } else {
this.set("expandDetails", null); this.set("expandDetails", null);
} }
} },
} },
}); });

View File

@ -11,7 +11,7 @@ export default Component.extend({
@discourseComputed("deliveryStatuses", "model.last_delivery_status") @discourseComputed("deliveryStatuses", "model.last_delivery_status")
status(deliveryStatuses, lastDeliveryStatus) { status(deliveryStatuses, lastDeliveryStatus) {
return deliveryStatuses.find(s => s.id === lastDeliveryStatus); return deliveryStatuses.find((s) => s.id === lastDeliveryStatus);
}, },
@discourseComputed("status.id", "icons") @discourseComputed("status.id", "icons")
@ -34,5 +34,5 @@ export default Component.extend({
"deliveryStatus", "deliveryStatus",
I18n.t(`admin.web_hooks.delivery_status.${this.get("status.name")}`) I18n.t(`admin.web_hooks.delivery_status.${this.get("status.name")}`)
); );
} },
}); });

View File

@ -8,5 +8,5 @@ export default Component.extend({
willDestroyElement() { willDestroyElement() {
this._super(...arguments); this._super(...arguments);
$("body").removeClass("admin-interface"); $("body").removeClass("admin-interface");
} },
}); });

View File

@ -1,4 +1,4 @@
import Component from "@ember/component"; import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
tagName: "" tagName: "",
}); });

View File

@ -18,7 +18,7 @@ export default Component.extend({
styleSelection: true, styleSelection: true,
maxlength: computed("onlyHex", function() { maxlength: computed("onlyHex", function () {
return this.onlyHex ? 6 : null; return this.onlyHex ? 6 : null;
}), }),
@ -28,7 +28,7 @@ export default Component.extend({
}, },
@observes("hexValue", "brightnessValue", "valid") @observes("hexValue", "brightnessValue", "valid")
hexValueChanged: function() { hexValueChanged: function () {
const hex = this.hexValue; const hex = this.hexValue;
let text = this.element.querySelector("input.hex-input"); let text = this.element.querySelector("input.hex-input");
@ -47,7 +47,7 @@ export default Component.extend({
if (this.pickerLoaded) { if (this.pickerLoaded) {
$(this.element.querySelector(".picker")).spectrum({ $(this.element.querySelector(".picker")).spectrum({
color: "#" + hex color: "#" + hex,
}); });
} }
} else { } else {
@ -69,5 +69,5 @@ export default Component.extend({
}); });
}); });
schedule("afterRender", () => this.hexValueChanged()); schedule("afterRender", () => this.hexValueChanged());
} },
}); });

View File

@ -28,18 +28,18 @@ export default Component.extend({
set(value, styles, fieldName) { set(value, styles, fieldName) {
styles.setField(fieldName, value); styles.setField(fieldName, value);
return value; return value;
} },
}, },
actions: { actions: {
reset() { reset() {
bootbox.confirm( bootbox.confirm(
I18n.t("admin.customize.email_style.reset_confirm", { I18n.t("admin.customize.email_style.reset_confirm", {
fieldName: I18n.t(`admin.customize.email_style.${this.fieldName}`) fieldName: I18n.t(`admin.customize.email_style.${this.fieldName}`),
}), }),
I18n.t("no_value"), I18n.t("no_value"),
I18n.t("yes_value"), I18n.t("yes_value"),
result => { (result) => {
if (result) { if (result) {
this.styles.setField( this.styles.setField(
this.fieldName, this.fieldName,
@ -49,6 +49,6 @@ export default Component.extend({
} }
} }
); );
} },
} },
}); });

View File

@ -60,7 +60,7 @@ export default Component.extend(bufferedProperty("host"), {
}, },
delete() { delete() {
bootbox.confirm(I18n.t("admin.embedding.confirm_delete"), result => { bootbox.confirm(I18n.t("admin.embedding.confirm_delete"), (result) => {
if (result) { if (result) {
this.host.destroyRecord().then(() => { this.host.destroyRecord().then(() => {
this.deleteHost(this.host); this.deleteHost(this.host);
@ -77,6 +77,6 @@ export default Component.extend(bufferedProperty("host"), {
this.rollbackBuffer(); this.rollbackBuffer();
this.set("editToggled", false); this.set("editToggled", false);
} }
} },
} },
}); });

View File

@ -27,6 +27,6 @@ export default Component.extend({
set(value) { set(value) {
this.set("value", value); this.set("value", value);
return value; return value;
} },
} },
}); });

View File

@ -1,4 +1,4 @@
import Component from "@ember/component"; import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
classNames: ["flag-user-lists"] classNames: ["flag-user-lists"],
}); });

View File

@ -7,5 +7,5 @@ export default Component.extend({
@observes("code") @observes("code")
_refresh() { _refresh() {
highlightSyntax(this.element, this.siteSettings, this.session); highlightSyntax(this.element, this.siteSettings, this.session);
} },
}); });

View File

@ -37,6 +37,6 @@ export default Component.extend({
finished() { finished() {
this.set("checked", this.checkedInternal); this.set("checked", this.checkedInternal);
this.action(); this.action();
} },
} },
}); });

View File

@ -1,4 +1,4 @@
import Component from "@ember/component"; import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
classNames: ["install-theme-item"] classNames: ["install-theme-item"],
}); });

View File

@ -24,7 +24,9 @@ export default Component.extend({
this.set("show", true); this.set("show", true);
if (!this.location) { if (!this.location) {
ajax("/admin/users/ip-info", { data: { ip: this.ip } }).then(location => ajax("/admin/users/ip-info", {
data: { ip: this.ip },
}).then((location) =>
this.set("location", EmberObject.create(location)) this.set("location", EmberObject.create(location))
); );
} }
@ -35,17 +37,17 @@ export default Component.extend({
const data = { const data = {
ip: this.ip, ip: this.ip,
exclude: this.userId, exclude: this.userId,
order: "trust_level DESC" order: "trust_level DESC",
}; };
ajax("/admin/users/total-others-with-same-ip", { data }).then(result => ajax("/admin/users/total-others-with-same-ip", {
this.set("totalOthersWithSameIP", result.total) data,
); }).then((result) => this.set("totalOthersWithSameIP", result.total));
AdminUser.findAll("active", data).then(users => { AdminUser.findAll("active", data).then((users) => {
this.setProperties({ this.setProperties({
other_accounts: users, other_accounts: users,
otherAccountsLoading: false otherAccountsLoading: false,
}); });
}); });
} }
@ -91,12 +93,12 @@ export default Component.extend({
I18n.t("ip_lookup.confirm_delete_other_accounts"), I18n.t("ip_lookup.confirm_delete_other_accounts"),
I18n.t("no_value"), I18n.t("no_value"),
I18n.t("yes_value"), I18n.t("yes_value"),
confirmed => { (confirmed) => {
if (confirmed) { if (confirmed) {
this.setProperties({ this.setProperties({
other_accounts: null, other_accounts: null,
otherAccountsLoading: true, otherAccountsLoading: true,
totalOthersWithSameIP: null totalOthersWithSameIP: null,
}); });
ajax("/admin/users/delete-others-with-same-ip.json", { ajax("/admin/users/delete-others-with-same-ip.json", {
@ -104,12 +106,12 @@ export default Component.extend({
data: { data: {
ip: this.ip, ip: this.ip,
exclude: this.userId, exclude: this.userId,
order: "trust_level DESC" order: "trust_level DESC",
} },
}).then(() => this.send("lookup")); }).then(() => this.send("lookup"));
} }
} }
); );
} },
} },
}); });

View File

@ -1,4 +1,4 @@
import Component from "@ember/component"; import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
tagName: "tr" tagName: "tr",
}); });

View File

@ -13,7 +13,7 @@ export default Component.extend({
@discourseComputed @discourseComputed
penaltyActions() { penaltyActions() {
return ACTIONS.map(id => { return ACTIONS.map((id) => {
return { id, name: I18n.t(`admin.user.penalty_post_${id}`) }; return { id, name: I18n.t(`admin.user.penalty_post_${id}`) };
}); });
}, },
@ -28,7 +28,7 @@ export default Component.extend({
if (postAction === "edit") { if (postAction === "edit") {
this._focusEditTextarea(); this._focusEditTextarea();
} }
} },
}, },
@afterRender @afterRender
@ -37,5 +37,5 @@ export default Component.extend({
const body = elem.closest(".modal-body"); const body = elem.closest(".modal-body");
body.scrollTo(0, body.clientHeight); body.scrollTo(0, body.clientHeight);
elem.querySelector(".post-editor").focus(); elem.querySelector(".post-editor").focus();
} },
}); });

View File

@ -19,7 +19,7 @@ export default Component.extend({
{ id: "post_id", name: I18n.t("admin.permalink.post_id") }, { id: "post_id", name: I18n.t("admin.permalink.post_id") },
{ id: "category_id", name: I18n.t("admin.permalink.category_id") }, { id: "category_id", name: I18n.t("admin.permalink.category_id") },
{ id: "tag_name", name: I18n.t("admin.permalink.tag_name") }, { id: "tag_name", name: I18n.t("admin.permalink.tag_name") },
{ id: "external_url", name: I18n.t("admin.permalink.external_url") } { id: "external_url", name: I18n.t("admin.permalink.external_url") },
]; ];
}, },
@ -27,7 +27,7 @@ export default Component.extend({
this._super(...arguments); this._super(...arguments);
schedule("afterRender", () => { schedule("afterRender", () => {
$(this.element.querySelector(".external-url")).keydown(e => { $(this.element.querySelector(".external-url")).keydown((e) => {
// enter key // enter key
if (e.keyCode === 13) { if (e.keyCode === 13) {
this.send("submit"); this.send("submit");
@ -50,28 +50,28 @@ export default Component.extend({
Permalink.create({ Permalink.create({
url: this.url, url: this.url,
permalink_type: this.permalinkType, permalink_type: this.permalinkType,
permalink_type_value: this.permalink_type_value permalink_type_value: this.permalink_type_value,
}) })
.save() .save()
.then( .then(
result => { (result) => {
this.setProperties({ this.setProperties({
url: "", url: "",
permalink_type_value: "", permalink_type_value: "",
formSubmitted: false formSubmitted: false,
}); });
this.action(Permalink.create(result.permalink)); this.action(Permalink.create(result.permalink));
this.focusPermalink(); this.focusPermalink();
}, },
e => { (e) => {
this.set("formSubmitted", false); this.set("formSubmitted", false);
let error; let error;
if (e.responseJSON && e.responseJSON.errors) { if (e.responseJSON && e.responseJSON.errors) {
error = I18n.t("generic_error_with_reason", { error = I18n.t("generic_error_with_reason", {
error: e.responseJSON.errors.join(". ") error: e.responseJSON.errors.join(". "),
}); });
} else { } else {
error = I18n.t("generic_error"); error = I18n.t("generic_error");
@ -84,6 +84,6 @@ export default Component.extend({
onChangePermalinkType(type) { onChangePermalinkType(type) {
this.set("permalinkType", type); this.set("permalinkType", type);
} },
} },
}); });

View File

@ -12,5 +12,5 @@ export default FilterComponent.extend({
@action @action
onChange() { onChange() {
this.applyFilter(this.filter.id, !this.checked || undefined); this.applyFilter(this.filter.id, !this.checked || undefined);
} },
}); });

View File

@ -8,5 +8,5 @@ export default FilterComponent.extend({
@action @action
onChange(categoryId) { onChange(categoryId) {
this.applyFilter(this.filter.id, categoryId || undefined); this.applyFilter(this.filter.id, categoryId || undefined);
} },
}); });

View File

@ -5,5 +5,5 @@ export default Component.extend({
@action @action
onChange(value) { onChange(value) {
this.applyFilter(this.filter.id, value); this.applyFilter(this.filter.id, value);
} },
}); });

View File

@ -6,7 +6,7 @@ export default FilterComponent.extend({
@computed @computed
get groupOptions() { get groupOptions() {
return (this.site.groups || []).map(group => { return (this.site.groups || []).map((group) => {
return { name: group["name"], value: group["id"] }; return { name: group["name"], value: group["id"] };
}); });
}, },
@ -14,5 +14,5 @@ export default FilterComponent.extend({
@computed("filter.default") @computed("filter.default")
get groupId() { get groupId() {
return this.filter.default ? parseInt(this.filter.default, 10) : null; return this.filter.default ? parseInt(this.filter.default, 10) : null;
} },
}); });

View File

@ -36,8 +36,8 @@ export default Component.extend({
maxFiles: 1, // only 1 file at a time maxFiles: 1, // only 1 file at a time
headers: { headers: {
"X-CSRF-Token": document.querySelector("meta[name='csrf-token']") "X-CSRF-Token": document.querySelector("meta[name='csrf-token']")
.content .content,
} },
}); });
this.resumable.on("fileAdded", () => { this.resumable.on("fileAdded", () => {
@ -51,7 +51,7 @@ export default Component.extend({
}); });
}); });
this.resumable.on("fileProgress", file => { this.resumable.on("fileProgress", (file) => {
// update progress // update progress
later(() => { later(() => {
this.set("progress", parseInt(file.progress() * 100, 10)); this.set("progress", parseInt(file.progress() * 100, 10));
@ -59,7 +59,7 @@ export default Component.extend({
}); });
}); });
this.resumable.on("fileSuccess", file => { this.resumable.on("fileSuccess", (file) => {
later(() => { later(() => {
// mark as not uploading anymore // mark as not uploading anymore
this._reset(); this._reset();
@ -136,5 +136,5 @@ export default Component.extend({
this.setProperties({ isUploading: false, progress: 0 }); this.setProperties({ isUploading: false, progress: 0 });
this._updateIcon(); this._updateIcon();
this._updateProgressBar(); this._updateProgressBar();
} },
}); });

View File

@ -30,20 +30,20 @@ export default Component.extend({
{ id: "block", name: I18n.t("admin.logs.screened_ips.actions.block") }, { id: "block", name: I18n.t("admin.logs.screened_ips.actions.block") },
{ {
id: "do_nothing", id: "do_nothing",
name: I18n.t("admin.logs.screened_ips.actions.do_nothing") name: I18n.t("admin.logs.screened_ips.actions.do_nothing"),
}, },
{ {
id: "allow_admin", id: "allow_admin",
name: I18n.t("admin.logs.screened_ips.actions.allow_admin") name: I18n.t("admin.logs.screened_ips.actions.allow_admin"),
} },
]; ];
} else { } else {
return [ return [
{ id: "block", name: I18n.t("admin.logs.screened_ips.actions.block") }, { id: "block", name: I18n.t("admin.logs.screened_ips.actions.block") },
{ {
id: "do_nothing", id: "do_nothing",
name: I18n.t("admin.logs.screened_ips.actions.do_nothing") name: I18n.t("admin.logs.screened_ips.actions.do_nothing"),
} },
]; ];
} }
}, },
@ -54,23 +54,23 @@ export default Component.extend({
this.set("formSubmitted", true); this.set("formSubmitted", true);
const screenedIpAddress = ScreenedIpAddress.create({ const screenedIpAddress = ScreenedIpAddress.create({
ip_address: this.ip_address, ip_address: this.ip_address,
action_name: this.actionName action_name: this.actionName,
}); });
screenedIpAddress screenedIpAddress
.save() .save()
.then(result => { .then((result) => {
this.setProperties({ ip_address: "", formSubmitted: false }); this.setProperties({ ip_address: "", formSubmitted: false });
this.action(ScreenedIpAddress.create(result.screened_ip_address)); this.action(ScreenedIpAddress.create(result.screened_ip_address));
schedule("afterRender", () => schedule("afterRender", () =>
this.element.querySelector(".ip-address-input").focus() this.element.querySelector(".ip-address-input").focus()
); );
}) })
.catch(e => { .catch((e) => {
this.set("formSubmitted", false); this.set("formSubmitted", false);
const msg = const msg =
e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors
? I18n.t("generic_error_with_reason", { ? I18n.t("generic_error_with_reason", {
error: e.jqXHR.responseJSON.errors.join(". ") error: e.jqXHR.responseJSON.errors.join(". "),
}) })
: I18n.t("generic_error"); : I18n.t("generic_error");
bootbox.alert(msg, () => bootbox.alert(msg, () =>
@ -78,17 +78,17 @@ export default Component.extend({
); );
}); });
} }
} },
}, },
@on("didInsertElement") @on("didInsertElement")
_init() { _init() {
schedule("afterRender", () => { schedule("afterRender", () => {
$(this.element.querySelector(".ip-address-input")).keydown(e => { $(this.element.querySelector(".ip-address-input")).keydown((e) => {
if (e.keyCode === 13) { if (e.keyCode === 13) {
this.send("submit"); this.send("submit");
} }
}); });
}); });
} },
}); });

View File

@ -40,7 +40,7 @@ export default Component.extend({
removeValue(value) { removeValue(value) {
this._removeValue(value); this._removeValue(value);
} },
}, },
_checkInvalidInput(inputs) { _checkInvalidInput(inputs) {
@ -78,7 +78,7 @@ export default Component.extend({
this.set( this.set(
"values", "values",
this.collection this.collection
.map(function(elem) { .map(function (elem) {
return `${elem.key}|${elem.secret}`; return `${elem.key}|${elem.secret}`;
}) })
.join("\n") .join("\n")
@ -89,9 +89,9 @@ export default Component.extend({
if (values && values.length) { if (values && values.length) {
const keys = ["key", "secret"]; const keys = ["key", "secret"];
var res = []; var res = [];
values.split(delimiter).forEach(function(str) { values.split(delimiter).forEach(function (str) {
var object = {}; var object = {};
str.split("|").forEach(function(a, i) { str.split("|").forEach(function (a, i) {
object[keys[i]] = a; object[keys[i]] = a;
}); });
res.push(object); res.push(object);
@ -101,5 +101,5 @@ export default Component.extend({
} else { } else {
return []; return [];
} }
} },
}); });

View File

@ -1,4 +1,4 @@
import Component from "@ember/component"; import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
tagName: "" tagName: "",
}); });

View File

@ -53,5 +53,5 @@ export default Component.extend({
return values && values.length return values && values.length
? values.split(delimiter || "\n").filter(Boolean) ? values.split(delimiter || "\n").filter(Boolean)
: []; : [];
} },
}); });

View File

@ -9,7 +9,7 @@ export default Component.extend(BufferedContent, SettingComponent, {
_save() { _save() {
const setting = this.buffered; const setting = this.buffered;
return SiteSetting.update(setting.get("setting"), setting.get("value"), { return SiteSetting.update(setting.get("setting"), setting.get("value"), {
updateExistingUsers: this.updateExistingUsers updateExistingUsers: this.updateExistingUsers,
}); });
} },
}); });

View File

@ -2,5 +2,5 @@ import ImageUploader from "discourse/components/image-uploader";
export default ImageUploader.extend({ export default ImageUploader.extend({
layoutName: "components/image-uploader", layoutName: "components/image-uploader",
uploadUrlParams: "&for_site_setting=true" uploadUrlParams: "&for_site_setting=true",
}); });

View File

@ -14,6 +14,6 @@ export default Component.extend({
set(value) { set(value) {
this.set("value", value ? "true" : "false"); this.set("value", value ? "true" : "false");
return value; return value;
} },
} },
}); });

View File

@ -3,13 +3,13 @@ import Category from "discourse/models/category";
import { computed } from "@ember/object"; import { computed } from "@ember/object";
export default Component.extend({ export default Component.extend({
selectedCategories: computed("value", function() { selectedCategories: computed("value", function () {
return Category.findByIds(this.value.split("|").filter(Boolean)); return Category.findByIds(this.value.split("|").filter(Boolean));
}), }),
actions: { actions: {
onChangeSelectedCategories(value) { onChangeSelectedCategories(value) {
this.set("value", (value || []).mapBy("id").join("|")); this.set("value", (value || []).mapBy("id").join("|"));
} },
} },
}); });

View File

@ -5,10 +5,7 @@ function RGBToHex(rgb) {
// Choose correct separator // Choose correct separator
let sep = rgb.indexOf(",") > -1 ? "," : " "; let sep = rgb.indexOf(",") > -1 ? "," : " ";
// Turn "rgb(r,g,b)" into [r,g,b] // Turn "rgb(r,g,b)" into [r,g,b]
rgb = rgb rgb = rgb.substr(4).split(")")[0].split(sep);
.substr(4)
.split(")")[0]
.split(sep);
let r = (+rgb[0]).toString(16), let r = (+rgb[0]).toString(16),
g = (+rgb[1]).toString(16), g = (+rgb[1]).toString(16),
@ -22,7 +19,7 @@ function RGBToHex(rgb) {
} }
export default Component.extend({ export default Component.extend({
valid: computed("value", function() { valid: computed("value", function () {
let value = this.value.toLowerCase(); let value = this.value.toLowerCase();
let testColor = new Option().style; let testColor = new Option().style;
@ -45,5 +42,5 @@ export default Component.extend({
@action @action
onChangeColor(color) { onChangeColor(color) {
this.set("value", color); this.set("value", color);
} },
}); });

View File

@ -7,24 +7,21 @@ export default Component.extend({
createdChoices: null, createdChoices: null,
settingValue: computed("value", function() { settingValue: computed("value", function () {
return this.value return this.value.toString().split(this.tokenSeparator).filter(Boolean);
.toString()
.split(this.tokenSeparator)
.filter(Boolean);
}), }),
settingChoices: computed( settingChoices: computed(
"settingValue", "settingValue",
"setting.choices.[]", "setting.choices.[]",
"createdChoices.[]", "createdChoices.[]",
function() { function () {
return [ return [
...new Set([ ...new Set([
...makeArray(this.settingValue), ...makeArray(this.settingValue),
...makeArray(this.setting.choices), ...makeArray(this.setting.choices),
...makeArray(this.createdChoices) ...makeArray(this.createdChoices),
]) ]),
]; ];
} }
), ),
@ -36,8 +33,8 @@ export default Component.extend({
onChangeChoices(choices) { onChangeChoices(choices) {
this.set("createdChoices", [ this.set("createdChoices", [
...new Set([...makeArray(this.createdChoices), ...makeArray(choices)]) ...new Set([...makeArray(this.createdChoices), ...makeArray(choices)]),
]); ]);
} },
} },
}); });

View File

@ -7,19 +7,19 @@ export default Component.extend({
nameProperty: "name", nameProperty: "name",
valueProperty: "id", valueProperty: "id",
groupChoices: computed("site.groups", function() { groupChoices: computed("site.groups", function () {
return (this.site.groups || []).map(g => { return (this.site.groups || []).map((g) => {
return { name: g.name, id: g.id.toString() }; return { name: g.name, id: g.id.toString() };
}); });
}), }),
settingValue: computed("value", function() { settingValue: computed("value", function () {
return (this.value || "").split(this.tokenSeparator).filter(Boolean); return (this.value || "").split(this.tokenSeparator).filter(Boolean);
}), }),
actions: { actions: {
onChangeGroupListSetting(value) { onChangeGroupListSetting(value) {
this.set("value", value.join(this.tokenSeparator)); this.set("value", value.join(this.tokenSeparator));
} },
} },
}); });

View File

@ -7,5 +7,5 @@ export default Component.extend({
@action @action
onChange(value) { onChange(value) {
this.set("value", value.join(this.inputDelimiter || "\n")); this.set("value", value.join(this.inputDelimiter || "\n"));
} },
}); });

View File

@ -7,11 +7,11 @@ export default Component.extend({
selectedTags: { selectedTags: {
get(value) { get(value) {
return value.split("|").filter(Boolean); return value.split("|").filter(Boolean);
} },
}, },
@action @action
changeSelectedTags(tags) { changeSelectedTags(tags) {
this.set("value", tags.join("|")); this.set("value", tags.join("|"));
} },
}); });

View File

@ -7,10 +7,10 @@ export default Component.extend({
showModal("admin-uploaded-image-list", { showModal("admin-uploaded-image-list", {
admin: true, admin: true,
title: `admin.site_settings.${setting.setting}.title`, title: `admin.site_settings.${setting.setting}.title`,
model: { value, setting } model: { value, setting },
}).setProperties({ }).setProperties({
save: v => this.set("value", v) save: (v) => this.set("value", v),
}); });
} },
} },
}); });

View File

@ -15,7 +15,7 @@ export default Component.extend({
this.element.querySelector(".site-text-id, .site-text-value"), this.element.querySelector(".site-text-id, .site-text-value"),
term, term,
{ {
className: "text-highlight" className: "text-highlight",
} }
); );
} }
@ -36,5 +36,5 @@ export default Component.extend({
} }
return this.term; return this.term;
} },
}); });

View File

@ -14,10 +14,10 @@ export default Component.extend({
$(this.element).on( $(this.element).on(
"click.discourse-staff-logs", "click.discourse-staff-logs",
"[data-link-post-id]", "[data-link-post-id]",
e => { (e) => {
let postId = $(e.target).attr("data-link-post-id"); let postId = $(e.target).attr("data-link-post-id");
this.store.find("post", postId).then(p => { this.store.find("post", postId).then((p) => {
DiscourseURL.routeTo(p.get("url")); DiscourseURL.routeTo(p.get("url"));
}); });
return false; return false;
@ -27,7 +27,7 @@ export default Component.extend({
$(this.element).on( $(this.element).on(
"click.discourse-staff-logs", "click.discourse-staff-logs",
"[data-link-topic-id]", "[data-link-topic-id]",
e => { (e) => {
let topicId = $(e.target).attr("data-link-topic-id"); let topicId = $(e.target).attr("data-link-topic-id");
DiscourseURL.routeTo(`/t/${topicId}`); DiscourseURL.routeTo(`/t/${topicId}`);
@ -35,5 +35,5 @@ export default Component.extend({
return false; return false;
} }
); );
} },
}); });

View File

@ -1,4 +1,4 @@
import Component from "@ember/component"; import Component from "@ember/component";
export default Component.extend({ export default Component.extend({
tagName: "" tagName: "",
}); });

View File

@ -19,5 +19,5 @@ export default Component.extend(UploadMixin, {
this.refresh(); this.refresh();
this.closeModal(); this.closeModal();
}); });
} },
}); });

View File

@ -13,8 +13,8 @@ export default Component.extend(BufferedContent, SettingComponent, {
type: "PUT", type: "PUT",
data: { data: {
name: this.setting.setting, name: this.setting.setting,
value: this.get("buffered.value") value: this.get("buffered.value"),
} },
}); });
} },
}); });

View File

@ -15,12 +15,13 @@ export default Component.extend(BufferedContent, SettingComponent, {
return this.get("buffered.value") return this.get("buffered.value")
.split("|") .split("|")
.filter(Boolean) .filter(Boolean)
.map(themeName => { .map((themeName) => {
if (themeName !== "") { if (themeName !== "") {
return this.setting.allThemes.find(theme => theme.name === themeName) return this.setting.allThemes.find(
.id; (theme) => theme.name === themeName
).id;
} }
return themeName; return themeName;
}); });
} },
}); });

View File

@ -14,5 +14,5 @@ export default Component.extend(BufferedContent, SettingComponent, {
this.get("translation.key"), this.get("translation.key"),
this.get("buffered.value") this.get("buffered.value")
); );
} },
}); });

View File

@ -67,7 +67,7 @@ export default Component.extend({
children = this.childrenExpanded children = this.childrenExpanded
? children ? children
: children.slice(0, MAX_COMPONENTS); : children.slice(0, MAX_COMPONENTS);
return children.map(t => { return children.map((t) => {
const name = escape(t.name); const name = escape(t.name);
return t.enabled ? name : `${iconHTML("ban")} ${name}`; return t.enabled ? name : `${iconHTML("ban")} ${name}`;
}); });
@ -96,22 +96,22 @@ export default Component.extend({
$list.css("display", ""); $list.css("display", "");
$container.animate( $container.animate(
{ {
height: `${$container.height() + $list.outerHeight(true)}px` height: `${$container.height() + $list.outerHeight(true)}px`,
}, },
{ {
duration, duration,
done: () => { done: () => {
$list.css("display", ""); $list.css("display", "");
$container.css("height", ""); $container.css("height", "");
} },
} }
); );
$list.animate( $list.animate(
{ {
opacity: 1 opacity: 1,
}, },
{ {
duration duration,
} }
); );
}, },
@ -119,22 +119,22 @@ export default Component.extend({
collapseComponentsList($container, $list, duration) { collapseComponentsList($container, $list, duration) {
$container.animate( $container.animate(
{ {
height: `${$container.height() - $list.outerHeight(true)}px` height: `${$container.height() - $list.outerHeight(true)}px`,
}, },
{ {
duration, duration,
done: () => { done: () => {
$list.css("display", "none"); $list.css("display", "none");
$container.css("height", ""); $container.css("height", "");
} },
} }
); );
$list.animate( $list.animate(
{ {
opacity: 0 opacity: 0,
}, },
{ {
duration duration,
} }
); );
}, },
@ -142,6 +142,6 @@ export default Component.extend({
actions: { actions: {
toggleChildrenExpanded() { toggleChildrenExpanded() {
this.toggleProperty("childrenExpanded"); this.toggleProperty("childrenExpanded");
} },
} },
}); });

View File

@ -35,10 +35,10 @@ export default Component.extend({
) )
inactiveThemes(themes) { inactiveThemes(themes) {
if (this.componentsTabActive) { if (this.componentsTabActive) {
return themes.filter(theme => theme.get("parent_themes.length") <= 0); return themes.filter((theme) => theme.get("parent_themes.length") <= 0);
} }
return themes.filter( return themes.filter(
theme => !theme.get("user_selectable") && !theme.get("default") (theme) => !theme.get("user_selectable") && !theme.get("default")
); );
}, },
@ -50,10 +50,10 @@ export default Component.extend({
) )
activeThemes(themes) { activeThemes(themes) {
if (this.componentsTabActive) { if (this.componentsTabActive) {
return themes.filter(theme => theme.get("parent_themes.length") > 0); return themes.filter((theme) => theme.get("parent_themes.length") > 0);
} else { } else {
return themes return themes
.filter(theme => theme.get("user_selectable") || theme.get("default")) .filter((theme) => theme.get("user_selectable") || theme.get("default"))
.sort((a, b) => { .sort((a, b) => {
if (a.get("default") && !b.get("default")) { if (a.get("default") && !b.get("default")) {
return -1; return -1;
@ -76,6 +76,6 @@ export default Component.extend({
}, },
navigateToTheme(theme) { navigateToTheme(theme) {
this.router.transitionTo("adminCustomizeThemes.show", theme); this.router.transitionTo("adminCustomizeThemes.show", theme);
} },
} },
}); });

View File

@ -30,7 +30,7 @@ export default Component.extend({
@discourseComputed("choices.[]", "collection.[]") @discourseComputed("choices.[]", "collection.[]")
filteredChoices(choices, collection) { filteredChoices(choices, collection) {
return makeArray(choices).filter(i => collection.indexOf(i) < 0); return makeArray(choices).filter((i) => collection.indexOf(i) < 0);
}, },
keyDown(event) { keyDown(event) {
@ -55,7 +55,7 @@ export default Component.extend({
selectChoice(choice) { selectChoice(choice) {
this._addValue(choice); this._addValue(choice);
} },
}, },
_addValue(value) { _addValue(value) {
@ -98,9 +98,9 @@ export default Component.extend({
_splitValues(values, delimiter) { _splitValues(values, delimiter) {
if (values && values.length) { if (values && values.length) {
return values.split(delimiter).filter(x => x); return values.split(delimiter).filter((x) => x);
} else { } else {
return []; return [];
} }
} },
}); });

View File

@ -6,7 +6,7 @@ import WatchedWord from "admin/models/watched-word";
import bootbox from "bootbox"; import bootbox from "bootbox";
import discourseComputed, { import discourseComputed, {
on, on,
observes observes,
} from "discourse-common/utils/decorators"; } from "discourse-common/utils/decorators";
export default Component.extend({ export default Component.extend({
@ -33,9 +33,11 @@ export default Component.extend({
@discourseComputed("word") @discourseComputed("word")
isUniqueWord(word) { isUniqueWord(word) {
const words = this.filteredContent || []; const words = this.filteredContent || [];
const filtered = words.filter(content => content.action === this.actionKey); const filtered = words.filter(
(content) => content.action === this.actionKey
);
return filtered.every( return filtered.every(
content => content.word.toLowerCase() !== word.toLowerCase() (content) => content.word.toLowerCase() !== word.toLowerCase()
); );
}, },
@ -44,7 +46,7 @@ export default Component.extend({
if (!this.isUniqueWord) { if (!this.isUniqueWord) {
this.setProperties({ this.setProperties({
showMessage: true, showMessage: true,
message: I18n.t("admin.watched_words.form.exists") message: I18n.t("admin.watched_words.form.exists"),
}); });
return; return;
} }
@ -54,29 +56,29 @@ export default Component.extend({
const watchedWord = WatchedWord.create({ const watchedWord = WatchedWord.create({
word: this.word, word: this.word,
action: this.actionKey action: this.actionKey,
}); });
watchedWord watchedWord
.save() .save()
.then(result => { .then((result) => {
this.setProperties({ this.setProperties({
word: "", word: "",
formSubmitted: false, formSubmitted: false,
showMessage: true, showMessage: true,
message: I18n.t("admin.watched_words.form.success") message: I18n.t("admin.watched_words.form.success"),
}); });
this.action(WatchedWord.create(result)); this.action(WatchedWord.create(result));
schedule("afterRender", () => schedule("afterRender", () =>
this.element.querySelector(".watched-word-input").focus() this.element.querySelector(".watched-word-input").focus()
); );
}) })
.catch(e => { .catch((e) => {
this.set("formSubmitted", false); this.set("formSubmitted", false);
const msg = const msg =
e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors
? I18n.t("generic_error_with_reason", { ? I18n.t("generic_error_with_reason", {
error: e.jqXHR.responseJSON.errors.join(". ") error: e.jqXHR.responseJSON.errors.join(". "),
}) })
: I18n.t("generic_error"); : I18n.t("generic_error");
bootbox.alert(msg, () => bootbox.alert(msg, () =>
@ -84,17 +86,17 @@ export default Component.extend({
); );
}); });
} }
} },
}, },
@on("didInsertElement") @on("didInsertElement")
_init() { _init() {
schedule("afterRender", () => { schedule("afterRender", () => {
$(this.element.querySelector(".watched-word-input")).keydown(e => { $(this.element.querySelector(".watched-word-input")).keydown((e) => {
if (e.keyCode === 13) { if (e.keyCode === 13) {
this.send("submit"); this.send("submit");
} }
}); });
}); });
} },
}); });

View File

@ -25,5 +25,5 @@ export default Component.extend(UploadMixin, {
bootbox.alert(I18n.t("admin.watched_words.form.upload_successful")); bootbox.alert(I18n.t("admin.watched_words.form.upload_successful"));
this.done(); this.done();
} }
} },
}); });

View File

@ -9,6 +9,6 @@ export default Controller.extend({
undoRevokeKey(key) { undoRevokeKey(key) {
key.undoRevoke().catch(popupAjaxError); key.undoRevoke().catch(popupAjaxError);
} },
} },
}); });

View File

@ -8,7 +8,7 @@ import showModal from "discourse/lib/show-modal";
export default Controller.extend({ export default Controller.extend({
userModes: [ userModes: [
{ id: "all", name: I18n.t("admin.api.all_users") }, { id: "all", name: I18n.t("admin.api.all_users") },
{ id: "single", name: I18n.t("admin.api.single_user") } { id: "single", name: I18n.t("admin.api.single_user") },
], ],
useGlobalKey: false, useGlobalKey: false,
scopes: null, scopes: null,
@ -37,7 +37,7 @@ export default Controller.extend({
if (!this.useGlobalKey) { if (!this.useGlobalKey) {
const selectedScopes = Object.values(this.scopes) const selectedScopes = Object.values(this.scopes)
.flat() .flat()
.filter(action => { .filter((action) => {
return action.selected; return action.selected;
}); });
@ -55,9 +55,9 @@ export default Controller.extend({
return showModal("admin-api-key-urls", { return showModal("admin-api-key-urls", {
admin: true, admin: true,
model: { model: {
urls urls,
} },
}); });
} },
} },
}); });

View File

@ -58,9 +58,9 @@ export default Controller.extend(bufferedProperty("model"), {
return showModal("admin-api-key-urls", { return showModal("admin-api-key-urls", {
admin: true, admin: true,
model: { model: {
urls urls,
} },
}); });
} },
} },
}); });

View File

@ -31,7 +31,7 @@ export default Controller.extend({
I18n.t("admin.backups.read_only.enable.confirm"), I18n.t("admin.backups.read_only.enable.confirm"),
I18n.t("no_value"), I18n.t("no_value"),
I18n.t("yes_value"), I18n.t("yes_value"),
confirmed => { (confirmed) => {
if (confirmed) { if (confirmed) {
this.set("currentUser.hideReadOnlyAlert", true); this.set("currentUser.hideReadOnlyAlert", true);
this._toggleReadOnlyMode(true); this._toggleReadOnlyMode(true);
@ -48,13 +48,13 @@ export default Controller.extend({
ajax(`/admin/backups/${link}`, { type: "PUT" }).then(() => ajax(`/admin/backups/${link}`, { type: "PUT" }).then(() =>
bootbox.alert(I18n.t("admin.backups.operations.download.alert")) bootbox.alert(I18n.t("admin.backups.operations.download.alert"))
); );
} },
}, },
_toggleReadOnlyMode(enable) { _toggleReadOnlyMode(enable) {
ajax("/admin/backups/readonly", { ajax("/admin/backups/readonly", {
type: "PUT", type: "PUT",
data: { enable } data: { enable },
}).then(() => this.site.set("isReadOnly", enable)); }).then(() => this.site.set("isReadOnly", enable));
} },
}); });

View File

@ -9,5 +9,5 @@ export default Controller.extend({
this._super(...arguments); this._super(...arguments);
this.logs = []; this.logs = [];
} },
}); });

View File

@ -7,5 +7,5 @@ export default Controller.extend({
"model.restoreEnabled", "model.restoreEnabled",
"noOperationIsRunning" "noOperationIsRunning"
), ),
rollbackDisabled: not("rollbackEnabled") rollbackDisabled: not("rollbackEnabled"),
}); });

View File

@ -17,7 +17,7 @@ export default Controller.extend({
type: "POST", type: "POST",
processData: false, processData: false,
contentType: false, contentType: false,
data: new FormData() data: new FormData(),
}; };
options.data.append("file", file); options.data.append("file", file);
@ -34,6 +34,6 @@ export default Controller.extend({
} else { } else {
bootbox.alert(I18n.t("admin.badges.mass_award.aborted")); bootbox.alert(I18n.t("admin.badges.mass_award.aborted"));
} }
} },
} },
}); });

View File

@ -57,7 +57,7 @@ export default Controller.extend(bufferedProperty("model"), {
}, },
@observes("model.id") @observes("model.id")
_resetSaving: function() { _resetSaving: function () {
this.set("saving", false); this.set("saving", false);
this.set("savingStatus", ""); this.set("savingStatus", "");
}, },
@ -81,12 +81,12 @@ export default Controller.extend(bufferedProperty("model"), {
"query", "query",
"badge_grouping_id", "badge_grouping_id",
"trigger", "trigger",
"badge_type_id" "badge_type_id",
]; ];
if (this.get("buffered.system")) { if (this.get("buffered.system")) {
let protectedFields = this.protectedSystemFields || []; let protectedFields = this.protectedSystemFields || [];
fields = fields.filter(f => !protectedFields.includes(f)); fields = fields.filter((f) => !protectedFields.includes(f));
} }
this.set("saving", true); this.set("saving", true);
@ -99,12 +99,12 @@ export default Controller.extend(bufferedProperty("model"), {
"auto_revoke", "auto_revoke",
"enabled", "enabled",
"show_posts", "show_posts",
"target_posts" "target_posts",
]; ];
const data = {}; const data = {};
const buffered = this.buffered; const buffered = this.buffered;
fields.forEach(function(field) { fields.forEach(function (field) {
var d = buffered.get(field); var d = buffered.get(field);
if (boolFields.includes(field)) { if (boolFields.includes(field)) {
d = !!d; d = !!d;
@ -149,7 +149,7 @@ export default Controller.extend(bufferedProperty("model"), {
I18n.t("admin.badges.delete_confirm"), I18n.t("admin.badges.delete_confirm"),
I18n.t("no_value"), I18n.t("no_value"),
I18n.t("yes_value"), I18n.t("yes_value"),
result => { (result) => {
if (result) { if (result) {
model model
.destroy() .destroy()
@ -163,6 +163,6 @@ export default Controller.extend(bufferedProperty("model"), {
} }
} }
); );
} },
} },
}); });

View File

@ -14,5 +14,5 @@ export default Controller.extend({
} else { } else {
return this.routing.currentRouteName; return this.routing.currentRouteName;
} }
} },
}); });

View File

@ -8,18 +8,18 @@ export default Controller.extend({
@discourseComputed("model.colors", "onlyOverridden") @discourseComputed("model.colors", "onlyOverridden")
colors(allColors, onlyOverridden) { colors(allColors, onlyOverridden) {
if (onlyOverridden) { if (onlyOverridden) {
return allColors.filter(color => color.get("overridden")); return allColors.filter((color) => color.get("overridden"));
} else { } else {
return allColors; return allColors;
} }
}, },
actions: { actions: {
revert: function(color) { revert: function (color) {
color.revert(); color.revert();
}, },
undo: function(color) { undo: function (color) {
color.undo(); color.undo();
}, },
@ -68,7 +68,7 @@ export default Controller.extend({
}); });
}, },
save: function() { save: function () {
this.model.save(); this.model.save();
}, },
@ -76,13 +76,13 @@ export default Controller.extend({
this.model.updateUserSelectable(this.get("model.user_selectable")); this.model.updateUserSelectable(this.get("model.user_selectable"));
}, },
destroy: function() { destroy: function () {
const model = this.model; const model = this.model;
return bootbox.confirm( return bootbox.confirm(
I18n.t("admin.customize.colors.delete_confirm"), I18n.t("admin.customize.colors.delete_confirm"),
I18n.t("no_value"), I18n.t("no_value"),
I18n.t("yes_value"), I18n.t("yes_value"),
result => { (result) => {
if (result) { if (result) {
model.destroy().then(() => { model.destroy().then(() => {
this.allColors.removeObject(model); this.allColors.removeObject(model);
@ -91,6 +91,6 @@ export default Controller.extend({
} }
} }
); );
} },
} },
}); });

View File

@ -18,7 +18,7 @@ export default Controller.extend({
@discourseComputed("baseColorScheme") @discourseComputed("baseColorScheme")
baseColors(baseColorScheme) { baseColors(baseColorScheme) {
const baseColorsHash = EmberObject.create({}); const baseColorsHash = EmberObject.create({});
baseColorScheme.get("colors").forEach(color => { baseColorScheme.get("colors").forEach((color) => {
baseColorsHash.set(color.get("name"), color); baseColorsHash.set(color.get("name"), color);
}); });
return baseColorsHash; return baseColorsHash;
@ -30,7 +30,7 @@ export default Controller.extend({
const newColorScheme = base.copy(); const newColorScheme = base.copy();
newColorScheme.setProperties({ newColorScheme.setProperties({
name: I18n.t("admin.customize.colors.new_name"), name: I18n.t("admin.customize.colors.new_name"),
base_scheme_id: base.get("base_scheme_id") base_scheme_id: base.get("base_scheme_id"),
}); });
newColorScheme.save().then(() => { newColorScheme.save().then(() => {
this.model.pushObject(newColorScheme); this.model.pushObject(newColorScheme);
@ -42,8 +42,8 @@ export default Controller.extend({
newColorScheme() { newColorScheme() {
showModal("admin-color-scheme-select-base", { showModal("admin-color-scheme-select-base", {
model: this.baseColorSchemes, model: this.baseColorSchemes,
admin: true admin: true,
}); });
} },
} },
}); });

View File

@ -20,17 +20,17 @@ export default Controller.extend({
this.set("saving", true); this.set("saving", true);
this.model this.model
.update(this.model.getProperties("html", "css")) .update(this.model.getProperties("html", "css"))
.catch(e => { .catch((e) => {
const msg = const msg =
e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors
? I18n.t("admin.customize.email_style.save_error_with_reason", { ? I18n.t("admin.customize.email_style.save_error_with_reason", {
error: e.jqXHR.responseJSON.errors.join(". ") error: e.jqXHR.responseJSON.errors.join(". "),
}) })
: I18n.t("generic_error"); : I18n.t("generic_error");
bootbox.alert(msg); bootbox.alert(msg);
}) })
.finally(() => this.set("model.changed", false)); .finally(() => this.set("model.changed", false));
} }
} },
} },
}); });

View File

@ -45,11 +45,11 @@ export default Controller.extend(bufferedProperty("emailTemplate"), {
this.set("saved", false); this.set("saved", false);
bootbox.confirm( bootbox.confirm(
I18n.t("admin.customize.email_templates.revert_confirm"), I18n.t("admin.customize.email_templates.revert_confirm"),
result => { (result) => {
if (result) { if (result) {
this.emailTemplate this.emailTemplate
.revert() .revert()
.then(props => { .then((props) => {
const buffered = this.buffered; const buffered = this.buffered;
buffered.setProperties(props); buffered.setProperties(props);
this.commitBuffer(); this.commitBuffer();
@ -58,5 +58,5 @@ export default Controller.extend(bufferedProperty("emailTemplate"), {
} }
} }
); );
} },
}); });

View File

@ -14,5 +14,5 @@ export default Controller.extend({
@action @action
onSelectTemplate(template) { onSelectTemplate(template) {
this.transitionToRoute("adminCustomizeEmailTemplates.edit", template); this.transitionToRoute("adminCustomizeEmailTemplates.edit", template);
} },
}); });

View File

@ -14,14 +14,14 @@ export default Controller.extend(bufferedProperty("model"), {
save() { save() {
this.setProperties({ this.setProperties({
isSaving: true, isSaving: true,
saved: false saved: false,
}); });
ajax("robots.json", { ajax("robots.json", {
type: "PUT", type: "PUT",
data: { robots_txt: this.buffered.get("robots_txt") } data: { robots_txt: this.buffered.get("robots_txt") },
}) })
.then(data => { .then((data) => {
this.commitBuffer(); this.commitBuffer();
this.set("saved", true); this.set("saved", true);
this.set("model.overridden", data.overridden); this.set("model.overridden", data.overridden);
@ -32,16 +32,16 @@ export default Controller.extend(bufferedProperty("model"), {
reset() { reset() {
this.setProperties({ this.setProperties({
isSaving: true, isSaving: true,
saved: false saved: false,
}); });
ajax("robots.json", { type: "DELETE" }) ajax("robots.json", { type: "DELETE" })
.then(data => { .then((data) => {
this.buffered.set("robots_txt", data.robots_txt); this.buffered.set("robots_txt", data.robots_txt);
this.commitBuffer(); this.commitBuffer();
this.set("saved", true); this.set("saved", true);
this.set("model.overridden", false); this.set("model.overridden", false);
}) })
.finally(() => this.set("isSaving", false)); .finally(() => this.set("isSaving", false));
} },
} },
}); });

View File

@ -12,15 +12,15 @@ export default Controller.extend({
editRouteName: "adminCustomizeThemes.edit", editRouteName: "adminCustomizeThemes.edit",
showRouteName: "adminCustomizeThemes.show", showRouteName: "adminCustomizeThemes.show",
setTargetName: function(name) { setTargetName: function (name) {
const target = this.get("model.targets").find(t => t.name === name); const target = this.get("model.targets").find((t) => t.name === name);
this.set("currentTarget", target && target.id); this.set("currentTarget", target && target.id);
}, },
@discourseComputed("currentTarget") @discourseComputed("currentTarget")
currentTargetName(id) { currentTargetName(id) {
const target = this.get("model.targets").find( const target = this.get("model.targets").find(
t => t.id === parseInt(id, 10) (t) => t.id === parseInt(id, 10)
); );
return target && target.name; return target && target.name;
}, },
@ -50,9 +50,9 @@ export default Controller.extend({
onlyOverriddenChanged(onlyShowOverridden) { onlyOverriddenChanged(onlyShowOverridden) {
if (onlyShowOverridden) { if (onlyShowOverridden) {
if (!this.model.hasEdited(this.currentTargetName, this.fieldName)) { if (!this.model.hasEdited(this.currentTargetName, this.fieldName)) {
let firstTarget = this.get("model.targets").find(t => t.edited); let firstTarget = this.get("model.targets").find((t) => t.edited);
let firstField = this.get(`model.fields.${firstTarget.name}`).find( let firstField = this.get(`model.fields.${firstTarget.name}`).find(
f => f.edited (f) => f.edited
); );
this.replaceRoute( this.replaceRoute(
@ -63,6 +63,6 @@ export default Controller.extend({
); );
} }
} }
} },
} },
}); });

View File

@ -5,7 +5,7 @@ import {
filterBy, filterBy,
match, match,
mapBy, mapBy,
notEmpty notEmpty,
} from "@ember/object/computed"; } from "@ember/object/computed";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
@ -38,14 +38,14 @@ export default Controller.extend({
@discourseComputed("model.editedFields") @discourseComputed("model.editedFields")
editedFieldsFormatted() { editedFieldsFormatted() {
const descriptions = []; const descriptions = [];
["common", "desktop", "mobile"].forEach(target => { ["common", "desktop", "mobile"].forEach((target) => {
const fields = this.editedFieldsForTarget(target); const fields = this.editedFieldsForTarget(target);
if (fields.length < 1) { if (fields.length < 1) {
return; return;
} }
let resultString = I18n.t("admin.customize.theme." + target); let resultString = I18n.t("admin.customize.theme." + target);
const formattedFields = fields const formattedFields = fields
.map(f => I18n.t("admin.customize.theme." + f.name + ".text")) .map((f) => I18n.t("admin.customize.theme." + f.name + ".text"))
.join(" , "); .join(" , ");
resultString += `: ${formattedFields}`; resultString += `: ${formattedFields}`;
descriptions.push(resultString); descriptions.push(resultString);
@ -64,7 +64,7 @@ export default Controller.extend({
if (available) { if (available) {
const themes = !childThemes const themes = !childThemes
? available ? available
: available.filter(theme => childThemes.indexOf(theme) === -1); : available.filter((theme) => childThemes.indexOf(theme) === -1);
return themes.length === 0 ? null : themes; return themes.length === 0 ? null : themes;
} }
}, },
@ -83,7 +83,7 @@ export default Controller.extend({
value: this.parentThemesNames.join("|"), value: this.parentThemesNames.join("|"),
defaultValues: this.availableActiveThemesNames.join("|"), defaultValues: this.availableActiveThemesNames.join("|"),
allThemes: this.allThemes, allThemes: this.allThemes,
setDefaultValuesLabel: I18n.t("admin.customize.theme.add_all_themes") setDefaultValuesLabel: I18n.t("admin.customize.theme.add_all_themes"),
}); });
}, },
@ -101,7 +101,7 @@ export default Controller.extend({
value: this.childThemesNames.join("|"), value: this.childThemesNames.join("|"),
defaultValues: this.availableActiveComponentsNames.join("|"), defaultValues: this.availableActiveComponentsNames.join("|"),
allThemes: this.allThemes, allThemes: this.allThemes,
setDefaultValuesLabel: I18n.t("admin.customize.theme.add_all") setDefaultValuesLabel: I18n.t("admin.customize.theme.add_all"),
}); });
}, },
@ -110,7 +110,7 @@ export default Controller.extend({
if (!this.get("model.component")) { if (!this.get("model.component")) {
const themeId = this.get("model.id"); const themeId = this.get("model.id");
return allThemes.filter( return allThemes.filter(
theme => theme.get("id") !== themeId && theme.get("component") (theme) => theme.get("id") !== themeId && theme.get("component")
); );
} }
}, },
@ -134,14 +134,14 @@ export default Controller.extend({
@discourseComputed("model.settings") @discourseComputed("model.settings")
settings(settings) { settings(settings) {
return settings.map(setting => ThemeSettings.create(setting)); return settings.map((setting) => ThemeSettings.create(setting));
}, },
hasSettings: notEmpty("settings"), hasSettings: notEmpty("settings"),
@discourseComputed("model.translations") @discourseComputed("model.translations")
translations(translations) { translations(translations) {
return translations.map(setting => ThemeSettings.create(setting)); return translations.map((setting) => ThemeSettings.create(setting));
}, },
hasTranslations: notEmpty("translations"), hasTranslations: notEmpty("translations"),
@ -153,7 +153,7 @@ export default Controller.extend({
editedFieldsForTarget(target) { editedFieldsForTarget(target) {
return this.get("model.editedFields").filter( return this.get("model.editedFields").filter(
field => field.target === target (field) => field.target === target
); );
}, },
@ -178,10 +178,10 @@ export default Controller.extend({
color_scheme_id: null, color_scheme_id: null,
user_selectable: false, user_selectable: false,
child_themes: [], child_themes: [],
childThemes: [] childThemes: [],
}); });
this.get("parentController.model.content").forEach(theme => { this.get("parentController.model.content").forEach((theme) => {
const children = makeArray(theme.get("childThemes")); const children = makeArray(theme.get("childThemes"));
const rawChildren = makeArray(theme.get("child_themes")); const rawChildren = makeArray(theme.get("child_themes"));
const index = children ? children.indexOf(model) : -1; const index = children ? children.indexOf(model) : -1;
@ -190,7 +190,7 @@ export default Controller.extend({
rawChildren.splice(index, 1); rawChildren.splice(index, 1);
theme.setProperties({ theme.setProperties({
childThemes: children, childThemes: children,
child_themes: rawChildren child_themes: rawChildren,
}); });
} }
}); });
@ -245,7 +245,7 @@ export default Controller.extend({
addUpload(info) { addUpload(info) {
let model = this.model; let model = this.model;
model.setField("common", info.name, "", info.upload_id, THEME_UPLOAD_VAR); model.setField("common", info.name, "", info.upload_id, THEME_UPLOAD_VAR);
model.saveChanges("theme_fields").catch(e => popupAjaxError(e)); model.saveChanges("theme_fields").catch((e) => popupAjaxError(e));
}, },
cancelChangeScheme() { cancelChangeScheme() {
@ -276,7 +276,7 @@ export default Controller.extend({
if (this.get("model.remote_theme.is_git")) { if (this.get("model.remote_theme.is_git")) {
bootbox.confirm( bootbox.confirm(
I18n.t("admin.customize.theme.edit_confirm"), I18n.t("admin.customize.theme.edit_confirm"),
result => { (result) => {
if (result) { if (result) {
this.transitionToEditRoute(); this.transitionToEditRoute();
} }
@ -291,7 +291,7 @@ export default Controller.extend({
const model = this.model; const model = this.model;
model.saveChanges("default").then(() => { model.saveChanges("default").then(() => {
if (model.get("default")) { if (model.get("default")) {
this.allThemes.forEach(theme => { this.allThemes.forEach((theme) => {
if (theme !== model && theme.get("default")) { if (theme !== model && theme.get("default")) {
theme.set("default", false); theme.set("default", false);
} }
@ -315,7 +315,7 @@ export default Controller.extend({
I18n.t("admin.customize.theme.delete_upload_confirm"), I18n.t("admin.customize.theme.delete_upload_confirm"),
I18n.t("no_value"), I18n.t("no_value"),
I18n.t("yes_value"), I18n.t("yes_value"),
result => { (result) => {
if (result) { if (result) {
this.model.removeField(upload); this.model.removeField(upload);
} }
@ -332,11 +332,11 @@ export default Controller.extend({
destroy() { destroy() {
return bootbox.confirm( return bootbox.confirm(
I18n.t("admin.customize.delete_confirm", { I18n.t("admin.customize.delete_confirm", {
theme_name: this.get("model.name") theme_name: this.get("model.name"),
}), }),
I18n.t("no_value"), I18n.t("no_value"),
I18n.t("yes_value"), I18n.t("yes_value"),
result => { (result) => {
if (result) { if (result) {
const model = this.model; const model = this.model;
model.setProperties({ recentlyInstalled: false }); model.setProperties({ recentlyInstalled: false });
@ -354,14 +354,14 @@ export default Controller.extend({
? this.parentThemes ? this.parentThemes
: this.get("model.childThemes"); : this.get("model.childThemes");
if (relatives && relatives.length > 0) { if (relatives && relatives.length > 0) {
const names = relatives.map(relative => relative.get("name")); const names = relatives.map((relative) => relative.get("name"));
bootbox.confirm( bootbox.confirm(
I18n.t(`${this.convertKey}_alert`, { I18n.t(`${this.convertKey}_alert`, {
relatives: names.join(", ") relatives: names.join(", "),
}), }),
I18n.t("no_value"), I18n.t("no_value"),
I18n.t("yes_value"), I18n.t("yes_value"),
result => { (result) => {
if (result) { if (result) {
this.commitSwitchType(); this.commitSwitchType();
} }
@ -384,6 +384,6 @@ export default Controller.extend({
this.model this.model
.saveChanges("enabled") .saveChanges("enabled")
.catch(() => this.model.set("enabled", true)); .catch(() => this.model.set("enabled", true));
} },
} },
}); });

View File

@ -7,16 +7,16 @@ export default Controller.extend({
@discourseComputed("model", "model.@each.component") @discourseComputed("model", "model.@each.component")
fullThemes(themes) { fullThemes(themes) {
return themes.filter(t => !t.get("component")); return themes.filter((t) => !t.get("component"));
}, },
@discourseComputed("model", "model.@each.component") @discourseComputed("model", "model.@each.component")
childThemes(themes) { childThemes(themes) {
return themes.filter(t => t.get("component")); return themes.filter((t) => t.get("component"));
}, },
@discourseComputed("model", "model.@each.component") @discourseComputed("model", "model.@each.component")
installedThemes(themes) { installedThemes(themes) {
return themes.map(t => t.name); return themes.map((t) => t.name);
} },
}); });

View File

@ -11,8 +11,8 @@ import { computed } from "@ember/object";
import getURL from "discourse-common/lib/get-url"; import getURL from "discourse-common/lib/get-url";
function staticReport(reportType) { function staticReport(reportType) {
return computed("reports.[]", function() { return computed("reports.[]", function () {
return makeArray(this.reports).find(report => report.type === reportType); return makeArray(this.reports).find((report) => report.type === reportType);
}); });
} }
@ -27,7 +27,7 @@ export default Controller.extend(PeriodComputationMixin, {
return (metrics || "").split("|").filter(Boolean); return (metrics || "").split("|").filter(Boolean);
}, },
hiddenReports: computed("siteSettings.dashboard_hidden_reports", function() { hiddenReports: computed("siteSettings.dashboard_hidden_reports", function () {
return (this.siteSettings.dashboard_hidden_reports || "") return (this.siteSettings.dashboard_hidden_reports || "")
.split("|") .split("|")
.filter(Boolean); .filter(Boolean);
@ -36,21 +36,21 @@ export default Controller.extend(PeriodComputationMixin, {
isActivityMetricsVisible: computed( isActivityMetricsVisible: computed(
"activityMetrics", "activityMetrics",
"hiddenReports", "hiddenReports",
function() { function () {
return ( return (
this.activityMetrics.length && this.activityMetrics.length &&
this.activityMetrics.some(x => !this.hiddenReports.includes(x)) this.activityMetrics.some((x) => !this.hiddenReports.includes(x))
); );
} }
), ),
isSearchReportsVisible: computed("hiddenReports", function() { isSearchReportsVisible: computed("hiddenReports", function () {
return ["top_referred_topics", "trending_search"].some( return ["top_referred_topics", "trending_search"].some(
x => !this.hiddenReports.includes(x) (x) => !this.hiddenReports.includes(x)
); );
}), }),
isCommunityHealthVisible: computed("hiddenReports", function() { isCommunityHealthVisible: computed("hiddenReports", function () {
return [ return [
"consolidated_page_views", "consolidated_page_views",
"signups", "signups",
@ -58,56 +58,52 @@ export default Controller.extend(PeriodComputationMixin, {
"posts", "posts",
"dau_by_mau", "dau_by_mau",
"daily_engaged_users", "daily_engaged_users",
"new_contributors" "new_contributors",
].some(x => !this.hiddenReports.includes(x)); ].some((x) => !this.hiddenReports.includes(x));
}), }),
@discourseComputed @discourseComputed
activityMetricsFilters() { activityMetricsFilters() {
return { return {
startDate: this.lastMonth, startDate: this.lastMonth,
endDate: this.today endDate: this.today,
}; };
}, },
@discourseComputed @discourseComputed
topReferredTopicsOptions() { topReferredTopicsOptions() {
return { return {
table: { total: false, limit: 8 } table: { total: false, limit: 8 },
}; };
}, },
@discourseComputed @discourseComputed
topReferredTopicsFilters() { topReferredTopicsFilters() {
return { return {
startDate: moment() startDate: moment().subtract(6, "days").startOf("day"),
.subtract(6, "days") endDate: this.today,
.startOf("day"),
endDate: this.today
}; };
}, },
@discourseComputed @discourseComputed
trendingSearchFilters() { trendingSearchFilters() {
return { return {
startDate: moment() startDate: moment().subtract(1, "month").startOf("day"),
.subtract(1, "month") endDate: this.today,
.startOf("day"),
endDate: this.today
}; };
}, },
@discourseComputed @discourseComputed
trendingSearchOptions() { trendingSearchOptions() {
return { return {
table: { total: false, limit: 8 } table: { total: false, limit: 8 },
}; };
}, },
@discourseComputed @discourseComputed
trendingSearchDisabledLabel() { trendingSearchDisabledLabel() {
return I18n.t("admin.dashboard.reports.trending_search.disabled", { return I18n.t("admin.dashboard.reports.trending_search.disabled", {
basePath: getURL("") basePath: getURL(""),
}); });
}, },
@ -120,23 +116,21 @@ export default Controller.extend(PeriodComputationMixin, {
if ( if (
!this.dashboardFetchedAt || !this.dashboardFetchedAt ||
moment() moment().subtract(30, "minutes").toDate() > this.dashboardFetchedAt
.subtract(30, "minutes")
.toDate() > this.dashboardFetchedAt
) { ) {
this.set("isLoading", true); this.set("isLoading", true);
AdminDashboard.fetchGeneral() AdminDashboard.fetchGeneral()
.then(adminDashboardModel => { .then((adminDashboardModel) => {
this.setProperties({ this.setProperties({
dashboardFetchedAt: new Date(), dashboardFetchedAt: new Date(),
model: adminDashboardModel, model: adminDashboardModel,
reports: makeArray(adminDashboardModel.reports).map(x => reports: makeArray(adminDashboardModel.reports).map((x) =>
Report.create(x) Report.create(x)
) ),
}); });
}) })
.catch(e => { .catch((e) => {
this.exceptionController.set("thrown", e.jqXHR); this.exceptionController.set("thrown", e.jqXHR);
this.replaceRoute("exception"); this.replaceRoute("exception");
}) })
@ -151,5 +145,5 @@ export default Controller.extend(PeriodComputationMixin, {
_reportsForPeriodURL(period) { _reportsForPeriodURL(period) {
return getURL(`/admin?period=${period}`); return getURL(`/admin?period=${period}`);
} },
}); });

Some files were not shown because too many files have changed in this diff Show More