DEV: apply coding standards (#66)
This commit is contained in:
@@ -34,7 +34,7 @@ export default Ember.Component.extend({
|
||||
|
||||
this.set("grippie", $grippie);
|
||||
|
||||
const mousemove = e => {
|
||||
const mousemove = (e) => {
|
||||
const diffY = this.startY - e.screenY;
|
||||
const diffX = this.startX - e.screenX;
|
||||
|
||||
@@ -47,7 +47,7 @@ export default Ember.Component.extend({
|
||||
this.appEvents.trigger("ace:resize");
|
||||
};
|
||||
|
||||
const throttledMousemove = (event => {
|
||||
const throttledMousemove = ((event) => {
|
||||
event.preventDefault();
|
||||
Ember.run.throttle(this, mousemove, event, 20);
|
||||
}).bind(this);
|
||||
@@ -59,16 +59,16 @@ export default Ember.Component.extend({
|
||||
startY: null,
|
||||
startX: null,
|
||||
startHeight: null,
|
||||
startWidth: null
|
||||
startWidth: null,
|
||||
});
|
||||
}).bind(this);
|
||||
|
||||
$grippie.on("mousedown", e => {
|
||||
$grippie.on("mousedown", (e) => {
|
||||
this.setProperties({
|
||||
startY: e.screenY,
|
||||
startX: e.screenX,
|
||||
startHeight: $target.height(),
|
||||
startWidth: $target.width()
|
||||
startWidth: $target.width(),
|
||||
});
|
||||
|
||||
$document.on("mousemove", throttledMousemove);
|
||||
@@ -90,5 +90,5 @@ export default Ember.Component.extend({
|
||||
this.grippie && this.grippie.off("mousedown");
|
||||
this.set("grippie", null);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -13,5 +13,5 @@ export default Ember.Component.extend({
|
||||
result.push({ value: key, name: hash[key] });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ export default Ember.Component.extend({
|
||||
_bindClicks() {
|
||||
$(this.element)
|
||||
.find(".schema-table-name")
|
||||
.click(e => {
|
||||
.click((e) => {
|
||||
this.set("table.open", !this.table.open);
|
||||
e.preventDefault();
|
||||
});
|
||||
@@ -18,8 +18,6 @@ export default Ember.Component.extend({
|
||||
|
||||
@on("willDestroyElement")
|
||||
_cleanup() {
|
||||
$(this.element)
|
||||
.find(".schema-table-name")
|
||||
.off("click");
|
||||
}
|
||||
$(this.element).find(".schema-table-name").off("click");
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
default as computed,
|
||||
observes
|
||||
observes,
|
||||
} from "discourse-common/utils/decorators";
|
||||
import debounce from "discourse/lib/debounce";
|
||||
|
||||
@@ -8,7 +8,7 @@ export default Ember.Component.extend({
|
||||
actions: {
|
||||
collapseSchema() {
|
||||
this.set("hideSchema", true);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@computed("schema")
|
||||
@@ -18,7 +18,7 @@ export default Ember.Component.extend({
|
||||
continue;
|
||||
}
|
||||
|
||||
schema[key].forEach(col => {
|
||||
schema[key].forEach((col) => {
|
||||
const notes_components = [];
|
||||
if (col.primary) {
|
||||
notes_components.push("primary key");
|
||||
@@ -71,7 +71,7 @@ export default Ember.Component.extend({
|
||||
tables.push({
|
||||
name: key,
|
||||
columns: schema[key],
|
||||
open: false
|
||||
open: false,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
@@ -81,19 +81,19 @@ export default Ember.Component.extend({
|
||||
tables.unshift({
|
||||
name: key,
|
||||
columns: schema[key],
|
||||
open: haveFilter
|
||||
open: haveFilter,
|
||||
});
|
||||
} else if (filter.test(key)) {
|
||||
// whole table matches
|
||||
tables.push({
|
||||
name: key,
|
||||
columns: schema[key],
|
||||
open: haveFilter
|
||||
open: haveFilter,
|
||||
});
|
||||
} else {
|
||||
// filter the columns
|
||||
let filterCols = [];
|
||||
schema[key].forEach(col => {
|
||||
schema[key].forEach((col) => {
|
||||
if (filter.source === col.column_name) {
|
||||
filterCols.unshift(col);
|
||||
} else if (filter.test(col.column_name)) {
|
||||
@@ -104,7 +104,7 @@ export default Ember.Component.extend({
|
||||
tables.push({
|
||||
name: key,
|
||||
columns: filterCols,
|
||||
open: haveFilter
|
||||
open: haveFilter,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ export default Ember.Component.extend({
|
||||
},
|
||||
|
||||
@observes("filter")
|
||||
triggerFilter: debounce(function() {
|
||||
triggerFilter: debounce(function () {
|
||||
this.set("filteredTables", this.filterTables(this.transformedSchema));
|
||||
this.set("loading", false);
|
||||
}, 500),
|
||||
@@ -128,5 +128,5 @@ export default Ember.Component.extend({
|
||||
|
||||
this.set("loading", true);
|
||||
this.triggerFilter();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ export default Ember.Component.extend({
|
||||
showReportsTab: false,
|
||||
|
||||
checkForReports() {
|
||||
return ajax(`/g/${this.group.name}/reports`).then(response => {
|
||||
return ajax(`/g/${this.group.name}/reports`).then((response) => {
|
||||
return this.set("showReportsTab", response.queries.length > 0);
|
||||
});
|
||||
},
|
||||
@@ -13,12 +13,12 @@ export default Ember.Component.extend({
|
||||
init(args) {
|
||||
this.set("group", args.group);
|
||||
if (
|
||||
(this.get("currentUser.groups") || []).some(g => g.id === this.group.id)
|
||||
(this.get("currentUser.groups") || []).some((g) => g.id === this.group.id)
|
||||
) {
|
||||
// User is a part of the group. Now check if the group has reports
|
||||
this.checkForReports();
|
||||
}
|
||||
|
||||
this._super(args);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
default as computed,
|
||||
on,
|
||||
observes
|
||||
observes,
|
||||
} from "discourse-common/utils/decorators";
|
||||
|
||||
export default Ember.Component.extend({
|
||||
@@ -20,21 +20,21 @@ export default Ember.Component.extend({
|
||||
|
||||
$(fileInput).on("change", () => this.fileSelected(fileInput.files));
|
||||
|
||||
$this.on("dragover", e => {
|
||||
$this.on("dragover", (e) => {
|
||||
if (e.preventDefault) e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
$this.on("dragenter", e => {
|
||||
$this.on("dragenter", (e) => {
|
||||
if (e.preventDefault) e.preventDefault();
|
||||
this.set("hover", this.hover + 1);
|
||||
return false;
|
||||
});
|
||||
$this.on("dragleave", e => {
|
||||
$this.on("dragleave", (e) => {
|
||||
if (e.preventDefault) e.preventDefault();
|
||||
this.set("hover", this.hover - 1);
|
||||
return false;
|
||||
});
|
||||
$this.on("drop", e => {
|
||||
$this.on("drop", (e) => {
|
||||
if (e.preventDefault) e.preventDefault();
|
||||
|
||||
this.set("hover", 0);
|
||||
@@ -73,7 +73,7 @@ export default Ember.Component.extend({
|
||||
actions: {
|
||||
selectFile() {
|
||||
$(this.fileInput).click();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
fileSelected(fileList) {
|
||||
@@ -82,7 +82,7 @@ export default Ember.Component.extend({
|
||||
files[i] = fileList[i];
|
||||
}
|
||||
const fileNameRegex = /\.(json|txt)$/;
|
||||
files = files.filter(file => {
|
||||
files = files.filter((file) => {
|
||||
if (fileNameRegex.test(file.name)) {
|
||||
return true;
|
||||
}
|
||||
@@ -96,10 +96,10 @@ export default Ember.Component.extend({
|
||||
this.set("loading", true);
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = evt => {
|
||||
reader.onload = (evt) => {
|
||||
this.setProperties({ value: evt.target.result, loading: false });
|
||||
};
|
||||
|
||||
reader.readAsText(firstFile);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import I18n from "I18n";
|
||||
import { default as computed } from "discourse-common/utils/decorators";
|
||||
// import Category from 'discourse/models/category';
|
||||
|
||||
@@ -20,7 +21,7 @@ const layoutMap = {
|
||||
badge_id: "generic",
|
||||
int_list: "generic",
|
||||
string_list: "generic",
|
||||
user_list: "user_list"
|
||||
user_list: "user_list",
|
||||
};
|
||||
|
||||
function allowsInputTypeTime() {
|
||||
@@ -40,7 +41,7 @@ export default Ember.Component.extend({
|
||||
boolTypes: [
|
||||
{ name: I18n.t("explorer.types.bool.true"), id: "Y" },
|
||||
{ name: I18n.t("explorer.types.bool.false"), id: "N" },
|
||||
{ name: I18n.t("explorer.types.bool.null_"), id: "#null" }
|
||||
{ name: I18n.t("explorer.types.bool.null_"), id: "#null" },
|
||||
],
|
||||
|
||||
value: Ember.computed("params", "info.identifier", {
|
||||
@@ -50,7 +51,7 @@ export default Ember.Component.extend({
|
||||
set(key, value) {
|
||||
this.params[this.get("info.identifier")] = value.toString();
|
||||
return value;
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
valueBool: Ember.computed("params", "info.identifier", {
|
||||
@@ -61,7 +62,7 @@ export default Ember.Component.extend({
|
||||
value = !!value;
|
||||
this.params[this.get("info.identifier")] = value.toString();
|
||||
return value;
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
@computed("value", "info.type", "info.nullable")
|
||||
@@ -88,7 +89,7 @@ export default Ember.Component.extend({
|
||||
/^(-?)NaN$/i.test(value)
|
||||
);
|
||||
case "int_list":
|
||||
return value.split(",").every(i => /^(-?\d+|null)$/.test(i.trim()));
|
||||
return value.split(",").every((i) => /^(-?\d+|null)$/.test(i.trim()));
|
||||
case "post_id":
|
||||
return isPositiveInt || /\d+\/\d+(\?u=.*)?$/.test(value);
|
||||
case "category_id":
|
||||
@@ -97,7 +98,7 @@ export default Ember.Component.extend({
|
||||
}
|
||||
|
||||
if (isPositiveInt) {
|
||||
return !!this.site.categories.find(c => c.id === intVal);
|
||||
return !!this.site.categories.find((c) => c.id === intVal);
|
||||
} else if (/\//.test(value)) {
|
||||
const match = /(.*)\/(.*)/.exec(value);
|
||||
if (!match) return false;
|
||||
@@ -112,9 +113,9 @@ export default Ember.Component.extend({
|
||||
case "group_id":
|
||||
const groups = this.site.get("groups");
|
||||
if (isPositiveInt) {
|
||||
return !!groups.find(g => g.id === intVal);
|
||||
return !!groups.find((g) => g.id === intVal);
|
||||
} else {
|
||||
return !!groups.find(g => g.name === value);
|
||||
return !!groups.find((g) => g.name === value);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -134,5 +135,5 @@ export default Ember.Component.extend({
|
||||
@computed("layoutType")
|
||||
layoutName(layoutType) {
|
||||
return `admin/components/q-params/${layoutType}`;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import I18n from "I18n";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import getURL from "discourse-common/lib/get-url";
|
||||
import Badge from "discourse/models/badge";
|
||||
@@ -13,7 +14,7 @@ function randomIdShort() {
|
||||
|
||||
function transformedRelTable(table, modelClass) {
|
||||
const result = {};
|
||||
table.forEach(item => {
|
||||
table.forEach((item) => {
|
||||
if (modelClass) {
|
||||
result[item.id] = modelClass.create(item);
|
||||
} else {
|
||||
@@ -62,7 +63,7 @@ const QueryResultComponent = Ember.Component.extend({
|
||||
@computed("content.duration")
|
||||
duration(contentDuration) {
|
||||
return I18n.t("explorer.run_time", {
|
||||
value: I18n.toNumber(contentDuration, { precision: 1 })
|
||||
value: I18n.toNumber(contentDuration, { precision: 1 }),
|
||||
});
|
||||
},
|
||||
|
||||
@@ -82,7 +83,7 @@ const QueryResultComponent = Ember.Component.extend({
|
||||
if (!columns) {
|
||||
return [];
|
||||
}
|
||||
return columns.map(colName => {
|
||||
return columns.map((colName) => {
|
||||
if (colName.endsWith("_id")) {
|
||||
return colName.slice(0, -3);
|
||||
}
|
||||
@@ -201,7 +202,7 @@ const QueryResultComponent = Ember.Component.extend({
|
||||
addInput("explain", this.hasExplain);
|
||||
addInput("limit", "1000000");
|
||||
|
||||
ajax("/session/csrf.json").then(csrf => {
|
||||
ajax("/session/csrf.json").then((csrf) => {
|
||||
addInput("authenticity_token", csrf.csrf);
|
||||
|
||||
document.body.appendChild(form);
|
||||
@@ -216,8 +217,8 @@ const QueryResultComponent = Ember.Component.extend({
|
||||
},
|
||||
downloadResultCsv() {
|
||||
this.downloadResult("csv");
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default QueryResultComponent;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import Handlebars from "handlebars";
|
||||
import { categoryLinkHTML } from "discourse/helpers/category-link";
|
||||
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
|
||||
import { iconHTML, convertIconClass } from "discourse-common/lib/icon-library";
|
||||
@@ -19,7 +20,7 @@ function icon_or_image_replacement(str, ctx) {
|
||||
function category_badge_replacement(str, ctx) {
|
||||
const category = Ember.get(ctx.contexts[0], str);
|
||||
return categoryLinkHTML(category, {
|
||||
allowUncategorized: true
|
||||
allowUncategorized: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -57,7 +58,7 @@ const QueryRowContentComponent = Ember.Component.extend({
|
||||
const helpers = {
|
||||
"icon-or-image": icon_or_image_replacement,
|
||||
"category-link": category_badge_replacement,
|
||||
reltime: bound_date_replacement
|
||||
reltime: bound_date_replacement,
|
||||
};
|
||||
|
||||
const parts = this.columnTemplates.map((t, idx) => {
|
||||
@@ -67,7 +68,7 @@ const QueryRowContentComponent = Ember.Component.extend({
|
||||
const ctx = {
|
||||
value,
|
||||
id,
|
||||
baseuri: Discourse.BaseUri === "/" ? "" : Discourse.BaseUri
|
||||
baseuri: Discourse.BaseUri === "/" ? "" : Discourse.BaseUri,
|
||||
};
|
||||
const params = {};
|
||||
|
||||
@@ -101,7 +102,7 @@ const QueryRowContentComponent = Ember.Component.extend({
|
||||
});
|
||||
|
||||
this.set("rowContents", `<td>${parts.join("</td><td>")}</td>`.htmlSafe());
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default QueryRowContentComponent;
|
||||
|
||||
@@ -61,17 +61,13 @@ export default Ember.Component.extend({
|
||||
open() {
|
||||
this.set("visible", true);
|
||||
window.setTimeout(
|
||||
() =>
|
||||
$(this.element)
|
||||
.find("input")
|
||||
.select()
|
||||
.focus(),
|
||||
() => $(this.element).find("input").select().focus(),
|
||||
160
|
||||
);
|
||||
},
|
||||
|
||||
close() {
|
||||
this.set("visible", false);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import {
|
||||
default as computed,
|
||||
observes
|
||||
observes,
|
||||
} from "discourse-common/utils/decorators";
|
||||
|
||||
const NoQuery = Query.create({ name: "No queries", fake: true, group_ids: [] });
|
||||
@@ -34,7 +34,7 @@ export default Ember.Controller.extend({
|
||||
filteredContent(search) {
|
||||
const regexp = new RegExp(search, "i");
|
||||
return this.sortedQueries.filter(
|
||||
result => regexp.test(result.name) || regexp.test(result.description)
|
||||
(result) => regexp.test(result.name) || regexp.test(result.description)
|
||||
);
|
||||
},
|
||||
|
||||
@@ -58,22 +58,23 @@ export default Ember.Controller.extend({
|
||||
@computed("selectedItem", "editing")
|
||||
selectedGroupNames() {
|
||||
const groupIds = this.selectedItem.group_ids || [];
|
||||
const groupNames = groupIds.map(id => {
|
||||
return this.groupOptions.find(groupOption => groupOption.id === id).name;
|
||||
const groupNames = groupIds.map((id) => {
|
||||
return this.groupOptions.find((groupOption) => groupOption.id === id)
|
||||
.name;
|
||||
});
|
||||
return groupNames.join(", ");
|
||||
},
|
||||
|
||||
@computed("groups")
|
||||
groupOptions(groups) {
|
||||
return groups.map(g => {
|
||||
return groups.map((g) => {
|
||||
return { id: g.id, name: g.name };
|
||||
});
|
||||
},
|
||||
|
||||
@computed("selectedItem", "selectedItem.dirty")
|
||||
othersDirty(selectedItem) {
|
||||
return !!this.model.find(q => q !== selectedItem && q.dirty);
|
||||
return !!this.model.find((q) => q !== selectedItem && q.dirty);
|
||||
},
|
||||
|
||||
@observes("editing")
|
||||
@@ -90,7 +91,7 @@ export default Ember.Controller.extend({
|
||||
this.setProperties({
|
||||
showResults: false,
|
||||
results: null,
|
||||
editing: true
|
||||
editing: true,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -106,7 +107,7 @@ export default Ember.Controller.extend({
|
||||
query.markNotDirty();
|
||||
this.set("editing", false);
|
||||
})
|
||||
.catch(x => {
|
||||
.catch((x) => {
|
||||
popupAjaxError(x);
|
||||
throw x;
|
||||
})
|
||||
@@ -149,7 +150,7 @@ export default Ember.Controller.extend({
|
||||
showResults: false,
|
||||
editDisabled: false,
|
||||
selectedQueryId: null,
|
||||
sortBy: ["last_run_at:desc"]
|
||||
sortBy: ["last_run_at:desc"],
|
||||
});
|
||||
this.send("refreshModel");
|
||||
this.transitionToRoute("adminPlugins.explorer");
|
||||
@@ -184,12 +185,12 @@ export default Ember.Controller.extend({
|
||||
this.setProperties({
|
||||
loading: true,
|
||||
showCreate: false,
|
||||
showRecentQueries: false
|
||||
showRecentQueries: false,
|
||||
});
|
||||
this.store
|
||||
.createRecord("query", { name })
|
||||
.save()
|
||||
.then(result => this.addCreatedRecord(result.target))
|
||||
.then((result) => this.addCreatedRecord(result.target))
|
||||
.catch(popupAjaxError)
|
||||
.finally(() => this.set("loading", false));
|
||||
},
|
||||
@@ -198,7 +199,7 @@ export default Ember.Controller.extend({
|
||||
this.set("loading", true);
|
||||
this.store
|
||||
.find("query", this.get("selectedItem.id"))
|
||||
.then(result => {
|
||||
.then((result) => {
|
||||
const query = this.get("selectedItem");
|
||||
query.setProperties(result.getProperties(Query.updatePropertyNames));
|
||||
if (!query.group_ids || !Array.isArray(query.group_ids))
|
||||
@@ -249,11 +250,11 @@ export default Ember.Controller.extend({
|
||||
type: "POST",
|
||||
data: {
|
||||
params: JSON.stringify(this.get("selectedItem.params")),
|
||||
explain: this.explain
|
||||
}
|
||||
explain: this.explain,
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(result => {
|
||||
.then((result) => {
|
||||
this.set("results", result);
|
||||
if (!result.success) {
|
||||
this.set("showResults", false);
|
||||
@@ -262,7 +263,7 @@ export default Ember.Controller.extend({
|
||||
|
||||
this.set("showResults", true);
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
this.set("showResults", false);
|
||||
if (err.jqXHR && err.jqXHR.status === 422 && err.jqXHR.responseJSON) {
|
||||
this.set("results", err.jqXHR.responseJSON);
|
||||
@@ -271,6 +272,6 @@ export default Ember.Controller.extend({
|
||||
}
|
||||
})
|
||||
.finally(() => this.set("loading", false));
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default Ember.Controller.extend({
|
||||
queries: Ember.computed.alias("model.queries")
|
||||
queries: Ember.computed.alias("model.queries"),
|
||||
});
|
||||
|
||||
@@ -15,10 +15,10 @@ export default Ember.Controller.extend({
|
||||
type: "POST",
|
||||
data: {
|
||||
params: JSON.stringify(this.model.params),
|
||||
explain: this.explain
|
||||
}
|
||||
explain: this.explain,
|
||||
},
|
||||
})
|
||||
.then(result => {
|
||||
.then((result) => {
|
||||
this.set("results", result);
|
||||
if (!result.success) {
|
||||
return;
|
||||
@@ -26,7 +26,7 @@ export default Ember.Controller.extend({
|
||||
|
||||
this.set("showResults", true);
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
if (err.jqXHR && err.jqXHR.status === 422 && err.jqXHR.responseJSON) {
|
||||
this.set("results", err.jqXHR.responseJSON);
|
||||
} else {
|
||||
@@ -34,6 +34,6 @@ export default Ember.Controller.extend({
|
||||
}
|
||||
})
|
||||
.finally(() => this.set("loading", false));
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||
this.store
|
||||
.createRecord("query", object)
|
||||
.save()
|
||||
.then(query => {
|
||||
.then((query) => {
|
||||
this.send("closeModal");
|
||||
this.set("loading", false);
|
||||
|
||||
@@ -38,6 +38,6 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||
parentController.addCreatedRecord(query.target);
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,5 +3,5 @@ export default {
|
||||
path: "/plugins",
|
||||
map() {
|
||||
this.route("explorer");
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2,8 +2,8 @@ export default {
|
||||
resource: "group",
|
||||
|
||||
map() {
|
||||
this.route("reports", function() {
|
||||
this.route("reports", function () {
|
||||
this.route("show", { path: "/:query_id" });
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ export default {
|
||||
|
||||
if (!String.prototype.endsWith) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
String.prototype.endsWith = function(searchString, position) {
|
||||
String.prototype.endsWith = function (searchString, position) {
|
||||
const subjectString = this.toString();
|
||||
if (position === undefined || position > subjectString.length) {
|
||||
position = subjectString.length;
|
||||
@@ -15,5 +15,5 @@ export default {
|
||||
return lastIndex !== -1 && lastIndex === position;
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
default as computed,
|
||||
on,
|
||||
observes
|
||||
observes,
|
||||
} from "discourse-common/utils/decorators";
|
||||
import getURL from "discourse-common/lib/get-url";
|
||||
import RestModel from "discourse/models/rest";
|
||||
@@ -39,7 +39,7 @@ const Query = RestModel.extend({
|
||||
const newParams = {};
|
||||
const oldParams = this.params;
|
||||
const paramInfo = this.param_info || [];
|
||||
paramInfo.forEach(pinfo => {
|
||||
paramInfo.forEach((pinfo) => {
|
||||
const name = pinfo.identifier;
|
||||
if (oldParams[pinfo.identifier]) {
|
||||
newParams[name] = oldParams[name];
|
||||
@@ -74,7 +74,7 @@ const Query = RestModel.extend({
|
||||
props.id = this.id;
|
||||
}
|
||||
return props;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Query.reopenClass({
|
||||
@@ -85,8 +85,8 @@ Query.reopenClass({
|
||||
"user_id",
|
||||
"created_at",
|
||||
"group_ids",
|
||||
"last_run_at"
|
||||
]
|
||||
"last_run_at",
|
||||
],
|
||||
});
|
||||
|
||||
export default Query;
|
||||
|
||||
@@ -7,23 +7,23 @@ export default DiscourseRoute.extend({
|
||||
model() {
|
||||
const groupPromise = ajax("/admin/plugins/explorer/groups.json");
|
||||
const schemaPromise = ajax("/admin/plugins/explorer/schema.json", {
|
||||
cache: true
|
||||
cache: true,
|
||||
});
|
||||
const queryPromise = this.store.findAll("query");
|
||||
|
||||
return groupPromise
|
||||
.then(groups => {
|
||||
.then((groups) => {
|
||||
let groupNames = {};
|
||||
groups.forEach(g => {
|
||||
groups.forEach((g) => {
|
||||
groupNames[g.id] = g.name;
|
||||
});
|
||||
return schemaPromise.then(schema => {
|
||||
return queryPromise.then(model => {
|
||||
model.forEach(query => {
|
||||
return schemaPromise.then((schema) => {
|
||||
return queryPromise.then((model) => {
|
||||
model.forEach((query) => {
|
||||
query.markNotDirty();
|
||||
query.set(
|
||||
"group_names",
|
||||
(query.group_ids || []).map(id => groupNames[id])
|
||||
(query.group_ids || []).map((id) => groupNames[id])
|
||||
);
|
||||
});
|
||||
return { model, schema, groups };
|
||||
@@ -45,6 +45,6 @@ export default DiscourseRoute.extend({
|
||||
refreshModel() {
|
||||
this.refresh();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -7,10 +7,10 @@ export default DiscourseRoute.extend({
|
||||
model() {
|
||||
const group = this.modelFor("group");
|
||||
return ajax(`/g/${group.name}/reports`)
|
||||
.then(queries => {
|
||||
.then((queries) => {
|
||||
return {
|
||||
model: queries,
|
||||
group
|
||||
group,
|
||||
};
|
||||
})
|
||||
.catch(() => this.transitionTo("group.members", group));
|
||||
@@ -33,6 +33,6 @@ export default DiscourseRoute.extend({
|
||||
refreshModel() {
|
||||
this.refresh();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@ export default DiscourseRoute.extend({
|
||||
model(params) {
|
||||
const group = this.modelFor("group");
|
||||
return ajax(`/g/${group.name}/reports/${params.query_id}`)
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
const queryParamInfo = response.query.param_info;
|
||||
const queryParams = queryParamInfo.reduce((acc, param) => {
|
||||
acc[param.identifier] = param.default;
|
||||
@@ -16,7 +16,7 @@ export default DiscourseRoute.extend({
|
||||
|
||||
return {
|
||||
model: Object.assign({ params: queryParams }, response.query),
|
||||
group
|
||||
group,
|
||||
};
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -32,6 +32,6 @@ export default DiscourseRoute.extend({
|
||||
refreshModel() {
|
||||
this.refresh();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user