Little refactoring of all assets. JS code better identing.

This commit is contained in:
Alexander Simonov 2015-07-12 22:32:46 +03:00
parent 78a30c8d59
commit 229e88a438
No known key found for this signature in database
GPG key ID: 5CCFFED829314C35
12 changed files with 2112 additions and 2064 deletions

View file

@ -1,46 +1,46 @@
<!DOCTYPE html>
<html ng-app="drone" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="/"/>
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Open+Sans:400,600,300' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/icon?family=Material+Icons' rel='stylesheet' type='text/css'>
<link href='//cdnjs.cloudflare.com/ajax/libs/octicons/2.1.2/octicons.min.css' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Droid+Sans+Mono" />
<link href='/static/styles/drone.css' rel='stylesheet' type='text/css'>
<link rel="icon" href="/static/favicon.png">
<base href="/"/>
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Open+Sans:400,600,300' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/icon?family=Material+Icons' rel='stylesheet' type='text/css'>
<link href='//cdnjs.cloudflare.com/ajax/libs/octicons/2.1.2/octicons.min.css' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Droid+Sans+Mono"/>
<link href='/static/styles/drone.css' rel='stylesheet' type='text/css'>
<link rel="icon" href="/static/favicon.png">
</head>
<body>
<div ui-view="layout"></div>
<div ui-view="layout"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-route.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-resource.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.6.0/moment.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-route.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-resource.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.6.0/moment.min.js"></script>
<!-- main javascript application -->
<script src="/static/scripts/term.js"></script>
<script src="/static/scripts/drone.js"></script>
<script src="/static/scripts/controllers/repos.js"></script>
<script src="/static/scripts/controllers/builds.js"></script>
<script src="/static/scripts/controllers/users.js"></script>
<!-- main javascript application -->
<script src="/static/scripts/term.js"></script>
<script src="/static/scripts/drone.js"></script>
<script src="/static/scripts/controllers/repos.js"></script>
<script src="/static/scripts/controllers/builds.js"></script>
<script src="/static/scripts/controllers/users.js"></script>
<script src="/static/scripts/services/repos.js"></script>
<script src="/static/scripts/services/builds.js"></script>
<script src="/static/scripts/services/users.js"></script>
<script src="/static/scripts/services/logs.js"></script>
<script src="/static/scripts/services/tokens.js"></script>
<script src="/static/scripts/services/feed.js"></script>
<script src="/static/scripts/services/repos.js"></script>
<script src="/static/scripts/services/builds.js"></script>
<script src="/static/scripts/services/users.js"></script>
<script src="/static/scripts/services/logs.js"></script>
<script src="/static/scripts/services/tokens.js"></script>
<script src="/static/scripts/services/feed.js"></script>
<script src="/static/scripts/filters/filter.js"></script>
<script src="/static/scripts/filters/gravatar.js"></script>
<script src="/static/scripts/filters/time.js"></script>
<script src="/static/scripts/filters/filter.js"></script>
<script src="/static/scripts/filters/gravatar.js"></script>
<script src="/static/scripts/filters/time.js"></script>
</body>
</html>

View file

@ -1,221 +1,221 @@
(function () {
/**
* BuildsCtrl responsible for rendering the repo's
* recent build history.
*/
function BuildsCtrl($scope, $stateParams, builds, repos, users, logs) {
var owner = $stateParams.owner;
var name = $stateParams.name;
var fullName = owner+'/'+name;
/**
* BuildsCtrl responsible for rendering the repo's
* recent build history.
*/
function BuildsCtrl($scope, $stateParams, builds, repos, users, logs) {
var owner = $stateParams.owner;
var name = $stateParams.name;
var fullName = owner + '/' + name;
// Gets the currently authenticated user
users.getCached().then(function(payload){
$scope.user = payload.data;
});
// Gets the currently authenticated user
users.getCached().then(function (payload) {
$scope.user = payload.data;
});
// Gets a repository
repos.get(fullName).then(function(payload){
$scope.repo = payload.data;
}).catch(function(err){
$scope.error = err;
});
// Gets a repository
repos.get(fullName).then(function (payload) {
$scope.repo = payload.data;
}).catch(function (err) {
$scope.error = err;
});
// Gets a list of builds
builds.list(fullName).then(function(payload){
$scope.builds = angular.isArray(payload.data) ? payload.data : [];
}).catch(function(err){
$scope.error = err;
});
// Gets a list of builds
builds.list(fullName).then(function (payload) {
$scope.builds = angular.isArray(payload.data) ? payload.data : [];
}).catch(function (err) {
$scope.error = err;
});
$scope.watch = function(repo) {
repos.watch(repo.full_name).then(function(payload) {
$scope.repo.starred = true;
});
}
$scope.watch = function (repo) {
repos.watch(repo.full_name).then(function (payload) {
$scope.repo.starred = true;
});
};
$scope.unwatch = function(repo) {
repos.unwatch(repo.full_name).then(function() {
$scope.repo.starred = false;
});
}
$scope.unwatch = function (repo) {
repos.unwatch(repo.full_name).then(function () {
$scope.repo.starred = false;
});
};
repos.subscribe(fullName, function(event) {
var added = false;
for (var i=0;i<$scope.builds.length;i++) {
var build = $scope.builds[i];
if (event.number !== build.number) {
continue; // ignore
}
// update the build status
$scope.builds[i] = event;
$scope.$apply();
added = true;
}
repos.subscribe(fullName, function (event) {
var added = false;
for (var i = 0; i < $scope.builds.length; i++) {
var build = $scope.builds[i];
if (event.number !== build.number) {
continue; // ignore
}
// update the build status
$scope.builds[i] = event;
$scope.$apply();
added = true;
}
if (!added) {
$scope.builds.push(event);
$scope.$apply();
}
});
}
if (!added) {
$scope.builds.push(event);
$scope.$apply();
}
});
}
/**
* BuildCtrl responsible for rendering a build.
*/
function BuildCtrl($scope, $stateParams, $window, logs, builds, repos, users) {
/**
* BuildCtrl responsible for rendering a build.
*/
function BuildCtrl($scope, $stateParams, $window, logs, builds, repos, users) {
var number = $stateParams.number;
var owner = $stateParams.owner;
var name = $stateParams.name;
var fullName = owner+'/'+name;
var number = $stateParams.number;
var owner = $stateParams.owner;
var name = $stateParams.name;
var fullName = owner + '/' + name;
// Gets the currently authenticated user
users.getCached().then(function(payload){
$scope.user = payload.data;
});
// Gets the currently authenticated user
users.getCached().then(function (payload) {
$scope.user = payload.data;
});
// Gets a repository
repos.get(fullName).then(function(payload){
$scope.repo = payload.data;
}).catch(function(err){
$scope.error = err;
});
// Gets a repository
repos.get(fullName).then(function (payload) {
$scope.repo = payload.data;
}).catch(function (err) {
$scope.error = err;
});
// Gets the build
builds.get(fullName, number).then(function(payload){
$scope.build = payload.data;
}).catch(function(err){
$scope.error = err;
});
// Gets the build
builds.get(fullName, number).then(function (payload) {
$scope.build = payload.data;
}).catch(function (err) {
$scope.error = err;
});
repos.subscribe(fullName, function(event) {
if (event.number !== parseInt(number)) {
return; // ignore
}
// update the build
$scope.build = event;
$scope.$apply();
});
}
repos.subscribe(fullName, function (event) {
if (event.number !== parseInt(number)) {
return; // ignore
}
// update the build
$scope.build = event;
$scope.$apply();
});
}
/**
* BuildOutCtrl responsible for rendering a build output.
*/
function BuildOutCtrl($scope, $stateParams, $window, logs, builds, repos, users) {
/**
* BuildOutCtrl responsible for rendering a build output.
*/
function BuildOutCtrl($scope, $stateParams, $window, logs, builds, repos, users) {
var step = parseInt($stateParams.step) || 1;
var number = $stateParams.number;
var owner = $stateParams.owner;
var name = $stateParams.name;
var fullName = owner+'/'+name;
var streaming = false;
var tail = false;
var step = parseInt($stateParams.step) || 1;
var number = $stateParams.number;
var owner = $stateParams.owner;
var name = $stateParams.name;
var fullName = owner + '/' + name;
var streaming = false;
var tail = false;
// Initiates streaming a build.
var stream = function() {
if (streaming) {
return;
}
streaming = true;
// Initiates streaming a build.
var stream = function () {
if (streaming) {
return;
}
streaming = true;
var convert = new Filter({stream:true,newline:false});
var term = document.getElementById("term");
term.innerHTML = "";
var convert = new Filter({stream: true, newline: false});
var term = document.getElementById("term");
term.innerHTML = "";
// subscribes to the build otuput.
logs.subscribe(fullName, number, step, function(data){
term.innerHTML += convert.toHtml(data.replace("\\n","\n"));
if (tail) {
// scrolls to the bottom of the page if enabled
$window.scrollTo(0, $window.document.body.scrollHeight);
}
});
}
// subscribes to the build otuput.
logs.subscribe(fullName, number, step, function (data) {
term.innerHTML += convert.toHtml(data.replace("\\n", "\n"));
if (tail) {
// scrolls to the bottom of the page if enabled
$window.scrollTo(0, $window.document.body.scrollHeight);
}
});
};
// Gets the currently authenticated user
users.getCached().then(function(payload){
$scope.user = payload.data;
});
// Gets the currently authenticated user
users.getCached().then(function (payload) {
$scope.user = payload.data;
});
// Gets a repository
repos.get(fullName).then(function(payload){
$scope.repo = payload.data;
}).catch(function(err){
$scope.error = err;
});
// Gets a repository
repos.get(fullName).then(function (payload) {
$scope.repo = payload.data;
}).catch(function (err) {
$scope.error = err;
});
// Gets the build
builds.get(fullName, number).then(function(payload){
$scope.build = payload.data;
$scope.task = payload.data.jobs[step-1];
// Gets the build
builds.get(fullName, number).then(function (payload) {
$scope.build = payload.data;
$scope.task = payload.data.jobs[step - 1];
if (['pending', 'killed'].indexOf($scope.task.status) !== -1) {
// do nothing
} else if ($scope.task.status === 'running') {
// stream the build
stream();
} else {
if (['pending', 'killed'].indexOf($scope.task.status) !== -1) {
// do nothing
} else if ($scope.task.status === 'running') {
// stream the build
stream();
} else {
// fetch the logs for the finished build.
logs.get(fullName, number, step).then(function(payload){
var convert = new Filter({stream:false,newline:false});
var term = document.getElementById("term")
term.innerHTML = convert.toHtml(payload.data);
}).catch(function(err){
$scope.error = err;
});
}
}).catch(function(err){
$scope.error = err;
});
// fetch the logs for the finished build.
logs.get(fullName, number, step).then(function (payload) {
var convert = new Filter({stream: false, newline: false});
var term = document.getElementById("term")
term.innerHTML = convert.toHtml(payload.data);
}).catch(function (err) {
$scope.error = err;
});
}
}).catch(function (err) {
$scope.error = err;
});
$scope.restart = function() {
builds.restart(fullName, number).then(function(payload){
$scope.build = payload.data;
$scope.task = payload.data.builds[step-1];
}).catch(function(err){
$scope.error = err;
});
};
$scope.restart = function () {
builds.restart(fullName, number).then(function (payload) {
$scope.build = payload.data;
$scope.task = payload.data.builds[step - 1];
}).catch(function (err) {
$scope.error = err;
});
};
$scope.cancel = function() {
builds.cancel(fullName, number).then(function(payload){
$scope.build = payload.data;
$scope.task = payload.data.builds[step-1];
}).catch(function(err) {
$scope.error = err;
});
};
$scope.cancel = function () {
builds.cancel(fullName, number).then(function (payload) {
$scope.build = payload.data;
$scope.task = payload.data.builds[step - 1];
}).catch(function (err) {
$scope.error = err;
});
};
$scope.tail = function() {
tail = !tail;
};
$scope.tail = function () {
tail = !tail;
};
repos.subscribe(fullName, function(event) {
if (event.number !== parseInt(number)) {
return; // ignore
}
// update the build
$scope.build = event;
$scope.task = event.builds[step-1];
$scope.$apply();
repos.subscribe(fullName, function (event) {
if (event.number !== parseInt(number)) {
return; // ignore
}
// update the build
$scope.build = event;
$scope.task = event.builds[step - 1];
$scope.$apply();
// start streaming the current build
if ($scope.task.status === 'running') {
stream();
} else {
// resets our streaming state
streaming = false;
}
});
}
// start streaming the current build
if ($scope.task.status === 'running') {
stream();
} else {
// resets our streaming state
streaming = false;
}
});
}
angular
.module('drone')
.controller('BuildOutCtrl', BuildOutCtrl)
.controller('BuildCtrl', BuildCtrl)
.controller('BuildsCtrl', BuildsCtrl);
angular
.module('drone')
.controller('BuildOutCtrl', BuildOutCtrl)
.controller('BuildCtrl', BuildCtrl)
.controller('BuildsCtrl', BuildsCtrl);
})();

View file

@ -1,115 +1,115 @@
(function () {
/**
* ReposCtrl responsible for rendering the user's
* repository home screen.
*/
function ReposCtrl($scope, $stateParams, repos, users) {
// Gets the currently authenticated user
users.getCached().then(function(payload){
$scope.user = payload.data;
});
/**
* ReposCtrl responsible for rendering the user's
* repository home screen.
*/
function ReposCtrl($scope, $stateParams, repos, users) {
// Gets the currently authenticated user
users.getCached().then(function (payload) {
$scope.user = payload.data;
});
// Gets a list of repos to display in the
// dropdown.
repos.list().then(function(payload){
$scope.repos = angular.isArray(payload.data) ? payload.data : [];
}).catch(function(err){
$scope.error = err;
});
}
// Gets a list of repos to display in the
// dropdown.
repos.list().then(function (payload) {
$scope.repos = angular.isArray(payload.data) ? payload.data : [];
}).catch(function (err) {
$scope.error = err;
});
}
/**
* RepoAddCtrl responsible for activaing a new
* repository.
*/
function RepoAddCtrl($scope, $location, repos, users) {
/**
* RepoAddCtrl responsible for activaing a new
* repository.
*/
function RepoAddCtrl($scope, $location, repos, users) {
// Gets the currently authenticated user
users.getCached().then(function(payload){
$scope.user = payload.data;
});
// Gets the currently authenticated user
users.getCached().then(function (payload) {
$scope.user = payload.data;
});
$scope.add = function(slug) {
repos.post(slug).then(function(payload) {
$location.path('/'+slug);
}).catch(function(err){
$scope.error = err;
});
}
}
$scope.add = function (slug) {
repos.post(slug).then(function (payload) {
$location.path('/' + slug);
}).catch(function (err) {
$scope.error = err;
});
}
}
/**
* RepoEditCtrl responsible for editing a repository.
*/
function RepoEditCtrl($scope, $window, $location, $stateParams, repos, users) {
var owner = $stateParams.owner;
var name = $stateParams.name;
var fullName = owner+'/'+name;
/**
* RepoEditCtrl responsible for editing a repository.
*/
function RepoEditCtrl($scope, $window, $location, $stateParams, repos, users) {
var owner = $stateParams.owner;
var name = $stateParams.name;
var fullName = owner + '/' + name;
// Inject window for composing url
$scope.window = $window;
// Inject window for composing url
$scope.window = $window;
// Gets the currently authenticated user
users.getCached().then(function(payload){
$scope.user = payload.data;
});
// Gets the currently authenticated user
users.getCached().then(function (payload) {
$scope.user = payload.data;
});
// Gets a repository
repos.get(fullName).then(function(payload){
$scope.repo = payload.data;
}).catch(function(err){
$scope.error = err;
});
// Gets a repository
repos.get(fullName).then(function (payload) {
$scope.repo = payload.data;
}).catch(function (err) {
$scope.error = err;
});
$scope.save = function(repo) {
repo.timeout = parseInt(repo.timeout);
repos.update(repo).then(function(payload) {
$scope.repo = payload.data;
}).catch(function(err){
$scope.error = err;
});
}
$scope.save = function (repo) {
repo.timeout = parseInt(repo.timeout);
repos.update(repo).then(function (payload) {
$scope.repo = payload.data;
}).catch(function (err) {
$scope.error = err;
});
};
$scope.delete = function(repo) {
repos.delete(repo).then(function(payload) {
$location.path('/');
}).catch(function(err){
$scope.error = err;
});
}
$scope.delete = function (repo) {
repos.delete(repo).then(function (payload) {
$location.path('/');
}).catch(function (err) {
$scope.error = err;
});
};
$scope.param={}
$scope.addParam = function(param) {
if (!$scope.repo.params) {
$scope.repo.params = {}
}
$scope.repo.params[param.key]=param.value;
$scope.param={}
$scope.param = {};
$scope.addParam = function (param) {
if (!$scope.repo.params) {
$scope.repo.params = {}
}
$scope.repo.params[param.key] = param.value;
$scope.param = {};
// auto-update
repos.update($scope.repo).then(function(payload) {
$scope.repo = payload.data;
}).catch(function(err){
$scope.error = err;
});
}
// auto-update
repos.update($scope.repo).then(function (payload) {
$scope.repo = payload.data;
}).catch(function (err) {
$scope.error = err;
});
};
$scope.deleteParam = function(key) {
delete $scope.repo.params[key];
$scope.deleteParam = function (key) {
delete $scope.repo.params[key];
// auto-update
repos.update($scope.repo).then(function(payload) {
$scope.repo = payload.data;
}).catch(function(err){
$scope.error = err;
});
}
}
// auto-update
repos.update($scope.repo).then(function (payload) {
$scope.repo = payload.data;
}).catch(function (err) {
$scope.error = err;
});
}
}
angular
.module('drone')
.controller('ReposCtrl', ReposCtrl)
.controller('RepoAddCtrl', RepoAddCtrl)
.controller('RepoEditCtrl', RepoEditCtrl);
angular
.module('drone')
.controller('ReposCtrl', ReposCtrl)
.controller('RepoAddCtrl', RepoAddCtrl)
.controller('RepoEditCtrl', RepoEditCtrl);
})();

View file

@ -2,226 +2,230 @@
(function () {
/**
* Creates the angular application.
*/
angular.module('drone', [
'ngRoute',
'ui.filters',
'ui.router'
]);
/**
* Creates the angular application.
*/
angular.module('drone', [
'ngRoute',
'ui.filters',
'ui.router'
]);
/**
* Bootstraps the application and retrieves the
* token from the
*/
function Authorize() {
// First, parse the query string
var params = {}, queryString = location.hash.substring(1),
regex = /([^&=]+)=([^&]*)/g, m;
/**
* Bootstraps the application and retrieves the
* token from the
*/
function Authorize() {
// First, parse the query string
var params = {}, queryString = location.hash.substring(1),
regex = /([^&=]+)=([^&]*)/g, m;
// Loop through and retrieve the token
while (m = regex.exec(queryString)) {
params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
// Loop through and retrieve the token
while (m = regex.exec(queryString)) {
params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
// if the user has just received an auth token we
// should extract from the URL, save to local storage
// and then remove from the URL for good measure.
if (params.access_token) {
localStorage.setItem("access_token", params.access_token);
history.replaceState({}, document.title, location.pathname);
}
}
// if the user has just received an auth token we
// should extract from the URL, save to local storage
// and then remove from the URL for good measure.
if (params.access_token) {
localStorage.setItem("access_token", params.access_token);
history.replaceState({}, document.title, location.pathname);
}
}
/**
* Defines the route configuration for the
* main application.
*/
function Config ($stateProvider, $httpProvider, $locationProvider) {
/**
* Defines the route configuration for the
* main application.
*/
function Config($stateProvider, $httpProvider, $locationProvider) {
// Resolver that will attempt to load the currently
// authenticated user prior to loading the page.
var resolveUser = {
user: function(users) {
return users.getCached();
}
}
// Resolver that will attempt to load the currently
// authenticated user prior to loading the page.
var resolveUser = {
user: function (users) {
return users.getCached();
}
};
$stateProvider
.state('app', {
abstract: true,
views: {
'layout': {
templateUrl: '/static/scripts/views/layout.html',
controller: function ($scope, $routeParams, repos, users) {
users.getCached().then(function(payload){
$scope.user = payload.data;
console.log(repos.list());
});
}
}
},
resolve: resolveUser
})
.state('app.index', {
url: '/',
views: {
'toolbar': {
templateUrl: '/static/scripts/views/repos/index/toolbar.html'
},
'content': {
templateUrl: '/static/scripts/views/repos/index/content.html',
controller: 'ReposCtrl',
resolve: resolveUser
}
},
title: 'Dashboard'
})
.state('login', {
url: '/login',
templateUrl: '/static/scripts/views/login.html',
title: 'Login',
controller: 'UserLoginCtrl'
})
.state('app.profile', {
url: '/profile',
views: {
'toolbar': { templateUrl: '/static/scripts/views/profile/toolbar.html' },
'content': {
templateUrl: '/static/scripts/views/profile/content.html',
controller: 'UserCtrl',
resolve: resolveUser
}
},
title: 'Profile'
})
.state('app.users', {
url: '/users',
views: {
'toolbar': { templateUrl: '/static/scripts/views/users/toolbar.html' },
'content': {
templateUrl: '/static/scripts/views/users/content.html',
controller: 'UsersCtrl',
resolve: resolveUser
}
},
title: 'Users'
})
.state('app.new_repo', {
url: '/new',
views: {
'toolbar': { templateUrl: '/static/scripts/views/repos/add/toolbar.html' },
'content': {
templateUrl: '/static/scripts/views/repos/add/content.html',
controller: 'RepoAddCtrl',
resolve: resolveUser
}
},
title: 'Add Repository'
})
.state('app.builds', {
url: '/:owner/:name',
views: {
'toolbar': {
templateUrl: '/static/scripts/views/builds/index/toolbar.html',
controller: 'BuildsCtrl'
},
'content': {
templateUrl: '/static/scripts/views/builds/index/content.html',
controller: 'BuildsCtrl'
}
}
})
.state('app.repo_edit', {
url: '/:owner/:name/edit',
views: {
'toolbar': { templateUrl: '/static/scripts/views/repos/toolbar.html' },
'content': { templateUrl: '/static/scripts/views/repos/edit.html' }
},
controller: 'RepoEditCtrl',
resolve: resolveUser
})
.state('app.repo.env', {
url: '/:owner/:name/edit/env',
views: {
'toolbar': { templateUrl: '/static/scripts/views/repos/toolbar.html' },
'content': { templateUrl: '/static/scripts/views/repos/env.html' }
},
controller: 'RepoEditCtrl',
resolve: resolveUser
})
.state('app.repo.del', {
url: '/:owner/:name/delete',
views: {
'toolbar': { templateUrl: '/static/scripts/views/repos/toolbar.html' },
'content': { templateUrl: '/static/scripts/views/repos/del.html' }
},
controller: 'RepoEditCtrl',
resolve: resolveUser
})
.state('app.build', {
url: '/:owner/:name/:number',
views: {
'toolbar': { templateUrl: '/static/scripts/views/builds/show/toolbar.html' },
'content': { templateUrl: '/static/scripts/views/builds/show/content.html' }
},
controller: 'BuildCtrl',
resolve: resolveUser
})
.state('app.build_step', {
url: '/:owner/:name/:number/:step',
views: {
'toolbar': { templateUrl: '/static/scripts/views/builds/step/toolbar.html' },
'content': { templateUrl: '/static/scripts/views/builds/step/content.html' }
},
controller: 'BuildOutCtrl',
resolve: resolveUser
})
$stateProvider
.state('app', {
abstract: true,
views: {
'layout': {
templateUrl: '/static/scripts/views/layout.html',
controller: function ($scope, $routeParams, repos, users) {
users.getCached().then(function (payload) {
$scope.user = payload.data;
});
}
}
}
})
.state('app.index', {
url: '/',
views: {
'toolbar': {
templateUrl: '/static/scripts/views/repos/index/toolbar.html'
},
'content': {
templateUrl: '/static/scripts/views/repos/index/content.html',
controller: 'ReposCtrl',
resolve: resolveUser
}
},
title: 'Dashboard'
})
.state('login', {
url: '/login',
templateUrl: '/static/scripts/views/login.html',
title: 'Login',
controller: 'UserLoginCtrl'
})
.state('app.profile', {
url: '/profile',
views: {
'toolbar': {templateUrl: '/static/scripts/views/profile/toolbar.html'},
'content': {
templateUrl: '/static/scripts/views/profile/content.html',
controller: 'UserCtrl',
resolve: resolveUser
}
},
title: 'Profile'
})
.state('app.users', {
url: '/users',
views: {
'toolbar': {templateUrl: '/static/scripts/views/users/toolbar.html'},
'content': {
templateUrl: '/static/scripts/views/users/content.html',
controller: 'UsersCtrl',
resolve: resolveUser
}
},
title: 'Users'
})
.state('app.new_repo', {
url: '/new',
views: {
'toolbar': {templateUrl: '/static/scripts/views/repos/add/toolbar.html'},
'content': {
templateUrl: '/static/scripts/views/repos/add/content.html',
controller: 'RepoAddCtrl',
resolve: resolveUser
}
},
title: 'Add Repository'
})
.state('app.builds', {
url: '/:owner/:name',
views: {
'toolbar': {
templateUrl: '/static/scripts/views/builds/index/toolbar.html',
controller: 'BuildsCtrl'
},
'content': {
templateUrl: '/static/scripts/views/builds/index/content.html',
controller: 'BuildsCtrl'
}
}
})
.state('app.repo_edit', {
url: '/:owner/:name/edit',
views: {
'toolbar': {
templateUrl: '/static/scripts/views/repos/toolbar.html',
controller: 'RepoEditCtrl',
resolve: resolveUser
},
'content': {
templateUrl: '/static/scripts/views/repos/edit.html',
controller: 'RepoEditCtrl',
resolve: resolveUser
}
},
title: 'Edit Repository'
})
.state('app.repo.env', {
url: '/:owner/:name/edit/env',
views: {
'toolbar': {templateUrl: '/static/scripts/views/repos/toolbar.html'},
'content': {templateUrl: '/static/scripts/views/repos/env.html'}
},
controller: 'RepoEditCtrl',
resolve: resolveUser
})
.state('app.repo.del', {
url: '/:owner/:name/delete',
views: {
'toolbar': {templateUrl: '/static/scripts/views/repos/toolbar.html'},
'content': {templateUrl: '/static/scripts/views/repos/del.html'}
},
controller: 'RepoEditCtrl',
resolve: resolveUser
})
.state('app.build', {
url: '/:owner/:name/:number',
views: {
'toolbar': {templateUrl: '/static/scripts/views/builds/show/toolbar.html'},
'content': {templateUrl: '/static/scripts/views/builds/show/content.html'}
},
controller: 'BuildCtrl',
resolve: resolveUser
})
.state('app.build_step', {
url: '/:owner/:name/:number/:step',
views: {
'toolbar': {templateUrl: '/static/scripts/views/builds/step/toolbar.html'},
'content': {templateUrl: '/static/scripts/views/builds/step/content.html'}
},
controller: 'BuildOutCtrl',
resolve: resolveUser
});
// Enables html5 mode
$locationProvider.html5Mode(true)
// Enables html5 mode
$locationProvider.html5Mode(true);
// Appends the Bearer token to authorize every
// outbound http request.
$httpProvider.defaults.headers.common.Authorization = 'Bearer '+localStorage.getItem('access_token');
// Appends the Bearer token to authorize every
// outbound http request.
$httpProvider.defaults.headers.common.Authorization = 'Bearer ' + localStorage.getItem('access_token');
// Intercepts every oubput http response and redirects
// the user to the logic screen if the request was rejected.
$httpProvider.interceptors.push(function($q, $location) {
return {
'responseError': function(rejection) {
if (rejection.status === 401 && rejection.config.url !== "/api/user") {
$location.path('/login');
}
if (rejection.status === 0) {
// this happens when the app is down or
// the browser loses internet connectivity.
}
return $q.reject(rejection);
}
};
});
}
// Intercepts every oubput http response and redirects
// the user to the logic screen if the request was rejected.
$httpProvider.interceptors.push(function ($q, $location) {
return {
'responseError': function (rejection) {
if (rejection.status === 401 && rejection.config.url !== "/api/user") {
$location.path('/login');
}
if (rejection.status === 0) {
// this happens when the app is down or
// the browser loses internet connectivity.
}
return $q.reject(rejection);
}
};
});
}
function RouteChange($rootScope, repos, logs) {
$rootScope.$on('$stateChangeStart', function () {
// repos.unsubscribe();
// logs.unsubscribe();
});
function RouteChange($rootScope, repos, logs) {
$rootScope.$on('$stateChangeStart', function () {
repos.unsubscribe();
logs.unsubscribe();
});
$rootScope.$on('$stateChangeSuccess', function (event, current) {
if (current.title) {
document.title = current.title + ' · drone';
}
});
}
$rootScope.$on('$stateChangeSuccess', function (event, current, previous) {
if (current.title) {
document.title = current.title + ' · drone';
}
});
}
angular
.module('drone')
.config(Authorize)
.config(Config)
.run(RouteChange);
angular
.module('drone')
.config(Authorize)
.config(Config)
.run(RouteChange);
})();

View file

@ -2,116 +2,116 @@
(function () {
/**
* The RepoService provides access to repository
* data using REST API calls.
*/
function RepoService($http, $window) {
/**
* The RepoService provides access to repository
* data using REST API calls.
*/
function RepoService($http, $window) {
var callback,
websocket,
token = localStorage.getItem('access_token');
var callback,
websocket,
token = localStorage.getItem('access_token');
/**
* Gets a list of all repositories.
*/
this.list = function() {
return $http.get('/api/user/repos');
};
/**
* Gets a list of all repositories.
*/
this.list = function () {
return $http.get('/api/user/repos');
};
/**
* Gets a repository by name.
*
* @param {string} Name of the repository.
*/
this.get = function(repoName) {
return $http.get('/api/repos/'+repoName);
};
/**
* Gets a repository by name.
*
* @param {string} Name of the repository.
*/
this.get = function (repoName) {
return $http.get('/api/repos/' + repoName);
};
/**
* Creates a new repository.
*
* @param {object} JSON representation of a repository.
*/
this.post = function(repoName) {
return $http.post('/api/repos/' + repoName);
};
/**
* Creates a new repository.
*
* @param {object} JSON representation of a repository.
*/
this.post = function (repoName) {
return $http.post('/api/repos/' + repoName);
};
/**
* Updates an existing repository.
*
* @param {object} JSON representation of a repository.
*/
this.update = function(repo) {
return $http.patch('/api/repos/'+repo.full_name, repo);
};
/**
* Updates an existing repository.
*
* @param {object} JSON representation of a repository.
*/
this.update = function (repo) {
return $http.patch('/api/repos/' + repo.full_name, repo);
};
/**
* Deletes a repository.
*
* @param {string} Name of the repository.
*/
this.delete = function(repoName) {
return $http.delete('/api/repos/'+repoName);
};
/**
* Deletes a repository.
*
* @param {string} Name of the repository.
*/
this.delete = function (repoName) {
return $http.delete('/api/repos/' + repoName);
};
/**
* Watch a repository.
*
* @param {string} Name of the repository.
*/
this.watch = function(repoName) {
return $http.post('/api/repos/'+repoName+'/watch');
};
/**
* Watch a repository.
*
* @param {string} Name of the repository.
*/
this.watch = function (repoName) {
return $http.post('/api/repos/' + repoName + '/watch');
};
/**
* Unwatch a repository.
*
* @param {string} Name of the repository.
*/
this.unwatch = function(repoName) {
return $http.delete('/api/repos/'+repoName+'/unwatch');
};
/**
* Unwatch a repository.
*
* @param {string} Name of the repository.
*/
this.unwatch = function (repoName) {
return $http.delete('/api/repos/' + repoName + '/unwatch');
};
var callback,
events,
token = localStorage.getItem('access_token');
var callback,
events,
token = localStorage.getItem('access_token');
/**
* Subscribes to a live update feed for a repository
*
* @param {string} Name of the repository.
*/
this.subscribe = function(repo, _callback) {
callback = _callback;
/**
* Subscribes to a live update feed for a repository
*
* @param {string} Name of the repository.
*/
this.subscribe = function (repo, _callback) {
callback = _callback;
events = new EventSource("/api/stream/" + repo + "?access_token=" + token, { withCredentials: true });
events.onmessage = function (event) {
if (callback !== undefined) {
callback(angular.fromJson(event.data));
}
};
events.onerror = function (event) {
callback = undefined;
if (events !== undefined) {
events.close();
events = undefined;
}
console.log('user event stream closed due to error.', event);
};
};
events = new EventSource("/api/stream/" + repo + "?access_token=" + token, {withCredentials: true});
events.onmessage = function (event) {
if (callback !== undefined) {
callback(angular.fromJson(event.data));
}
};
events.onerror = function (event) {
callback = undefined;
if (events !== undefined) {
events.close();
events = undefined;
}
console.log('user event stream closed due to error.', event);
};
};
this.unsubscribe = function() {
callback = undefined;
if (events !== undefined) {
events.close();
events = undefined;
}
};
}
this.unsubscribe = function () {
callback = undefined;
if (events !== undefined) {
events.close();
events = undefined;
}
};
}
angular
.module('drone')
.service('repos', RepoService);
angular
.module('drone')
.service('repos', RepoService);
})();

View file

@ -1,15 +1,15 @@
<header>
<a class="logo float-left" href="/"></a>
<a class="menu-item help float-right" href="http://readme.drone.io" target="_blank">
<i class="material-icons md-18">help</i>
</a>
<a class="menu-item users float-right" href="/users" ng-if="user.admin">
<i class="material-icons md-18">supervisor_account</i>
</a>
<a class="menu-item settings float-right" href="/profile">
<i class="material-icons md-18">settings</i>
</a>
<a class="menu-item user-name float-right" href="/profile">{{ "+"+user.login }}</a>
<a class="logo float-left" href="/"></a>
<a class="menu-item help float-right" href="http://readme.drone.io" target="_blank">
<i class="material-icons md-18">help</i>
</a>
<a class="menu-item users float-right" href="/users" ng-if="user.admin">
<i class="material-icons md-18">supervisor_account</i>
</a>
<a class="menu-item settings float-right" href="/profile">
<i class="material-icons md-18">settings</i>
</a>
<a class="menu-item user-name float-right" href="/profile">{{ "+"+user.login }}</a>
</header>
<div class="toolbar" ui-view="toolbar"></div>
<div ui-view="content"></div>

View file

@ -1,67 +1,74 @@
<style>
html, body {
background:#EEEEEE;
padding:0px;
margin:0px;
font-family:"Roboto";
font-size:15px;
text-transform:uppercase;
width:100%;
height:100%;
}
a.box {
background:#FFF;
width:250px;
padding:20px;
box-shadow: 0px 0px 0 rgba(255,255,255,0.05);
-webkit-transition: all .5s;
-webkit-box-flex: 0;
display:block;
text-decoration:none;
border-radius:3px;
}
a.box:hover {
box-shadow: 7px 7px 0 rgba(255,255,255,0.05);
}
div.logo {
background: url(/static/images/logo.svg) no-repeat center center;;
background-size:72px;
height:150px;
-webkit-transition: all .5s;
}
div.login {
text-align: center;
padding: 15px;
color: #424242;
font-size: 18px;
text-transform: uppercase;
border-radius: 3px;
-webkit-transition: all .5s;
background: #424242;
color: rgba(255,255,255,0.7);
}
body > div {
width:100%;
height:100%;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
}
</style>
<style>
html, body {
background: #EEEEEE;
padding: 0px;
margin: 0px;
font-family: "Roboto";
font-size: 15px;
text-transform: uppercase;
width: 100%;
height: 100%;
}
a.box {
background: #FFF;
width: 250px;
padding: 20px;
box-shadow: 0px 0px 0 rgba(255, 255, 255, 0.05);
-webkit-transition: all .5s;
-webkit-box-flex: 0;
display: block;
text-decoration: none;
border-radius: 3px;
}
a.box:hover {
box-shadow: 7px 7px 0 rgba(255, 255, 255, 0.05);
}
div.logo {
background: url(/static/images/logo.svg) no-repeat center center;
background-size: 72px;
height: 150px;
-webkit-transition: all .5s;
}
div.login {
text-align: center;
padding: 15px;
color: #424242;
font-size: 18px;
text-transform: uppercase;
border-radius: 3px;
-webkit-transition: all .5s;
background: #424242;
color: rgba(255, 255, 255, 0.7);
}
body > div {
width: 100%;
height: 100%;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
}
</style>
<a href="/authorize" target="_self" class="box">
<div class="logo"></div>
<div ng-switch="error" class="alert alert-error" ng-if="error">
<div ng-switch-when="internal_error">Oops. There was an unexpected error. Please try again.</div>
<div ng-switch-when="user_not_found">There was an error authorizing your account.</div>
<div ng-switch-when="access_denied_org">Login is restricted to approved organization members only</div>
<div ng-switch-when="access_denied">Self-registration is disabled. Please contact the system admin to grant access.</div>
</div>
<div class="login">Login</div>
<div class="logo"></div>
<div ng-switch="error" class="alert alert-error" ng-if="error">
<div ng-switch-when="internal_error">Oops. There was an unexpected error. Please try again.</div>
<div ng-switch-when="user_not_found">There was an error authorizing your account.</div>
<div ng-switch-when="access_denied_org">Login is restricted to approved organization members only</div>
<div ng-switch-when="access_denied">Self-registration is disabled. Please contact the system admin to grant
access.
</div>
</div>
<div class="login">Login</div>
</a>

View file

@ -1,70 +1,75 @@
<article>
<section>
<h2>Settings</h2>
<div class="row">
<div>Post Commit Hooks</div>
<div>
<input id="post_commits" type="checkbox" hidden="hidden" ng-model="repo.hooks.push" ng-change="save(repo)" />
<label for="post_commits" class="switch"></label>
</div>
</div>
<div class="row">
<div>Pull Request Hooks</div>
<div>
<input id="pull_requests" type="checkbox" hidden="hidden" ng-model="repo.hooks.pull_request" ng-change="save(repo)" />
<label for="pull_requests" class="switch"></label>
</div>
</div>
<a class="row" ng-href="{{ repo.full_name }}/edit/env">
<div>Private Variables</div>
<div>
Inject private variables into your build environment
</div>
</a>
<a class="row" ng-href="{{ repo.full_name }}/delete">
<div>Delete</div>
<div>Delete this repository and its build history</div>
</a>
</section>
<section>
<h2>Settings</h2>
<section ng-if="user.admin">
<h2>Admin settings</h2>
<div class="row">
<div>Trusted (Evelvate Privilege)</div>
<div>
<input id="trusted" type="checkbox" hidden="hidden" ng-model="repo.trusted" ng-change="save(repo)" />
<label for="trusted" class="switch"></label>
</div>
</div>
<div class="row">
<div>Timeout in minutes</div>
<div>
<input type="range" ng-model="repo.timeout" min="0" max="900" ng-blur="save(repo)" />
<span class="slider-label">{{ repo.timeout }} minutes</span>
</div>
</div>
</section>
<div class="row">
<div>Post Commit Hooks</div>
<div>
<input id="post_commits" type="checkbox" hidden="hidden" ng-model="repo.hooks.push" ng-change="save(repo)"/>
<label for="post_commits" class="switch"></label>
</div>
</div>
<div class="row">
<div>Pull Request Hooks</div>
<div>
<input id="pull_requests" type="checkbox" hidden="hidden" ng-model="repo.hooks.pull_request"
ng-change="save(repo)"/>
<label for="pull_requests" class="switch"></label>
</div>
</div>
<a class="row" ng-href="{{ repo.full_name }}/edit/env">
<div>Private Variables</div>
<div>
Inject private variables into your build environment
</div>
</a>
<a class="row" ng-href="{{ repo.full_name }}/delete">
<div>Delete</div>
<div>Delete this repository and its build history</div>
</a>
</section>
<section>
<h2>Badges</h2>
<div class="row">
<div>Markdown</div>
<div>
<pre class="snippet">[![Build Status]({{ window.location.origin }}/api/badges/{{ repo.full_name }}/status.svg)]({{ window.location.origin }}/{{ repo.full_name }})</pre>
</div>
</div>
<div class="row">
<div>CCMenu</div>
<div>
<pre class="snippet">{{ window.location.origin }}/api/badges/{{ repo.full_name }}/cc.xml</pre>
</div>
</div>
</section>
<section ng-if="user.admin">
<h2>Admin settings</h2>
<section>
<h2>Public Key</h2>
<div>
<pre class="snippet snippet-padding">{{ repo.keypair.public }}</pre>
</div>
</section>
<div class="row">
<div>Trusted (Evelvate Privilege)</div>
<div>
<input id="trusted" type="checkbox" hidden="hidden" ng-model="repo.trusted" ng-change="save(repo)"/>
<label for="trusted" class="switch"></label>
</div>
</div>
<div class="row">
<div>Timeout in minutes</div>
<div>
<input type="range" ng-model="repo.timeout" min="0" max="900" ng-blur="save(repo)"/>
<span class="slider-label">{{ repo.timeout }} minutes</span>
</div>
</div>
</section>
<section>
<h2>Badges</h2>
<div class="row">
<div>Markdown</div>
<div>
<pre class="snippet">[![Build Status]({{ window.location.origin }}/api/badges/{{ repo.full_name }}/status.svg)]({{ window.location.origin }}/{{ repo.full_name }})</pre>
</div>
</div>
<div class="row">
<div>CCMenu</div>
<div>
<pre class="snippet">{{ window.location.origin }}/api/badges/{{ repo.full_name }}/cc.xml</pre>
</div>
</div>
</section>
<section>
<h2>Public Key</h2>
<div>
<pre class="snippet snippet-padding">{{ repo.keypair.public }}</pre>
</div>
</section>
</article>

View file

@ -1,10 +1,12 @@
<div class="breadcrumb" style="position:relative;top:0px;">
<a href="/{{ repo.full_name }}/edit" class="icon icon-home"></a>
<a ng-href="/{{ repo.full_name }}">{{ repo.owner }} / {{ repo.name }}</a>
<div class="breadcrumb">
<a href="/{{ repo.full_name }}/edit" class="icon icon-home">
<i class="material-icons md-18">home</i>
</a>
<a ng-href="/{{ repo.full_name }}">{{ repo.owner }} / {{ repo.name }}</a>
</div>
<div class="menu">
<a ng-href="/{{ repo.full_name }}/edit" class="nav-item settings float-right"></a>
<button ng-click="watch(repo)" ng-if="!repo.starred" class="nav-item star float-right"></button>
<button ng-click="unwatch(repo)" ng-if="repo.starred" class="nav-item unstar float-right"></button>
<a ng-href="/{{ repo.full_name }}/edit" class="nav-item settings float-right"></a>
<button ng-click="watch(repo)" ng-if="!repo.starred" class="nav-item star float-right"></button>
<button ng-click="unwatch(repo)" ng-if="repo.starred" class="nav-item unstar float-right"></button>
</div>

View file

@ -1,30 +1,36 @@
<article>
<section>
<form style="padding:30px">
<input type="text" ng-model="login" placeholder="i.e. octocat" style="font-size:14px;padding:10px 20px;width:400px;border: 1px solid #d9d9d9;outline:none;"/>
<button ng-click="add(login)" style="display: inline-block;background:#EEE;font-size:14px; padding:0px 20px;text-transform:uppercase;cursor:pointer;color:#616161;height:39px;line-height:41px;margin-left:10px;">Add User</button>
<section>
<form style="padding:30px">
<input type="text" ng-model="login" placeholder="i.e. octocat"
style="font-size:14px;padding:10px 20px;width:400px;border: 1px solid #d9d9d9;outline:none;"/>
<button ng-click="add(login)"
style="display: inline-block;background:#EEE;font-size:14px; padding:0px 20px;text-transform:uppercase;cursor:pointer;color:#616161;height:39px;line-height:41px;margin-left:10px;">
Add User
</button>
</form>
</section>
</form>
</section>
<section>
<div class="row row-user" ng-repeat="user in users">
<div>
<img ng-src="{{ user.gravatar_id | gravatar }}" />
</div>
<div>
<h3>{{ user.login }} <small ng-if="user.admin">Admin</small></h3>
<p>{{ user.email }}</p>
<button ng-click="toggle(user)" ng-class="{'btn-admin':true, 'btn-checked': user.admin}">
<i class="material-icons md-18">account_circle</i>
</button>
<button ng-click="remove(user)" class="btn-remove">
<i class="material-icons md-18">delete</i>
</button>
</div>
</div>
</section>
<section>
<div class="row row-user" ng-repeat="user in users">
<div>
<img ng-src="{{ user.gravatar_id | gravatar }}"/>
</div>
<div>
<h3>{{ user.login }}
<small ng-if="user.admin">Admin</small>
</h3>
<p>{{ user.email }}</p>
<button ng-click="toggle(user)" ng-class="{'btn-admin':true, 'btn-checked': user.admin}">
<i class="material-icons md-18">account_circle</i>
</button>
<button ng-click="remove(user)" class="btn-remove">
<i class="material-icons md-18">delete</i>
</button>
</div>
</div>
</section>
</article>

View file

@ -1,6 +1,6 @@
<div class="breadcrumb" style="position:relative;top:0px;">
<a href="/" class="icon icon-home">
<i class="material-icons md-18">home</i>
</a>
<a href="#">Users</a>
<div class="breadcrumb" style="position:relative;top:0px;">
<a href="/" class="icon icon-home">
<i class="material-icons md-18">home</i>
</a>
<a href="#">Users</a>
</div>

File diff suppressed because it is too large Load diff