|
|
|
|
|
|
10
|
self.title = title
|
10
|
self.title = title
|
|
11
|
self.styles = styles
|
11
|
self.styles = styles
|
|
12
|
self.version = version
|
12
|
self.version = version
|
|
|
|
13
|
+ self.content = []
|
|
13
|
|
14
|
|
|
14
|
- def create(self, content):
|
|
|
|
|
|
15
|
+ def add(self, content):
|
|
|
|
16
|
+ self.content.append(content)
|
|
|
|
17
|
+
|
|
|
|
18
|
+ def create(self, content = []):
|
|
15
|
f = open(self.path, 'w')
|
19
|
f = open(self.path, 'w')
|
|
16
|
head = self.getHeader(title=self.title)
|
20
|
head = self.getHeader(title=self.title)
|
|
17
|
body = self.getBody(content, title=self.title)
|
21
|
body = self.getBody(content, title=self.title)
|
|
|
|
|
|
|
42
|
def getBody(self, content: List[str], title: str) -> str:
|
46
|
def getBody(self, content: List[str], title: str) -> str:
|
|
43
|
sidebar = self.getSideBar()
|
47
|
sidebar = self.getSideBar()
|
|
44
|
topBar = self.getTopBar(title=title)
|
48
|
topBar = self.getTopBar(title=title)
|
|
|
|
49
|
+ if len(self.content) > 0 :
|
|
|
|
50
|
+ content = [*self.content, *content]
|
|
|
|
51
|
+
|
|
45
|
content = '\n'.join(content)
|
52
|
content = '\n'.join(content)
|
|
46
|
return f'''
|
53
|
return f'''
|
|
47
|
<body x-data="{{ page: 'main', 'loaded': false, 'darkMode': true, 'stickyMenu': false, 'sidebarToggle': false, 'scrollTop': false }}"
|
54
|
<body x-data="{{ page: 'main', 'loaded': false, 'darkMode': true, 'stickyMenu': false, 'sidebarToggle': false, 'scrollTop': false }}"
|
|
|
|
|
|
|
108
|
</div>
|
115
|
</div>
|
|
109
|
</div>'''
|
116
|
</div>'''
|
|
110
|
|
117
|
|
|
111
|
- return f'''
|
|
|
|
|
|
118
|
+ self.add(f'''
|
|
112
|
<div class="rounded-sm border border-stroke bg-white px-7.5 py-6 shadow-default dark:border-strokedark dark:bg-boxdark">
|
119
|
<div class="rounded-sm border border-stroke bg-white px-7.5 py-6 shadow-default dark:border-strokedark dark:bg-boxdark">
|
|
113
|
<div class="flex flex-col">
|
120
|
<div class="flex flex-col">
|
|
114
|
<div class="flex-1 p-6">
|
121
|
<div class="flex-1 p-6">
|
|
|
|
|
|
|
130
|
</div>
|
137
|
</div>
|
|
131
|
</div>
|
138
|
</div>
|
|
132
|
</div>
|
139
|
</div>
|
|
133
|
-</div>'''
|
|
|
|
|
|
140
|
+</div>''')
|
|
134
|
|
141
|
|
|
135
|
def cardItemStat(self, count: str = '$3.456K', title: str = 'Total views', stat: str = None, arrow: str = 'up', icon=None) -> str:
|
142
|
def cardItemStat(self, count: str = '$3.456K', title: str = 'Total views', stat: str = None, arrow: str = 'up', icon=None) -> str:
|
|
136
|
|
143
|
|
|
|
|
|
|
|
152
|
<path d="M11 10.9219C9.38438 10.9219 8.07812 9.61562 8.07812 8C8.07812 6.38438 9.38438 5.07812 11 5.07812C12.6156 5.07812 13.9219 6.38438 13.9219 8C13.9219 9.61562 12.6156 10.9219 11 10.9219ZM11 6.625C10.2437 6.625 9.625 7.24375 9.625 8C9.625 8.75625 10.2437 9.375 11 9.375C11.7563 9.375 12.375 8.75625 12.375 8C12.375 7.24375 11.7563 6.625 11 6.625Z" fill=""></path>
|
159
|
<path d="M11 10.9219C9.38438 10.9219 8.07812 9.61562 8.07812 8C8.07812 6.38438 9.38438 5.07812 11 5.07812C12.6156 5.07812 13.9219 6.38438 13.9219 8C13.9219 9.61562 12.6156 10.9219 11 10.9219ZM11 6.625C10.2437 6.625 9.625 7.24375 9.625 8C9.625 8.75625 10.2437 9.375 11 9.375C11.7563 9.375 12.375 8.75625 12.375 8C12.375 7.24375 11.7563 6.625 11 6.625Z" fill=""></path>
|
|
153
|
</svg>'''
|
160
|
</svg>'''
|
|
154
|
|
161
|
|
|
155
|
- return f'''
|
|
|
|
|
|
162
|
+ self.add(f'''
|
|
156
|
<div class="rounded-sm border border-stroke bg-white px-7.5 py-6 shadow-default dark:border-strokedark dark:bg-boxdark">
|
163
|
<div class="rounded-sm border border-stroke bg-white px-7.5 py-6 shadow-default dark:border-strokedark dark:bg-boxdark">
|
|
157
|
<div class="flex h-11.5 w-11.5 items-center justify-center rounded-full bg-meta-2 dark:bg-meta-4">
|
164
|
<div class="flex h-11.5 w-11.5 items-center justify-center rounded-full bg-meta-2 dark:bg-meta-4">
|
|
158
|
{icon}
|
165
|
{icon}
|
|
|
|
|
|
|
166
|
|
173
|
|
|
167
|
{stat_html}
|
174
|
{stat_html}
|
|
168
|
</div>
|
175
|
</div>
|
|
169
|
-</div>'''
|
|
|
|
|
|
176
|
+</div>''')
|
|
170
|
|
177
|
|
|
171
|
def getSideBar(self) -> str:
|
178
|
def getSideBar(self) -> str:
|
|
172
|
menu = ''.join([f'''
|
179
|
menu = ''.join([f'''
|
|
|
|
|
|
|
411
|
def addChart(self, config: Dict, name: str = None, title: str = 'Chart', className: str=None):
|
418
|
def addChart(self, config: Dict, name: str = None, title: str = 'Chart', className: str=None):
|
|
412
|
if name is None:
|
419
|
if name is None:
|
|
413
|
name = f'chart_{int(time.time())}'
|
420
|
name = f'chart_{int(time.time())}'
|
|
414
|
- return self.addCard([f'<div id="{name}" class="-ml-5"></div>'], title=title, className=className, extra=f'''
|
|
|
|
|
|
421
|
+ self.addCard([f'<div id="{name}" class="-ml-5"></div>'], title=title, className=className, extra=f'''
|
|
415
|
<script>
|
422
|
<script>
|
|
416
|
document.addEventListener("DOMContentLoaded", () => {{
|
423
|
document.addEventListener("DOMContentLoaded", () => {{
|
|
417
|
const chartSelector = document.querySelectorAll("#{name}");
|
424
|
const chartSelector = document.querySelectorAll("#{name}");
|
|
|
|
|
|
|
428
|
|
435
|
|
|
429
|
def addCard(self, content, title: str = 'Chart', className: str=None, extra: str=None):
|
436
|
def addCard(self, content, title: str = 'Chart', className: str=None, extra: str=None):
|
|
430
|
content = '\n'.join(content)
|
437
|
content = '\n'.join(content)
|
|
431
|
- return f'''
|
|
|
|
|
|
438
|
+ self.add(f'''
|
|
432
|
<div
|
439
|
<div
|
|
433
|
class="col-span-12 rounded-sm border border-stroke bg-white px-5 pb-5 pt-7.5 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5 {className or ""}">
|
440
|
class="col-span-12 rounded-sm border border-stroke bg-white px-5 pb-5 pt-7.5 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5 {className or ""}">
|
|
434
|
<div>
|
441
|
<div>
|
|
|
|
|
|
|
438
|
</div>
|
445
|
</div>
|
|
439
|
<div>{content}</div>
|
446
|
<div>{content}</div>
|
|
440
|
{extra or ""}
|
447
|
{extra or ""}
|
|
441
|
-</div>'''
|
|
|
|
|
|
448
|
+</div>''')
|