Abhinav commited on
Commit
157e563
·
unverified ·
1 Parent(s): 83dba3e

feat: Add Profile icons (fontawesome)

Browse files
pages/{avatarItems.py → Avatar_Items.py} RENAMED
@@ -1,11 +1,11 @@
1
  import streamlit as st
2
  from utils.wolvesville import Wolvesville
3
- from utils.models import Role
4
  from typing import List
5
 
6
  api = Wolvesville()
7
 
8
- items: List[Role] = api.getItems()
9
 
10
  st.title("Avatar Items")
11
 
 
1
  import streamlit as st
2
  from utils.wolvesville import Wolvesville
3
+ from utils.models import AvatarItems
4
  from typing import List
5
 
6
  api = Wolvesville()
7
 
8
+ items: List[AvatarItems] = api.getItems()
9
 
10
  st.title("Avatar Items")
11
 
pages/{screens.py → Loading_Screens.py} RENAMED
File without changes
pages/Profile_Icons.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.wolvesville import Wolvesville
3
+ from utils.models import ProfileIcons
4
+ from typing import List
5
+
6
+ api = Wolvesville()
7
+
8
+
9
+ css_example = '''
10
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
11
+ '''
12
+ st.write(css_example, unsafe_allow_html=True)
13
+
14
+
15
+ icons: List[ProfileIcons] = api.getProfileIcons()
16
+
17
+
18
+ for item in icons:
19
+ rarity = item.rarity.title()
20
+ HTML = f"<p><i class=\"fas fa-{item.name} fa-2xl\"></i> {rarity}</p>"
21
+ st.write(HTML, unsafe_allow_html=True)
22
+
23
+ st.divider()
pages/{roles.py → Roles.py} RENAMED
File without changes
utils/models.py CHANGED
@@ -112,4 +112,27 @@ def _getAvatarObjects(items: List[Dict[str, Union[str, Dict]]]):
112
  except Exception as e:
113
  print(e)
114
  print(item)
115
- return itemList
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  except Exception as e:
113
  print(e)
114
  print(item)
115
+ return itemList
116
+
117
+ class ProfileIcons(BaseModel):
118
+ id: str
119
+ name: str
120
+ rarity: str
121
+
122
+ def getIconName(name: str):
123
+ parts = name.split(":")
124
+ icon = parts[1]
125
+ return icon
126
+
127
+ def _getProfileIconObjects(profile_icons: List[Dict[str, Union[str, Dict]]]):
128
+ profileIconList = []
129
+ for icon in profile_icons:
130
+ try:
131
+ entry = ProfileIcons(**icon)
132
+ entry.name = getIconName(entry.name)
133
+
134
+ profileIconList.append(entry)
135
+ except Exception as e:
136
+ print(e)
137
+ print(icon)
138
+ return profileIconList
utils/wolvesville.py CHANGED
@@ -4,7 +4,8 @@ from utils.models import (
4
  _getRoleIconObjects,
5
  _mapRoleRoleIcons,
6
  _getScreenObjects,
7
- _getAvatarObjects
 
8
  )
9
  from dotenv import load_dotenv
10
  from os import getenv
@@ -52,4 +53,9 @@ class Wolvesville:
52
  def getItems(self):
53
  screens = requests.get(f"{self.url}/items/avatarItems", headers=self.headers).json()
54
  resp = _getAvatarObjects(items=screens)
 
 
 
 
 
55
  return resp
 
4
  _getRoleIconObjects,
5
  _mapRoleRoleIcons,
6
  _getScreenObjects,
7
+ _getAvatarObjects,
8
+ _getProfileIconObjects
9
  )
10
  from dotenv import load_dotenv
11
  from os import getenv
 
53
  def getItems(self):
54
  screens = requests.get(f"{self.url}/items/avatarItems", headers=self.headers).json()
55
  resp = _getAvatarObjects(items=screens)
56
+ return resp
57
+
58
+ def getProfileIcons(self):
59
+ icons = requests.get(f"{self.url}/items/profileIcons", headers=self.headers).json()
60
+ resp = _getProfileIconObjects(profile_icons=icons)
61
  return resp