-
-
Notifications
You must be signed in to change notification settings - Fork 826
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add package manager * Add SettingModal validate * Reverse modal button order * Add plugin package management * Refactor ClearableInput
- Loading branch information
1 parent
d95ef40
commit 987fa80
Showing
42 changed files
with
3,484 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fragment PackageData on Package { | ||
package_id | ||
name | ||
version | ||
date | ||
metadata | ||
sourceURL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
mutation ReloadScrapers { | ||
reloadScrapers | ||
} | ||
|
||
mutation InstallScraperPackages($packages: [PackageSpecInput!]!) { | ||
installPackages(type: Scraper, packages: $packages) | ||
} | ||
|
||
mutation UpdateScraperPackages($packages: [PackageSpecInput!]!) { | ||
updatePackages(type: Scraper, packages: $packages) | ||
} | ||
|
||
mutation UninstallScraperPackages($packages: [PackageSpecInput!]!) { | ||
uninstallPackages(type: Scraper, packages: $packages) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
enum PackageType { | ||
Scraper | ||
Plugin | ||
} | ||
|
||
type Package { | ||
package_id: String! | ||
name: String! | ||
version: String | ||
date: Timestamp | ||
requires: [Package!]! | ||
|
||
sourceURL: String! | ||
|
||
"The available upgraded version of this package" | ||
upgrade: Package | ||
|
||
metadata: Map! | ||
} | ||
|
||
input PackageSpecInput { | ||
id: String! | ||
sourceURL: String! | ||
} | ||
|
||
type PackageSource { | ||
name: String | ||
url: String! | ||
local_path: String | ||
} | ||
|
||
input PackageSourceInput { | ||
name: String | ||
url: String! | ||
local_path: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
"strconv" | ||
|
||
"github.com/stashapp/stash/internal/manager" | ||
"github.com/stashapp/stash/internal/manager/task" | ||
"github.com/stashapp/stash/pkg/logger" | ||
"github.com/stashapp/stash/pkg/models" | ||
) | ||
|
||
func refreshPackageType(typeArg PackageType) { | ||
mgr := manager.GetInstance() | ||
|
||
if typeArg == PackageTypePlugin { | ||
if err := mgr.PluginCache.LoadPlugins(); err != nil { | ||
logger.Errorf("Error reading plugin configs: %v", err) | ||
} | ||
} else if typeArg == PackageTypeScraper { | ||
if err := mgr.ScraperCache.ReloadScrapers(); err != nil { | ||
logger.Errorf("Error reading scraper configs: %v", err) | ||
} | ||
} | ||
} | ||
|
||
func (r *mutationResolver) InstallPackages(ctx context.Context, typeArg PackageType, packages []*models.PackageSpecInput) (string, error) { | ||
pm, err := getPackageManager(typeArg) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
mgr := manager.GetInstance() | ||
t := &task.InstallPackagesJob{ | ||
PackagesJob: task.PackagesJob{ | ||
PackageManager: pm, | ||
OnComplete: func() { refreshPackageType(typeArg) }, | ||
}, | ||
Packages: packages, | ||
} | ||
jobID := mgr.JobManager.Add(ctx, "Installing packages...", t) | ||
|
||
return strconv.Itoa(jobID), nil | ||
} | ||
|
||
func (r *mutationResolver) UpdatePackages(ctx context.Context, typeArg PackageType, packages []*models.PackageSpecInput) (string, error) { | ||
pm, err := getPackageManager(typeArg) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
mgr := manager.GetInstance() | ||
t := &task.UpdatePackagesJob{ | ||
PackagesJob: task.PackagesJob{ | ||
PackageManager: pm, | ||
OnComplete: func() { refreshPackageType(typeArg) }, | ||
}, | ||
Packages: packages, | ||
} | ||
jobID := mgr.JobManager.Add(ctx, "Updating packages...", t) | ||
|
||
return strconv.Itoa(jobID), nil | ||
} | ||
|
||
func (r *mutationResolver) UninstallPackages(ctx context.Context, typeArg PackageType, packages []*models.PackageSpecInput) (string, error) { | ||
pm, err := getPackageManager(typeArg) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
mgr := manager.GetInstance() | ||
t := &task.UninstallPackagesJob{ | ||
PackagesJob: task.PackagesJob{ | ||
PackageManager: pm, | ||
OnComplete: func() { refreshPackageType(typeArg) }, | ||
}, | ||
Packages: packages, | ||
} | ||
jobID := mgr.JobManager.Add(ctx, "Updating packages...", t) | ||
|
||
return strconv.Itoa(jobID), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.