Skip to content

Commit

Permalink
feat(Settings): Added Process Empty Associations setting (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndickerson authored Jul 11, 2018
1 parent 3944209 commit 341a74f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/app/components/settings-modal/settings-modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export class SettingsModalComponent implements OnInit {

constructor(private fileService: FileService, private formUtils: FormUtils, private modalRef: NovoModalRef) {}

private static removeExistFields(value: ISettings): ISettings {
private static removeExtraFields(value: ISettings): ISettings {
let result: any = Object.assign({}, value);
delete result.existFields;
delete result.version;
return result;
}

Expand Down Expand Up @@ -71,7 +72,7 @@ export class SettingsModalComponent implements OnInit {
}

load(): void {
this.form.setValue(SettingsModalComponent.removeExistFields(this.fileService.readSettings()));
this.form.setValue(SettingsModalComponent.removeExtraFields(this.fileService.readSettings()));
}

close(): void {
Expand Down Expand Up @@ -189,6 +190,17 @@ export class SettingsModalComponent implements OnInit {
description: 'Default value is MM/dd/yy HH:mm. ' +
'Documentation: http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html',
sortOrder: 32,
}, {
name: 'processEmptyAssociations',
type: 'tiles',
label: 'Process Empty Associations',
required: true,
description: 'If set to true then all To-Many association cells that are empty will remove any existing associations. ' +
'Default value is false, which will ignore the empty cells.',
options: [
{ label: 'Yes', value: true },
{ label: 'No', value: false }],
sortOrder: 33,
}, {
name: 'numThreads',
type: 'number',
Expand Down
1 change: 1 addition & 0 deletions src/app/providers/file/file.service.fakes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class FileServiceFakes {
loginUrl: '',
listDelimiter: ';',
dateFormat: 'MM/dd/yyyy',
processEmptyAssociations: false,
numThreads: 15,
existFields: [{
entity: 'Candidate',
Expand Down
8 changes: 7 additions & 1 deletion src/app/providers/file/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ISettings } from '../../../interfaces/ISettings';
@Injectable()
export class FileService {
// The version of the settings file to use for backwards compatibility breaking changes
static SETTINGS_FILE_VERSION: number = 1;
static SETTINGS_FILE_VERSION: number = 2;

private defaultConfig: IConfig = {
onboarded: false,
Expand All @@ -31,6 +31,7 @@ export class FileService {
clientSecret: '',
dataCenter: 'bhnext',
listDelimiter: ';',
processEmptyAssociations: false,
dateFormat: 'MM/dd/yy HH:mm',
authorizeUrl: 'https://auth9.bullhornstaffing.com/oauth/authorize',
tokenUrl: 'https://auth9.bullhornstaffing.com/oauth/token',
Expand Down Expand Up @@ -91,10 +92,15 @@ export class FileService {
if (this.electronService.fs.existsSync(this.settingsFile)) {
try {
let settings: ISettings = JSON.parse(this.electronService.fs.readFileSync(this.settingsFile, 'utf8'));
// Decrypt passwords for versions 1+
if (settings.version && settings.version >= 1) {
settings.password = EncryptUtils.decrypt(settings.password);
settings.clientSecret = EncryptUtils.decrypt(settings.clientSecret);
}
// Default processEmptyAssociations before version 2
if (!settings.version || settings.version < 2) {
settings.processEmptyAssociations = false;
}
return settings;
} catch (parseErr) {
this.modalService.open(ErrorModalComponent, {
Expand Down
1 change: 1 addition & 0 deletions src/app/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class Utils {
args = args.concat(['tokenUrl', settings.tokenUrl]);
args = args.concat(['listDelimiter', settings.listDelimiter]);
args = args.concat(['dateFormat', settings.dateFormat]);
args = args.concat(['processEmptyAssociations', settings.processEmptyAssociations ? 'true' : 'false']);
args = args.concat(['numThreads', settings.numThreads.toString()]);
args = args.concat(['resultsFileEnabled', 'true']);
args = args.concat(['resultsFilePath', resultsFilePath]);
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/ISettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export interface ISettings {
existFields?: IExistField[];
listDelimiter: string;
dateFormat: string;
processEmptyAssociations: boolean;
numThreads: number;
}

0 comments on commit 341a74f

Please sign in to comment.