2019-03-23 21:09:05 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2019-07-28 09:36:52 +00:00
|
|
|
|
2019-03-23 21:09:05 +00:00
|
|
|
"github.com/stashapp/stash/pkg/manager/config"
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
|
|
"github.com/stashapp/stash/pkg/utils"
|
|
|
|
)
|
|
|
|
|
2019-03-26 15:35:06 +00:00
|
|
|
func (r *queryResolver) Configuration(ctx context.Context) (*models.ConfigResult, error) {
|
2019-03-23 21:09:05 +00:00
|
|
|
return makeConfigResult(), nil
|
|
|
|
}
|
|
|
|
|
2020-05-09 03:08:00 +00:00
|
|
|
func (r *queryResolver) Directory(ctx context.Context, path *string) (*models.Directory, error) {
|
2019-03-23 21:09:05 +00:00
|
|
|
var dirPath = ""
|
|
|
|
if path != nil {
|
|
|
|
dirPath = *path
|
|
|
|
}
|
2020-05-09 03:08:00 +00:00
|
|
|
currentDir := utils.GetDir(dirPath)
|
|
|
|
|
|
|
|
return &models.Directory{
|
|
|
|
Path: currentDir,
|
|
|
|
Parent: utils.GetParent(currentDir),
|
|
|
|
Directories: utils.ListDir(currentDir),
|
|
|
|
}, nil
|
2019-03-23 21:09:05 +00:00
|
|
|
}
|
|
|
|
|
2019-03-26 15:35:06 +00:00
|
|
|
func makeConfigResult() *models.ConfigResult {
|
|
|
|
return &models.ConfigResult{
|
2019-08-22 22:24:14 +00:00
|
|
|
General: makeConfigGeneralResult(),
|
|
|
|
Interface: makeConfigInterfaceResult(),
|
2019-03-23 21:09:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-26 15:35:06 +00:00
|
|
|
func makeConfigGeneralResult() *models.ConfigGeneralResult {
|
2019-10-25 00:13:44 +00:00
|
|
|
logFile := config.GetLogFile()
|
2019-11-04 21:38:33 +00:00
|
|
|
|
|
|
|
maxTranscodeSize := config.GetMaxTranscodeSize()
|
|
|
|
maxStreamingTranscodeSize := config.GetMaxStreamingTranscodeSize()
|
|
|
|
|
2020-03-20 21:55:15 +00:00
|
|
|
scraperUserAgent := config.GetScraperUserAgent()
|
|
|
|
|
2019-03-26 15:35:06 +00:00
|
|
|
return &models.ConfigGeneralResult{
|
2019-11-04 21:38:33 +00:00
|
|
|
Stashes: config.GetStashPaths(),
|
|
|
|
DatabasePath: config.GetDatabasePath(),
|
|
|
|
GeneratedPath: config.GetGeneratedPath(),
|
|
|
|
MaxTranscodeSize: &maxTranscodeSize,
|
|
|
|
MaxStreamingTranscodeSize: &maxStreamingTranscodeSize,
|
2020-04-09 22:38:34 +00:00
|
|
|
ForceMkv: config.GetForceMKV(),
|
|
|
|
ForceHevc: config.GetForceHEVC(),
|
2019-11-04 21:38:33 +00:00
|
|
|
Username: config.GetUsername(),
|
|
|
|
Password: config.GetPasswordHash(),
|
2020-04-08 02:51:12 +00:00
|
|
|
MaxSessionAge: config.GetMaxSessionAge(),
|
2019-11-04 21:38:33 +00:00
|
|
|
LogFile: &logFile,
|
|
|
|
LogOut: config.GetLogOut(),
|
|
|
|
LogLevel: config.GetLogLevel(),
|
|
|
|
LogAccess: config.GetLogAccess(),
|
2019-12-17 14:26:16 +00:00
|
|
|
Excludes: config.GetExcludes(),
|
2020-03-20 21:55:15 +00:00
|
|
|
ScraperUserAgent: &scraperUserAgent,
|
2019-03-23 21:09:05 +00:00
|
|
|
}
|
2019-03-24 17:04:31 +00:00
|
|
|
}
|
2019-08-22 22:24:14 +00:00
|
|
|
|
|
|
|
func makeConfigInterfaceResult() *models.ConfigInterfaceResult {
|
2019-11-29 01:41:17 +00:00
|
|
|
soundOnPreview := config.GetSoundOnPreview()
|
|
|
|
wallShowTitle := config.GetWallShowTitle()
|
|
|
|
maximumLoopDuration := config.GetMaximumLoopDuration()
|
|
|
|
autostartVideo := config.GetAutostartVideo()
|
2019-12-05 17:24:22 +00:00
|
|
|
showStudioAsText := config.GetShowStudioAsText()
|
2019-08-22 22:24:14 +00:00
|
|
|
css := config.GetCSS()
|
|
|
|
cssEnabled := config.GetCSSEnabled()
|
2020-02-26 09:07:03 +00:00
|
|
|
language := config.GetLanguage()
|
2020-02-06 21:42:29 +00:00
|
|
|
|
2019-08-22 22:24:14 +00:00
|
|
|
return &models.ConfigInterfaceResult{
|
2019-11-29 01:41:17 +00:00
|
|
|
SoundOnPreview: &soundOnPreview,
|
|
|
|
WallShowTitle: &wallShowTitle,
|
|
|
|
MaximumLoopDuration: &maximumLoopDuration,
|
|
|
|
AutostartVideo: &autostartVideo,
|
2019-12-05 17:24:22 +00:00
|
|
|
ShowStudioAsText: &showStudioAsText,
|
2019-11-29 01:41:17 +00:00
|
|
|
CSS: &css,
|
|
|
|
CSSEnabled: &cssEnabled,
|
2020-02-26 09:05:12 +00:00
|
|
|
Language: &language,
|
2019-08-22 22:24:14 +00:00
|
|
|
}
|
|
|
|
}
|