Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Set runner tags via admin area
Browse files Browse the repository at this point in the history
  • Loading branch information
dzaporozhets committed Jan 13, 2015
1 parent f2ccfd9 commit 05b4a93
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 27 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Expand Up @@ -43,6 +43,7 @@
@import "sections/projects.scss";
@import "sections/builds.scss";
@import "sections/login.scss";
@import "sections/runners.scss";

/*
* NProgress
Expand Down
12 changes: 12 additions & 0 deletions app/assets/stylesheets/sections/runners.scss
@@ -0,0 +1,12 @@
.runner-state {
padding: 6px 12px;
margin-right: 10px;
color: #FFF;

&.runner-state-shared {
background: #32b186;
}
&.runner-state-specific {
background: #3286b1;
}
}
13 changes: 6 additions & 7 deletions app/controllers/admin/runners_controller.rb
Expand Up @@ -13,11 +13,11 @@ def show
end

def update
@runner.update_attributes(description: params[:runner][:description])
@runner.update_attributes(params[:runner])

respond_to do |format|
format.js
format.html { redirect_to admin_runners_path }
format.html { redirect_to admin_runner_path(@runner) }
end
end

Expand All @@ -28,12 +28,11 @@ def destroy
end

def assign_all
Project.unassigned(@runner).all.each { |project| @runner.assign_to(project, current_user) }

respond_to do |format|
format.js
format.html { redirect_to admin_runners_path, notice: "Runner was assigned to all projects" }
Project.unassigned(@runner).all.each do |project|
@runner.assign_to(project, current_user)
end

redirect_to admin_runner_path(@runner), notice: "Runner was assigned to all projects"
end

private
Expand Down
15 changes: 8 additions & 7 deletions app/views/admin/runners/_runner.html.haml
Expand Up @@ -9,7 +9,7 @@

%td
= link_to admin_runner_path(runner) do
= runner.token
= runner.short_sha
%td
.runner-description
= runner.description
Expand All @@ -26,15 +26,16 @@
- else
= runner.projects.count
%td
%span.label.label-success
#{runner.builds.success.count}
%span /
%span.label.label-danger
#{runner.builds.failed.count}
#{runner.builds.count}
%td
- runner.tag_list.each do |tag|
%span.label.label-primary
= tag
%td
#{time_ago_in_words(runner.created_at)} ago
%td
.pull-right
= link_to 'Assign to all', assign_all_admin_runner_path(runner), class: 'btn btn-small assign-all-runner', title: 'Assign runner to all projects', method: :put, remote: true
= link_to 'Edit', admin_runner_path(runner), class: 'btn btn-small'
 
= link_to 'Remove', [:admin, runner], data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-small'

2 changes: 0 additions & 2 deletions app/views/admin/runners/assign_all.js.haml

This file was deleted.

3 changes: 2 additions & 1 deletion app/views/admin/runners/index.html.haml
Expand Up @@ -38,7 +38,8 @@
%th Runner token
%th Description
%th Projects
%th Builds Stats
%th Builds
%th Tags
%th Registered
%th

Expand Down
43 changes: 35 additions & 8 deletions app/views/admin/runners/show.html.haml
@@ -1,11 +1,11 @@
%h4.page-title
Runner: #{@runner.token}

%p.light= @runner.description
%p
= link_to admin_runners_path do
← Back to runners list
%hr
%h4
- if @runner.shared?
%span.runner-state.runner-state-shared
Shared
- else
%span.runner-state.runner-state-specific
Specific
Runner ##{@runner.id}

- if @runner.shared?
.bs-callout.bs-callout-success
Expand All @@ -15,6 +15,27 @@
.bs-callout.bs-callout-info
%h4 This runner will process build only from ASSIGNED projects
%p If you want runner to build unassigned projects you just need to disable all assignee projects
%hr
= form_for @runner, url: admin_runner_path(@runner), html: { class: 'form-horizontal' } do |f|
.form-group
= label_tag :token, class: 'control-label' do
Token
.col-sm-10
= f.text_field :token, class: 'form-control', readonly: true
.form-group
= label_tag :description, class: 'control-label' do
Description
.col-sm-10
= f.text_field :description, class: 'form-control'
.form-group
= label_tag :tag_list, class: 'control-label' do
Tags
.col-sm-10
= f.text_field :tag_list, class: 'form-control'
.help-block You can setup jobs to only use runners with specific tags
.form-actions
= f.submit 'Save', class: 'btn btn-save'

.row
.col-md-6
%h4 Restrict projects for this runner
Expand All @@ -39,6 +60,12 @@
%tr
%th Project
%th
.pull-right
= link_to 'Assign to all', assign_all_admin_runner_path(@runner),
class: 'btn btn-small assign-all-runner',
title: 'Assign runner to all projects',
method: :put

- @projects.each do |project|
%tr
%td
Expand Down
2 changes: 1 addition & 1 deletion app/views/runners/index.html.haml
Expand Up @@ -5,7 +5,7 @@
Runners can be placed on separate users, servers, and even on your local machine.

.bs-callout
%h4 How to setup new project runner
%h4 How to setup a new project specific runner

%br
%p
Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/runners_spec.rb
Expand Up @@ -22,6 +22,6 @@
visit admin_runner_path(runner)
end

it { page.should have_content runner.token }
it { find_field('runner_token').value.should eq runner.token }
end
end

0 comments on commit 05b4a93

Please sign in to comment.