various
Dieser Commit ist enthalten in:
Ursprung
d8fd5cb258
Commit
dae08e53d4
13 geänderte Dateien mit 148 neuen und 69 gelöschten Zeilen
|
@ -1,3 +1,3 @@
|
||||||
{{#if currentUser.admin}}
|
{{#if currentUser.admin}}
|
||||||
{{nav-item route='adminWizards' label='admin.wizard.nav'}}
|
{{nav-item route='adminWizards' label='admin.wizard.nav_label'}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import Controller from "@ember/controller";
|
||||||
|
import { fmt } from "discourse/lib/computed";
|
||||||
|
|
||||||
|
export default Controller.extend({
|
||||||
|
downloadUrl: fmt("wizard.id", "/admin/wizards/submissions/%@/download")
|
||||||
|
});
|
|
@ -198,8 +198,6 @@ CustomWizard.reopenClass({
|
||||||
submissions(wizardId) {
|
submissions(wizardId) {
|
||||||
return ajax(`/admin/wizards/submissions/${wizardId}`, {
|
return ajax(`/admin/wizards/submissions/${wizardId}`, {
|
||||||
type: "GET"
|
type: "GET"
|
||||||
}).then(result => {
|
|
||||||
return result.submissions;
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,31 @@ import CustomWizard from '../models/custom-wizard';
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
export default DiscourseRoute.extend({
|
||||||
|
beforeModel() {
|
||||||
|
const param = this.paramsFor('adminWizardSubmissions').wizard_id;
|
||||||
|
const wizards = this.modelFor('admin-wizards-submissions');
|
||||||
|
|
||||||
|
if (wizards.length && (param === 'first')) {
|
||||||
|
const wizard = wizards.get(`${param}Object`);
|
||||||
|
if (wizard) {
|
||||||
|
this.transitionTo('adminWizardSubmissions', wizard.id.dasherize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
model(params) {
|
model(params) {
|
||||||
|
const wizardId = params.wizard_id;
|
||||||
|
if (wizardId && wizardId !== 'new') {
|
||||||
return CustomWizard.submissions(params.wizard_id);
|
return CustomWizard.submissions(params.wizard_id);
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setupController(controller, model) {
|
setupController(controller, model) {
|
||||||
|
if (model.submissions) {
|
||||||
let fields = [];
|
let fields = [];
|
||||||
model.forEach((s) => {
|
model.submissions.forEach((s) => {
|
||||||
Object.keys(s).forEach((k) => {
|
Object.keys(s).forEach((k) => {
|
||||||
if (fields.indexOf(k) < 0) {
|
if (fields.indexOf(k) < 0) {
|
||||||
fields.push(k);
|
fields.push(k);
|
||||||
|
@ -17,7 +35,7 @@ export default DiscourseRoute.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
let submissions = [];
|
let submissions = [];
|
||||||
model.forEach((s) => {
|
model.submissions.forEach((s) => {
|
||||||
let submission = {};
|
let submission = {};
|
||||||
fields.forEach((f) => {
|
fields.forEach((f) => {
|
||||||
submission[f] = s[f];
|
submission[f] = s[f];
|
||||||
|
@ -25,6 +43,13 @@ export default DiscourseRoute.extend({
|
||||||
submissions.push(submission);
|
submissions.push(submission);
|
||||||
});
|
});
|
||||||
|
|
||||||
controller.setProperties({ submissions, fields });
|
console.log(model.id)
|
||||||
|
|
||||||
|
controller.setProperties({
|
||||||
|
wizard: model.wizard,
|
||||||
|
submissions,
|
||||||
|
fields
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,6 @@ import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
export default DiscourseRoute.extend({
|
||||||
redirect() {
|
redirect() {
|
||||||
this.transitionTo('adminWizard', 'first');
|
this.transitionTo('adminWizardSubmissions', 'first');
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -1,3 +1,14 @@
|
||||||
|
<div class="wizard-header large">
|
||||||
|
<label>{{i18n 'admin.wizard.submissions.title' name=wizard.name}}</label>
|
||||||
|
|
||||||
|
<a class="btn btn-default download-link" href="{{downloadUrl}}" target="_blank">
|
||||||
|
{{d-icon 'download'}}
|
||||||
|
<span class="d-button-label">
|
||||||
|
{{i18n "admin.wizard.submissions.download"}}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="wizard-submissions">
|
<div class="wizard-submissions">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
name="background"
|
name="background"
|
||||||
value=model.background
|
value=model.background
|
||||||
placeholderKey="admin.wizard.background_placeholder"
|
placeholderKey="admin.wizard.background_placeholder"
|
||||||
class="medium"}}
|
class="small"}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content submissions">
|
||||||
{{outlet}}
|
{{outlet}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{{#admin-nav}}
|
{{#admin-nav}}
|
||||||
{{nav-item route='adminWizardsCustom' label='admin.wizard.custom_label'}}
|
{{nav-item route='adminWizardsCustom' label='admin.wizard.nav_label'}}
|
||||||
{{nav-item route='adminWizardsSubmissions' label='admin.wizard.submissions_label'}}
|
{{nav-item route='adminWizardsSubmissions' label='admin.wizard.submissions.nav_label'}}
|
||||||
{{#if siteSettings.wizard_api_features}}
|
{{#if siteSettings.wizard_api_features}}
|
||||||
{{nav-item route='adminWizardsApis' label='admin.wizard.api.nav_label'}}
|
{{nav-item route='adminWizardsApis' label='admin.wizard.api.nav_label'}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{nav-item route='adminWizardsTransfer' label='admin.wizard.transfer.nav_label'}}
|
{{nav-item route='adminWizardsTransfer' label='admin.wizard.transfer.nav_label'}}
|
||||||
{{/admin-nav}}
|
{{/admin-nav}}
|
||||||
|
|
||||||
<div class="admin-container">
|
<div class="admin-container admin-wizard-container">
|
||||||
{{outlet}}
|
{{outlet}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,14 +2,26 @@
|
||||||
@import 'wizard-transfer';
|
@import 'wizard-transfer';
|
||||||
@import 'wizard-api';
|
@import 'wizard-api';
|
||||||
|
|
||||||
body.admin-wizard {
|
.admin-wizard-container {
|
||||||
.admin-container > .row {
|
.row {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
|
||||||
|
|
||||||
.boxed.white {
|
> .content {
|
||||||
background-color: initial;
|
flex: 1;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-left: 30px;
|
||||||
|
|
||||||
|
table {
|
||||||
|
margin-top: 0;
|
||||||
|
min-width: 100%;
|
||||||
|
width: auto;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.wizard-submissions {
|
||||||
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wizard-list {
|
.wizard-list {
|
||||||
|
@ -97,11 +109,21 @@ body.admin-wizard {
|
||||||
min-height: 31px;
|
min-height: 31px;
|
||||||
margin-bottom: 30px;
|
margin-bottom: 30px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
input {
|
input {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
width: 350px;
|
width: 350px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.download-link {
|
||||||
|
font-size: 1rem;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.medium {
|
&.medium {
|
||||||
|
@ -138,8 +160,6 @@ body.admin-wizard {
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-wizard.settings {
|
.admin-wizard.settings {
|
||||||
margin-top: 10px;
|
|
||||||
margin-left: 30px;
|
|
||||||
|
|
||||||
[class~='setting'] {
|
[class~='setting'] {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
@ -410,16 +430,6 @@ body.admin-wizard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-contents .wizard-submissions {
|
|
||||||
width: 100%;
|
|
||||||
margin-top: 10px;
|
|
||||||
margin-left: 30px;
|
|
||||||
|
|
||||||
table {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.wizard-field-composer textarea {
|
.wizard-field-composer textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 150px;
|
min-height: 150px;
|
||||||
|
|
|
@ -7,12 +7,10 @@ en:
|
||||||
admin:
|
admin:
|
||||||
wizard:
|
wizard:
|
||||||
label: "Wizard"
|
label: "Wizard"
|
||||||
nav: "Wizards"
|
nav_label: "Wizards"
|
||||||
new: "New"
|
new: "New"
|
||||||
custom_label: "Custom"
|
|
||||||
submissions_label: "Submissions"
|
|
||||||
name: "Name"
|
name: "Name"
|
||||||
name_placeholder: "name"
|
name_placeholder: "wizard name"
|
||||||
background: "Background"
|
background: "Background"
|
||||||
background_placeholder: "#hex"
|
background_placeholder: "#hex"
|
||||||
save_submissions: "Save"
|
save_submissions: "Save"
|
||||||
|
@ -198,6 +196,11 @@ en:
|
||||||
body: "Body"
|
body: "Body"
|
||||||
body_placeholder: "JSON"
|
body_placeholder: "JSON"
|
||||||
|
|
||||||
|
submissions:
|
||||||
|
nav_label: "Submissions"
|
||||||
|
title: "{{name}} Submissions"
|
||||||
|
download: "Download"
|
||||||
|
|
||||||
api:
|
api:
|
||||||
label: "API"
|
label: "API"
|
||||||
nav_label: 'APIs'
|
nav_label: 'APIs'
|
||||||
|
|
|
@ -17,10 +17,12 @@ Discourse::Application.routes.append do
|
||||||
get 'admin/wizards/custom/new' => 'admin#index'
|
get 'admin/wizards/custom/new' => 'admin#index'
|
||||||
get 'admin/wizards/custom/all' => 'admin#custom_wizards'
|
get 'admin/wizards/custom/all' => 'admin#custom_wizards'
|
||||||
get 'admin/wizards/custom/:wizard_id' => 'admin#find_wizard'
|
get 'admin/wizards/custom/:wizard_id' => 'admin#find_wizard'
|
||||||
|
get 'admin/wizards/custom/:wizard_id' => 'admin#find_wizard'
|
||||||
put 'admin/wizards/custom/save' => 'admin#save'
|
put 'admin/wizards/custom/save' => 'admin#save'
|
||||||
delete 'admin/wizards/custom/remove' => 'admin#remove'
|
delete 'admin/wizards/custom/remove' => 'admin#remove'
|
||||||
get 'admin/wizards/submissions' => 'admin#index'
|
get 'admin/wizards/submissions' => 'admin#index'
|
||||||
get 'admin/wizards/submissions/:wizard_id' => 'admin#submissions'
|
get 'admin/wizards/submissions/:wizard_id' => 'admin#submissions'
|
||||||
|
get 'admin/wizards/submissions/:wizard_id/download' => 'admin#download_submissions'
|
||||||
get 'admin/wizards/apis' => 'api#list'
|
get 'admin/wizards/apis' => 'api#list'
|
||||||
get 'admin/wizards/apis/new' => 'api#index'
|
get 'admin/wizards/apis/new' => 'api#index'
|
||||||
get 'admin/wizards/apis/:name' => 'api#find'
|
get 'admin/wizards/apis/:name' => 'api#find'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class CustomWizard::AdminController < ::ApplicationController
|
class CustomWizard::AdminController < ::Admin::AdminController
|
||||||
before_action :ensure_logged_in
|
skip_before_action :check_xhr, only: [:download_submissions]
|
||||||
before_action :ensure_admin
|
before_action :ensure_admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -55,38 +55,42 @@ class CustomWizard::AdminController < ::ApplicationController
|
||||||
|
|
||||||
def find_wizard
|
def find_wizard
|
||||||
params.require(:wizard_id)
|
params.require(:wizard_id)
|
||||||
|
|
||||||
wizard = PluginStore.get('custom_wizard', params[:wizard_id].underscore)
|
wizard = PluginStore.get('custom_wizard', params[:wizard_id].underscore)
|
||||||
|
|
||||||
render json: success_json.merge(wizard: wizard)
|
render json: success_json.merge(wizard: wizard)
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_wizards
|
def custom_wizards
|
||||||
rows = PluginStoreRow.where(plugin_name: 'custom_wizard').order(:id)
|
rows = PluginStoreRow.where(plugin_name: 'custom_wizard').order(:id)
|
||||||
|
|
||||||
wizards = [*rows].map { |r| CustomWizard::Template.new(r.value) }
|
wizards = [*rows].map { |r| CustomWizard::Template.new(r.value) }
|
||||||
|
|
||||||
render json: success_json.merge(wizards: wizards)
|
render json: success_json.merge(wizards: wizards)
|
||||||
end
|
end
|
||||||
|
|
||||||
def submissions
|
def submissions
|
||||||
params.require(:wizard_id)
|
params.require(:wizard_id)
|
||||||
|
|
||||||
rows = PluginStoreRow.where(plugin_name: "#{params[:wizard_id]}_submissions").order('id DESC')
|
wizard_id = params[:wizard_id].underscore
|
||||||
|
wizard = PluginStore.get('custom_wizard', wizard_id)
|
||||||
|
|
||||||
all_submissions = [*rows].map do |r|
|
if wizard.present?
|
||||||
submissions = ::JSON.parse(r.value)
|
render json: success_json.merge(
|
||||||
|
submissions: build_submissions(wizard_id),
|
||||||
if user = User.find_by(id: r.key)
|
wizard: wizard.slice(:id, :name)
|
||||||
username = user.username
|
)
|
||||||
else
|
else
|
||||||
username = I18n.t('admin.wizard.submissions.no_user', id: r.key)
|
head :ok
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
submissions.map { |s| { username: username }.merge!(s.except("redirect_to")) }
|
def download_submissions
|
||||||
end.flatten
|
params.require(:wizard_id)
|
||||||
|
wizard_id = params[:wizard_id].underscore
|
||||||
|
|
||||||
render json: success_json.merge(submissions: all_submissions)
|
wizard = PluginStore.get('custom_wizard', wizard_id)
|
||||||
|
submissions = build_submissions(wizard_id).to_json
|
||||||
|
|
||||||
|
send_data submissions,
|
||||||
|
filename: "#{Discourse.current_hostname}-wizard-submissions-#{wizard['name']}.json",
|
||||||
|
content_type: "application/json"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -244,4 +248,24 @@ class CustomWizard::AdminController < ::ApplicationController
|
||||||
|
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def build_submissions(wizard_id)
|
||||||
|
rows = PluginStoreRow.where(plugin_name: "#{wizard_id}_submissions").order('id DESC')
|
||||||
|
|
||||||
|
submissions = [*rows].map do |row|
|
||||||
|
value = ::JSON.parse(row.value)
|
||||||
|
|
||||||
|
if user = User.find_by(id: row.key)
|
||||||
|
username = user.username
|
||||||
|
else
|
||||||
|
username = I18n.t('admin.wizard.submissions.no_user', id: row.key)
|
||||||
|
end
|
||||||
|
|
||||||
|
value.map do |submission|
|
||||||
|
{
|
||||||
|
username: username
|
||||||
|
}.merge!(submission.except("redirect_to"))
|
||||||
|
end
|
||||||
|
end.flatten
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Laden …
In neuem Issue referenzieren