Skip to content

Favorite Lecture View #1498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 4, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions api/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func configGinUsersRouter(router *gin.Engine, daoWrapper dao.DaoWrapper) {
router.POST("/api/users/settings/customSpeeds", routes.updateCustomSpeeds)
router.POST("/api/users/settings/autoSkip", routes.updateAutoSkip)
router.POST("/api/users/settings/defaultMode", routes.updateDefaultMode)
router.POST("api/users/settings/lectureView", routes.updatePreferredView)

router.POST("/api/users/resetPassword", routes.resetPassword)

Expand Down Expand Up @@ -782,6 +783,25 @@ func (r usersRoutes) updateDefaultMode(c *gin.Context) {
}
}

func (r usersRoutes) updatePreferredView(c *gin.Context) {
u := getUserFromContext(c)
request := getRequestFromContext(c)

err := r.UsersDao.AddUserSetting(&model.UserSetting{
UserID: u.ID,
Type: model.LectureView,
Value: request.Value,
})
if err != nil {
_ = c.Error(tools.RequestError{
Status: http.StatusInternalServerError,
CustomMessage: "can not add user setting",
Err: err,
})
return
}
}

func (r usersRoutes) exportPersonalData(c *gin.Context) {
var resp personalData
u := c.MustGet("TUMLiveContext").(tools.TUMLiveContext).User
Expand Down
10 changes: 10 additions & 0 deletions model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const (
UserDefinedSpeeds
AutoSkip
DefaultMode
LectureView
)

type UserSetting struct {
Expand Down Expand Up @@ -238,6 +239,15 @@ func (u *User) GetDefaultMode() (DefaultModeSetting, error) {
return DefaultModeSetting{Beta: false}, nil
}

func (u *User) GetPreferredView() string {
for _, setting := range u.Settings {
if setting.Type == LectureView {
return setting.Value
}
}
return "Combined"
}

type argonParams struct {
memory uint32
iterations uint32
Expand Down
2 changes: 1 addition & 1 deletion web/template/partial/stream/actions.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
{{if $stream.PlaylistUrl}}
<a class="text-left flex justify-start items-center w-full text-3 px-4 py-2 hover:cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-600"
title="Combined view"
@click="watch.switchView('/w/{{$course.Slug}}/{{$stream.Model.ID}}')">
@click="watch.switchView('/w/{{$course.Slug}}/{{$stream.Model.ID}}/COMB')">
<i class="text-lg fas fa-object-group text-4 hover:text-1 w-8"></i>
<span class="font-light text-sm">Combined view</span>
</a>
Expand Down
23 changes: 23 additions & 0 deletions web/template/user-settings.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
<label for="seek-time-20">20s</label>
</div>
</section>


<section x-data="{ autoSkip: {{toJson .TUMLiveContext.User.GetAutoSkipEnabled}} }">
<h2>Automatically Skip First Silence</h2>
<span class="mr-2">
Expand Down Expand Up @@ -167,6 +169,27 @@
</label>
</span>
</section>

<section x-data="{ currentView: {{toJson .TUMLiveContext.User.GetPreferredView}} }">
<h2>Preferred Lecture View</h2>
<input class="w-auto" type="radio" name="lectureView" value="Presentation" id="view1" x-model="currentView"
:checked="currentView==='Presentation'"
@change="global.updatePreference(global.UserSetting.LectureView, currentView).then((r) => {err=r})">
<label for="view1">Presentation Only</label><br>
<input class="w-auto" type="radio" name="lectureView" value="Camera" id="view2" x-model="currentView"
:checked="currentView==='Camera'"
@change="global.updatePreference(global.UserSetting.LectureView, currentView).then((r) => {err=r;})">
<label for="view2">Camera Only</label><br>
<input class="w-auto" type="radio" name="lectureView" value="Split" id="view3" x-model="currentView"
:checked="currentView==='Split'"
@change="global.updatePreference(global.UserSetting.LectureView, currentView).then((r) => {err=r})">
<label for="view3">Splitview</label><br>
<input class="w-auto" type="radio" name="lectureView" value="Combined" id="view4" x-model="currentView"
:checked="currentView==='Combined'"
@change="global.updatePreference(global.UserSetting.LectureView, currentView).then((r) => {err=r;})">
<label for="view4">Combined View</label>
</section>

<section>
<h2>Privacy & Data Protection</h2>
<a href="/api/users/exportData" download="personal_data.json"
Expand Down
1 change: 1 addition & 0 deletions web/ts/user-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export enum UserSetting {
CustomSpeeds = "customSpeeds",
AutoSkip = "autoSkip",
DefaultMode = "defaultMode",
LectureView = "lectureView",
}

export function updatePreference(t: UserSetting, value: string | boolean | number[]): Promise<string> {
Expand Down
15 changes: 15 additions & 0 deletions web/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ func (r mainRoutes) WatchPage(c *gin.Context) {
}
}

if c.Param("version") == "" {
switch tumLiveContext.User.GetPreferredView() {
case "Presentation":

c.Redirect(http.StatusFound, c.Request.RequestURI+"/PRES")

case "Camera":
c.Redirect(http.StatusFound, c.Request.RequestURI+"/CAM")
case "Combined":
c.Redirect(http.StatusFound, c.Request.RequestURI+"/COMB")
case "Split":
c.Redirect(http.StatusFound, c.Request.RequestURI+"/SPLIT")
}
}

// Check for fetching progress
if tumLiveContext.User != nil && tumLiveContext.Stream.Recording {

Expand Down
Loading