Added receipts list

master
alexey 2 months ago
parent 895fb918b5
commit 0e894fafd6

@ -45,6 +45,7 @@ get "/" do
else
repo_data = repo.getrepos
@repos_number = repo_data.length
@rcp_number = db.get_recips.length
erb :index
end
end
@ -87,6 +88,23 @@ get "/repos/:reponame" do
end
end
post "/gitdelete/:reponame" do
input_name = params["reponamedup"]
repo = GitRepo.new(cfg.get_repo, db)
if repo.path.nil?
print_error_page(503, "Путь к репозиториям не существует")
else
if params["reponame"] == input_name
repo.delete_repo(input_name)
end
redirect "/repos"
end
end
get "/gitdelete" do
redirect "/repos"
end
get "/repos" do
@page_name = "Список доступных git репозиториев"
repo = GitRepo.new(cfg.get_repo, db)
@ -131,6 +149,12 @@ post "/gitcreate" do
redirect "/gitcreate"
end
get "/recips" do
@page_name = "Список доступных сценариев сборки"
@rcp_data = db.get_recips
erb :receips
end
not_found do
status 404
@page_name = "Кто-то потерялся"

@ -6,6 +6,12 @@ Sequel.connect(cfg_internal.get_db)
class Repos < Sequel::Model(:repos)
end
class Recips < Sequel::Model(:recips)
end
class RepocRecips < Sequel::Model(:repos_recips)
end
class DBase
attr :error, :last_id
@ -24,4 +30,11 @@ class DBase
def get_repo_info_by_name(repo_name)
Repos.where(reponame: repo_name)
end
def get_recips()
result = []
Recips.order(:id).map do |item|
{ :fname => item[:filepath], :descr => item[:descr], :id => item[:id] }
end
end
end

@ -138,4 +138,14 @@ class GitRepo
info[:error] = @error
info
end
def delete_repo(reponame)
git_path = File.expand_path(reponame + ".git", @path)
File.open("locks/gitcreate", "r") do |f|
f.flock(File::LOCK_EX)
if File.exist?(git_path)
FileUtils.rm_rf(git_path, secure: true)
end
end
end
end

@ -139,10 +139,11 @@
title: 'Подтвердите удаление репозитория!',
content: '' +
'<div class="container">' +
'<form action="/gitdelete" class="formName" method="post">' +
'<form action="/gitdelete/<%= ERB::Util.url_encode(@page_name) %>" class="formName" method="post">' +
'<div class="text-danger mx-auto p-2">' +
'<label>Введите имя удаляемого репозитория</label>' +
'<input type="text" class="frmchk form-control" required name="reponamedup"/>' +
'<input type="hidden" class="frmchk form-control" id="repohid" name="repohid" value="<%= @page_name %>"/>' +
'</div>' +
'</form>' +
'</div>',
@ -154,7 +155,7 @@
titleClass: 'text-danger mx-auto p-2',
btnClass: 'btn btn-danger',
action: function () {
var correct_name = $("#reponame").val();
var correct_name = this.$content.find("#repohid").val();
var name = this.$content.find('.frmchk').val();
if(!name){
$.alert({

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="ru">
<head>
<meta charset="utf-8">
@ -18,6 +18,25 @@
</div>
</div>
</div>
<div class="container">
<div class="hstack gap-3">
<span class="p-1">
<a href="/repos">git-репозитории</a>
</span>
<span>|</span>
<span class="p-1">
<a href="/projs">проекты</a>
</span>
<span>|</span>
<span class="p-1">
<a href="/recips">рецепты</a>
</span>
<span>|</span>
<span class="p-1">
<a href="/rpms">rpm-пакеты</a>
</span>
</div>
</div>
<div class="container">
<div style="padding-top: 45px;"></div>
</div>

@ -41,7 +41,7 @@
<path d="M0 2.5A.5.5 0 0 1 .5 2H2a.5.5 0 0 1 .485.379L2.89 4H14.5a.5.5 0 0 1 .485.621l-1.5 6A.5.5 0 0 1 13 11H4a.5.5 0 0 1-.485-.379L1.61 3H.5a.5.5 0 0 1-.5-.5zM3.14 5l1.25 5h8.22l1.25-5H3.14zM5 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm-2 1a2 2 0 1 1 4 0 2 2 0 0 1-4 0zm9-1a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm-2 1a2 2 0 1 1 4 0 2 2 0 0 1-4 0z"></path>
</svg></div>
<div class="px-3">
<h2 class="fw-bold mb-0">2</h2>
<h2 class="fw-bold mb-0"><%= @rcp_number %></h2>
<p class="mb-0">Рецепты</p>
</div>
</div>

@ -0,0 +1,30 @@
<%= erb :header %>
<div class="container py-4 py-xl-5">
<div class="row mb-5">
<div class="col-md-8 col-xl-6 text-center mx-auto">
<h2>Доступные рецепты</h2>
<p class="w-lg-50">Страница управления рецептами</p>
<div>
<div class="px-3"><a href="/rcpcreate"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-plus-circle text-primary" style="font-size: 29px;">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"></path>
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"></path>
</svg>&nbsp;Добавить рецепт</a></div>
</div>
</div>
<div class="container text-center">
<div class="row gy-3">
<% @rcp_data.each do |item| %>
<div class="col-4">
<div class="card">
<div class="card-body">
<h5 class="card-title"><%= item[:fname] %></h5>
<p class="card-text"><%= item[:descr] %></p>
<a href="/recips/<%= item[:id] %>" class="card-link">Редактировать</a>
</div>
</div>
</div>
<% end %>
</div>
</div>
</div>
<%= erb :footer %>
Loading…
Cancel
Save