Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e05f19d7
Commit
e05f19d7
authored
Feb 21, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Geo Nodes admin screen (CRUD)
parent
85083b38
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
1 deletion
+84
-1
app/controllers/admin/geo_nodes_controller.rb
app/controllers/admin/geo_nodes_controller.rb
+28
-0
app/models/geo_node.rb
app/models/geo_node.rb
+10
-1
app/views/admin/geo_nodes/index.html.haml
app/views/admin/geo_nodes/index.html.haml
+44
-0
config/routes.rb
config/routes.rb
+2
-0
No files found.
app/controllers/admin/geo_nodes_controller.rb
0 → 100644
View file @
e05f19d7
class
Admin::GeoNodesController
<
Admin
::
ApplicationController
def
index
@nodes
=
GeoNode
.
all
@node
=
GeoNode
.
new
end
def
create
@node
=
GeoNode
.
new
(
geo_node_params
)
if
@node
.
save
redirect_to
admin_geo_nodes_path
,
notice:
'Node was successfully created.'
else
@nodes
=
GeoNode
.
all
render
:index
end
end
def
destroy
@node
=
GeoNode
.
find
(
params
[
:id
])
@node
.
destroy
redirect_to
admin_geo_nodes_path
end
def
geo_node_params
params
.
require
(
:geo_node
).
permit
(
:url
,
:host
,
:port
,
:primary
,
:relative_url_root
,
:schema
)
end
end
app/models/geo_node.rb
View file @
e05f19d7
...
...
@@ -23,13 +23,22 @@ class GeoNode < ActiveRecord::Base
validates
:schema
,
inclusion:
%w(http https)
def
uri
URI
.
parse
(
"
#{
schema
}
://
#{
host
}
:
#{
port
}
/
#{
relative_url_root
}
"
)
relative_url
=
relative_url_root
[
0
]
==
'/'
?
relative_url_root
[
1
..-
1
]
:
relative_url_root
URI
.
parse
(
"
#{
schema
}
://
#{
host
}
:
#{
port
}
/
#{
relative_url
}
"
)
end
def
url
uri
.
to_s
end
def
url
=
(
new_url
)
new_uri
=
URI
.
parse
(
new_url
)
self
.
schema
=
new_uri
.
scheme
self
.
host
=
new_uri
.
host
self
.
port
=
new_uri
.
port
self
.
relative_url_root
=
new_uri
.
path
end
def
notify_url
URI
::
join
(
uri
,
"
#{
uri
.
path
}
/"
,
'api/geo/refresh_projects'
).
to_s
end
...
...
app/views/admin/geo_nodes/index.html.haml
0 → 100644
View file @
e05f19d7
-
page_title
'Geo nodes'
%h3
.page-title
Geo nodes
%p
.light
#{
link_to
'Geo nodes'
,
help_page_path
(
'geo'
,
'nodes'
),
class:
'vlink'
}
are special GitLab
replicated instances.
%hr
=
form_for
@node
,
as: :geo_node
,
url:
admin_geo_nodes_path
,
html:
{
class:
'form-horizontal'
}
do
|
f
|
-
if
@node
.
errors
.
any?
.alert.alert-danger
-
@node
.
errors
.
full_messages
.
each
do
|
msg
|
%p
=
msg
.form-group
=
f
.
label
:url
,
'URL:'
,
class:
'control-label'
.col-sm-10
=
f
.
text_field
:url
,
class:
'form-control'
.form-group
=
f
.
label
:primary
,
'Primary'
,
class:
'control-label checkbox'
.col-sm-10
.checkbox
=
f
.
label
:primary
do
=
f
.
check_box
:primary
%strong
This is a primary node
.form-actions
=
f
.
submit
'Add Node'
,
class:
'btn btn-create'
%hr
-
if
@nodes
.
any?
.panel.panel-default
.panel-heading
Geo nodes (
#{
@nodes
.
count
}
)
%ul
.well-list
-
@nodes
.
each
do
|
node
|
%li
.list-item-name
%strong
=
node
.
url
%p
#{
node
.
primary
?
'Primary node'
:
'Readonly node'
}
.pull-right
=
link_to
'Remove'
,
admin_geo_node_path
(
node
),
data:
{
confirm:
'Are you sure?'
},
method: :delete
,
class:
'btn btn-remove btn-sm'
config/routes.rb
View file @
e05f19d7
...
...
@@ -277,6 +277,8 @@ Rails.application.routes.draw do
get
:download
,
on: :member
end
resources
:geo_nodes
,
only:
[
:index
,
:create
,
:destroy
]
resources
:labels
resources
:runners
,
only:
[
:index
,
:show
,
:update
,
:destroy
]
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment