2016-12-01 13:54:21 -05:00
|
|
|
{{#explorer-container hideSchema=hideSchema everEditing=everEditing}}
|
|
|
|
{{#if disallow}}
|
2018-09-04 14:53:12 -04:00
|
|
|
<h1>{{i18n "explorer.admins_only"}}</h1>
|
2016-12-01 13:54:21 -05:00
|
|
|
{{else}}
|
2018-08-19 06:58:24 -04:00
|
|
|
{{#unless selectedQueryId}}
|
|
|
|
<div class="query-list">
|
2018-11-02 08:41:20 -04:00
|
|
|
{{text-field value=search placeholderKey="explorer.search_placeholder"}}
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
action=(action "showCreate")
|
|
|
|
icon="plus"
|
|
|
|
class="no-text btn-right"
|
|
|
|
}}
|
2021-08-20 06:26:48 -04:00
|
|
|
{{pick-files-button
|
|
|
|
class="import-btn"
|
|
|
|
label="explorer.import.label"
|
|
|
|
icon="upload"
|
2022-04-05 22:48:02 -04:00
|
|
|
acceptedFormatsOverride=acceptedImportFileTypes
|
|
|
|
showButton=true
|
2022-06-17 09:01:34 -04:00
|
|
|
onFilesPicked=(action "import")
|
|
|
|
}}
|
2016-12-01 13:54:21 -05:00
|
|
|
</div>
|
2015-06-30 22:51:38 -04:00
|
|
|
|
2018-08-19 06:58:24 -04:00
|
|
|
{{#if showCreate}}
|
|
|
|
<div class="query-create">
|
2022-06-17 09:01:34 -04:00
|
|
|
{{text-field
|
|
|
|
value=newQueryName
|
|
|
|
placeholderKey="explorer.create_placeholder"
|
|
|
|
}}
|
|
|
|
{{d-button
|
|
|
|
action=(action "create")
|
|
|
|
disabled=createDisabled
|
|
|
|
label="explorer.create"
|
|
|
|
icon="plus"
|
|
|
|
}}
|
2018-08-19 06:58:24 -04:00
|
|
|
</div>
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{#if othersDirty}}
|
|
|
|
<div class="warning">
|
2020-01-06 12:52:27 -05:00
|
|
|
{{d-icon "exclamation-triangle"}}
|
2018-08-19 06:58:24 -04:00
|
|
|
{{i18n "explorer.others_dirty"}}
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
|
|
|
{{/unless}}
|
2015-07-09 13:50:00 -04:00
|
|
|
|
2018-12-16 09:22:23 -05:00
|
|
|
{{#if model.length}}
|
2018-09-07 06:28:52 -04:00
|
|
|
{{#unless selectedItem.fake}}
|
2018-05-09 16:06:20 -04:00
|
|
|
<div class="query-edit {{if editName "editing"}}">
|
|
|
|
{{#if selectedItem}}
|
|
|
|
{{#if editing}}
|
|
|
|
<div class="name">
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
action=(action "goHome")
|
|
|
|
icon="chevron-left"
|
|
|
|
class="previous"
|
|
|
|
}}
|
2018-08-29 03:51:02 -04:00
|
|
|
<div class="name-text-field">
|
|
|
|
{{text-field value=selectedItem.name}}
|
|
|
|
</div>
|
2018-05-09 16:06:20 -04:00
|
|
|
</div>
|
2022-06-17 09:01:34 -04:00
|
|
|
|
2018-05-09 16:06:20 -04:00
|
|
|
<div class="desc">
|
2022-06-17 09:01:34 -04:00
|
|
|
{{textarea
|
|
|
|
value=selectedItem.description
|
|
|
|
placeholder=(i18n "explorer.description_placeholder")
|
|
|
|
}}
|
2018-05-09 16:06:20 -04:00
|
|
|
</div>
|
|
|
|
{{else}}
|
|
|
|
<div class="name">
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
action=(action "goHome")
|
|
|
|
icon="chevron-left"
|
|
|
|
class="previous"
|
|
|
|
}}
|
|
|
|
|
2021-07-02 11:35:50 -04:00
|
|
|
<h1>
|
|
|
|
{{selectedItem.name}}
|
2018-10-10 07:29:13 -04:00
|
|
|
{{#unless editDisabled}}
|
2022-06-17 09:01:34 -04:00
|
|
|
<a href {{action "editName" class="edit-query-name"}}>
|
|
|
|
{{d-icon "pencil-alt"}}
|
|
|
|
</a>
|
2018-10-10 07:29:13 -04:00
|
|
|
{{/unless}}
|
2018-09-04 14:53:12 -04:00
|
|
|
</h1>
|
2018-05-09 16:06:20 -04:00
|
|
|
</div>
|
2022-06-17 09:01:34 -04:00
|
|
|
|
2018-05-09 16:06:20 -04:00
|
|
|
<div class="desc">
|
|
|
|
{{selectedItem.description}}
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
|
|
|
|
2021-04-15 11:17:07 -04:00
|
|
|
<div class="pull-left">
|
|
|
|
<div class="groups">
|
|
|
|
<span class="label">{{i18n "explorer.allow_groups"}}</span>
|
|
|
|
<span>
|
|
|
|
{{multi-select
|
|
|
|
value=selectedItem.group_ids
|
|
|
|
content=groupOptions
|
|
|
|
allowAny=false
|
|
|
|
onSelect=(action (mut selectedItem.group_ids))
|
|
|
|
}}
|
2019-09-11 10:09:41 -04:00
|
|
|
</span>
|
2022-06-17 09:01:34 -04:00
|
|
|
|
2021-04-15 11:17:07 -04:00
|
|
|
{{#if runDisabled}}
|
|
|
|
{{#unless editing}}
|
2021-07-05 17:15:57 -04:00
|
|
|
<span class="setting-controls">
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
class="ok"
|
|
|
|
action=(action "save")
|
|
|
|
icon="check"
|
|
|
|
}}
|
|
|
|
{{d-button
|
|
|
|
class="cancel"
|
|
|
|
action=(action "discard")
|
|
|
|
icon="times"
|
|
|
|
}}
|
2021-07-05 17:15:57 -04:00
|
|
|
</span>
|
|
|
|
{{/unless}}
|
2021-04-15 11:17:07 -04:00
|
|
|
{{/if}}
|
|
|
|
</div>
|
2019-09-11 10:09:41 -04:00
|
|
|
</div>
|
2021-07-05 17:15:57 -04:00
|
|
|
|
2021-04-15 11:17:07 -04:00
|
|
|
<div class="clear"></div>
|
|
|
|
|
2018-05-09 16:06:20 -04:00
|
|
|
{{! the SQL editor will show the first time you }}
|
|
|
|
{{#if everEditing}}
|
|
|
|
<div class="query-editor {{if hideSchema "no-schema"}}">
|
2019-04-07 02:05:43 -04:00
|
|
|
<div class="panels-flex">
|
|
|
|
<div class="editor-panel">
|
|
|
|
{{ace-editor content=selectedItem.sql mode="sql"}}
|
|
|
|
</div>
|
2022-06-17 09:01:34 -04:00
|
|
|
|
2019-04-07 02:05:43 -04:00
|
|
|
<div class="right-panel">
|
|
|
|
{{#if hideSchema}}
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
action=(action "expandSchema")
|
|
|
|
icon="chevron-left"
|
|
|
|
class="no-text unhide"
|
|
|
|
}}
|
2019-04-07 02:05:43 -04:00
|
|
|
{{/if}}
|
2022-06-17 09:01:34 -04:00
|
|
|
|
2019-04-07 02:05:43 -04:00
|
|
|
<div class="schema">
|
|
|
|
{{explorer-schema schema=schema hideSchema=hideSchema}}
|
|
|
|
</div>
|
2018-05-09 16:06:20 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-05 17:15:57 -04:00
|
|
|
|
2019-04-07 02:05:43 -04:00
|
|
|
<div class="grippie">
|
|
|
|
{{d-icon "discourse-expand"}}
|
2016-12-01 13:54:21 -05:00
|
|
|
</div>
|
2021-07-05 17:15:57 -04:00
|
|
|
|
2018-05-09 16:06:20 -04:00
|
|
|
<div class="clear"></div>
|
2016-12-01 13:54:21 -05:00
|
|
|
</div>
|
2018-05-09 16:06:20 -04:00
|
|
|
{{else}}
|
|
|
|
<div class="sql">
|
|
|
|
{{hljs-code-view value=selectedItem.sql codeClass="sql"}}
|
2015-09-21 14:19:31 -04:00
|
|
|
</div>
|
2018-05-09 16:06:20 -04:00
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
<div class="clear"></div>
|
|
|
|
|
2021-09-14 09:44:32 -04:00
|
|
|
<div class="pull-left left-buttons">
|
2018-05-09 16:06:20 -04:00
|
|
|
{{#if everEditing}}
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
action=(action "save")
|
|
|
|
label="explorer.save"
|
|
|
|
disabled=saveDisable
|
|
|
|
}}
|
2018-05-09 16:06:20 -04:00
|
|
|
{{else}}
|
2018-10-10 07:29:13 -04:00
|
|
|
{{#unless editDisabled}}
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
action=(action "editName")
|
|
|
|
label="explorer.edit"
|
|
|
|
icon="pencil-alt"
|
|
|
|
}}
|
2018-10-10 07:29:13 -04:00
|
|
|
{{/unless}}
|
2018-05-09 16:06:20 -04:00
|
|
|
{{/if}}
|
2022-06-17 09:01:34 -04:00
|
|
|
|
|
|
|
{{d-button
|
|
|
|
action=(action "download")
|
|
|
|
label="explorer.export"
|
|
|
|
disabled=runDisabled
|
|
|
|
icon="download"
|
|
|
|
}}
|
|
|
|
|
2021-04-15 11:17:07 -04:00
|
|
|
{{#if everEditing}}
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
action=(action "showHelpModal")
|
|
|
|
label="explorer.help.label"
|
|
|
|
icon="question-circle"
|
|
|
|
}}
|
2021-04-15 11:17:07 -04:00
|
|
|
{{/if}}
|
2015-09-21 14:19:31 -04:00
|
|
|
</div>
|
2021-07-05 17:15:57 -04:00
|
|
|
|
2021-09-14 09:44:32 -04:00
|
|
|
<div class="pull-right right-buttons">
|
2018-05-09 16:06:20 -04:00
|
|
|
{{#if selectedItem.destroyed}}
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
action=(action "recover")
|
|
|
|
class=""
|
|
|
|
icon="undo"
|
|
|
|
label="explorer.recover"
|
|
|
|
}}
|
2018-05-09 16:06:20 -04:00
|
|
|
{{else}}
|
|
|
|
{{#if everEditing}}
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
action=(action "discard")
|
|
|
|
icon="undo"
|
|
|
|
label="explorer.undo"
|
|
|
|
disabled=saveDisabled
|
|
|
|
}}
|
2018-05-09 16:06:20 -04:00
|
|
|
{{/if}}
|
2022-06-17 09:01:34 -04:00
|
|
|
|
|
|
|
{{d-button
|
|
|
|
action=(action "destroy")
|
|
|
|
class="btn-danger"
|
|
|
|
icon="trash-alt"
|
|
|
|
label="explorer.delete"
|
|
|
|
}}
|
2018-05-09 16:06:20 -04:00
|
|
|
{{/if}}
|
2015-09-21 14:19:31 -04:00
|
|
|
</div>
|
2021-07-05 17:15:57 -04:00
|
|
|
|
2018-05-09 16:06:20 -04:00
|
|
|
<div class="clear"></div>
|
2016-12-01 13:54:21 -05:00
|
|
|
{{/if}}
|
2018-05-09 16:06:20 -04:00
|
|
|
</div>
|
2016-12-01 13:54:21 -05:00
|
|
|
|
2018-05-09 16:06:20 -04:00
|
|
|
<form class="query-run" {{action "run" on="submit"}}>
|
|
|
|
{{#if selectedItem.hasParams}}
|
|
|
|
<div class="query-params">
|
|
|
|
{{#each selectedItem.param_info as |pinfo|}}
|
2021-09-14 11:10:16 -04:00
|
|
|
{{param-input
|
|
|
|
params=selectedItem.params
|
|
|
|
initialValues=parsedParams
|
|
|
|
info=pinfo
|
|
|
|
}}
|
2018-05-09 16:06:20 -04:00
|
|
|
{{/each}}
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
2021-07-05 17:15:57 -04:00
|
|
|
|
2018-05-09 16:06:20 -04:00
|
|
|
{{#if runDisabled}}
|
|
|
|
{{#if saveDisabled}}
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
label="explorer.run"
|
|
|
|
disabled="true"
|
|
|
|
class="btn-primary"
|
|
|
|
}}
|
2016-12-01 13:54:21 -05:00
|
|
|
{{else}}
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
action=(action "saverun")
|
|
|
|
icon="play"
|
|
|
|
label="explorer.saverun"
|
|
|
|
class="btn-primary"
|
|
|
|
}}
|
2016-12-01 13:54:21 -05:00
|
|
|
{{/if}}
|
2018-05-09 16:06:20 -04:00
|
|
|
{{else}}
|
2022-06-17 09:01:34 -04:00
|
|
|
{{d-button
|
|
|
|
action=(action "run")
|
|
|
|
icon="play"
|
|
|
|
label="explorer.run"
|
|
|
|
disabled=runDisabled
|
|
|
|
class="btn-primary"
|
|
|
|
type="submit"
|
|
|
|
}}
|
2018-05-09 16:06:20 -04:00
|
|
|
{{/if}}
|
2021-07-05 17:15:57 -04:00
|
|
|
|
2022-06-17 09:01:34 -04:00
|
|
|
<label class="query-plan">
|
|
|
|
{{input type="checkbox" checked=explain name="explain"}}
|
|
|
|
{{i18n "explorer.explain_label"}}
|
|
|
|
</label>
|
2018-05-09 16:06:20 -04:00
|
|
|
</form>
|
|
|
|
|
|
|
|
<hr>
|
2018-09-07 06:28:52 -04:00
|
|
|
{{/unless}}
|
2021-07-05 17:15:57 -04:00
|
|
|
|
2018-05-09 16:06:20 -04:00
|
|
|
{{conditional-loading-spinner condition=loading}}
|
2021-07-05 17:15:57 -04:00
|
|
|
|
2018-05-09 16:06:20 -04:00
|
|
|
{{#unless selectedItem.fake}}
|
|
|
|
{{#if results}}
|
|
|
|
<div class="query-results">
|
|
|
|
{{#if showResults}}
|
|
|
|
{{query-result query=selectedItem content=results}}
|
2016-12-01 13:54:21 -05:00
|
|
|
{{else}}
|
2018-05-09 16:06:20 -04:00
|
|
|
{{#each results.errors as |err|}}
|
|
|
|
<pre class="query-error"><code>{{~err}}</code></pre>
|
|
|
|
{{/each}}
|
2016-12-01 13:54:21 -05:00
|
|
|
{{/if}}
|
2015-09-21 14:19:31 -04:00
|
|
|
</div>
|
2015-07-14 19:01:38 -04:00
|
|
|
{{/if}}
|
2018-05-09 16:06:20 -04:00
|
|
|
{{/unless}}
|
2015-09-21 14:19:31 -04:00
|
|
|
|
2021-07-05 17:15:57 -04:00
|
|
|
{{#if showRecentQueries}}
|
|
|
|
<div class="container">
|
|
|
|
<table class="recent-queries">
|
|
|
|
<thead class="heading-container">
|
|
|
|
<th class="col heading name">
|
2022-06-17 09:01:34 -04:00
|
|
|
<div
|
|
|
|
role="button"
|
|
|
|
class="heading-toggle"
|
|
|
|
{{action "sortByProperty" "name"}}
|
|
|
|
>
|
|
|
|
{{table-header-toggle
|
|
|
|
field="name"
|
|
|
|
labelKey="explorer.query_name"
|
|
|
|
order=order
|
|
|
|
asc=asc
|
|
|
|
automatic=true
|
|
|
|
}}
|
2021-07-05 17:15:57 -04:00
|
|
|
</div>
|
|
|
|
</th>
|
|
|
|
<th class="col heading created-by">
|
2022-06-17 09:01:34 -04:00
|
|
|
<div
|
|
|
|
role="button"
|
|
|
|
class="heading-toggle"
|
|
|
|
{{action "sortByProperty" "username"}}
|
|
|
|
>
|
|
|
|
{{table-header-toggle
|
|
|
|
field="username"
|
|
|
|
labelKey="explorer.query_user"
|
|
|
|
order=order
|
|
|
|
asc=asc
|
|
|
|
automatic=true
|
|
|
|
}}
|
2021-07-05 17:15:57 -04:00
|
|
|
</div>
|
|
|
|
</th>
|
|
|
|
<th class="col heading group-names">
|
|
|
|
<div class="group-names-header">
|
|
|
|
{{i18n "explorer.query_groups"}}
|
|
|
|
</div>
|
|
|
|
</th>
|
|
|
|
<th class="col heading created-at">
|
2022-06-17 09:01:34 -04:00
|
|
|
<div
|
|
|
|
role="button"
|
|
|
|
class="heading-toggle"
|
|
|
|
{{action "sortByProperty" "last_run_at"}}
|
|
|
|
>
|
|
|
|
{{table-header-toggle
|
|
|
|
field="last_run_at"
|
|
|
|
labelKey="explorer.query_time"
|
|
|
|
order=order
|
|
|
|
asc=asc
|
|
|
|
automatic=true
|
|
|
|
}}
|
2021-07-05 17:15:57 -04:00
|
|
|
</div>
|
|
|
|
</th>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{{#each filteredContent as |query|}}
|
|
|
|
<tr class="query-row">
|
|
|
|
<td>
|
2022-06-17 09:01:34 -04:00
|
|
|
<a
|
|
|
|
{{action "scrollTop"}}
|
|
|
|
href="/admin/plugins/explorer/?id={{query.id}}"
|
|
|
|
>
|
2021-07-05 17:15:57 -04:00
|
|
|
<b class="query-name">{{query.name}}</b>
|
|
|
|
<medium class="query-desc">{{query.description}}</medium>
|
2018-08-31 14:11:33 -04:00
|
|
|
</a>
|
2021-07-05 17:15:57 -04:00
|
|
|
</td>
|
|
|
|
<td class="query-created-by">
|
|
|
|
{{#if query.username}}
|
|
|
|
<a href="/u/{{query.username}}/activity">
|
|
|
|
<medium>{{query.username}}</medium>
|
|
|
|
</a>
|
|
|
|
{{/if}}
|
2021-07-02 11:35:50 -04:00
|
|
|
</td>
|
|
|
|
<td class="query-group-names">
|
|
|
|
{{#each query.group_names as |group|}}
|
|
|
|
{{share-report group=group query=query}}
|
|
|
|
{{/each}}
|
|
|
|
</td>
|
|
|
|
<td class="query-created-at">
|
|
|
|
{{#if query.last_run_at}}
|
|
|
|
<medium>
|
|
|
|
{{bound-date query.last_run_at}}
|
|
|
|
</medium>
|
|
|
|
{{else if query.created_at}}
|
|
|
|
<medium>
|
|
|
|
{{bound-date query.created_at}}
|
|
|
|
</medium>
|
|
|
|
{{/if}}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{{else}}
|
|
|
|
<br>
|
2022-06-17 09:01:34 -04:00
|
|
|
<em class="no-search-results">
|
|
|
|
{{i18n "explorer.no_search_results"}}
|
|
|
|
</em>
|
2021-07-02 11:35:50 -04:00
|
|
|
{{/each}}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
2018-08-12 12:08:25 -04:00
|
|
|
|
2018-05-09 16:06:20 -04:00
|
|
|
<div class="explorer-pad-bottom"></div>
|
2016-12-01 13:54:21 -05:00
|
|
|
{{/if}}
|
2015-07-02 12:15:55 -04:00
|
|
|
{{/if}}
|
2016-12-01 13:54:21 -05:00
|
|
|
{{/explorer-container}}
|