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> <!DOCTYPE html>
<html ng-app="drone" lang="en"> <html ng-app="drone" lang="en">
<head> <head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<base href="/"/> <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=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=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/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='//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 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 rel="stylesheet" href="//fonts.googleapis.com/css?family=Droid+Sans+Mono"/>
<link href='/static/styles/drone.css' rel='stylesheet' type='text/css'> <link href='/static/styles/drone.css' rel='stylesheet' type='text/css'>
<link rel="icon" href="/static/favicon.png"> <link rel="icon" href="/static/favicon.png">
</head> </head>
<body> <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.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-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.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/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/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/moment.js/2.6.0/moment.min.js"></script>
<!-- main javascript application --> <!-- main javascript application -->
<script src="/static/scripts/term.js"></script> <script src="/static/scripts/term.js"></script>
<script src="/static/scripts/drone.js"></script> <script src="/static/scripts/drone.js"></script>
<script src="/static/scripts/controllers/repos.js"></script> <script src="/static/scripts/controllers/repos.js"></script>
<script src="/static/scripts/controllers/builds.js"></script> <script src="/static/scripts/controllers/builds.js"></script>
<script src="/static/scripts/controllers/users.js"></script> <script src="/static/scripts/controllers/users.js"></script>
<script src="/static/scripts/services/repos.js"></script> <script src="/static/scripts/services/repos.js"></script>
<script src="/static/scripts/services/builds.js"></script> <script src="/static/scripts/services/builds.js"></script>
<script src="/static/scripts/services/users.js"></script> <script src="/static/scripts/services/users.js"></script>
<script src="/static/scripts/services/logs.js"></script> <script src="/static/scripts/services/logs.js"></script>
<script src="/static/scripts/services/tokens.js"></script> <script src="/static/scripts/services/tokens.js"></script>
<script src="/static/scripts/services/feed.js"></script> <script src="/static/scripts/services/feed.js"></script>
<script src="/static/scripts/filters/filter.js"></script> <script src="/static/scripts/filters/filter.js"></script>
<script src="/static/scripts/filters/gravatar.js"></script> <script src="/static/scripts/filters/gravatar.js"></script>
<script src="/static/scripts/filters/time.js"></script> <script src="/static/scripts/filters/time.js"></script>
</body> </body>
</html> </html>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,70 +1,75 @@
<article> <article>
<section> <section>
<h2>Settings</h2> <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 ng-if="user.admin"> <div class="row">
<h2>Admin settings</h2> <div>Post Commit Hooks</div>
<div class="row"> <div>
<div>Trusted (Evelvate Privilege)</div> <input id="post_commits" type="checkbox" hidden="hidden" ng-model="repo.hooks.push" ng-change="save(repo)"/>
<div> <label for="post_commits" class="switch"></label>
<input id="trusted" type="checkbox" hidden="hidden" ng-model="repo.trusted" ng-change="save(repo)" /> </div>
<label for="trusted" class="switch"></label> </div>
</div> <div class="row">
</div> <div>Pull Request Hooks</div>
<div class="row"> <div>
<div>Timeout in minutes</div> <input id="pull_requests" type="checkbox" hidden="hidden" ng-model="repo.hooks.pull_request"
<div> ng-change="save(repo)"/>
<input type="range" ng-model="repo.timeout" min="0" max="900" ng-blur="save(repo)" /> <label for="pull_requests" class="switch"></label>
<span class="slider-label">{{ repo.timeout }} minutes</span> </div>
</div> </div>
</div> <a class="row" ng-href="{{ repo.full_name }}/edit/env">
</section> <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> <section ng-if="user.admin">
<h2>Badges</h2> <h2>Admin settings</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> <div class="row">
<h2>Public Key</h2> <div>Trusted (Evelvate Privilege)</div>
<div> <div>
<pre class="snippet snippet-padding">{{ repo.keypair.public }}</pre> <input id="trusted" type="checkbox" hidden="hidden" ng-model="repo.trusted" ng-change="save(repo)"/>
</div> <label for="trusted" class="switch"></label>
</section> </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> </article>

View file

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

View file

@ -1,30 +1,36 @@
<article> <article>
<section> <section>
<form style="padding:30px"> <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;"/> <input type="text" ng-model="login" placeholder="i.e. octocat"
<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> 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> </form>
</section> </section>
<section> <section>
<div class="row row-user" ng-repeat="user in users"> <div class="row row-user" ng-repeat="user in users">
<div> <div>
<img ng-src="{{ user.gravatar_id | gravatar }}" /> <img ng-src="{{ user.gravatar_id | gravatar }}"/>
</div> </div>
<div> <div>
<h3>{{ user.login }} <small ng-if="user.admin">Admin</small></h3> <h3>{{ user.login }}
<p>{{ user.email }}</p> <small ng-if="user.admin">Admin</small>
<button ng-click="toggle(user)" ng-class="{'btn-admin':true, 'btn-checked': user.admin}"> </h3>
<i class="material-icons md-18">account_circle</i> <p>{{ user.email }}</p>
</button> <button ng-click="toggle(user)" ng-class="{'btn-admin':true, 'btn-checked': user.admin}">
<button ng-click="remove(user)" class="btn-remove"> <i class="material-icons md-18">account_circle</i>
<i class="material-icons md-18">delete</i> </button>
</button> <button ng-click="remove(user)" class="btn-remove">
</div> <i class="material-icons md-18">delete</i>
</div> </button>
</section> </div>
</div>
</section>
</article> </article>

View file

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

File diff suppressed because it is too large Load diff