initial commit
This commit is contained in:
parent
ca656b8d7d
commit
84182672c7
25
gui/dialog_box_ui.py
Normal file
25
gui/dialog_box_ui.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import sys
|
||||
from PyQt6.QtWidgets import QApplication, QDialog, QDialogButtonBox, QLabel, QVBoxLayout
|
||||
|
||||
|
||||
class DialogBox(QDialog):
|
||||
def __init__(self, title, message):
|
||||
super().__init__()
|
||||
self.setWindowTitle(title)
|
||||
self.resize(100, 100)
|
||||
# self.setModal(True)
|
||||
self.label = QLabel(message)
|
||||
self.button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok)
|
||||
self.button_box.accepted.connect(self.accept)
|
||||
|
||||
layout = QVBoxLayout()
|
||||
layout.addWidget(self.label)
|
||||
layout.addWidget(self.button_box)
|
||||
self.setLayout(layout)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
dialog = DialogBox("Stack Update", "Stack updated successfully")
|
||||
dialog.show()
|
||||
sys.exit(app.exec())
|
21
gui/workers/load_container_image_status_worker.py
Normal file
21
gui/workers/load_container_image_status_worker.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from PyQt6.QtCore import QThread, pyqtSignal
|
||||
|
||||
|
||||
class LoadContainerImageStatusWorker(QThread):
|
||||
image_status_retrieved = pyqtSignal(str)
|
||||
error_occurred = pyqtSignal(str)
|
||||
|
||||
def __init__(self, portainer, endpoint_id, container_id):
|
||||
super().__init__()
|
||||
self.portainer = portainer
|
||||
self.endpoint_id = endpoint_id
|
||||
self.container_id = container_id
|
||||
# self.image_status = None
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
image_status = self.portainer.containers.get_container_image_status(self.endpoint_id, self.container_id)
|
||||
# self.image_status = image_status['Status']
|
||||
self.image_status_retrieved.emit(image_status['Status'])
|
||||
except Exception as e:
|
||||
self.image_status_retrieved.emit("Not available")
|
26
portainer_api/containers.py
Normal file
26
portainer_api/containers.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
import json
|
||||
|
||||
from utils.date_converter import datetime_from_timestamp
|
||||
from .base import Portainer
|
||||
|
||||
|
||||
class Containers(Portainer):
|
||||
def list_containers_of_stack(self, endpoint_id, stack_name):
|
||||
endpoint_containers = self.portainer.containers.list_containers_by_endpoint(endpoint=endpoint_id)
|
||||
containers_list = []
|
||||
for container in endpoint_containers:
|
||||
if container['Labels'].get('com.docker.compose.project') == stack_name:
|
||||
container_data = {
|
||||
"id": container['Id'],
|
||||
"name": container['Names'][0].lstrip('/'),
|
||||
"image": container['Image'],
|
||||
"created": datetime_from_timestamp(container['Created']),
|
||||
"status": container['Status'],
|
||||
"labels": container['Labels'],
|
||||
}
|
||||
containers_list.append(container_data)
|
||||
return containers_list
|
||||
|
||||
def get_container_image_status(self, endpoint_id, container_id):
|
||||
status = self.portainer.containers.get_container_image_status(endpoint_id, container_id)
|
||||
return status
|
Loading…
Reference in a new issue