discourse-data-explorer/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs

196 lines
7.4 KiB
Handlebars
Raw Normal View History

2016-12-01 13:54:21 -05:00
{{#explorer-container hideSchema=hideSchema everEditing=everEditing}}
2015-06-30 22:51:38 -04:00
2016-12-01 13:54:21 -05:00
{{#if disallow}}
<h2>{{i18n "explorer.admins_only"}}</h2>
{{else}}
2018-08-19 06:58:24 -04:00
{{#unless selectedQueryId}}
<div class="query-list">
{{combo-box valueAttribute="id" value=selectedQueryId nameProperty="listName" none="explorer.menu_none" content=content castInteger="true" nameChanges="true"}}
{{d-button action="showCreate" icon="plus" class="no-text"}}
{{d-button action="importQuery" label="explorer.import.label" icon="upload"}}
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">
{{text-field value=newQueryName placeholderKey="explorer.create_placeholder"}}
{{d-button action="create" disabled=createDisabled label="explorer.create" icon="plus" class="btn-primary"}}
</div>
{{/if}}
{{#if othersDirty}}
<div class="warning">
{{fa-icon "warning"}}
{{i18n "explorer.others_dirty"}}
</div>
{{/if}}
2018-08-19 06:58:24 -04:00
<hr>
{{/unless}}
{{#if content.length}}
{{#if selectedItem.fake}}
<p>{{i18n "explorer.no_query_selected"}} <a {{action "showCreate"}}>{{i18n "explorer.no_query_selected_hook"}}</a></p>
{{else}}
<div class="query-edit {{if editName "editing"}}">
{{#if selectedItem}}
{{#if editing}}
<div class="name">
<div class="previous">
{{d-button action="goHome" icon="chevron-left" class="no-text btn-med"}}
</div>
<div class="name-text-field">
{{text-field value=selectedItem.name}}
</div>
</div>
<div class="desc">
{{textarea value=selectedItem.description placeholder=(i18n "explorer.description_placeholder")}}
</div>
{{else}}
<div class="name">
<div class="previous">
{{d-button action="goHome" icon="chevron-left" class="no-text btn-med"}}
</div>
<h2>{{selectedItem.name}}</h2>
{{d-button action="editName" icon="pencil" class="no-text btn-small"}}
</div>
<div class="desc">
{{selectedItem.description}}
</div>
{{/if}}
{{! the SQL editor will show the first time you }}
{{#if everEditing}}
<div class="query-editor {{if hideSchema "no-schema"}}">
<div class="right-panel">
<div class="schema grippie-target">
{{explorer-schema schema=schema hideSchema=hideSchema}}
</div>
</div>
<div class="editor-panel">
{{ace-editor content=selectedItem.sql mode="sql"}}
2016-12-01 13:54:21 -05:00
</div>
<div class="grippie"></div>
<div class="clear"></div>
2016-12-01 13:54:21 -05:00
</div>
{{else}}
<div class="sql">
{{hljs-code-view value=selectedItem.sql codeClass="sql"}}
</div>
{{/if}}
<div class="clear"></div>
<div class="pull-left">
{{#if everEditing}}
{{d-button action="save" label="explorer.save" disabled=saveDisabled class="btn-primary"}}
{{else}}
{{d-button action="editName" label="explorer.edit" icon="pencil" class="btn-primary"}}
{{/if}}
{{d-button action="download" label="explorer.export" disabled=runDisabled icon="download"}}
</div>
<div class="pull-right">
{{#if selectedItem.destroyed}}
{{d-button action="recover" class="" icon="undo" label="explorer.recover"}}
{{else}}
{{#if everEditing}}
{{d-button action="discard" class="btn-danger" icon="undo" label="explorer.undo" disabled=saveDisabled}}
{{/if}}
{{d-button action="destroy" class="btn-danger" icon="trash" label="explorer.delete"}}
{{/if}}
</div>
<div class="clear"></div>
2016-12-01 13:54:21 -05:00
{{/if}}
</div>
2016-12-01 13:54:21 -05:00
<form class="query-run" {{action "run" on="submit"}}>
{{#if selectedItem.hasParams}}
<div class="query-params">
{{#each selectedItem.param_info as |pinfo|}}
{{param-input params=selectedItem.params info=pinfo}}
{{! <div class="param">
{{param-field params=selectedItem.params pname=pinfo.identifier type=pinfo.type}
<span class="param-name">{{pinfo.identifier}</span>
</div> }}
{{/each}}
</div>
{{/if}}
{{#if runDisabled}}
{{#if saveDisabled}}
{{d-button label="explorer.run" disabled="true" class="btn-primary"}}
2016-12-01 13:54:21 -05:00
{{else}}
{{d-button action="saverun" label="explorer.saverun"}}
2016-12-01 13:54:21 -05:00
{{/if}}
{{else}}
{{d-button action="run" label="explorer.run" disabled=runDisabled class="btn-primary" type="submit"}}
{{/if}}
<label class="query-plan">{{input type="checkbox" checked=explain name="explain"}} {{i18n "explorer.explain_label"}}</label>
</form>
<hr>
{{/if}}
{{conditional-loading-spinner condition=loading}}
{{#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}}
{{#each results.errors as |err|}}
<pre class="query-error"><code>{{~err}}</code></pre>
{{/each}}
2016-12-01 13:54:21 -05:00
{{/if}}
</div>
2015-07-14 19:01:38 -04:00
{{/if}}
{{/unless}}
{{#if showRecentQueries}}
{{#if sortedQueries.length}}
<table class="recent-queries">
<thead class="heading-container">
<th class="col heading name">{{i18n 'explorer.query_name'}}</th>
<th class="col heading user">{{i18n 'explorer.query_user'}}</th>
<th class="col heading time">{{i18n 'explorer.query_time'}}</th>
</thead>
<tr></tr>
{{#each sortedQueries as |query|}}
<tr>
<td>
<a {{action "scrollTop"}} href="/admin/plugins/explorer/?id={{query.id}}">
<b class="query-name">{{query.name}}</b>
<br>
<medium class="query-desc">{{query.description}}</medium>
<br>
</a>
</td>
<td class="query-created-by">
2018-08-28 02:30:25 -04:00
{{#if query.username}}
<a href="/users/{{query.username}}/activity">
<medium>{{query.username}}</medium>
</a>
{{/if}}
</td>
<td class="query-created-at">
{{#if query.last_run_at}}
<medium>
{{bound-date query.last_run_at}}
</medium>
{{else}}
<medium>
{{bound-date query.created_at}}
</medium>
{{/if}}
</td>
</tr>
{{/each}}
</table>
{{/if}}
{{/if}}
<div class="explorer-pad-bottom"></div>
2016-12-01 13:54:21 -05:00
{{else}}
<p>{{i18n "explorer.no_queries"}} <a {{action "showCreate"}}>{{i18n "explorer.no_queries_hook"}}</a></p>
2016-12-01 13:54:21 -05:00
{{/if}}
{{/if}}
2016-12-01 13:54:21 -05:00
{{/explorer-container}}