mirror of
https://github.com/documize/community.git
synced 2025-07-19 13:19:43 +02:00
parent
4d1eb952b2
commit
7206f721f4
8 changed files with 783 additions and 697 deletions
|
@ -97,12 +97,12 @@ func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
|
||||||
response.WriteJSON(w, org)
|
response.WriteJSON(w, org)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSetting returns the requested organization level setting.
|
// GetInstanceSetting returns the requested organization level setting.
|
||||||
func (h *Handler) GetSetting(w http.ResponseWriter, r *http.Request) {
|
func (h *Handler) GetInstanceSetting(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := domain.GetRequestContext(r)
|
ctx := domain.GetRequestContext(r)
|
||||||
|
|
||||||
orgID := request.Param(r, "orgID")
|
orgID := request.Param(r, "orgID")
|
||||||
if orgID != ctx.OrgID {
|
if orgID != ctx.OrgID || !ctx.Administrator {
|
||||||
response.WriteForbiddenError(w)
|
response.WriteForbiddenError(w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -113,27 +113,21 @@ func (h *Handler) GetSetting(w http.ResponseWriter, r *http.Request) {
|
||||||
response.WriteJSON(w, setting)
|
response.WriteJSON(w, setting)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveSetting saves org level setting.
|
// SaveInstanceSetting saves org level setting.
|
||||||
func (h *Handler) SaveSetting(w http.ResponseWriter, r *http.Request) {
|
func (h *Handler) SaveInstanceSetting(w http.ResponseWriter, r *http.Request) {
|
||||||
|
method := "org.SaveInstanceSetting"
|
||||||
ctx := domain.GetRequestContext(r)
|
ctx := domain.GetRequestContext(r)
|
||||||
method := "org.SaveSetting"
|
|
||||||
|
|
||||||
orgID := request.Param(r, "orgID")
|
orgID := request.Param(r, "orgID")
|
||||||
if orgID != ctx.OrgID {
|
if orgID != ctx.OrgID || !ctx.Administrator {
|
||||||
response.WriteForbiddenError(w)
|
response.WriteForbiddenError(w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
key := request.Query(r, "key")
|
key := request.Query(r, "key")
|
||||||
|
|
||||||
if !ctx.Administrator {
|
|
||||||
response.WriteForbiddenError(w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
defer streamutil.Close(r.Body)
|
defer streamutil.Close(r.Body)
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := ioutil.ReadAll(r.Body)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response.WriteServerError(w, method, err)
|
response.WriteServerError(w, method, err)
|
||||||
h.Runtime.Log.Error(method, err)
|
h.Runtime.Log.Error(method, err)
|
||||||
|
@ -145,3 +139,44 @@ func (h *Handler) SaveSetting(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
response.WriteEmpty(w)
|
response.WriteEmpty(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetGlobalSetting returns the requested organization level setting.
|
||||||
|
func (h *Handler) GetGlobalSetting(w http.ResponseWriter, r *http.Request) {
|
||||||
|
ctx := domain.GetRequestContext(r)
|
||||||
|
|
||||||
|
if !ctx.Global {
|
||||||
|
response.WriteForbiddenError(w)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
key := request.Query(r, "key")
|
||||||
|
setting, _ := h.Store.Setting.Get(key, "")
|
||||||
|
|
||||||
|
response.WriteJSON(w, setting)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveGlobalSetting saves org level setting.
|
||||||
|
func (h *Handler) SaveGlobalSetting(w http.ResponseWriter, r *http.Request) {
|
||||||
|
method := "org.SaveGlobalSetting"
|
||||||
|
ctx := domain.GetRequestContext(r)
|
||||||
|
|
||||||
|
if !ctx.Global {
|
||||||
|
response.WriteForbiddenError(w)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
key := request.Query(r, "key")
|
||||||
|
|
||||||
|
defer streamutil.Close(r.Body)
|
||||||
|
body, err := ioutil.ReadAll(r.Body)
|
||||||
|
if err != nil {
|
||||||
|
response.WriteServerError(w, method, err)
|
||||||
|
h.Runtime.Log.Error(method, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
config := string(body)
|
||||||
|
h.Store.Setting.Set(key, config)
|
||||||
|
|
||||||
|
response.WriteEmpty(w)
|
||||||
|
}
|
||||||
|
|
1350
embed/bindata.go
1350
embed/bindata.go
File diff suppressed because one or more lines are too long
|
@ -19,6 +19,8 @@ export default Component.extend(Notifier, {
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
|
// Jira specific.
|
||||||
let jira = this.get('jira');
|
let jira = this.get('jira');
|
||||||
|
|
||||||
if (is.not.object(jira)) {
|
if (is.not.object(jira)) {
|
||||||
|
@ -30,6 +32,19 @@ export default Component.extend(Notifier, {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set('jiraCreds', jira);
|
this.set('jiraCreds', jira);
|
||||||
|
|
||||||
|
if (this.get('session.isGlobalAdmin')) {
|
||||||
|
// Trello specific.
|
||||||
|
let trello = this.get('trello');
|
||||||
|
|
||||||
|
if (is.not.object(trello)) {
|
||||||
|
trello = {
|
||||||
|
appKey: ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.set('trelloCreds', trello);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -42,8 +57,11 @@ export default Component.extend(Notifier, {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showWait();
|
this.showWait();
|
||||||
|
this.get('orgSvc').saveOrgSetting(orgId, 'jira', this.get('jiraCreds')).then(() => {
|
||||||
|
if (this.get('session.isGlobalAdmin')) {
|
||||||
|
this.get('orgSvc').saveGlobalSetting('SECTION-TRELLO', this.get('trelloCreds'));
|
||||||
|
}
|
||||||
|
|
||||||
this.get('orgSvc').saveOrgSetting(orgId, 'jira', this.get('jiraCreds')).then(() =>{
|
|
||||||
this.showDone();
|
this.showDone();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ export default Route.extend(AuthenticatedRouteMixin, {
|
||||||
let orgId = this.get("appMeta.orgId");
|
let orgId = this.get("appMeta.orgId");
|
||||||
|
|
||||||
return RSVP.hash({
|
return RSVP.hash({
|
||||||
jira: this.get('orgService').getOrgSetting(orgId, "jira")
|
jira: this.get('orgService').getOrgSetting(orgId, 'jira'),
|
||||||
|
trello: this.get('orgService').getGlobalSetting('SECTION-TRELLO')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{{customize/integration-settings jira=model.jira}}
|
{{customize/integration-settings jira=model.jira trello=model.trello}}
|
||||||
|
|
|
@ -57,5 +57,20 @@ export default Service.extend({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: JSON.stringify(config)
|
data: JSON.stringify(config)
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
getGlobalSetting(key) {
|
||||||
|
return this.get('ajax').request(`organization/setting?key=${key}`, {
|
||||||
|
method: 'GET'
|
||||||
|
}).then((response) => {
|
||||||
|
return JSON.parse(response);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
saveGlobalSetting(key, config) {
|
||||||
|
return this.get('ajax').request(`organization/setting?key=${key}`, {
|
||||||
|
method: 'POST',
|
||||||
|
data: JSON.stringify(config)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,29 +9,44 @@
|
||||||
|
|
||||||
<div class="view-customize">
|
<div class="view-customize">
|
||||||
<form class="mt-5">
|
<form class="mt-5">
|
||||||
<h2>Jira Connector</h2>
|
|
||||||
|
<h2>Jira</h2>
|
||||||
<p>Displays issues within documentation</p>
|
<p>Displays issues within documentation</p>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="siteTitle" class="col-sm-4 col-form-label">URL</label>
|
<label for="jira-url" class="col-sm-4 col-form-label">URL</label>
|
||||||
<div class="col-sm-7">
|
<div class="col-sm-7">
|
||||||
{{focus-input id="jira-url" type="text" value=jiraCreds.url class="form-control"}}
|
{{focus-input id="jira-url" type="text" value=jiraCreds.url class="form-control"}}
|
||||||
<small class="form-text text-muted">Fully qualified domain name for your Jira instance e.g. http://jira.example.org</small>
|
<small class="form-text text-muted">Fully qualified domain name for your Jira instance e.g. http://jira.example.org</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="siteTitle" class="col-sm-4 col-form-label">Username</label>
|
<label for="jira-username" class="col-sm-4 col-form-label">Username</label>
|
||||||
<div class="col-sm-7">
|
<div class="col-sm-7">
|
||||||
{{input id="jira-username" type="text" value=jiraCreds.username class="form-control"}}
|
{{input id="jira-username" type="text" value=jiraCreds.username class="form-control"}}
|
||||||
<small class="form-text text-muted">Your Jira login username/email</small>
|
<small class="form-text text-muted">Your Jira login username/email</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="siteTitle" class="col-sm-4 col-form-label">Password</label>
|
<label for="jira-secret" class="col-sm-4 col-form-label">Password</label>
|
||||||
<div class="col-sm-7">
|
<div class="col-sm-7">
|
||||||
{{input id="jira-secret" type="password" value=jiraCreds.secret class="form-control"}}
|
{{input id="jira-secret" type="password" value=jiraCreds.secret class="form-control"}}
|
||||||
<small class="form-text text-muted">Provide API Token if using Atlassian Cloud or Password when self-hosting Jira</small>
|
<small class="form-text text-muted">Provide API Token if using Atlassian Cloud or Password when self-hosting Jira</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{#if session.isGlobalAdmin}}
|
||||||
|
<h2>Trello</h2>
|
||||||
|
<p>Displays boards within documentation</p>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="trello-key" class="col-sm-4 col-form-label">App Key</label>
|
||||||
|
<div class="col-sm-7">
|
||||||
|
{{input id="trello-key" type="text" value=trelloCreds.appKey class="form-control"}}
|
||||||
|
<small class="form-text text-muted">See <a href="https://trello.com/app-key">https://trello.com/app-key</a></small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<div class="btn btn-success font-weight-bold text-uppercase mt-4" {{action 'onSave'}}>Save</div>
|
<div class="btn btn-success font-weight-bold text-uppercase mt-4" {{action 'onSave'}}>Save</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
|
@ -117,10 +117,12 @@ func RegisterEndpoints(rt *env.Runtime, s *domain.Store) {
|
||||||
AddPrivate(rt, "documents/{documentID}/pages/{pageID}/meta", []string{"GET", "OPTIONS"}, nil, page.GetMeta)
|
AddPrivate(rt, "documents/{documentID}/pages/{pageID}/meta", []string{"GET", "OPTIONS"}, nil, page.GetMeta)
|
||||||
AddPrivate(rt, "documents/{documentID}/pages/{pageID}/copy/{targetID}", []string{"POST", "OPTIONS"}, nil, page.Copy)
|
AddPrivate(rt, "documents/{documentID}/pages/{pageID}/copy/{targetID}", []string{"POST", "OPTIONS"}, nil, page.Copy)
|
||||||
|
|
||||||
|
AddPrivate(rt, "organization/setting", []string{"GET", "OPTIONS"}, nil, organization.GetGlobalSetting)
|
||||||
|
AddPrivate(rt, "organization/setting", []string{"POST", "OPTIONS"}, nil, organization.SaveGlobalSetting)
|
||||||
AddPrivate(rt, "organization/{orgID}", []string{"GET", "OPTIONS"}, nil, organization.Get)
|
AddPrivate(rt, "organization/{orgID}", []string{"GET", "OPTIONS"}, nil, organization.Get)
|
||||||
AddPrivate(rt, "organization/{orgID}", []string{"PUT", "OPTIONS"}, nil, organization.Update)
|
AddPrivate(rt, "organization/{orgID}", []string{"PUT", "OPTIONS"}, nil, organization.Update)
|
||||||
AddPrivate(rt, "organization/{orgID}/setting", []string{"GET", "OPTIONS"}, nil, organization.GetSetting)
|
AddPrivate(rt, "organization/{orgID}/setting", []string{"GET", "OPTIONS"}, nil, organization.GetInstanceSetting)
|
||||||
AddPrivate(rt, "organization/{orgID}/setting", []string{"POST", "OPTIONS"}, nil, organization.SaveSetting)
|
AddPrivate(rt, "organization/{orgID}/setting", []string{"POST", "OPTIONS"}, nil, organization.SaveInstanceSetting)
|
||||||
|
|
||||||
AddPrivate(rt, "space/{spaceID}", []string{"DELETE", "OPTIONS"}, nil, space.Delete)
|
AddPrivate(rt, "space/{spaceID}", []string{"DELETE", "OPTIONS"}, nil, space.Delete)
|
||||||
AddPrivate(rt, "space/{spaceID}/move/{moveToId}", []string{"DELETE", "OPTIONS"}, nil, space.Remove)
|
AddPrivate(rt, "space/{spaceID}/move/{moveToId}", []string{"DELETE", "OPTIONS"}, nil, space.Remove)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue