enhanced temporary skill install logic to tell user how to install the skill with their voice.
parent
22a3f07f13
commit
ea25800f78
|
@ -47,8 +47,10 @@ class SkillSummaryView(SeleneBaseView):
|
|||
icon=skill['icon'],
|
||||
icon_image=skill.get('icon_image'),
|
||||
id=skill['id'],
|
||||
title=skill['title'],
|
||||
# TODO remove skill_name when login/install is implemented
|
||||
skill_name=skill['skill_name'],
|
||||
summary=markdown(skill['summary'], output_format='html5'),
|
||||
title=skill['title'],
|
||||
triggers=skill['triggers']
|
||||
)
|
||||
search_term_match = (
|
||||
|
|
|
@ -12,6 +12,7 @@ import { SkillsService, Skill } from "../skills.service";
|
|||
})
|
||||
export class SkillSummaryComponent implements OnInit {
|
||||
@Input() public skills: Skill[];
|
||||
private skillToInstall: Skill;
|
||||
public voiceIcon = faComment;
|
||||
|
||||
constructor(public loginSnackbar: MatSnackBar, private skillsService: SkillsService) { }
|
||||
|
@ -24,6 +25,7 @@ export class SkillSummaryComponent implements OnInit {
|
|||
* @param {Skill} skill
|
||||
*/
|
||||
install_skill(skill: Skill) : void {
|
||||
this.skillToInstall = skill;
|
||||
this.skillsService.installSkill(skill).subscribe(
|
||||
(response) => {
|
||||
this.onInstallSuccess(response)
|
||||
|
@ -53,16 +55,37 @@ export class SkillSummaryComponent implements OnInit {
|
|||
* If a user attempts to install a skill without being logged in, show a
|
||||
* snackbar to notify the user and give them the ability to log in.
|
||||
*
|
||||
* @param response
|
||||
* @param response - object representing the response from the API call
|
||||
*/
|
||||
onInstallFailure(response) : void {
|
||||
if (response.status === 401) {
|
||||
let skillNameParts = this.skillToInstall.skill_name.split('-');
|
||||
let installName = [];
|
||||
skillNameParts.forEach(
|
||||
(part) => {
|
||||
if (part.toLowerCase() != 'mycroft' && part.toLowerCase() != 'skill') {
|
||||
installName.push(part);
|
||||
}
|
||||
}
|
||||
);
|
||||
this.loginSnackbar.open(
|
||||
'To install a skill, log in to your account.',
|
||||
'LOG IN',
|
||||
'Skill installation functionality coming soon. ' +
|
||||
'In the meantime use your voice to install skills ' +
|
||||
'by saying: "Hey Mycroft, install ' + installName.join(' ') + '"',
|
||||
'',
|
||||
{panelClass: 'mycroft-snackbar', duration: 5000}
|
||||
|
||||
);
|
||||
|
||||
// This is the snackbar logic for when the login and install
|
||||
// functionality is in place
|
||||
//
|
||||
// this.loginSnackbar.open(
|
||||
// 'To install a skill, log in to your account.',
|
||||
// 'LOG IN',
|
||||
// {panelClass: 'mycroft-snackbar', duration: 5000}
|
||||
//
|
||||
// );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue