Order items manually

This commit is contained in:
Jake Howard 2016-10-04 14:01:59 +01:00
parent dc7f19fa37
commit 6caac1019d
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -27,13 +27,26 @@ const styles = StyleSheet.create({
} as React.ViewStyle
});
const ITEM_ORDER = [
'score',
'calc_time',
'guesses',
'crack_times_display',
'online_throttling_100_per_hour',
'online_no_throttling_10_per_second',
'offline_slow_hashing_1e4_per_second',
'offline_fast_hashing_1e10_per_second',
'feedback',
'sequence'
];
interface Props {
value: string;
}
interface State {}
export default class Result extends React.Component<Props, State> {
export default class Results extends React.Component<Props, State> {
dataSource: any;
constructor() {
@ -42,18 +55,30 @@ export default class Result extends React.Component<Props, State> {
}
parseData(results: any) {
const newResults = _.clone(results);
let newResults = _.clone(results);
const hashTimes = Object.keys(newResults.crack_times_display).map(function (key) {
const value = newResults.crack_times_display[key];
return {key, value};
});
const guesses = [{
key: 'guesses',
value: newResults.guesses * Math.pow(10, newResults.guesses_log10)
}];
delete newResults.crack_times_display;
delete newResults.crack_times_seconds;
delete newResults.guesses_log10;
delete newResults.password;
delete newResults.guesses;
const out = Object.keys(newResults).map(function (key) {
const value = newResults[key];
return {key, value};
});
return _.union(out, hashTimes);
const allResults = _.union(out, hashTimes, guesses);
let orderedResults : any[] = [];
allResults.forEach(function (result) {
orderedResults[ITEM_ORDER.indexOf(result.key)] = result;
});
return orderedResults;
}
renderRow(rowData: any, sectionId: string, rowId: string) {