display used time to shred drive

This commit is contained in:
2022-05-11 23:45:05 +02:00
parent 818e78796d
commit 48bbad914f
7 changed files with 53 additions and 10 deletions

View File

@ -77,6 +77,8 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
string sModelName = it->getModelName();
string sCapacity = it->sCapacityToText();
string sState = " ";
string sTime = " ";
bool bSelectedEntry = false;
@ -94,6 +96,7 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
}
stringstream stream;
time_t u32localtime;
switch (it->state)
{
@ -101,10 +104,14 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
stream << fixed << setprecision(2) << (it->getTaskPercentage());
sState = "Shredding: " + stream.str() + "%";
break;
time(&u32localtime);
sTime = this->calculateTimeDelta(it->getActionStartTimestamp(), u32localtime);
break;
case Drive::DELETE_ACTIVE:
sState = "Deleting ...";
time(&u32localtime);
sTime = this->calculateTimeDelta(it->getActionStartTimestamp(), u32localtime);
break;
case Drive::NONE:
@ -134,7 +141,7 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
break;
}
WINDOW * tmp = createEntryWindow( ((int)(u16StdscrX/3) - 2), 5, 3, (5* (u8Index) )+3, sModelFamily, sModelName, sCapacity, sState, bSelectedEntry);
WINDOW * tmp = createEntryWindow( ((int)(u16StdscrX/3) - 2), 5, 3, (5* (u8Index) )+3, sModelFamily, sModelName, sCapacity, sState, sTime, bSelectedEntry);
wrefresh(tmp);
u8Index++;
}//end loop though drives
@ -288,7 +295,7 @@ WINDOW* TUI::overwriteDetailViewWindow( int iXSize, int iYSize, int iXStart)
return newWindow;
}
WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, string sModelFamily, string sModelName, string sCapacity, string sState, bool bSelected)
WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, string sModelFamily, string sModelName, string sCapacity, string sState, string sTime, bool bSelected)
{
WINDOW *newWindow;
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
@ -313,6 +320,7 @@ WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
mvwaddstr(newWindow,3, 1, sCapacity.c_str());
mvwaddstr(newWindow,2, iXSize-sState.length()-5, sState.c_str());
mvwaddstr(newWindow,3, iXSize-sState.length()-5, sTime.c_str());
return newWindow;
}
@ -439,6 +447,21 @@ WINDOW* TUI::createFrozenWarning(int iXSize, int iYSize, int iXStart, int iYStar
return newWindow;
}
string TUI::calculateTimeDelta(time_t start, time_t end)
{
std::ostringstream out;
int hr=(int)((end - start)/3600);
int min=((int)((end - start)/60))%60;
int sec=(int)((end - start)%60);
char s[25];
sprintf(s, "%02d:%02d:%02d", hr, min, sec);
out << s;
return out.str();
}
void TUI::displaySelectedDrive(Drive drive, int stdscrX, int stdscrY)
{
struct MenuState menustate;