From c80dadd4d9fe93f792bcd39ff02a7b8ed2dfd2a7 Mon Sep 17 00:00:00 2001 From: Dobin Date: Wed, 6 Mar 2024 21:34:45 +0000 Subject: [PATCH] feature: web project --- app/storage.py | 43 +++++++ app/templates/files.html | 52 ++++++++ app/templates/index.html | 8 ++ app/templates/inject.html | 0 app/templates/project.html | 117 +++++++++++------ .../{build.html => project_add_get.html} | 9 +- app/templates/project_add_post.html | 1 + app/views.py | 119 ++++++++++++++---- 8 files changed, 281 insertions(+), 68 deletions(-) create mode 100644 app/storage.py create mode 100644 app/templates/files.html delete mode 100644 app/templates/inject.html rename app/templates/{build.html => project_add_get.html} (87%) create mode 100644 app/templates/project_add_post.html diff --git a/app/storage.py b/app/storage.py new file mode 100644 index 0000000..e631708 --- /dev/null +++ b/app/storage.py @@ -0,0 +1,43 @@ +import pickle + +from typing import List, Tuple +from model.settings import Settings + + +class Project(): + def __init__(self, name: str, settings: Settings): + self.name = name + self.settings: Settings = settings + + +class Storage(): + def __init__(self): + self.data: List[Project] = self.get_data() + + def get_project(self, name): + for project in self.data: + if project.name == name: + return project + return None + + def add_project(self, project): + self.data.append(project) + self.save_data() + + def get_data(self): + print("Read data") + with open("app/data.pickle", "rb") as f: + data = f.read() + data = pickle.loads(data) + + for project in data: + print(" {}".format(project.name)) + + return data + + def save_data(self): + print("Save data") + with open("app/data.pickle", "wb") as f: + f.write(pickle.dumps(self.data)) + +storage = Storage() \ No newline at end of file diff --git a/app/templates/files.html b/app/templates/files.html new file mode 100644 index 0000000..658f5c7 --- /dev/null +++ b/app/templates/files.html @@ -0,0 +1,52 @@ + + + + {% include 'header.html' %} + + + +{% include 'navigation.html' %} + +
+
+ +
+ +
+ +
+
+ {% for log_file in log_files %} +
+
{{log_file['content']|safe}} +
+
+ {% endfor %} +
+
+
+ +
+ + + \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/index.html index 211bb7f..442d97a 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -10,6 +10,14 @@

SuperMega

+ + + + Add \ No newline at end of file diff --git a/app/templates/inject.html b/app/templates/inject.html deleted file mode 100644 index e69de29..0000000 diff --git a/app/templates/project.html b/app/templates/project.html index 658f5c7..1e67c05 100644 --- a/app/templates/project.html +++ b/app/templates/project.html @@ -4,49 +4,88 @@ {% include 'header.html' %} - -{% include 'navigation.html' %} + {% include 'navigation.html' %} -
-
+
+ +

Project {{project_name}}

+ +
+
+ + + +
+ +
+ +
+ + + + + + + + + + + + + + -
- -
- -
-
- {% for log_file in log_files %} -
-
{{log_file['content']|safe}} -
- {% endfor %} -
-
-
+
- +
+
+
\ No newline at end of file diff --git a/app/templates/build.html b/app/templates/project_add_get.html similarity index 87% rename from app/templates/build.html rename to app/templates/project_add_get.html index b3e82de..6f12d40 100644 --- a/app/templates/build.html +++ b/app/templates/project_add_get.html @@ -10,11 +10,12 @@
- -
-
+ + + +