Первый стрим
This commit is contained in:
0
app/keyboards/__init__.py
Normal file
0
app/keyboards/__init__.py
Normal file
42
app/keyboards/docker_keyboards.py
Normal file
42
app/keyboards/docker_keyboards.py
Normal file
@ -0,0 +1,42 @@
|
||||
from aiogram.types import InlineKeyboardButton
|
||||
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
||||
|
||||
|
||||
def container_names_keyboard(stdout: str):
|
||||
container_names = [line.split(" ")[-1].strip() for line in stdout.splitlines()[1:]]
|
||||
builder = InlineKeyboardBuilder()
|
||||
for name in container_names:
|
||||
data = f"container_{name}"
|
||||
builder.add(
|
||||
InlineKeyboardButton(
|
||||
text=name,
|
||||
callback_data=data,
|
||||
)
|
||||
)
|
||||
builder.adjust(1)
|
||||
|
||||
return builder
|
||||
|
||||
|
||||
def container_actions_keyboard(name: str):
|
||||
builder = InlineKeyboardBuilder()
|
||||
|
||||
builder.add(InlineKeyboardButton(
|
||||
text="Запустить контейнер",
|
||||
callback_data=f"action_start_{name}",
|
||||
))
|
||||
builder.add(InlineKeyboardButton(
|
||||
text="Остановить контейнер",
|
||||
callback_data=f"action_stop_{name}",
|
||||
))
|
||||
builder.add(InlineKeyboardButton(
|
||||
text="Перезапустить контейнер",
|
||||
callback_data=f"action_restart_{name}",
|
||||
))
|
||||
builder.add(InlineKeyboardButton(
|
||||
text="Удалить контейнер",
|
||||
callback_data=f"action_delete_{name}",
|
||||
))
|
||||
builder.adjust(1)
|
||||
|
||||
return builder
|
Reference in New Issue
Block a user