code to update repo params and flags. added styling as well
This commit is contained in:
parent
6b9ae21c7a
commit
50b659cadb
7 changed files with 327 additions and 89 deletions
|
@ -204,29 +204,16 @@ app.controller("ConfigController", function($scope, $http, user) {
|
|||
});
|
||||
|
||||
app.controller("RepoConfigController", function($scope, $http, $routeParams, user) {
|
||||
|
||||
$scope.user = user;
|
||||
|
||||
var remote = $routeParams.remote;
|
||||
var owner = $routeParams.owner;
|
||||
var name = $routeParams.name;
|
||||
|
||||
|
||||
|
||||
// load the repo meta-data
|
||||
$http({method: 'GET', url: '/v1/repos/'+remote+'/'+owner+"/"+name}).
|
||||
$http({method: 'GET', url: '/v1/repos/'+remote+'/'+owner+"/"+name+"?admin=1"}).
|
||||
success(function(data, status, headers, config) {
|
||||
$scope.repo = data;
|
||||
$scope.repoTemp = {
|
||||
pull_requests : $scope.repo.pull_requests,
|
||||
post_commits : $scope.repo.post_commits,
|
||||
params : $scope.repo.params,
|
||||
timeout : $scope.repo.timeout,
|
||||
privileged : $scope.repo.privileged
|
||||
};
|
||||
|
||||
$scope.badgeMarkdown = badgeMarkdown(data.remote+"/"+data.owner+"/"+data.name)
|
||||
$scope.badgeMarkup = badgeMarkup(data.remote+"/"+data.owner+"/"+data.name)
|
||||
}).
|
||||
error(function(data, status, headers, config) {
|
||||
console.log(data);
|
||||
|
@ -234,25 +221,14 @@ app.controller("RepoConfigController", function($scope, $http, $routeParams, use
|
|||
|
||||
$scope.save = function() {
|
||||
// request to create a new repository
|
||||
$http({method: 'PUT', url: '/v1/repos/'+remote+'/'+owner+"/"+name, data: $scope.repoTemp }).
|
||||
$http({method: 'PUT', url: '/v1/repos/'+remote+'/'+owner+"/"+name, data: $scope.repo }).
|
||||
success(function(data, status, headers, config) {
|
||||
delete $scope.failure;
|
||||
$scope.repo = data;
|
||||
}).
|
||||
error(function(data, status, headers, config) {
|
||||
$scope.failure = data;
|
||||
});
|
||||
};
|
||||
$scope.cancel = function() {
|
||||
delete $scope.failure;
|
||||
$scope.repoTemp = {
|
||||
pull_requests : $scope.repo.pull_requests,
|
||||
post_commits : $scope.repo.post_commits,
|
||||
params : $scope.repo.params,
|
||||
timeout : $scope.repo.timeout,
|
||||
privileged : $scope.repo.privileged
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
function badgeMarkdown(repo) {
|
||||
|
|
|
@ -32,6 +32,7 @@ angular.module('app').filter('fullName', function() {
|
|||
|
||||
angular.module('app').filter('fullPath', function() {
|
||||
return function(repo) {
|
||||
if (repo == undefined) { return ""; }
|
||||
return repo.remote+"/"+repo.owner+"/"+repo.name;
|
||||
}
|
||||
});
|
||||
|
@ -45,6 +46,7 @@ angular.module('app').filter('shortHash', function() {
|
|||
|
||||
angular.module('app').filter('badgeMarkdown', function() {
|
||||
return function(repo) {
|
||||
if (repo == undefined) { return ""; }
|
||||
var scheme = window.location.protocol;
|
||||
var host = window.location.host;
|
||||
var path = repo.host+'/'+repo.owner+'/'+repo.name;
|
||||
|
@ -54,6 +56,7 @@ angular.module('app').filter('badgeMarkdown', function() {
|
|||
|
||||
angular.module('app').filter('badgeMarkup', function() {
|
||||
return function(repo) {
|
||||
if (repo == undefined) { return ""; }
|
||||
var scheme = window.location.protocol;
|
||||
var host = window.location.host;
|
||||
var path = repo.host+'/'+repo.owner+'/'+repo.name;
|
||||
|
@ -65,6 +68,9 @@ angular.module('app').filter('unique', function() {
|
|||
return function(input, key) {
|
||||
var unique = {};
|
||||
var uniqueList = [];
|
||||
if (input == undefined) {
|
||||
return uniqueList;
|
||||
}
|
||||
for(var i = 0; i < input.length; i++){
|
||||
if(typeof unique[input[i][key]] == "undefined"){
|
||||
unique[input[i][key]] = "";
|
||||
|
|
|
@ -849,6 +849,55 @@ nav div.options .pure-button i {
|
|||
color: #666;
|
||||
font-size: 14px;
|
||||
}
|
||||
#repoconfpage {
|
||||
width: 100%;
|
||||
}
|
||||
#repoconfpage section {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-ms-box-sizing: border-box;
|
||||
-o-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #eee;
|
||||
max-width: 768px;
|
||||
margin: 0px auto;
|
||||
margin-top: 30px;
|
||||
margin-bottom: 30px;
|
||||
padding: 20px;
|
||||
}
|
||||
#repoconfpage section h2 {
|
||||
font-size: 16px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
#repoconfpage section .markdown,
|
||||
#repoconfpage section .params,
|
||||
#repoconfpage section .key {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-ms-box-sizing: border-box;
|
||||
-o-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
min-height: 50px;
|
||||
margin-top: 10px;
|
||||
font-family: 'Droid Sans Mono';
|
||||
border: 1px solid #eee;
|
||||
padding: 20px;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
color: #666;
|
||||
}
|
||||
#repoconfpage section .markdown:focus,
|
||||
#repoconfpage section .params:focus,
|
||||
#repoconfpage section .key:focus {
|
||||
border-color: #129FEA;
|
||||
outline: 0;
|
||||
}
|
||||
#repoconfpage section .pure-button-primary {
|
||||
color: #FFF;
|
||||
background: #4ab1ce;
|
||||
padding: 10px 20px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
#accountpage {
|
||||
width: 100%;
|
||||
}
|
||||
|
@ -943,7 +992,7 @@ nav div.options .pure-button i {
|
|||
color: #FFF;
|
||||
background: #4ab1ce;
|
||||
padding: 10px 20px;
|
||||
float: right;
|
||||
margin-top: 10px;
|
||||
}
|
||||
#repopage {
|
||||
width: 100%;
|
||||
|
@ -1189,4 +1238,74 @@ nav div.options .pure-button i {
|
|||
min-width: 300px;
|
||||
box-shadow: none;
|
||||
padding: 10px 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 0px;
|
||||
}
|
||||
.toggle {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.toggle:nth-child(2) {
|
||||
margin-top: 40px;
|
||||
}
|
||||
.toggle span {
|
||||
line-height: 32px;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.toggle input[type='checkbox'] {
|
||||
max-height: 0;
|
||||
max-width: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
.toggle input[type='checkbox'] + label {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
box-shadow: inset 0 0 0px 1px #d5d5d5;
|
||||
text-indent: -5000px;
|
||||
height: 30px;
|
||||
width: 50px;
|
||||
border-radius: 15px;
|
||||
}
|
||||
.toggle input[type='checkbox'] + label:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: block;
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
top: 0;
|
||||
left: 0;
|
||||
border-radius: 15px;
|
||||
background: rgba(19, 191, 17, 0);
|
||||
-webkit-transition: 0.25s ease-in-out;
|
||||
-moz-transition: 0.25s ease-in-out;
|
||||
-ms-transition: 0.25s ease-in-out;
|
||||
-o-transition: 0.25s ease-in-out;
|
||||
transition: 0.25s ease-in-out;
|
||||
}
|
||||
.toggle input[type='checkbox'] + label:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: block;
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
top: 0;
|
||||
left: 0px;
|
||||
border-radius: 15px;
|
||||
background: white;
|
||||
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
-webkit-transition: 0.25s ease-in-out;
|
||||
-moz-transition: 0.25s ease-in-out;
|
||||
-ms-transition: 0.25s ease-in-out;
|
||||
-o-transition: 0.25s ease-in-out;
|
||||
transition: 0.25s ease-in-out;
|
||||
}
|
||||
.toggle input[type='checkbox']:checked + label:before {
|
||||
width: 50px;
|
||||
background: #4ab1ce;
|
||||
}
|
||||
.toggle input[type='checkbox']:checked + label:after {
|
||||
left: 20px;
|
||||
box-shadow: inset 0 0 0 1px #4ab1ce, 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
@logo: 'Orbitron';
|
||||
@sans: 'Open Sans';
|
||||
@mono: 'Droid Sans Mono';
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
|
@ -761,6 +762,46 @@ nav {
|
|||
}
|
||||
}
|
||||
|
||||
#repoconfpage {
|
||||
width:100%;
|
||||
section {
|
||||
.border_box;
|
||||
border:1px solid #eee;
|
||||
max-width:768px;
|
||||
margin:0px auto;
|
||||
margin-top:30px;
|
||||
margin-bottom:30px;
|
||||
padding:20px;
|
||||
h2 {
|
||||
font-size: 16px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.markdown,
|
||||
.params,
|
||||
.key {
|
||||
.border_box;
|
||||
min-height:50px;
|
||||
margin-top:10px;
|
||||
font-family:@mono;
|
||||
border:1px solid #eee;
|
||||
padding:20px;
|
||||
width:100%;
|
||||
max-width:100%;
|
||||
color:#666;
|
||||
&:focus {
|
||||
border-color: #129FEA;
|
||||
outline: 0;
|
||||
}
|
||||
}
|
||||
.pure-button-primary {
|
||||
color:#FFF;
|
||||
background: @link2;
|
||||
padding:10px 20px;
|
||||
margin-top:20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#accountpage {
|
||||
width:100%;
|
||||
section {
|
||||
|
@ -852,7 +893,7 @@ nav {
|
|||
color:#FFF;
|
||||
background: @link2;
|
||||
padding:10px 20px;
|
||||
float:right;
|
||||
margin-top:10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1042,7 +1083,7 @@ nav {
|
|||
margin:0px auto;
|
||||
padding:30px;
|
||||
color:#FFF;
|
||||
font-family:'Droid Sans Mono';
|
||||
font-family:@mono;
|
||||
font-size:13px;
|
||||
white-space: pre-wrap;
|
||||
overflow: hidden;
|
||||
|
@ -1066,5 +1107,84 @@ nav {
|
|||
min-width:300px;
|
||||
box-shadow:none;
|
||||
padding:10px 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius:0px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.toggle {
|
||||
margin-bottom:10px;
|
||||
&:nth-child(2) {
|
||||
margin-top:40px;
|
||||
}
|
||||
span {
|
||||
line-height:32px;
|
||||
vertical-align:middle;
|
||||
display: inline-block;
|
||||
margin-left:10px;
|
||||
}
|
||||
input[type='checkbox'] {
|
||||
max-height: 0;
|
||||
max-width: 0;
|
||||
opacity: 0;
|
||||
|
||||
// The following provides the "container" for our toggle
|
||||
// in its default (off) state
|
||||
& + label {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
box-shadow: inset 0 0 0px 1px #d5d5d5;
|
||||
text-indent: -5000px;
|
||||
height: 30px;
|
||||
width: 50px;
|
||||
border-radius: 15px;
|
||||
|
||||
// The following provides the green background for the
|
||||
// "on" state of our toggle - it is hidden when the
|
||||
// switch is off
|
||||
&:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: block;
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
top: 0;
|
||||
left: 0;
|
||||
border-radius: 15px;
|
||||
background: rgba(19,191,17,0);
|
||||
.transition(.25s ease-in-out);
|
||||
}
|
||||
|
||||
|
||||
// The following provides the actual switch
|
||||
// and its drop shadow
|
||||
&:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: block;
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
top: 0;
|
||||
left: 0px;
|
||||
border-radius: 15px;
|
||||
background: white;
|
||||
box-shadow: inset 0 0 0 1px rgba(0,0,0,.2), 0 2px 4px rgba(0,0,0,.2);
|
||||
.transition(.25s ease-in-out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The following defines the "on" state for the switch
|
||||
&:checked + label:before {
|
||||
width: 50px;
|
||||
background: @link2;
|
||||
}
|
||||
|
||||
&:checked + label:after {
|
||||
left: 20px;
|
||||
box-shadow: inset 0 0 0 1px @link2, 0 2px 4px rgba(0,0,0,.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
server/app/styles/drone.min.css
vendored
2
server/app/styles/drone.min.css
vendored
File diff suppressed because one or more lines are too long
|
@ -1,74 +1,72 @@
|
|||
<article id="repopage">
|
||||
<article id="repoconfpage">
|
||||
<nav>
|
||||
<a href="/{{ repo | fullPath}}"><span class="fa fa-arrow-left"></span></a>
|
||||
<a href="/{{ repo | fullPath }}">
|
||||
<span class="fa fa-arrow-left"></span>
|
||||
</a>
|
||||
<span>{{ repo.owner }}</span>
|
||||
<span>/</span>
|
||||
<a href="/{{ repo | fullPath}}">{{ repo.name }}</a>
|
||||
<a href="/{{ repo | fullPath }}">{{ repo.name }}</a>
|
||||
<span>/</span>
|
||||
<a href="#">settings</a>
|
||||
</nav>
|
||||
|
||||
<!-- this section is used for generating the build status badge's url -->
|
||||
<section>
|
||||
<div class="pure-g">
|
||||
<div class="pure-u-1">
|
||||
<a href="/{{ repo | fullPath }}" target="_blank" style="float:right;">
|
||||
<img ng-src="/v1/badge/{{ repo | fullPath }}/status.svg" />
|
||||
</a>
|
||||
<h2>Status Badge</h2>
|
||||
</div>
|
||||
<div class="pure-u-1">
|
||||
<div class="markdown">{{ repo | badgeMarkdown }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
|
||||
<!-- summary column -->
|
||||
<div class="col-xs-6 col-sm-3">
|
||||
<!-- badge -->
|
||||
<a href="/{{ repo.remote }}/{{ repo.owner}}/{{ repo.name }}">
|
||||
<img ng-src="/v1/badge/{{ repo.remote }}/{{ repo.owner}}/{{ repo.name }}/status.svg" />
|
||||
</a>
|
||||
<div class="pure-g">
|
||||
<div class="pure-u-1">
|
||||
<div>
|
||||
<h2>Public Key</h2>
|
||||
<pre class="key">{{ repo.public_key }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- primary column -->
|
||||
<div class="col-xs-12 col-sm-9">
|
||||
|
||||
<div>
|
||||
<label>Post Commit Hook</label>
|
||||
<input type="checkbox" ng-model="repoTemp.post_commits" />
|
||||
<section>
|
||||
<div class="pure-g">
|
||||
<div class="pure-u-1">
|
||||
<div>
|
||||
<h2>Private Variables</h2>
|
||||
<textarea class="params" ng-model="repo.params" placeholder="FOO=BAR"></textarea>
|
||||
<button ng-click="save()" class="pure-button pure-button-primary">Save Variables</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div>
|
||||
<label>Pull Reqest Hook</label>
|
||||
<input type="checkbox" ng-model="repoTemp.pull_requests" />
|
||||
</div>
|
||||
<!-- this section is used to toggle builds and pull requests builds on and off -->
|
||||
<section>
|
||||
<div class="pure-g">
|
||||
<div class="pure-u-1">
|
||||
<div>
|
||||
<h2>Build Flags</h2>
|
||||
<div class="toggle">
|
||||
<input type="checkbox" ng-model="repo.post_commits" id="post_commit" />
|
||||
<label for="post_commit"></label>
|
||||
<span>Enable Post Commit Hooks</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>Private Variables</label>
|
||||
<div>TODO!</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>Privileged</label>
|
||||
<input type="checkbox" ng-model="repoTemp.privileged" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>Timeout</label>
|
||||
<input type="number" ng-model="repoTemp.timeout" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>URL</label>
|
||||
<span>{{ repo.url }}</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>Created</label>
|
||||
<span>{{ repo.created_at | fromNow }}</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>Updated</label>
|
||||
<span>{{ repo.updated_at | fromNow }}</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{failure}}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button ng-click="save()">Save</button>
|
||||
<button ng-click="cancel()">Cancel</button>
|
||||
<div class="toggle">
|
||||
<input type="checkbox" ng-model="repo.pull_requests" id="pull_requests" />
|
||||
<label for="pull_requests"></label>
|
||||
<span>Enable Pull Request Hooks</span>
|
||||
</div>
|
||||
<button ng-click="save()" class="pure-button pure-button-primary">Save Flags</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/drone/drone/server/database"
|
||||
"github.com/drone/drone/server/session"
|
||||
"github.com/drone/drone/shared/httputil"
|
||||
"github.com/drone/drone/shared/model"
|
||||
"github.com/drone/drone/shared/sshutil"
|
||||
"github.com/gorilla/pat"
|
||||
)
|
||||
|
@ -29,6 +30,7 @@ func NewRepoHandler(repos database.RepoManager, commits database.CommitManager,
|
|||
// GET /v1/repos/:host/:owner/:name
|
||||
func (h *RepoHandler) GetRepo(w http.ResponseWriter, r *http.Request) error {
|
||||
var host, owner, name = parseRepo(r)
|
||||
var admin = r.FormValue("admin")
|
||||
|
||||
// get the user form the session.
|
||||
user := h.sess.User(r)
|
||||
|
@ -44,7 +46,24 @@ func (h *RepoHandler) GetRepo(w http.ResponseWriter, r *http.Request) error {
|
|||
return notFound{err}
|
||||
}
|
||||
|
||||
return json.NewEncoder(w).Encode(repo)
|
||||
// if the user is not requesting admin data we can
|
||||
// return exactly what we have.
|
||||
if len(admin) == 0 {
|
||||
return json.NewEncoder(w).Encode(repo)
|
||||
}
|
||||
|
||||
// ammend the response to include data that otherwise
|
||||
// would be excluded from json serialization, assuming
|
||||
// the user is actually an admin of the repo.
|
||||
if ok, _ := h.perms.Admin(user, repo); !ok {
|
||||
return notFound{err}
|
||||
}
|
||||
|
||||
return json.NewEncoder(w).Encode(struct {
|
||||
*model.Repo
|
||||
PublicKey string `json:"public_key"`
|
||||
Params string `json:"params"`
|
||||
}{repo, repo.PublicKey, repo.Params})
|
||||
}
|
||||
|
||||
// PostRepo activates the named repository.
|
||||
|
|
Loading…
Reference in a new issue