Multiple profiles (#312)
* Navbar user profile * profiles stuff * fix profile * Lint fix * Some ui experiments * More ui work * progress * Lint fix * migration, web api, wip * profile view and web app * web app and apis * Invidious and profiles * Lint fix * bug fix * Remove ActionContentNode * Profile icon button, profile color * Lint fix * reset server url * href that doesn't work * remove activate button on active profile * TODO * Fin. * Final touches --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
8e03ca0ea6
commit
394dd23999
60 files changed
+1725
-311
No files matched your search
@@ -0,0 +1,73 @@
|
||||
namespace Http
|
||||
|
||||
class ProfilesRouter extends HttpRouter
|
||||
|
||||
function new(server as object)
|
||||
super()
|
||||
|
||||
m.profilesNode = server.task.profiles
|
||||
m.profilesContent = m.profilesNode.content.getChild(0)
|
||||
end function
|
||||
|
||||
@get("/api/profiles")
|
||||
function GetProfiles(context as object) as boolean
|
||||
response = context.response
|
||||
|
||||
profiles = m.profilesNode@.GetProfilesDto(false)
|
||||
response.Json(profiles)
|
||||
return true
|
||||
end function
|
||||
|
||||
@post("/api/profiles/activate")
|
||||
function ActivateProfile(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
payload = request.Json()
|
||||
if payload = invalid
|
||||
response.Default(400, `Invalid JSON payload`)
|
||||
return true
|
||||
end if
|
||||
|
||||
id = payload.id
|
||||
if StringUtils.IsNullOrEmpty(id)
|
||||
response.Default(400, "Missing profile id")
|
||||
return true
|
||||
end if
|
||||
|
||||
profile = m.profilesContent.findNode(id)
|
||||
if profile = invalid
|
||||
response.Default(404, `Profile id "${id}" not found`)
|
||||
return true
|
||||
end if
|
||||
|
||||
m.profilesNode@.SetCurrentProfile(profile)
|
||||
response.Default(200, "Profile updated")
|
||||
return true
|
||||
end function
|
||||
|
||||
@delete("/api/profiles")
|
||||
function Logout(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
id = request.query.id
|
||||
if StringUtils.IsNullOrEmpty(id)
|
||||
response.Default(400, "Missing profile id")
|
||||
return true
|
||||
end if
|
||||
|
||||
profile = m.profilesContent.findNode(id)
|
||||
if profile = invalid
|
||||
response.Default(404, `Profile id "${id}" not found`)
|
||||
return true
|
||||
end if
|
||||
|
||||
m.profilesNode@.LogoutWithProfile(profile)
|
||||
response.Default(200, "Profile logged out")
|
||||
return true
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
Reference in new issue
Block a user