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
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *queryResolver) Directories(ctx context.Context, path *string) ([]string, error) {
|
|
|
|
var dirPath = ""
|
|
|
|
if path != nil {
|
|
|
|
dirPath = *path
|
|
|
|
}
|
|
|
|
return utils.ListDir(dirPath), nil
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
|
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,
|
|
|
|
Username: config.GetUsername(),
|
|
|
|
Password: config.GetPasswordHash(),
|
|
|
|
LogFile: &logFile,
|
|
|
|
LogOut: config.GetLogOut(),
|
|
|
|
LogLevel: config.GetLogLevel(),
|
|
|
|
LogAccess: config.GetLogAccess(),
|
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()
|
2019-11-29 01:41:17 +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,
|
2019-08-22 22:24:14 +00:00
|
|
|
}
|
|
|
|
}
|