mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-22 18:01:02 +00:00
ability to save repository settings
This commit is contained in:
parent
feea108f51
commit
e72289c468
4 changed files with 65 additions and 19 deletions
|
@ -36,14 +36,14 @@
|
|||
<i class="{{"fa"}} {{"fa-dashboard"}}"></i>
|
||||
</a>
|
||||
</header>
|
||||
<section class="{{"pure-u-1"}}">
|
||||
<form class="{{"pure-form"}} {{"pure-form-stacked"}}">
|
||||
<section class="{{"pure-u-1"}}">{{$__amber_24 := .Repo.Name}}{{$__amber_25 := .Repo.Owner}}{{$__amber_26 := .Repo.Host}}{{$__amber_27 := __amber_add "/v1/repos/" $__amber_26}}{{$__amber_28 := __amber_add $__amber_27 "/"}}{{$__amber_29 := __amber_add $__amber_28 $__amber_25}}{{$__amber_30 := __amber_add $__amber_29 "/"}}{{$__amber_31 := __amber_add $__amber_30 $__amber_24}}
|
||||
<form class="{{"pure-form"}} {{"pure-form-stacked"}}" action="{{$__amber_31}}">
|
||||
<fieldset>
|
||||
<details open>
|
||||
<summary>Commit Hooks</summary>
|
||||
<div class="{{"pure-control-group"}}">
|
||||
<div class="{{"onoffswitch"}}">{{$__amber_24 := .Repo.PostCommit}}
|
||||
<input type="{{"checkbox"}}" name="{{"post_commits"}}" checked="{{$__amber_24}}" class="{{"onoffswitch-checkbox"}}" id="{{"post_commits"}}" />
|
||||
<div class="{{"onoffswitch"}}">{{$__amber_32 := .Repo.PostCommit}}
|
||||
<input type="{{"checkbox"}}" name="{{"post_commits"}}" checked="{{$__amber_32}}" class="{{"onoffswitch-checkbox"}}" id="{{"post_commits"}}" />
|
||||
<label class="{{"onoffswitch-label"}}" for="{{"post_commits"}}">
|
||||
<div class="{{"onoffswitch-inner"}}">
|
||||
<div class="{{"onoffswitch-active"}}">
|
||||
|
@ -58,8 +58,8 @@
|
|||
<span>Post Commit Hooks</span>
|
||||
</div>
|
||||
<div class="{{"pure-control-group"}}">
|
||||
<div class="{{"onoffswitch"}}">{{$__amber_25 := .Repo.PullRequest}}
|
||||
<input type="{{"checkbox"}}" name="{{"pull_requests"}}" checked="{{$__amber_25}}" class="{{"onoffswitch-checkbox"}}" id="{{"pull_requests"}}" />
|
||||
<div class="{{"onoffswitch"}}">{{$__amber_33 := .Repo.PullRequest}}
|
||||
<input type="{{"checkbox"}}" name="{{"pull_requests"}}" checked="{{$__amber_33}}" class="{{"onoffswitch-checkbox"}}" id="{{"pull_requests"}}" />
|
||||
<label class="{{"onoffswitch-label"}}" for="{{"pull_requests"}}">
|
||||
<div class="{{"onoffswitch-inner"}}">
|
||||
<div class="{{"onoffswitch-active"}}">
|
||||
|
@ -76,18 +76,18 @@
|
|||
</details>
|
||||
<details>
|
||||
<summary>Badges</summary>
|
||||
<textarea spellcheck="{{"false"}}">{{$__amber_26 := .Repo.Remote}}{{$__amber_27 := .Repo.Owner}}{{$__amber_28 := .Repo.Name}}{{$__amber_29 := .Repo.Remote}}{{$__amber_30 := .Repo.Owner}}{{$__amber_31 := .Repo.Name}}[![Build Status]({{.Scheme}}://{{.Host}}/v1/badge/{{$__amber_26}}/{{$__amber_27}}/{{$__amber_28}}/status.svg)]({{.Scheme}}://{{.Host}}/{{$__amber_29}}/{{$__amber_30}}/{{$__amber_31}})</textarea>
|
||||
<textarea spellcheck="{{"false"}}">{{$__amber_34 := .Repo.Remote}}{{$__amber_35 := .Repo.Owner}}{{$__amber_36 := .Repo.Name}}{{$__amber_37 := .Repo.Remote}}{{$__amber_38 := .Repo.Owner}}{{$__amber_39 := .Repo.Name}}[![Build Status]({{.Scheme}}://{{.Host}}/v1/badge/{{$__amber_34}}/{{$__amber_35}}/{{$__amber_36}}/status.svg)]({{.Scheme}}://{{.Host}}/{{$__amber_37}}/{{$__amber_38}}/{{$__amber_39}})</textarea>
|
||||
</details>
|
||||
<details>
|
||||
<summary>Private Variables</summary>
|
||||
<textarea spellcheck="{{"false"}}" placeholder="{{"FOO: BAR"}}">{{$__amber_32 := .Repo.Params}}{{$__amber_32}}</textarea>
|
||||
<textarea spellcheck="{{"false"}}" placeholder="{{"FOO: BAR"}}" name="{{"params"}}">{{$__amber_40 := .Repo.Params}}{{$__amber_40}}</textarea>
|
||||
</details>
|
||||
<details>
|
||||
<summary>Public Key</summary>
|
||||
<textarea spellcheck="{{"false"}}" rows="{{"5"}}">{{$__amber_33 := .Repo.PublicKey}}{{$__amber_33}}</textarea>
|
||||
<textarea spellcheck="{{"false"}}" rows="{{"5"}}">{{$__amber_41 := .Repo.PublicKey}}{{$__amber_41}}</textarea>
|
||||
</details>
|
||||
<div class="{{"pure-controls"}}">
|
||||
<button class="{{"pure-button"}} {{"pure-button-primary"}}">Save</button>
|
||||
<button class="{{"pure-button"}} {{"pure-button-primary"}}" type="{{"submit"}}">Save</button>
|
||||
<button class="{{"pure-button"}} {{"pure-button-secondary"}}" type="{{"reset"}}">Reset</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
@ -98,5 +98,29 @@
|
|||
<script src="{{"//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"}}"></script>
|
||||
<script src="{{"//cdnjs.cloudflare.com/ajax/libs/jquery-timeago/1.1.0/jquery.timeago.js"}}"></script>
|
||||
<script src="{{"/static/scripts/main.js"}}"></script>
|
||||
<script>
|
||||
{{$__amber_42 := .Repo.PostCommit}}{{$__amber_43 := .Repo.PullRequest}}document.getElementById("post_commits").checked = {{$__amber_42}};
|
||||
document.getElementById("pull_requests").checked = {{$__amber_43}};
|
||||
document.forms[0].onsubmit = function(event) {
|
||||
event.preventDefault();
|
||||
var form = event.target;
|
||||
$.ajax({
|
||||
url: form.action,
|
||||
type: 'PUT',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
post_commits: form.elements.post_commits.checked,
|
||||
pull_requests: form.elements.pull_requests.checked,
|
||||
params: form.elements.params.value
|
||||
}),
|
||||
dataType: 'json'
|
||||
}).done(function() {
|
||||
alert( "success" );
|
||||
}).fail(function() {
|
||||
alert( "error" );
|
||||
});
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -87,13 +87,12 @@
|
|||
<script></script>{{else}}
|
||||
<script>
|
||||
document.forms[0].onsubmit = function(event) {
|
||||
|
||||
var form = event.target
|
||||
var form = event.target;
|
||||
var formData = new FormData(form);
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', form.action);
|
||||
xhr.onload = function() {
|
||||
if (this.status == 200) {
|
||||
if (this.status == 201) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
$("#alert").text("Failed to activate the repository settings. Please try again");
|
||||
|
|
|
@ -16,7 +16,7 @@ block content
|
|||
i.fa.fa-dashboard
|
||||
|
||||
section.pure-u-1
|
||||
form.pure-form.pure-form-stacked
|
||||
form.pure-form.pure-form-stacked[action="/v1/repos/"+Repo.Host+"/"+Repo.Owner+"/"+Repo.Name]
|
||||
fieldset
|
||||
details[open]
|
||||
summary Commit Hooks
|
||||
|
@ -40,17 +40,41 @@ block content
|
|||
div.onoffswitch-inactive
|
||||
div.onoffswitch-switch OFF
|
||||
span Pull Request Hooks
|
||||
|
||||
details
|
||||
summary Badges
|
||||
textarea[spellcheck="false"] [![Build Status](#{Scheme}://#{Host}/v1/badge/#{Repo.Remote}/#{Repo.Owner}/#{Repo.Name}/status.svg)](#{Scheme}://#{Host}/#{Repo.Remote}/#{Repo.Owner}/#{Repo.Name})
|
||||
details
|
||||
summary Private Variables
|
||||
textarea[spellcheck="false"][placeholder="FOO: BAR"] #{Repo.Params}
|
||||
textarea[spellcheck="false"][placeholder="FOO: BAR"][name="params"] #{Repo.Params}
|
||||
details
|
||||
summary Public Key
|
||||
textarea[spellcheck="false"][rows="5"] #{Repo.PublicKey}
|
||||
|
||||
div.pure-controls
|
||||
button.pure-button.pure-button-primary Save
|
||||
button.pure-button.pure-button-primary[type="submit"] Save
|
||||
button.pure-button.pure-button-secondary[type="reset"] Reset
|
||||
|
||||
block append scripts
|
||||
script
|
||||
document.getElementById("post_commits").checked = #{Repo.PostCommit};
|
||||
document.getElementById("pull_requests").checked = #{Repo.PullRequest};
|
||||
document.forms[0].onsubmit = function(event) {
|
||||
event.preventDefault();
|
||||
var form = event.target;
|
||||
$.ajax({
|
||||
url: form.action,
|
||||
type: 'PUT',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
post_commits: form.elements.post_commits.checked,
|
||||
pull_requests: form.elements.pull_requests.checked,
|
||||
params: form.elements.params.value
|
||||
}),
|
||||
dataType: 'json'
|
||||
}).done(function() {
|
||||
alert( "success" );
|
||||
}).fail(function() {
|
||||
alert( "error" );
|
||||
});
|
||||
return false;
|
||||
}
|
|
@ -64,8 +64,7 @@ block append scripts
|
|||
else
|
||||
script
|
||||
document.forms[0].onsubmit = function(event) {
|
||||
|
||||
var form = event.target
|
||||
var form = event.target;
|
||||
var formData = new FormData(form);
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', form.action);
|
||||
|
|
Loading…
Reference in a new issue