Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
a2b6426fdb07
Commit
a2b6426f
authored
Jul 05, 2012
by
Dmitriy Zaporozhets
Browse files
Admin gitolite logs. Refactored project creation. Few style fixes.
parent
8c4d049b2dfa
Changes
15
Hide whitespace changes
Inline
Side-by-side
app/assets/stylesheets/gitlab_bootstrap.scss
View file @
a2b6426f
...
...
@@ -627,3 +627,10 @@
font-weight
:
600
;
line-height
:
28px
;
}
pre
.logs
{
.log
{
font-size
:
12px
;
line-height
:
18px
;
}
}
app/controllers/admin/logs_controller.rb
0 → 100644
View file @
a2b6426f
class
Admin::LogsController
<
ApplicationController
layout
"admin"
before_filter
:authenticate_user!
before_filter
:authenticate_admin!
end
app/controllers/projects_controller.rb
View file @
a2b6426f
...
...
@@ -21,10 +21,10 @@
@project
=
Project
.
create_by_user
(
params
[
:project
],
current_user
)
respond_to
do
|
format
|
if
@project
.
valid?
format
.
html
{
redirect_to
@project
,
notice:
'Project was successfully created.'
}
format
.
js
else
format
.
html
{
render
action:
"new"
}
format
.
js
format
.
html
do
if
@project
.
saved?
redirect_to
(
@project
,
notice:
'Project was successfully created.'
)
else
render
action:
"new"
end
end
...
...
@@ -30,11 +30,4 @@
end
end
rescue
Gitlab
::
Gitolite
::
AccessDenied
render
:js
=>
"location.href = '
#{
errors_githost_path
}
'"
and
return
rescue
StandardError
=>
ex
@project
.
errors
.
add
(
:base
,
"Cant save project. Please try again later"
)
respond_to
do
|
format
|
format
.
html
{
render
action:
"new"
}
format
.
js
end
end
...
...
app/helpers/application_helper.rb
View file @
a2b6426f
...
...
@@ -127,6 +127,7 @@
when
:admin_projects
;
controller
.
controller_name
==
"projects"
when
:admin_emails
;
controller
.
controller_name
==
'mailer'
when
:admin_resque
;
controller
.
controller_name
==
'resque'
when
:admin_logs
;
controller
.
controller_name
==
'logs'
else
false
...
...
app/models/project.rb
View file @
a2b6426f
...
...
@@ -23,6 +23,8 @@
has_many
:wikis
,
:dependent
=>
:destroy
has_many
:protected_branches
,
:dependent
=>
:destroy
attr_accessor
:error_code
#
# Protected attributes
#
...
...
@@ -48,7 +50,7 @@
Project
.
transaction
do
project
.
owner
=
user
return
project
unless
project
.
save
project
.
save
!
# Add user as project master
project
.
users_projects
.
create!
(
:project_access
=>
UsersProject
::
MASTER
,
:user
=>
user
)
...
...
@@ -59,6 +61,21 @@
end
project
rescue
Gitlab
::
Gitolite
::
AccessDenied
=>
ex
project
.
error_code
=
:gitolite
project
rescue
=>
ex
project
.
error_code
=
:db
project
.
errors
.
add
(
:base
,
"Cant save project. Please try again later"
)
project
end
def
git_error?
error_code
==
:gitolite
end
def
saved?
id
&&
valid?
end
#
...
...
app/views/admin/logs/show.html.haml
0 → 100644
View file @
a2b6426f
%h4
%i
.icon-file
githost.log
%pre
.logs
-
Gitlab
::
Logger
.
read_latest
.
each
do
|
line
|
%span
.log
=
line
app/views/events/_event_last_push.html.haml
View file @
a2b6426f
...
...
@@ -12,5 +12,5 @@
=
time_ago_in_words
(
event
.
created_at
)
ago.
=
link_to
new_mr_path_from_push_event
(
event
),
:title
=>
"New Merge Request"
,
:class
=>
"btn small
grouped
primary"
do
=
link_to
new_mr_path_from_push_event
(
event
),
:title
=>
"New Merge Request"
,
:class
=>
"btn
very_
small primary"
do
Create Merge Request
app/views/layouts/admin.html.haml
View file @
a2b6426f
...
...
@@ -12,6 +12,8 @@
=
link_to
"Projects"
,
admin_projects_path
%li
{
:class
=>
tab_class
(
:admin_users
)}
=
link_to
"Users"
,
admin_users_path
%li
{
:class
=>
tab_class
(
:admin_logs
)}
=
link_to
"Logs"
,
admin_logs_path
%li
{
:class
=>
tab_class
(
:admin_emails
)}
=
link_to
"Emails"
,
admin_emails_path
%li
{
:class
=>
tab_class
(
:admin_resque
)}
...
...
app/views/projects/_form.html.haml
View file @
a2b6426f
...
...
@@ -10,8 +10,8 @@
.input
=
f
.
text_field
:name
,
:placeholder
=>
"Example Project"
,
:class
=>
"xxlarge"
%h
r
%h
5
.page_title
.alert.alert-info
%h5
Advanced settings:
.clearfix
=
f
.
label
:path
do
...
...
@@ -14,7 +14,7 @@
.alert.alert-info
%h5
Advanced settings:
.clearfix
=
f
.
label
:path
do
Git Clone
Path
.input
.input-prepend
...
...
@@ -19,8 +19,7 @@
.input
.input-prepend
%span
.add-on
=
Gitlab
.
config
.
ssh_path
=
f
.
text_field
:path
,
:placeholder
=>
"example_project"
,
:disabled
=>
!
@project
.
new_record?
%span
.add-on
=
".git"
%strong
=
text_field_tag
:ppath
,
@project
.
path_to_repo
,
:class
=>
"xlarge"
,
:disabled
=>
true
.clearfix
=
f
.
label
:code
do
URL
...
...
app/views/projects/create.js.haml
View file @
a2b6426f
-
if
@project
.
vali
d?
-
if
@project
.
save
d?
:plain
location.href = "
#{
project_path
(
@project
,
:notice
=>
'Project was successfully created.'
)
}
";
-
else
...
...
@@ -2,6 +2,9 @@
:plain
location.href = "
#{
project_path
(
@project
,
:notice
=>
'Project was successfully created.'
)
}
";
-
else
-
if
@project
.
git_error?
location.href = "
#{
errors_githost_path
}
";
-
else
:plain
$('.project_new_holder').show();
$("#new_project").replaceWith("
#{
escape_javascript
(
render
(
'new_form'
))
}
");
...
...
app/views/projects/edit.html.haml
View file @
a2b6426f
=
render
"project_head"
.project_edit_holder
%h3
Edit Project
%h3
.page_title
Edit Project
%hr
=
render
"projects/form"
%div
.ajax_loader.hide
...
...
app/views/projects/new.html.haml
View file @
a2b6426f
.project_new_holder
%h3
%h3
.page_title
New Project
%hr
=
render
'new_form'
...
...
config/routes.rb
View file @
a2b6426f
...
...
@@ -50,6 +50,8 @@
get
'mailer/preview_note'
get
'mailer/preview_user_new'
get
'mailer/preview_issue_new'
resource
:logs
resource
:resque
,
:controller
=>
'resque'
root
:to
=>
"dashboard#index"
end
...
...
lib/gitlab/logger.rb
View file @
a2b6426f
...
...
@@ -2,5 +2,6 @@
class
Logger
def
self
.
error
(
message
)
@@logger
||=
::
Logger
.
new
(
File
.
join
(
Rails
.
root
,
"log/githost.log"
))
message
=
Time
.
now
.
to_s
(
:long
)
+
" -> "
+
message
@@logger
.
error
(
message
)
end
...
...
@@ -5,4 +6,9 @@
@@logger
.
error
(
message
)
end
def
self
.
read_latest
path
=
Rails
.
root
.
join
(
"log/githost.log"
)
logs
=
`tail -n 50
#{
path
}
`
.
split
(
"
\n
"
)
end
end
end
spec/requests/projects_spec.rb
View file @
a2b6426f
...
...
@@ -120,7 +120,7 @@
visit
edit_project_path
(
@project
)
fill_in
'project_name'
,
:with
=>
'Awesome'
fill_in
'project_
path
'
,
:with
=>
'gitlabhq'
fill_in
'project_
code
'
,
:with
=>
'gitlabhq'
click_button
"Save"
@project
=
@project
.
reload
end
...
...
Write
Preview
Supports
Markdown
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