From 229e88a4382bfc0771d94e3677201aa258183764 Mon Sep 17 00:00:00 2001 From: Alexander Simonov Date: Sun, 12 Jul 2015 22:32:46 +0300 Subject: [PATCH] Little refactoring of all assets. JS code better identing. --- cmd/drone-server/static/index.html | 66 +- .../static/scripts/controllers/builds.js | 374 +-- .../static/scripts/controllers/repos.js | 194 +- cmd/drone-server/static/scripts/drone.js | 422 +-- .../static/scripts/services/repos.js | 196 +- .../static/scripts/views/layout.html | 22 +- .../static/scripts/views/login.html | 135 +- .../static/scripts/views/repos/edit.html | 135 +- .../static/scripts/views/repos/toolbar.html | 14 +- .../static/scripts/views/users/content.html | 52 +- .../static/scripts/views/users/toolbar.html | 10 +- cmd/drone-server/static/styles/drone.css | 2556 +++++++++-------- 12 files changed, 2112 insertions(+), 2064 deletions(-) diff --git a/cmd/drone-server/static/index.html b/cmd/drone-server/static/index.html index 16cf68cd..36bd223c 100644 --- a/cmd/drone-server/static/index.html +++ b/cmd/drone-server/static/index.html @@ -1,46 +1,46 @@ - - + + - - - - - - - - - + + + + + + + + + -
+
- - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - + + + diff --git a/cmd/drone-server/static/scripts/controllers/builds.js b/cmd/drone-server/static/scripts/controllers/builds.js index 514d95fe..6a28a17b 100644 --- a/cmd/drone-server/static/scripts/controllers/builds.js +++ b/cmd/drone-server/static/scripts/controllers/builds.js @@ -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); })(); diff --git a/cmd/drone-server/static/scripts/controllers/repos.js b/cmd/drone-server/static/scripts/controllers/repos.js index e499949f..19768d74 100644 --- a/cmd/drone-server/static/scripts/controllers/repos.js +++ b/cmd/drone-server/static/scripts/controllers/repos.js @@ -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); })(); diff --git a/cmd/drone-server/static/scripts/drone.js b/cmd/drone-server/static/scripts/drone.js index bfcad6f6..3c85fcf7 100644 --- a/cmd/drone-server/static/scripts/drone.js +++ b/cmd/drone-server/static/scripts/drone.js @@ -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); })(); diff --git a/cmd/drone-server/static/scripts/services/repos.js b/cmd/drone-server/static/scripts/services/repos.js index 66795143..ce73c934 100644 --- a/cmd/drone-server/static/scripts/services/repos.js +++ b/cmd/drone-server/static/scripts/services/repos.js @@ -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); })(); diff --git a/cmd/drone-server/static/scripts/views/layout.html b/cmd/drone-server/static/scripts/views/layout.html index 82fd25a6..6b2068f4 100644 --- a/cmd/drone-server/static/scripts/views/layout.html +++ b/cmd/drone-server/static/scripts/views/layout.html @@ -1,15 +1,15 @@
- - - help - - - supervisor_account - - - settings - - {{ "+"+user.login }} + + + help + + + supervisor_account + + + settings + + {{ "+"+user.login }}
\ No newline at end of file diff --git a/cmd/drone-server/static/scripts/views/login.html b/cmd/drone-server/static/scripts/views/login.html index 44e16719..83bb4b90 100644 --- a/cmd/drone-server/static/scripts/views/login.html +++ b/cmd/drone-server/static/scripts/views/login.html @@ -1,67 +1,74 @@ - + - -
-
Oops. There was an unexpected error. Please try again.
-
There was an error authorizing your account.
-
Login is restricted to approved organization members only
-
Self-registration is disabled. Please contact the system admin to grant access.
-
- + +
+
Oops. There was an unexpected error. Please try again.
+
There was an error authorizing your account.
+
Login is restricted to approved organization members only
+
Self-registration is disabled. Please contact the system admin to grant + access. +
+
+
diff --git a/cmd/drone-server/static/scripts/views/repos/edit.html b/cmd/drone-server/static/scripts/views/repos/edit.html index c0338a79..efa5b872 100644 --- a/cmd/drone-server/static/scripts/views/repos/edit.html +++ b/cmd/drone-server/static/scripts/views/repos/edit.html @@ -1,70 +1,75 @@
-
-

Settings

-
-
Post Commit Hooks
-
- - -
-
-
-
Pull Request Hooks
-
- - -
-
- -
Private Variables
-
- Inject private variables into your build environment -
-
- -
Delete
-
Delete this repository and its build history
-
-
+
+

Settings

-
-

Admin settings

-
-
Trusted (Evelvate Privilege)
-
- - -
-
-
-
Timeout in minutes
-
- - {{ repo.timeout }} minutes -
-
-
+
+
Post Commit Hooks
+
+ + +
+
+
+
Pull Request Hooks
+
+ + +
+
+ +
Private Variables
+
+ Inject private variables into your build environment +
+
+ +
Delete
+
Delete this repository and its build history
+
+
-
-

Badges

-
-
Markdown
-
-
[![Build Status]({{ window.location.origin }}/api/badges/{{ repo.full_name }}/status.svg)]({{ window.location.origin }}/{{ repo.full_name }})
-
-
-
-
CCMenu
-
-
{{ window.location.origin }}/api/badges/{{ repo.full_name }}/cc.xml
-
-
-
+
+

Admin settings

-
-

Public Key

-
-
{{ repo.keypair.public }}
-
-
+
+
Trusted (Evelvate Privilege)
+
+ + +
+
+
+
Timeout in minutes
+
+ + {{ repo.timeout }} minutes +
+
+
+ +
+

Badges

+ +
+
Markdown
+
+
[![Build Status]({{ window.location.origin }}/api/badges/{{ repo.full_name }}/status.svg)]({{ window.location.origin }}/{{ repo.full_name }})
+
+
+
+
CCMenu
+
+
{{ window.location.origin }}/api/badges/{{ repo.full_name }}/cc.xml
+
+
+
+ +
+

Public Key

+ +
+
{{ repo.keypair.public }}
+
+
\ No newline at end of file diff --git a/cmd/drone-server/static/scripts/views/repos/toolbar.html b/cmd/drone-server/static/scripts/views/repos/toolbar.html index 3430cfd6..9be485c7 100644 --- a/cmd/drone-server/static/scripts/views/repos/toolbar.html +++ b/cmd/drone-server/static/scripts/views/repos/toolbar.html @@ -1,10 +1,12 @@ -