Skip to content

Commit

Permalink
#179: moved the delete btn from table to table header
Browse files Browse the repository at this point in the history
  • Loading branch information
yaxue1123 committed May 1, 2023
1 parent f027cd2 commit e05e19d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
7 changes: 6 additions & 1 deletion src/components/Experiment/Slices.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ class Slices extends React.Component {
</div>
<div className="my-2 d-flex flex-row justify-content-between">
<span>Showing {totalCount} slices.</span>
<button
className="btn btn-sm btn-outline-danger"
onClick={this.handleDeleteAllSlices}
>
Delete All
</button>
<Checkbox
label={"Include Dead/ Closing Slices"}
id={"checkbox-include-dead-slices"}
Expand All @@ -273,7 +279,6 @@ class Slices extends React.Component {
sortColumn={sortColumn}
onSort={this.handleSort}
parent={this.props.parent}
onDeleteAllSlices={this.handleDeleteAllSlices}
/>
<Pagination
itemsCount={totalCount}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Resource/SiteDetailPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const SiteDetailPage = props => {
<td>
{
data.status["deadline"] ?
utcToLocalTimeParser(data.status["deadline"]) : "Unknown"
(data.status["deadline"]) : "Unknown"
}
</td>
</tr>
Expand Down
6 changes: 0 additions & 6 deletions src/components/Slice/SlicesTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ class SlicesTable extends Component {
)
},
{
label: () => <button
className="btn btn-danger"
onClick={() => this.props.onDeleteAllSlices}
>
Delete All
</button>,
content: (slice) => (
<CopyButton
id={slice.slice_id}
Expand Down
24 changes: 17 additions & 7 deletions src/pages/SliceViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import CountdownTimer from "../components/common/CountdownTimer";
import Calendar from "../components/common/Calendar";
import { Link } from "react-router-dom";
import { autoCreateTokens } from "../utils/manageTokens";
import utcToLocalTimeParser from "../utils/utcToLocalTimeParser.js";
import { getSliceById, deleteSlice, extendSlice } from "../services/sliceService.js";
import sliceParser from "../services/parser/sliceParser.js";
import sliceErrorParser from "../services/parser/sliceErrorParser.js";
import utcToLocalTimeParser from "../utils/utcToLocalTimeParser.js";
import { toast } from "react-toastify";
import { default as portalData } from "../services/portalData.json";
import { saveAs } from "file-saver";
Expand Down Expand Up @@ -109,6 +109,14 @@ class SliceViewer extends Component {
});
}
}

calendarTimeParser = (apiTime) => {
console.log("---API time----");
console.log(apiTime);
console.log("---parsed calendar time----");
console.log(utcToLocalTimeParser(apiTime));
return utcToLocalTimeParser(apiTime);
}

render() {
const stateColors = {
Expand Down Expand Up @@ -158,12 +166,14 @@ class SliceViewer extends Component {
<h4>
<span className="badge badge-light font-weight-normal p-2 mt-1 mr-3">Lease End:
</span>
<Calendar
id="sliceViewerCalendar"
name="sliceViewerCalendar"
currentTime={utcToLocalTimeParser(leaseEndTime)}
onTimeChange={this.handleTimeChange}
/>
{
leaseEndTime !== "" && <Calendar
id="sliceViewerCalendar"
name="sliceViewerCalendar"
currentTime={this.calendarTimeParser(leaseEndTime)}
onTimeChange={this.handleTimeChange}
/>
}
<button
className="btn btn-sm btn-outline-primary m1-3 mr-3"
onClick={this.handleExtendSlice}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/utcToLocalTimeParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function utcToLocalTimeParser(UTCtime) {
// input format: %Y-%m-%d %H:%M:%S %z (offset %z is +0000)
const utcDateTime = UTCtime.substring(0, 19);
const stillUtc = moment.utc(utcDateTime).toDate();
const localTime = moment(stillUtc).local().format('YYYY-MM-DD HH:mm:ss');
const localTime = moment(stillUtc).local().format('yyyy-MM-dd HH:mm:ss');

return localTime;
}

0 comments on commit e05e19d

Please sign in to comment.