-
-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): Manage voice packs (#1108)
- Loading branch information
Showing
12 changed files
with
345 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
backend/lib/robots/mock/capabilities/MockVoicePackManagementCapability.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const ValetudoVoicePackOperationStatus = require("../../../entities/core/ValetudoVoicePackOperationStatus"); | ||
const VoicePackManagementCapability = require("../../../core/capabilities/VoicePackManagementCapability"); | ||
|
||
/** | ||
* @extends VoicePackManagementCapability<import("../MockRobot")> | ||
*/ | ||
class MockVoicePackManagementCapability extends VoicePackManagementCapability { | ||
/** | ||
* @param {object} options | ||
* @param {import("../MockRobot")} options.robot | ||
*/ | ||
constructor(options) { | ||
super(options); | ||
|
||
this.current_language = "EN"; | ||
this.status = ValetudoVoicePackOperationStatus.TYPE.IDLE; | ||
this.progress = undefined; | ||
} | ||
|
||
async getCurrentVoiceLanguage() { | ||
return this.current_language; | ||
} | ||
|
||
async downloadVoicePack(options) { | ||
this.status = ValetudoVoicePackOperationStatus.TYPE.DOWNLOADING; | ||
this.progress = 0; | ||
|
||
// Simulate download | ||
for (let i = 0; i < 5; i++) { | ||
setTimeout(() => { | ||
this.progress += 20; | ||
}, i * 1000); | ||
} | ||
|
||
setTimeout(() => { | ||
this.status = ValetudoVoicePackOperationStatus.TYPE.INSTALLING; | ||
this.progress = 0; | ||
}, 6000); | ||
|
||
// Simulate installing | ||
for (let i = 0; i < 5; i++) { | ||
setTimeout(() => { | ||
this.progress += 20; | ||
}, 7000 + i * 1000); | ||
} | ||
|
||
setTimeout(() => { | ||
this.status = ValetudoVoicePackOperationStatus.TYPE.IDLE; | ||
this.current_language = options.language; | ||
}, 13000); | ||
} | ||
|
||
async getVoicePackOperationStatus() { | ||
let statusOptions = { | ||
type: this.status, | ||
progress: this.progress, | ||
}; | ||
|
||
return new ValetudoVoicePackOperationStatus(statusOptions); | ||
} | ||
} | ||
|
||
module.exports = MockVoicePackManagementCapability; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from "react"; | ||
import {Card, CardContent, Divider, Grid, Stack, Typography} from "@material-ui/core"; | ||
import LoadingFade from "../../components/LoadingFade"; | ||
|
||
const CapabilityItem: React.FunctionComponent<{ children: React.ReactNode, title: string, loading?: boolean }> = ({ | ||
children, | ||
title, | ||
loading = false | ||
}): JSX.Element => { | ||
return ( | ||
<Grid item xs={12} sm={6} md={4}> | ||
<Card> | ||
<CardContent> | ||
<Stack direction="row" spacing={2} alignItems="center"> | ||
<Typography variant="h6" gutterBottom> | ||
{title} | ||
</Typography> | ||
<LoadingFade in={loading} size={20}/> | ||
</Stack> | ||
<Divider sx={{mb: 1}}/> | ||
{children} | ||
</CardContent> | ||
</Card> | ||
</Grid> | ||
); | ||
}; | ||
|
||
export default CapabilityItem; |
Oops, something went wrong.