Deprecations fixes
This commit is contained in:
parent
7d50fbbdae
commit
86a3d16ad4
|
@ -1,19 +1,11 @@
|
||||||
var ColumnHandlers = [];
|
|
||||||
var AssistedHandlers = {};
|
|
||||||
const Escape = Handlebars.Utils.escapeExpression;
|
|
||||||
|
|
||||||
import avatarTemplate from 'discourse/lib/avatar-template';
|
|
||||||
import { categoryLinkHTML } from 'discourse/helpers/category-link';
|
|
||||||
import Badge from 'discourse/models/badge';
|
import Badge from 'discourse/models/badge';
|
||||||
|
|
||||||
var defaultFallback = function(buffer, content, defaultRender) { defaultRender(buffer, content); };
|
|
||||||
|
|
||||||
function isoYMD(date) {
|
|
||||||
return date.getUTCFullYear() + "-" + date.getUTCMonth() + "-" + date.getUTCDate();
|
|
||||||
}
|
|
||||||
function randomIdShort() {
|
function randomIdShort() {
|
||||||
return 'xxxxxxxx'.replace(/[xy]/g, function() {
|
return 'xxxxxxxx'.replace(/[xy]/g, function() {
|
||||||
|
/*eslint-disable*/
|
||||||
return (Math.random() * 16 | 0).toString(16);
|
return (Math.random() * 16 | 0).toString(16);
|
||||||
|
/*eslint-enable*/
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,12 +50,10 @@ const QueryResultComponent = Ember.Component.extend({
|
||||||
}.property('params.@each'),
|
}.property('params.@each'),
|
||||||
|
|
||||||
columnDispNames: function() {
|
columnDispNames: function() {
|
||||||
const templates = this.get('columnTemplates');
|
|
||||||
const self = this;
|
|
||||||
if (!this.get('columns')) {
|
if (!this.get('columns')) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return this.get('columns').map(function(colName, idx) {
|
return this.get('columns').map(function(colName) {
|
||||||
if (colName.endsWith("_id")) {
|
if (colName.endsWith("_id")) {
|
||||||
return colName.slice(0, -3);
|
return colName.slice(0, -3);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +115,7 @@ const QueryResultComponent = Ember.Component.extend({
|
||||||
let windowName = randomIdShort();
|
let windowName = randomIdShort();
|
||||||
const newWindowContents = "<style>body{font-size:36px;display:flex;justify-content:center;align-items:center;}</style><body>Click anywhere to close this window once the download finishes.<script>window.onclick=function(){window.close()};</script>";
|
const newWindowContents = "<style>body{font-size:36px;display:flex;justify-content:center;align-items:center;}</style><body>Click anywhere to close this window once the download finishes.<script>window.onclick=function(){window.close()};</script>";
|
||||||
|
|
||||||
const _ = window.open('data:text/html;base64,' + btoa(newWindowContents), windowName);
|
window.open('data:text/html;base64,' + btoa(newWindowContents), windowName);
|
||||||
|
|
||||||
let form = document.createElement("form");
|
let form = document.createElement("form");
|
||||||
form.setAttribute('id', 'query-download-result');
|
form.setAttribute('id', 'query-download-result');
|
||||||
|
@ -134,7 +124,7 @@ const QueryResultComponent = Ember.Component.extend({
|
||||||
form.setAttribute('target', windowName);
|
form.setAttribute('target', windowName);
|
||||||
form.setAttribute('style', 'display:none;');
|
form.setAttribute('style', 'display:none;');
|
||||||
|
|
||||||
function addInput(form, name, value) {
|
function addInput(name, value) {
|
||||||
let field;
|
let field;
|
||||||
field = document.createElement('input');
|
field = document.createElement('input');
|
||||||
field.setAttribute('name', name);
|
field.setAttribute('name', name);
|
||||||
|
@ -142,12 +132,12 @@ const QueryResultComponent = Ember.Component.extend({
|
||||||
form.appendChild(field);
|
form.appendChild(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
addInput(form, 'params', JSON.stringify(this.get('params')));
|
addInput('params', JSON.stringify(this.get('params')));
|
||||||
addInput(form, 'explain', this.get('hasExplain'));
|
addInput('explain', this.get('hasExplain'));
|
||||||
addInput(form, 'limit', '1000000');
|
addInput('limit', '1000000');
|
||||||
|
|
||||||
Discourse.ajax('/session/csrf.json').then(function(csrf) {
|
Discourse.ajax('/session/csrf.json').then(function(csrf) {
|
||||||
addInput(form, 'authenticity_token', csrf.csrf);
|
addInput('authenticity_token', csrf.csrf);
|
||||||
|
|
||||||
document.body.appendChild(form);
|
document.body.appendChild(form);
|
||||||
form.submit();
|
form.submit();
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import binarySearch from 'discourse/plugins/discourse-data-explorer/discourse/lib/binary-search';
|
|
||||||
import avatarTemplate from 'discourse/lib/avatar-template';
|
|
||||||
|
|
||||||
function icon_or_image_replacement(str, ctx) {
|
function icon_or_image_replacement(str, ctx) {
|
||||||
str = Ember.get(ctx.contexts[0], str);
|
str = Ember.get(ctx.contexts[0], str);
|
||||||
|
@ -12,14 +10,11 @@ function icon_or_image_replacement(str, ctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function shorthandTinyAvatar(username, uploadId, ctx) {
|
function shorthandTinyAvatar(avatar_template, ctx) {
|
||||||
username = Ember.get(ctx.contexts[0], username);
|
|
||||||
uploadId = Ember.get(ctx.contexts[0], uploadId);
|
|
||||||
return new Handlebars.SafeString(Discourse.Utilities.avatarImg({
|
return new Handlebars.SafeString(Discourse.Utilities.avatarImg({
|
||||||
size: "tiny",
|
size: "tiny",
|
||||||
extraClasses: '',
|
extraClasses: '',
|
||||||
title: username,
|
avatarTemplate: avatar_template
|
||||||
avatarTemplate: avatarTemplate(username, uploadId)
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,14 +23,9 @@ const esc = Handlebars.Utils.escapeExpression;
|
||||||
const QueryRowContentComponent = Ember.Component.extend({
|
const QueryRowContentComponent = Ember.Component.extend({
|
||||||
tagName: "tr",
|
tagName: "tr",
|
||||||
|
|
||||||
transformedUserTable: function() {
|
|
||||||
return transformedRelTable(this.get('extra.relations.user'));
|
|
||||||
}.property('extra.relations.user'),
|
|
||||||
|
|
||||||
render: function(buffer) {
|
render: function(buffer) {
|
||||||
const self = this;
|
const self = this;
|
||||||
const row = this.get('row');
|
const row = this.get('row');
|
||||||
const relations = this.get('extra.relations');
|
|
||||||
const parent = self.get('parent');
|
const parent = self.get('parent');
|
||||||
|
|
||||||
const parts = this.get('columnTemplates').map(function(t, idx) {
|
const parts = this.get('columnTemplates').map(function(t, idx) {
|
||||||
|
|
|
@ -45,12 +45,12 @@ after_initialize do
|
||||||
|
|
||||||
class SmallPostWithExcerptSerializer < ApplicationSerializer
|
class SmallPostWithExcerptSerializer < ApplicationSerializer
|
||||||
attributes :id, :topic_id, :post_number, :excerpt
|
attributes :id, :topic_id, :post_number, :excerpt
|
||||||
attributes :username, :uploaded_avatar_id
|
attributes :username, :avatar_template
|
||||||
def excerpt
|
def excerpt
|
||||||
Post.excerpt(object.cooked, 70)
|
Post.excerpt(object.cooked, 70)
|
||||||
end
|
end
|
||||||
def username; object.user.username; end
|
def username; object.user.username; end
|
||||||
def uploaded_avatar_id; object.user.uploaded_avatar_id; end
|
def uploaded_avatar_id; object.user.avatar_template; end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Run a data explorer query on the currently connected database.
|
# Run a data explorer query on the currently connected database.
|
||||||
|
|
Loading…
Reference in New Issue