Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/ci/admin')
-rw-r--r--app/controllers/ci/admin/application_controller.rb10
-rw-r--r--app/controllers/ci/admin/application_settings_controller.rb31
-rw-r--r--app/controllers/ci/admin/builds_controller.rb12
-rw-r--r--app/controllers/ci/admin/events_controller.rb9
-rw-r--r--app/controllers/ci/admin/projects_controller.rb19
-rw-r--r--app/controllers/ci/admin/runner_projects_controller.rb34
-rw-r--r--app/controllers/ci/admin/runners_controller.rb69
7 files changed, 184 insertions, 0 deletions
diff --git a/app/controllers/ci/admin/application_controller.rb b/app/controllers/ci/admin/application_controller.rb
new file mode 100644
index 00000000000..430fae14c7d
--- /dev/null
+++ b/app/controllers/ci/admin/application_controller.rb
@@ -0,0 +1,10 @@
+module Ci
+ module Admin
+ class ApplicationController < Ci::ApplicationController
+ before_filter :authenticate_user!
+ before_filter :authenticate_admin!
+
+ layout "ci/admin"
+ end
+ end
+end
diff --git a/app/controllers/ci/admin/application_settings_controller.rb b/app/controllers/ci/admin/application_settings_controller.rb
new file mode 100644
index 00000000000..71e253fac67
--- /dev/null
+++ b/app/controllers/ci/admin/application_settings_controller.rb
@@ -0,0 +1,31 @@
+module Ci
+ class Admin::ApplicationSettingsController < Ci::Admin::ApplicationController
+ before_action :set_application_setting
+
+ def show
+ end
+
+ def update
+ if @application_setting.update_attributes(application_setting_params)
+ redirect_to ci_admin_application_settings_path,
+ notice: 'Application settings saved successfully'
+ else
+ render :show
+ end
+ end
+
+ private
+
+ def set_application_setting
+ @application_setting = Ci::ApplicationSetting.current
+ @application_setting ||= Ci::ApplicationSetting.create_from_defaults
+ end
+
+ def application_setting_params
+ params.require(:application_setting).permit(
+ :all_broken_builds,
+ :add_pusher,
+ )
+ end
+ end
+end
diff --git a/app/controllers/ci/admin/builds_controller.rb b/app/controllers/ci/admin/builds_controller.rb
new file mode 100644
index 00000000000..8fc776dd98e
--- /dev/null
+++ b/app/controllers/ci/admin/builds_controller.rb
@@ -0,0 +1,12 @@
+module Ci
+ class Admin::BuildsController < Ci::Admin::ApplicationController
+ def index
+ @scope = params[:scope]
+ @builds = Ci::Build.order('created_at DESC').page(params[:page]).per(30)
+
+ if ["pending", "running"].include? @scope
+ @builds = @builds.send(@scope)
+ end
+ end
+ end
+end
diff --git a/app/controllers/ci/admin/events_controller.rb b/app/controllers/ci/admin/events_controller.rb
new file mode 100644
index 00000000000..5939efff980
--- /dev/null
+++ b/app/controllers/ci/admin/events_controller.rb
@@ -0,0 +1,9 @@
+module Ci
+ class Admin::EventsController < Ci::Admin::ApplicationController
+ EVENTS_PER_PAGE = 50
+
+ def index
+ @events = Ci::Event.admin.order('created_at DESC').page(params[:page]).per(EVENTS_PER_PAGE)
+ end
+ end
+end
diff --git a/app/controllers/ci/admin/projects_controller.rb b/app/controllers/ci/admin/projects_controller.rb
new file mode 100644
index 00000000000..5bbd0ce7396
--- /dev/null
+++ b/app/controllers/ci/admin/projects_controller.rb
@@ -0,0 +1,19 @@
+module Ci
+ class Admin::ProjectsController < Ci::Admin::ApplicationController
+ def index
+ @projects = Ci::Project.ordered_by_last_commit_date.page(params[:page]).per(30)
+ end
+
+ def destroy
+ project.destroy
+
+ redirect_to ci_projects_url
+ end
+
+ protected
+
+ def project
+ @project ||= Ci::Project.find(params[:id])
+ end
+ end
+end
diff --git a/app/controllers/ci/admin/runner_projects_controller.rb b/app/controllers/ci/admin/runner_projects_controller.rb
new file mode 100644
index 00000000000..e7de6eb12ca
--- /dev/null
+++ b/app/controllers/ci/admin/runner_projects_controller.rb
@@ -0,0 +1,34 @@
+module Ci
+ class Admin::RunnerProjectsController < Ci::Admin::ApplicationController
+ layout 'ci/project'
+
+ def index
+ @runner_projects = project.runner_projects.all
+ @runner_project = project.runner_projects.new
+ end
+
+ def create
+ @runner = Ci::Runner.find(params[:runner_project][:runner_id])
+
+ if @runner.assign_to(project, current_user)
+ redirect_to ci_admin_runner_path(@runner)
+ else
+ redirect_to ci_admin_runner_path(@runner), alert: 'Failed adding runner to project'
+ end
+ end
+
+ def destroy
+ rp = Ci::RunnerProject.find(params[:id])
+ runner = rp.runner
+ rp.destroy
+
+ redirect_to ci_admin_runner_path(runner)
+ end
+
+ private
+
+ def project
+ @project ||= Ci::Project.find(params[:project_id])
+ end
+ end
+end
diff --git a/app/controllers/ci/admin/runners_controller.rb b/app/controllers/ci/admin/runners_controller.rb
new file mode 100644
index 00000000000..4f5f3776ddc
--- /dev/null
+++ b/app/controllers/ci/admin/runners_controller.rb
@@ -0,0 +1,69 @@
+module Ci
+ class Admin::RunnersController < Ci::Admin::ApplicationController
+ before_filter :runner, except: :index
+
+ def index
+ @runners = Ci::Runner.order('id DESC')
+ @runners = @runners.search(params[:search]) if params[:search].present?
+ @runners = @runners.page(params[:page]).per(30)
+ @active_runners_cnt = Ci::Runner.where("contacted_at > ?", 1.minutes.ago).count
+ end
+
+ def show
+ @builds = @runner.builds.order('id DESC').first(30)
+ @projects = Ci::Project.all
+ @projects = @projects.search(params[:search]) if params[:search].present?
+ @projects = @projects.where("projects.id NOT IN (?)", @runner.projects.pluck(:id)) if @runner.projects.any?
+ @projects = @projects.page(params[:page]).per(30)
+ end
+
+ def update
+ @runner.update_attributes(runner_params)
+
+ respond_to do |format|
+ format.js
+ format.html { redirect_to ci_admin_runner_path(@runner) }
+ end
+ end
+
+ def destroy
+ @runner.destroy
+
+ redirect_to ci_admin_runners_path
+ end
+
+ def resume
+ if @runner.update_attributes(active: true)
+ redirect_to ci_admin_runners_path, notice: 'Runner was successfully updated.'
+ else
+ redirect_to ci_admin_runners_path, alert: 'Runner was not updated.'
+ end
+ end
+
+ def pause
+ if @runner.update_attributes(active: false)
+ redirect_to ci_admin_runners_path, notice: 'Runner was successfully updated.'
+ else
+ redirect_to ci_admin_runners_path, alert: 'Runner was not updated.'
+ end
+ end
+
+ def assign_all
+ Ci::Project.unassigned(@runner).all.each do |project|
+ @runner.assign_to(project, current_user)
+ end
+
+ redirect_to ci_admin_runner_path(@runner), notice: "Runner was assigned to all projects"
+ end
+
+ private
+
+ def runner
+ @runner ||= Ci::Runner.find(params[:id])
+ end
+
+ def runner_params
+ params.require(:runner).permit(:token, :description, :tag_list, :contacted_at, :active)
+ end
+ end
+end