list.cpp 3.17 KB
Newer Older
Mario Bajer's avatar
Mario Bajer committed
1
2
3
4
5
/** @file list.cpp
 *  @brief Zeigt alle im Filesystem gespeicherten Matrizen an
 *
 * */

6

7
#include "Matrix.hpp"
Mario Bajer's avatar
Mario Bajer committed
8
#include "notmatrix.hpp"
9

10
11
12
13
14
15
namespace fs = filesystem;

int main(){

    htmlHeader("list.cgi");

Mario Bajer's avatar
Mario Bajer committed
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    cout << "<div class = \"container\">";
    cout << R"(<form action="/cgi-bin/multi.cgi" method="POST">)" << endl;
    cout << "<div class=\"form-row\">" << endl;
    cout << "<div class=\"form-group col-lg-2 mr-2\">" << endl;
    cout << "<label>Matrix A</label>" << endl;
    cout << R"(<input name="matrixA" class="form-control" type="number"/>)" << endl;
    cout << "</div>" << endl;
    cout << "<div class=\"form-group col-lg-2 mr-2\">" << endl;
    cout << "<label>Matrix B</label>" << endl;
    cout << R"(<input name="matrixB" class="form-control" type="number"/>)" << endl;
    cout << "</div>" << endl;
    cout << "<div class=\"form-group col-lg-2 mr-2\">" << endl;
    cout << "<label>Rechenoperation</label>" << endl;
    cout << R"(<select class="form-control" name="rechenop">)" << endl;
    cout << "<option>+</option>" << endl;
    cout << "<option>-</option>" << endl;
    cout << "<option>*</option>" << endl;
    cout << "</select>" << endl;
    cout << "</div>" << endl;
    cout << R"(<button type="submit" class="btn btn-primary my-auto">Berechnen</button>)" << endl;
    cout << "</div>" << endl;
    cout << "</form>" << endl;
    cout << "<br>" << endl;
    cout << "<table class=\"table\">" << endl;
    cout << "<thead class=\"thead-dark\">" << endl;
    cout << "<tr>" << endl;
    cout << "<th>ID</th>" << endl;
    cout << "<th>Dimension X</th>" << endl;
    cout << "<th>Dimension Y</th>" << endl;
    cout << "<th>File Location</th>" << endl;
    cout << "<th></th>" << endl;
    cout << "<th></th>" << endl;
    cout << "</tr>" << endl;
    cout << "</thead>" << endl;
    cout << "<tbody>" << endl;
51
52

    string path = "Json";
53
	
54
    for(const auto & entry : fs::directory_iterator(path)){
Mario Bajer's avatar
Mario Bajer committed
55
        vector<string> rs = parseHeader(entry.path());
56
        cout << "<tr>" << endl;
Mario Bajer's avatar
Mario Bajer committed
57
58
59
        cout << "<td>" << rs[0] << "</td>" << endl;
        cout << "<td>" << rs[1] << "</td>" << endl;
        cout << "<td>" << rs[2] << "</td>" << endl;
60
        cout << "<td>" << entry.path() << "</td>" << endl;
Mario Bajer's avatar
Mario Bajer committed
61
        cout << R"(<form action="/cgi-bin/show.cgi" method="GET">)" << endl;
62
        cout << "<td>" << endl;
Mario Bajer's avatar
Mario Bajer committed
63
        cout << R"(<button name="showBtn" class="btn btn-primary" type=submit value=)" << entry.path() << ">" << endl;
64
65
66
        cout << "Show" << endl;
        cout << "</button>" << endl;
        cout << "</form>" << endl;
Mario Bajer's avatar
Mario Bajer committed
67
        cout << R"(<form action="/cgi-bin/delete.cgi" method="GET">)" << endl;
68
        cout << "<td>" << endl;
Mario Bajer's avatar
Mario Bajer committed
69
        cout << R"(<button name="deleteBtn" class="btn btn-danger" type=submit value=)" << entry.path() << ">" << endl;
70
71
72
73
74
75
76
77
78
        cout << "Delete" << endl;
        cout << "</button>" << endl;
        cout << "</form>" << endl;
        cout << "</td>" << endl;
        cout << "</tr>" << endl;
    }

    cout << "</tbody>" << endl;
    cout << "</table>" << endl;
Mario Bajer's avatar
Mario Bajer committed
79
    cout << "</div>" << endl;
80
81
82
83
84

    cout << "<a href=\"http://localhost:80/index.html\">Back to Index</a>";
    cout << "</div>" << endl;
    cout << "</body>\n";
    cout << "</html>\n";
85
86
	
	return 0;
87
}