Commit d40b9ce2 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Admin gitolite logs. Refactored project creation. Few style fixes.

parent 369df86e
...@@ -627,3 +627,10 @@ h3.page_title { ...@@ -627,3 +627,10 @@ h3.page_title {
font-weight: 600; font-weight: 600;
line-height: 28px; line-height: 28px;
} }
pre.logs {
.log {
font-size:12px;
line-height:18px;
}
}
class Admin::LogsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :authenticate_admin!
end
...@@ -21,20 +21,13 @@ class ProjectsController < ApplicationController ...@@ -21,20 +21,13 @@ class ProjectsController < ApplicationController
@project = Project.create_by_user(params[:project], current_user) @project = Project.create_by_user(params[:project], current_user)
respond_to do |format| respond_to do |format|
if @project.valid? format.html do
format.html { redirect_to @project, notice: 'Project was successfully created.' } if @project.saved?
format.js redirect_to(@project, notice: 'Project was successfully created.')
else else
format.html { render action: "new" } render action: "new"
format.js end
end 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 format.js
end end
end end
......
...@@ -127,6 +127,7 @@ module ApplicationHelper ...@@ -127,6 +127,7 @@ module ApplicationHelper
when :admin_projects; controller.controller_name == "projects" when :admin_projects; controller.controller_name == "projects"
when :admin_emails; controller.controller_name == 'mailer' when :admin_emails; controller.controller_name == 'mailer'
when :admin_resque; controller.controller_name == 'resque' when :admin_resque; controller.controller_name == 'resque'
when :admin_logs; controller.controller_name == 'logs'
else else
false false
......
...@@ -23,6 +23,8 @@ class Project < ActiveRecord::Base ...@@ -23,6 +23,8 @@ class Project < ActiveRecord::Base
has_many :wikis, :dependent => :destroy has_many :wikis, :dependent => :destroy
has_many :protected_branches, :dependent => :destroy has_many :protected_branches, :dependent => :destroy
attr_accessor :error_code
# #
# Protected attributes # Protected attributes
# #
...@@ -48,7 +50,7 @@ class Project < ActiveRecord::Base ...@@ -48,7 +50,7 @@ class Project < ActiveRecord::Base
Project.transaction do Project.transaction do
project.owner = user project.owner = user
return project unless project.save project.save!
# Add user as project master # Add user as project master
project.users_projects.create!(:project_access => UsersProject::MASTER, :user => user) project.users_projects.create!(:project_access => UsersProject::MASTER, :user => user)
...@@ -59,6 +61,21 @@ class Project < ActiveRecord::Base ...@@ -59,6 +61,21 @@ class Project < ActiveRecord::Base
end end
project 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 end
# #
......
%h4
%i.icon-file
githost.log
%pre.logs
- Gitlab::Logger.read_latest.each do |line|
%span.log= line
...@@ -12,5 +12,5 @@ ...@@ -12,5 +12,5 @@
= time_ago_in_words(event.created_at) = time_ago_in_words(event.created_at)
ago. 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 Create Merge Request
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
= link_to "Projects", admin_projects_path = link_to "Projects", admin_projects_path
%li{:class => tab_class(:admin_users)} %li{:class => tab_class(:admin_users)}
= link_to "Users", admin_users_path = link_to "Users", admin_users_path
%li{:class => tab_class(:admin_logs)}
= link_to "Logs", admin_logs_path
%li{:class => tab_class(:admin_emails)} %li{:class => tab_class(:admin_emails)}
= link_to "Emails", admin_emails_path = link_to "Emails", admin_emails_path
%li{:class => tab_class(:admin_resque)} %li{:class => tab_class(:admin_resque)}
......
...@@ -10,17 +10,16 @@ ...@@ -10,17 +10,16 @@
.input .input
= f.text_field :name, :placeholder => "Example Project", :class => "xxlarge" = f.text_field :name, :placeholder => "Example Project", :class => "xxlarge"
%hr %h5.page_title
.alert.alert-info .alert.alert-info
%h5 Advanced settings: %h5 Advanced settings:
.clearfix .clearfix
= f.label :path do = f.label :path do
Git Clone Path
.input .input
.input-prepend .input-prepend
%span.add-on= Gitlab.config.ssh_path %strong
= f.text_field :path, :placeholder => "example_project", :disabled => !@project.new_record? = text_field_tag :ppath, @project.path_to_repo, :class => "xlarge", :disabled => true
%span.add-on= ".git"
.clearfix .clearfix
= f.label :code do = f.label :code do
URL URL
......
- if @project.valid? - if @project.saved?
:plain :plain
location.href = "#{project_path(@project, :notice => 'Project was successfully created.')}"; location.href = "#{project_path(@project, :notice => 'Project was successfully created.')}";
- else - else
- if @project.git_error?
location.href = "#{errors_githost_path}";
-else
:plain :plain
$('.project_new_holder').show(); $('.project_new_holder').show();
$("#new_project").replaceWith("#{escape_javascript(render('new_form'))}"); $("#new_project").replaceWith("#{escape_javascript(render('new_form'))}");
......
= render "project_head" = render "project_head"
.project_edit_holder .project_edit_holder
%h3 Edit Project %h3.page_title Edit Project
%hr %hr
= render "projects/form" = render "projects/form"
%div.ajax_loader.hide %div.ajax_loader.hide
......
.project_new_holder .project_new_holder
%h3 %h3.page_title
New Project New Project
%hr %hr
= render 'new_form' = render 'new_form'
......
...@@ -50,6 +50,8 @@ Gitlab::Application.routes.draw do ...@@ -50,6 +50,8 @@ Gitlab::Application.routes.draw do
get 'mailer/preview_note' get 'mailer/preview_note'
get 'mailer/preview_user_new' get 'mailer/preview_user_new'
get 'mailer/preview_issue_new' get 'mailer/preview_issue_new'
resource :logs
resource :resque, :controller => 'resque' resource :resque, :controller => 'resque'
root :to => "dashboard#index" root :to => "dashboard#index"
end end
......
...@@ -2,7 +2,13 @@ module Gitlab ...@@ -2,7 +2,13 @@ module Gitlab
class Logger class Logger
def self.error(message) def self.error(message)
@@logger ||= ::Logger.new(File.join(Rails.root, "log/githost.log")) @@logger ||= ::Logger.new(File.join(Rails.root, "log/githost.log"))
message = Time.now.to_s(:long) + " -> " + message
@@logger.error(message) @@logger.error(message)
end end
def self.read_latest
path = Rails.root.join("log/githost.log")
logs = `tail -n 50 #{path}`.split("\n")
end
end end
end end
...@@ -120,7 +120,7 @@ describe "Projects" do ...@@ -120,7 +120,7 @@ describe "Projects" do
visit edit_project_path(@project) visit edit_project_path(@project)
fill_in 'project_name', :with => 'Awesome' fill_in 'project_name', :with => 'Awesome'
fill_in 'project_path', :with => 'gitlabhq' fill_in 'project_code', :with => 'gitlabhq'
click_button "Save" click_button "Save"
@project = @project.reload @project = @project.reload
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment