forked from Dniel97/artemis
Added version select in session, removed get_profile_data_ignore_version, renamed scripts file
This commit is contained in:
parent
d584b93ca5
commit
ed46ea33e3
@ -21,6 +21,7 @@ class IUserSession(Interface):
|
||||
userId = Attribute("User's ID")
|
||||
current_ip = Attribute("User's current ip address")
|
||||
permissions = Attribute("User's permission level")
|
||||
ongeki_version = Attribute("User's selected Ongeki Version")
|
||||
|
||||
class PermissionOffset(Enum):
|
||||
USER = 0 # Regular user
|
||||
@ -36,6 +37,7 @@ class UserSession(object):
|
||||
self.userId = 0
|
||||
self.current_ip = "0.0.0.0"
|
||||
self.permissions = 0
|
||||
self.ongeki_version = 7
|
||||
|
||||
|
||||
class FrontendServlet(resource.Resource):
|
||||
|
@ -26,7 +26,7 @@ class OngekiFrontend(FE_Base):
|
||||
yaml.safe_load(open(f"{cfg_dir}/{OngekiConstants.CONFIG_NAME}"))
|
||||
)
|
||||
self.nav_name = "O.N.G.E.K.I."
|
||||
self.version = 7
|
||||
self.version_list = OngekiConstants.VERSION_NAMES
|
||||
|
||||
def render_GET(self, request: Request) -> bytes:
|
||||
template = self.environment.get_template(
|
||||
@ -34,15 +34,14 @@ class OngekiFrontend(FE_Base):
|
||||
)
|
||||
sesh: Session = request.getSession()
|
||||
usr_sesh = IUserSession(sesh)
|
||||
self.version = usr_sesh.ongeki_version
|
||||
if getattr(usr_sesh, "userId", 0) != 0:
|
||||
profile_data =self.data.profile.get_profile_data_ignore_version(usr_sesh.userId)
|
||||
profile_data =self.data.profile.get_profile_data(usr_sesh.userId, self.version)
|
||||
rival_list = self.data.profile.get_rivals(usr_sesh.userId)
|
||||
rival_data = {
|
||||
"userRivalList": rival_list,
|
||||
"userId": usr_sesh.userId
|
||||
}
|
||||
self.version = getattr(profile_data, "version" , 7)
|
||||
if len(rival_list) > 0:
|
||||
rival_info = OngekiBase.handle_get_user_rival_data_api_request(self, rival_data)
|
||||
|
||||
return template.render(
|
||||
@ -52,6 +51,8 @@ class OngekiFrontend(FE_Base):
|
||||
gachas=self.game_cfg.gachas.enabled_gachas,
|
||||
profile_data=profile_data,
|
||||
rival_info=rival_info["userRivalDataList"],
|
||||
version_list=self.version_list,
|
||||
version=self.version,
|
||||
sesh=vars(usr_sesh)
|
||||
).encode("utf-16")
|
||||
else:
|
||||
@ -67,12 +68,19 @@ class OngekiFrontend(FE_Base):
|
||||
self.data.profile.put_rival(usr_sesh.userId, rival_id)
|
||||
# self.logger.info(f"{usr_sesh.userId} added a rival")
|
||||
return redirectTo(b"/game/ongeki/", request)
|
||||
|
||||
elif uri == "/game/ongeki/rival.delete":
|
||||
rival_id = request.args[b"rivalUserId"][0].decode()
|
||||
self.data.profile.delete_rival(usr_sesh.userId, rival_id)
|
||||
# self.logger.info(f"{response}")
|
||||
return redirectTo(b"/game/ongeki/", request)
|
||||
|
||||
elif uri == "/game/ongeki/version.change":
|
||||
ongeki_version=request.args[b"version"][0].decode()
|
||||
if(ongeki_version.isdigit()):
|
||||
usr_sesh.ongeki_version=int(ongeki_version)
|
||||
return redirectTo(b"/game/ongeki/", request)
|
||||
|
||||
else:
|
||||
return b"Something went wrong"
|
||||
else:
|
||||
|
24
titles/ongeki/frontend/js/ongeki_scripts.js
Normal file
24
titles/ongeki/frontend/js/ongeki_scripts.js
Normal file
@ -0,0 +1,24 @@
|
||||
function deleteRival(rivalUserId){
|
||||
|
||||
$(document).ready(function () {
|
||||
$.post("/game/ongeki/rival.delete",
|
||||
{
|
||||
rivalUserId
|
||||
},
|
||||
function(data,status){
|
||||
window.location.replace("/game/ongeki/")
|
||||
})
|
||||
});
|
||||
}
|
||||
function changeVersion(sel){
|
||||
|
||||
$(document).ready(function () {
|
||||
$.post("/game/ongeki/version.change",
|
||||
{
|
||||
version: sel.value
|
||||
},
|
||||
function(data,status){
|
||||
window.location.replace("/game/ongeki/")
|
||||
})
|
||||
});
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
function deleteRival(rivalUserId){
|
||||
|
||||
$(document).ready(function () {
|
||||
$.post("/game/ongeki/rival.delete",
|
||||
{
|
||||
rivalUserId
|
||||
},
|
||||
function(data,status){
|
||||
window.location.replace("/game/ongeki/")
|
||||
})
|
||||
});
|
||||
}
|
@ -9,15 +9,24 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h2> Profile </h2>
|
||||
<h3>Version:
|
||||
<select name="version" id="version" onChange="changeVersion(this)">
|
||||
{% for ver in version_list %}
|
||||
<option value={{loop.index0}} {{ "selected" if loop.index0==version else "" }} >{{ver}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</h3>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h2> {{ profile_data.userName }}</h2>
|
||||
<h2> Name: {{ profile_data.userName if profile_data.userName is defined else "Profile not found" }}</h2>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h4> ID: {{ profile_data.user}}</h4>
|
||||
<h4> ID: {{ profile_data.user if profile_data.user is defined else 'Profile not found' }}</h4>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<h2> Rivals <button class="btn btn-success" data-bs-toggle="modal" data-bs-target="#rival_add">Add</button></h2>
|
||||
</div>
|
||||
@ -66,7 +75,7 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
{% include 'titles/ongeki/frontend/js/rival_scripts.js' %}
|
||||
{% include 'titles/ongeki/frontend/js/ongeki_scripts.js' %}
|
||||
</script>
|
||||
{% else %}
|
||||
<h2>Not Currently Logged In</h2>
|
||||
|
@ -295,17 +295,6 @@ class OngekiProfileData(BaseData):
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_profile_data_ignore_version(self, aime_id: int) -> Optional[Row]:
|
||||
sql = select(profile).where(
|
||||
and_(
|
||||
profile.c.user == aime_id,
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
def get_profile_options(self, aime_id: int) -> Optional[Row]:
|
||||
sql = select(option).where(
|
||||
and_(
|
||||
|
Loading…
Reference in New Issue
Block a user