Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleSubmit() {
const { submitState, setSubmitState, update, id } = this.props;
if(submitState == SUBMITSTATES.SUBMITTING) {
return;
}
setSubmitState(SUBMITSTATES.SUBMITTING);
const backupConfig = object.clone(this.props.backupConfig);
for(const key in backupConfig) {
if(input.isEmpty(backupConfig[key])) {
delete backupConfig[key];
continue;
}
if(key == "duration" || key == "interval") {
backupConfig[key] = time.convertToMilliseconds(backupConfig[key]);
}
}
if(!update) {
//create a new backup
backups.newBackupConfig(backupConfig)
.then(response => {
this.submitErr = response.data.message;
// redirect to the main page
render() {
const props = this.props;
const logs = props.logs;
const { sort, start, limit } = this.state;
const total = logs.length;
let showedLogs = object.clone(logs.slice(start, start + limit));
let sortedLogs = object.sortArrByKey(showedLogs, sort.key, sort.order);
sortedLogs.forEach(log => {
return time.convertTimeToLocaleString(['time'], log);
})
return (
<div>
<div>
{
this.headers.map((h, index) => {
return (
<div style="{"> this.setSortKey(h.key) }</div></div></div>
toggleSingleId(id) {
let selectedIds = object.clone(this.state.selectedIds);
if(!selectedIds.includes(id)) {
selectedIds.push(id);
}else {
selectedIds = selectedIds.filter(selectedId => selectedId != id);
}
this.setState({
selectedIds
});
}
authenticated(backupConfig, dbsColls) {
this.dbsColls = dbsColls;
const prevState = object.clone(this.state);
prevState.backupConfig = backupConfig;
prevState.backupConfig.db = this.dbsColls[0].db;
prevState.collections = undefined;
prevState.step += 1;
prevState.authState = AUTHSTATES.AUTHENTICATED;
this.setState(prevState);
}
createNewConnection(connection) {
connection = object.clone(connection);
const id = connection.username? `${ connection.username }@${ connection.server}`: `${ connection.server }`;
connection.id = id;
if(this.connections == null) {
this.connections = [];
}
const filteredConnections = object.filterArrWithKeyValue("id", id, this.connections);
if(filteredConnections.length > 0) {
object.updateArrWithKeyValue('id', id, this.connections, connection);
}else {
this.connections.push(connection);
}
localStore.setItem('connections', this.connections);
};
handleConfigChange(changes) {
const backupConfig = object.clone(this.state.backupConfig);
for(let key in changes) {
backupConfig[key] = changes[key];
}
this.setState({ backupConfig });
}