Commit d40b9ce2 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

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

parent 8c4d049b2dfa
......@@ -627,3 +627,10 @@ h3.page_title {
font-weight: 600;
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 @@ def create
@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
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
......
......@@ -127,6 +127,7 @@ def tab_class(tab_key)
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
......
......@@ -23,6 +23,8 @@ class Project < ActiveRecord::Base
has_many :wikis, :dependent => :destroy
has_many :protected_branches, :dependent => :destroy
attr_accessor :error_code
#
# Protected attributes
#
......@@ -48,7 +50,7 @@ def self.create_by_user(params, user)
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 @@ def self.create_by_user(params, user)
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
#
......
%h4
%i.icon-file
githost.log
%pre.logs
- Gitlab::Logger.read_latest.each do |line|
%span.log= line
......@@ -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
......@@ -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)}
......
......@@ -10,17 +10,16 @@
.input
= f.text_field :name, :placeholder => "Example Project", :class => "xxlarge"
%hr
%h5.page_title
.alert.alert-info
%h5 Advanced settings:
.clearfix
= f.label :path do
Git Clone
Path
.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
......
- if @project.valid?
- if @project.saved?
: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'))}");
......
= render "project_head"
.project_edit_holder
%h3 Edit Project
%h3.page_title Edit Project
%hr
= render "projects/form"
%div.ajax_loader.hide
......
.project_new_holder
%h3
%h3.page_title
New Project
%hr
= render 'new_form'
......
......@@ -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
......
......@@ -2,7 +2,13 @@ module Gitlab
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
def self.read_latest
path = Rails.root.join("log/githost.log")
logs = `tail -n 50 #{path}`.split("\n")
end
end
end
......@@ -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
......
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