added ability to handle email, password and number fields in the settings meta
parent
5593f6e5c5
commit
bbdd90dee7
|
@ -29,11 +29,9 @@ export class SkillService {
|
|||
}
|
||||
|
||||
updateSkillSettings(skillId: string, skillSettings: SkillSettings[]) {
|
||||
this.http.put(
|
||||
return this.http.put(
|
||||
`/api/skills/${skillId}/settings`,
|
||||
{skillSettings: skillSettings}
|
||||
).subscribe(
|
||||
(response) => { console.log(response); }
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,5 +24,20 @@
|
|||
<input matInput type="text" value="{{fieldValue}}" (change)="onInputChange($event)">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngSwitchCase="'number'" [appearance]="'outline'">
|
||||
<mat-label>{{fieldDefinition.label}}</mat-label>
|
||||
<input matInput type="number" value="{{fieldValue}}" (change)="onInputChange($event)">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngSwitchCase="'email'" [appearance]="'outline'">
|
||||
<mat-label>{{fieldDefinition.label}}</mat-label>
|
||||
<input matInput type="email" value="{{fieldValue}}" (change)="onInputChange($event)">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngSwitchCase="'password'" [appearance]="'outline'">
|
||||
<mat-label>{{fieldDefinition.label}}</mat-label>
|
||||
<input matInput type="password" value="{{fieldValue}}" (change)="onInputChange($event)">
|
||||
</mat-form-field>
|
||||
|
||||
<button *ngSwitchCase="'oauth'" mat-button>Connect</button>
|
||||
</ng-container>
|
||||
|
|
|
@ -11,7 +11,7 @@ import { SettingChange } from '@account/models/setting-change.model';
|
|||
})
|
||||
export class SettingFieldComponent implements OnInit {
|
||||
@Input() fieldDefinition: SettingField;
|
||||
@Input() settingsValues: object;
|
||||
@Input() settingsValues: any;
|
||||
@Output() newValue = new EventEmitter<SettingChange>();
|
||||
public fieldValue: string;
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@ import { SettingChange } from '@account/models/setting-change.model';
|
|||
import { Skill } from '@account/models/skill.model';
|
||||
import { SkillSettings } from '@account/models/skill-settings.model';
|
||||
import { SkillService } from '@account/http/skill.service';
|
||||
import { MatSnackBar, MatSnackBarConfig } from '@angular/material';
|
||||
|
||||
const fiveSeconds = 5000;
|
||||
|
||||
@Component({
|
||||
selector: 'account-skill-settings',
|
||||
|
@ -15,12 +18,16 @@ import { SkillService } from '@account/http/skill.service';
|
|||
export class SkillSettingsComponent implements OnInit {
|
||||
public disableSave = true;
|
||||
@Input() deviceCount: number;
|
||||
private snackbarConfig = new MatSnackBarConfig();
|
||||
@Input() skill: Skill;
|
||||
public skillSettings$: Observable<SkillSettings[]>;
|
||||
public skillSettings: SkillSettings[];
|
||||
@Output() done = new EventEmitter();
|
||||
|
||||
constructor(private skillService: SkillService) { }
|
||||
constructor(private snackbar: MatSnackBar, private skillService: SkillService) {
|
||||
this.snackbarConfig.panelClass = 'mycroft-no-action-snackbar';
|
||||
this.snackbarConfig.duration = fiveSeconds;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.skillSettings$ = this.skillService.getSkillSettings(this.skill.id).pipe(
|
||||
|
@ -41,7 +48,22 @@ export class SkillSettingsComponent implements OnInit {
|
|||
}
|
||||
|
||||
saveSettings(): void {
|
||||
this.skillService.updateSkillSettings(this.skill.id, this.skillSettings);
|
||||
this.skillService.updateSkillSettings(this.skill.id, this.skillSettings).subscribe(
|
||||
() => {
|
||||
this.snackbar.open(
|
||||
'Changes to ' + this.skill.name + 'settings saved',
|
||||
null,
|
||||
this.snackbarConfig
|
||||
);
|
||||
},
|
||||
() => {
|
||||
this.snackbar.open(
|
||||
'Error saving changes to ' + this.skill.name + ' settings',
|
||||
null,
|
||||
this.snackbarConfig
|
||||
);
|
||||
}
|
||||
);
|
||||
this.done.emit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue