Ticket #6589: mythtv-6589-backend_status-split_total_and_detailed_storage_info.patch

File mythtv-6589-backend_status-split_total_and_detailed_storage_info.patch, 3.9 KB (added by sphery <mtdean@…>, 3 years ago)

Splits "Disk Usage" into "Summary" and "Details" sections. Apply on top of (after) mythtv-6589-backend_status-move_total_disk_space_to_top.patch

  • programs/mythbackend/httpstatus.cpp

    old new  
    11111111    QDomElement storage = node.toElement(); 
    11121112    node = storage.firstChild(); 
    11131113 
    1114     os << "      Disk Usage:<br />\r\n"; 
     1114    // Loop once until we find id == "total".  This should be first, but a loop 
     1115    // separate from the per-filesystem details loop ensures total is first, 
     1116    // regardless. 
     1117    while (!node.isNull()) 
     1118    { 
     1119        QDomElement g = node.toElement(); 
     1120 
     1121        if (!g.isNull() && g.tagName() == "Group") 
     1122        { 
     1123            QString id   = g.attribute("id", "" ); 
     1124 
     1125            if (id == "total") 
     1126            { 
     1127                int nFree    = g.attribute("free" , "0" ).toInt(); 
     1128                int nTotal   = g.attribute("total", "0" ).toInt(); 
     1129                int nUsed    = g.attribute("used" , "0" ).toInt(); 
     1130                QString nDir = g.attribute("dir"  , "" ); 
     1131 
     1132                nDir.replace(QRegExp(","), ", "); 
     1133 
     1134                os << "      Disk Usage Summary:<br />\r\n"; 
     1135                os << "      <ul>\r\n"; 
     1136 
     1137                os << "        <li>Total Disk Space:</li>\r\n" 
     1138                << "          <ul>\r\n"; 
     1139                QLocale c(QLocale::C); 
     1140 
     1141                os << "            <li>Total Space: "; 
     1142                sRep = c.toString(nTotal) + " MB"; 
     1143                os << sRep << "</li>\r\n"; 
     1144 
     1145                os << "            <li>Space Used: "; 
     1146                sRep = c.toString(nUsed) + " MB"; 
     1147                os << sRep << "</li>\r\n"; 
     1148 
     1149                os << "            <li>Space Free: "; 
     1150                sRep = c.toString(nFree) + " MB"; 
     1151                os << sRep << "</li>\r\n"; 
     1152 
     1153                os << "          </ul>\r\n" 
     1154                << "        </li>\r\n"; 
     1155 
     1156                os << "      </ul>\r\n"; 
     1157                break; 
     1158            } 
     1159        } 
     1160 
     1161        node = node.nextSibling(); 
     1162    } 
     1163 
     1164    // Loop again to handle per-filesystem details. 
     1165    node = storage.firstChild(); 
     1166 
     1167    os << "      Disk Usage Details:<br />\r\n"; 
    11151168    os << "      <ul>\r\n"; 
    11161169 
    11171170 
     
    11301183            nDir.replace(QRegExp(","), ", "); 
    11311184 
    11321185 
    1133             if (id == "total") 
    1134             { 
    1135                 os << "        <li>Total Disk Space:</li>\r\n" 
    1136                 << "          <ul>\r\n"; 
    1137             } 
    1138             else 
     1186            if (id != "total") 
    11391187            { 
     1188 
    11401189                os << "        <li>MythTV Drive #" << id << ":" 
    11411190                << "</li>\r\n" 
    11421191                << "          <ul>\r\n"; 
     
    11471196                    os << "            <li>Directory: "; 
    11481197 
    11491198                os << nDir << "</li>\r\n"; 
    1150             } 
    11511199 
    1152             QLocale c(QLocale::C); 
     1200                QLocale c(QLocale::C); 
    11531201 
    1154             os << "            <li>Total Space: "; 
    1155             sRep = c.toString(nTotal) + " MB"; 
    1156             os << sRep << "</li>\r\n"; 
    1157  
    1158             os << "            <li>Space Used: "; 
    1159             sRep = c.toString(nUsed) + " MB"; 
    1160             os << sRep << "</li>\r\n"; 
    1161  
    1162             os << "            <li>Space Free: "; 
    1163             sRep = c.toString(nFree) + " MB"; 
    1164             os << sRep << "</li>\r\n"; 
     1202                os << "            <li>Total Space: "; 
     1203                sRep = c.toString(nTotal) + " MB"; 
     1204                os << sRep << "</li>\r\n"; 
     1205 
     1206                os << "            <li>Space Used: "; 
     1207                sRep = c.toString(nUsed) + " MB"; 
     1208                os << sRep << "</li>\r\n"; 
     1209 
     1210                os << "            <li>Space Free: "; 
     1211                sRep = c.toString(nFree) + " MB"; 
     1212                os << sRep << "</li>\r\n"; 
    11651213 
    1166             os << "          </ul>\r\n" 
    1167             << "        </li>\r\n"; 
     1214                os << "          </ul>\r\n" 
     1215                << "        </li>\r\n"; 
     1216            } 
    11681217 
    11691218        } 
    11701219