<commit_before>import { Component, Host, Input, OnDestroy } from '@angular/core';
import {
    FormBuilder,
    FormGroup,
    FormControl,
    Validators,
    FormGroupDirective } from '@angular/forms';

import { Observable ,  Subscription } from 'rxjs';
import { tap } from 'rxjs/operators';

import { BasePluginComponent } from '../base-plugin.component';
import { Cloud, CloudManCluster } from '../../../shared/models/cloud';
import { CloudService } from '../../../shared/services/cloud.service';

@Component({
    selector: 'clui-cloudman-config',
    templateUrl: './cloudman.component.html',
    providers: [CloudService],
    // tslint:disable-next-line:use-input-property-decorator
    inputs: ['cloud', 'initialConfig']
})

export class CloudManConfigComponent extends BasePluginComponent implements OnDestroy {

    @Input()
    set password (value: string) { this.hidePassword = true; this.clusterPasswordCtrl.setValue(value); }
    get password(): string { return this.clusterPasswordCtrl.value; }

    hidePassword = false;
    showAdvanced = false;
    showSavedClusters = false;
    savedClustersHelp = 'Select a saved cluster';
    errorMessage: string;

    // Form controls
    cmClusterForm: FormGroup;
    restartClusterCtrl = new FormControl();
    clusterPasswordCtrl = new FormControl(null, Validators.required);
    storageTypeCtrl = new FormControl('', Validators.required);
    clusterTypeCtrl = new FormControl('Galaxy');

    // Observables
    savedClustersObservable: Observable<CloudManCluster[]>;
    cloudCtrlSubscription: Subscription;
    restartCtrlSubscription: Subscription;

    get form(): FormGroup {
        return this.cmClusterForm;
    }

    get configName(): string {
        return 'config_cloudman';
    }

    constructor(fb: FormBuilder, @Host() parentContainer: FormGroupDirective,
                private _cloudService: CloudService) {
        super(fb, parentContainer);
        this.cmClusterForm = fb.group({
            'restartCluster': this.restartClusterCtrl,
            'clusterPassword': this.clusterPasswordCtrl,
            'storageType': this.storageTypeCtrl,
            'storageSize': [null],
            'clusterType': this.clusterTypeCtrl,
            'defaultBucket': [null, Validators.required],
            'masterPostStartScript': [null],
            'workerPostStartScript': [null],
            'clusterSharedString': [null],
            'extraUserData': [null]
        });
        this.cloudCtrlSubscription = this.cloudCtrl.valueChanges
                                     .subscribe(cluster => { this.showSavedClusters = false; this.restartClusterCtrl.patchValue(null); });
        this.restartCtrlSubscription = this.restartClusterCtrl.valueChanges
                                       .subscribe(cluster => { this.storageTypeCtrl.setValue('volume'); });
    }

    toggleAdvanced() {
        this.showAdvanced = !this.showAdvanced;
    }

    fetchSavedClusters() {
        this.showSavedClusters = true;
        this.savedClustersHelp = 'Retrieving saved clusters...';
        this.savedClustersObservable = this._cloudService.getSavedClusters(this.cloud.slug)
                                       .pipe(tap(clusters => { this.savedClustersHelp = 'Select a saved cluster'; },
                                                 error => { this.errorMessage = <any>error; }));
    }

    ngOnDestroy() {
        if (this.restartCtrlSubscription) {
            this.restartCtrlSubscription.unsubscribe();
        }
        if (this.cloudCtrlSubscription) {
            this.cloudCtrlSubscription.unsubscribe();
        }
    }
}
<commit_msg>Fixed incorrect default value for cloudman persistence<commit_after>import { Component, Host, Input, OnDestroy } from '@angular/core';
import {
    FormBuilder,
    FormGroup,
    FormControl,
    Validators,
    FormGroupDirective } from '@angular/forms';

import { Observable ,  Subscription } from 'rxjs';
import { tap } from 'rxjs/operators';

import { BasePluginComponent } from '../base-plugin.component';
import { Cloud, CloudManCluster } from '../../../shared/models/cloud';
import { CloudService } from '../../../shared/services/cloud.service';

@Component({
    selector: 'clui-cloudman-config',
    templateUrl: './cloudman.component.html',
    providers: [CloudService],
    // tslint:disable-next-line:use-input-property-decorator
    inputs: ['cloud', 'initialConfig']
})

export class CloudManConfigComponent extends BasePluginComponent implements OnDestroy {

    @Input()
    set password (value: string) { this.hidePassword = true; this.clusterPasswordCtrl.setValue(value); }
    get password(): string { return this.clusterPasswordCtrl.value; }

    hidePassword = false;
    showAdvanced = false;
    showSavedClusters = false;
    savedClustersHelp = 'Select a saved cluster';
    errorMessage: string;

    // Form controls
    cmClusterForm: FormGroup;
    restartClusterCtrl = new FormControl();
    clusterPasswordCtrl = new FormControl(null, Validators.required);
    storageTypeCtrl = new FormControl('transient', Validators.required);
    clusterTypeCtrl = new FormControl('Galaxy');

    // Observables
    savedClustersObservable: Observable<CloudManCluster[]>;
    cloudCtrlSubscription: Subscription;
    restartCtrlSubscription: Subscription;

    get form(): FormGroup {
        return this.cmClusterForm;
    }

    get configName(): string {
        return 'config_cloudman';
    }

    constructor(fb: FormBuilder, @Host() parentContainer: FormGroupDirective,
                private _cloudService: CloudService) {
        super(fb, parentContainer);
        this.cmClusterForm = fb.group({
            'restartCluster': this.restartClusterCtrl,
            'clusterPassword': this.clusterPasswordCtrl,
            'storageType': this.storageTypeCtrl,
            'storageSize': [null],
            'clusterType': this.clusterTypeCtrl,
            'defaultBucket': [null, Validators.required],
            'masterPostStartScript': [null],
            'workerPostStartScript': [null],
            'clusterSharedString': [null],
            'extraUserData': [null]
        });
        this.cloudCtrlSubscription = this.cloudCtrl.valueChanges
                                     .subscribe(cluster => { this.showSavedClusters = false; this.restartClusterCtrl.patchValue(null); });
        this.restartCtrlSubscription = this.restartClusterCtrl.valueChanges
                                       .subscribe(cluster => { if (cluster) { this.storageTypeCtrl.setValue('volume'); } });
    }

    toggleAdvanced() {
        this.showAdvanced = !this.showAdvanced;
    }

    fetchSavedClusters() {
        this.showSavedClusters = true;
        this.savedClustersHelp = 'Retrieving saved clusters...';
        this.savedClustersObservable = this._cloudService.getSavedClusters(this.cloud.slug)
                                       .pipe(tap(clusters => { this.savedClustersHelp = 'Select a saved cluster'; },
                                                 error => { this.errorMessage = <any>error; }));
    }

    ngOnDestroy() {
        if (this.restartCtrlSubscription) {
            this.restartCtrlSubscription.unsubscribe();
        }
        if (this.cloudCtrlSubscription) {
            this.cloudCtrlSubscription.unsubscribe();
        }
    }
}

{'fraction_non_alphanumeric': 0.11376999863257213, 'fraction_numerical': 0.0, 'mean_word_length': 2.725929699439633, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3222964', 'n_tokens_mistral': 1909, 'n_tokens_neox': 1902, 'n_words': 382}