feat(appstore): add remote app store templates with service upgrades and Redis/MariaDB platform support
This commit is contained in:
@@ -54,6 +54,11 @@ export interface ISettingsState {
|
||||
backupPasswordConfigured: boolean;
|
||||
}
|
||||
|
||||
export interface IAppStoreState {
|
||||
apps: interfaces.requests.ICatalogApp[];
|
||||
upgradeableServices: interfaces.requests.IUpgradeableService[];
|
||||
}
|
||||
|
||||
export interface IUiState {
|
||||
activeView: string;
|
||||
autoRefresh: boolean;
|
||||
@@ -137,6 +142,15 @@ export const settingsStatePart = await appState.getStatePart<ISettingsState>(
|
||||
'soft',
|
||||
);
|
||||
|
||||
export const appStoreStatePart = await appState.getStatePart<IAppStoreState>(
|
||||
'appStore',
|
||||
{
|
||||
apps: [],
|
||||
upgradeableServices: [],
|
||||
},
|
||||
'soft',
|
||||
);
|
||||
|
||||
export const uiStatePart = await appState.getStatePart<IUiState>(
|
||||
'ui',
|
||||
{
|
||||
@@ -914,7 +928,8 @@ export const setBackupPasswordAction = settingsStatePart.createAction<{ password
|
||||
|
||||
export const setActiveViewAction = uiStatePart.createAction<{ view: string }>(
|
||||
async (statePartArg, dataArg) => {
|
||||
return { ...statePartArg.getState(), activeView: dataArg.view };
|
||||
const normalizedView = dataArg.view.toLowerCase().replace(/\s+/g, '-');
|
||||
return { ...statePartArg.getState(), activeView: normalizedView };
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1055,6 +1070,68 @@ async function disconnectSocket() {
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// App Store Actions
|
||||
// ============================================================================
|
||||
|
||||
export const fetchAppTemplatesAction = appStoreStatePart.createAction(
|
||||
async (statePartArg) => {
|
||||
const context = getActionContext();
|
||||
try {
|
||||
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||
interfaces.requests.IReq_GetAppTemplates
|
||||
>('/typedrequest', 'getAppTemplates');
|
||||
const response = await typedRequest.fire({ identity: context.identity! });
|
||||
return { ...statePartArg.getState(), apps: response.apps };
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch app templates:', err);
|
||||
return statePartArg.getState();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export const fetchUpgradeableServicesAction = appStoreStatePart.createAction(
|
||||
async (statePartArg) => {
|
||||
const context = getActionContext();
|
||||
try {
|
||||
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||
interfaces.requests.IReq_GetUpgradeableServices
|
||||
>('/typedrequest', 'getUpgradeableServices');
|
||||
const response = await typedRequest.fire({ identity: context.identity! });
|
||||
return { ...statePartArg.getState(), upgradeableServices: response.services };
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch upgradeable services:', err);
|
||||
return statePartArg.getState();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export const upgradeServiceAction = appStoreStatePart.createAction<{
|
||||
serviceName: string;
|
||||
targetVersion: string;
|
||||
}>(async (statePartArg, dataArg) => {
|
||||
const context = getActionContext();
|
||||
try {
|
||||
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||
interfaces.requests.IReq_UpgradeService
|
||||
>('/typedrequest', 'upgradeService');
|
||||
await typedRequest.fire({
|
||||
identity: context.identity!,
|
||||
serviceName: dataArg.serviceName,
|
||||
targetVersion: dataArg.targetVersion,
|
||||
});
|
||||
// Re-fetch upgradeable services and services list
|
||||
const upgradeReq = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||
interfaces.requests.IReq_GetUpgradeableServices
|
||||
>('/typedrequest', 'getUpgradeableServices');
|
||||
const upgradeResp = await upgradeReq.fire({ identity: context.identity! });
|
||||
return { ...statePartArg.getState(), upgradeableServices: upgradeResp.services };
|
||||
} catch (err) {
|
||||
console.error('Failed to upgrade service:', err);
|
||||
return statePartArg.getState();
|
||||
}
|
||||
});
|
||||
|
||||
// Connect socket when logged in, disconnect when logged out
|
||||
loginStatePart.select((s) => s).subscribe((loginState) => {
|
||||
if (loginState.isLoggedIn) {
|
||||
|
||||
Reference in New Issue
Block a user