Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions api/src/store/store-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { store } from '@app/store/index.js';
import { syncInfoApps } from '@app/store/sync/info-apps-sync.js';
import { syncRegistration } from '@app/store/sync/registration-sync.js';
import { FileLoadStatus } from '@app/store/types.js';
import { setupConfigPathWatch } from '@app/store/watch/config-watch.js';

export const startStoreSync = async () => {
// The last state is stored so we don't end up in a loop of writing -> reading -> writing
Expand Down Expand Up @@ -45,6 +44,4 @@ export const startStoreSync = async () => {

lastState = state;
});

setupConfigPathWatch();
};
39 changes: 0 additions & 39 deletions api/src/store/watch/config-watch.ts

This file was deleted.

9 changes: 6 additions & 3 deletions api/src/unraid-api/cli/developer/developer.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { loadConfigFile, updateUserConfig } from '@app/store/modules/config.js';
import { writeConfigSync } from '@app/store/sync/config-disk-sync.js';
import { DeveloperQuestions } from '@app/unraid-api/cli/developer/developer.questions.js';
import { LogService } from '@app/unraid-api/cli/log.service.js';
import { RestartCommand } from '@app/unraid-api/cli/restart.command.js';
import { StartCommand } from '@app/unraid-api/cli/start.command.js';
import { StopCommand } from '@app/unraid-api/cli/stop.command.js';

interface DeveloperOptions {
disclaimer: boolean;
Expand All @@ -21,7 +22,8 @@ export class DeveloperCommand extends CommandRunner {
constructor(
private logger: LogService,
private readonly inquirerService: InquirerService,
private readonly restartCommand: RestartCommand
private readonly startCommand: StartCommand,
private readonly stopCommand: StopCommand
) {
super();
}
Expand All @@ -33,13 +35,14 @@ export class DeveloperCommand extends CommandRunner {
}
const { store } = await import('@app/store/index.js');
await store.dispatch(loadConfigFile());
await this.stopCommand.run([]);
store.dispatch(updateUserConfig({ local: { sandbox: options.sandbox ? 'yes' : 'no' } }));
writeConfigSync('flash');

this.logger.info(
'Updated Developer Configuration - restart the API in 5 seconds to apply them...'
);
await new Promise((resolve) => setTimeout(resolve, 5000));
await this.restartCommand.run([]);
await this.startCommand.run([], {});
}
}
15 changes: 7 additions & 8 deletions api/src/unraid-api/cli/sso/add-sso-user.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { writeConfigSync } from '@app/store/sync/config-disk-sync.js';
import { LogService } from '@app/unraid-api/cli/log.service.js';
import { RestartCommand } from '@app/unraid-api/cli/restart.command.js';
import { AddSSOUserQuestionSet } from '@app/unraid-api/cli/sso/add-sso-user.questions.js';
import { StartCommand } from '@app/unraid-api/cli/start.command.js';
import { StopCommand } from '@app/unraid-api/cli/stop.command.js';

interface AddSSOUserCommandOptions {
disclaimer: string;
Expand All @@ -25,7 +27,8 @@ export class AddSSOUserCommand extends CommandRunner {
constructor(
private readonly logger: LogService,
private readonly inquirerService: InquirerService,
private readonly restartCommand: RestartCommand
private readonly startCommand: StartCommand,
private readonly stopCommand: StopCommand
) {
super();
}
Expand All @@ -34,16 +37,12 @@ export class AddSSOUserCommand extends CommandRunner {
try {
options = await this.inquirerService.prompt(AddSSOUserQuestionSet.name, options);
if (options.disclaimer === 'y' && options.username) {
await this.stopCommand.run([]);
await store.dispatch(loadConfigFile());
const shouldRestart = store.getState().config.remote.ssoSubIds.length === 0;
store.dispatch(addSsoUser(options.username));
writeConfigSync('flash');
this.logger.info(`User added ${options.username}`);
if (shouldRestart) {
this.logger.info('Restarting the Unraid API in 5 seconds to enable the SSO button');
await new Promise((resolve) => setTimeout(resolve, 5000));
await this.restartCommand.run([]);
}
this.logger.info(`User added ${options.username}, starting the API`);
await this.startCommand.run([], {});
}
} catch (e: unknown) {
if (e instanceof Error) {
Expand Down
11 changes: 9 additions & 2 deletions api/src/unraid-api/cli/sso/remove-sso-user.command.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Injectable } from '@nestjs/common';

import { CommandRunner, InquirerService, Option, OptionChoiceFor, SubCommand } from 'nest-commander';
import { CommandRunner, InquirerService, Option, SubCommand } from 'nest-commander';

import { store } from '@app/store/index.js';
import { loadConfigFile, removeSsoUser } from '@app/store/modules/config.js';
import { writeConfigSync } from '@app/store/sync/config-disk-sync.js';
import { LogService } from '@app/unraid-api/cli/log.service.js';
import { RemoveSSOUserQuestionSet } from '@app/unraid-api/cli/sso/remove-sso-user.questions.js';
import { StartCommand } from '@app/unraid-api/cli/start.command.js';
import { StopCommand } from '@app/unraid-api/cli/stop.command.js';

interface RemoveSSOUserCommandOptions {
username: string;
Expand All @@ -21,20 +23,25 @@ interface RemoveSSOUserCommandOptions {
export class RemoveSSOUserCommand extends CommandRunner {
constructor(
private readonly logger: LogService,
private readonly inquirerService: InquirerService
private readonly inquirerService: InquirerService,
private readonly stopCommand: StopCommand,
private readonly startCommand: StartCommand
) {
super();
}
public async run(_input: string[], options: RemoveSSOUserCommandOptions): Promise<void> {
await store.dispatch(loadConfigFile());
options = await this.inquirerService.prompt(RemoveSSOUserQuestionSet.name, options);

await this.stopCommand.run([]);
store.dispatch(removeSsoUser(options.username === 'all' ? null : options.username));
if (options.username === 'all') {
this.logger.info('All users removed from SSO');
} else {
this.logger.info('User removed: ' + options.username);
}
writeConfigSync('flash');
await this.startCommand.run([], {});
}

@Option({
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1742838682466
1743604406580
Loading
Loading