File size: 5,563 Bytes
dc06d4c
 
 
 
 
 
 
 
 
 
 
 
 
 
dbee56e
 
 
 
 
 
 
 
 
 
 
 
dc06d4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>MasterMap Cleaner</title>
  <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">

</head>
<body>
  <header>
    <h1>MasterMap Cleaner</h1>
  </header>
  <main>
    <section class="guide-panel">
      <details>
        <summary>
          <span>User Guide</span>
          <small>Open README instructions</small>
        </summary>
        <div class="guide-content readme-content">
          {{ readme_guide_html|safe }}
        </div>
      </details>
    </section>

    <section>
      <h2>Dataset to Clean</h2>
      {% if clean_filename %}
        <div class="file-pill">{{ clean_filename }}</div>
        <form action="/remove-clean" method="post">
          <button class="danger" type="submit">Remove File</button>
        </form>
      {% else %}
        <form id="cleanUploadForm" action="/prepare-clean" method="post" enctype="multipart/form-data">
          <div class="dropbox">
            <strong>Drop or select an Excel file</strong>
            <input name="file" type="file" accept=".xlsx,.xlsm" required onchange="submitUploadForm('cleanUploadForm', 'cleanUploadStatus')">
          </div>
          <div id="cleanUploadStatus" class="status"></div>
        </form>
      {% endif %}

      <label for="sheetSelect">Source Sheet</label>
      <select id="sheetSelect" {% if not clean_sheets %}disabled{% endif %}>
        {% for sheet in clean_sheets %}
          <option value="{{ sheet }}" {% if sheet == clean_selected_sheet %}selected{% endif %}>{{ sheet }}</option>
        {% endfor %}
      </select>

      <label for="outputSheet">Output Sheet</label>
      <input id="outputSheet" value="{{ output_sheet }}">

      <label for="models">Groq Models</label>
      <textarea id="models">{{ models or default_models }}</textarea>
      <button id="fetchModels" class="secondary" type="button">Fetch Available Models</button>

      <button id="runButton" type="button" {% if not clean_path %}disabled{% endif %}>Run Cleaning</button>
      <div id="runStatus" class="status">{{ message }}</div>

      <hr>

      <h2>Apply Blueprint</h2>
      <label>Workbook</label>
      <div id="applyWorkbookFile">
      {% if apply_workbook_filename %}
        <div class="file-pill">{{ apply_workbook_filename }}</div>
      {% endif %}
      </div>
      <form id="applyWorkbookForm" action="/prepare-apply-workbook" method="post" enctype="multipart/form-data" onsubmit="return false;">
        <div class="dropbox">
          <strong>Drop or select workbook</strong>
          <input id="applyWorkbookInput" name="file" type="file" accept=".xlsx,.xlsm" required>
        </div>
        <div id="applyWorkbookUploadStatus" class="status"></div>
      </form>

      <label for="applySheetSelect">Sheet To Update</label>
      <select id="applySheetSelect" {% if not apply_sheets %}disabled{% endif %}>
        {% for sheet in apply_sheets %}
          <option value="{{ sheet }}" {% if sheet == apply_selected_sheet %}selected{% endif %}>{{ sheet }}</option>
        {% endfor %}
      </select>

      <label>Blueprint</label>
      <div id="applyBlueprintFile">
      {% if apply_blueprint_filename %}
        <div class="file-pill">{{ apply_blueprint_filename }}</div>
      {% endif %}
      </div>
      <form id="applyBlueprintForm" action="/prepare-apply-blueprint" method="post" enctype="multipart/form-data" onsubmit="return false;">
        <div class="dropbox">
          <strong>Drop or select blueprint</strong>
          <input id="applyBlueprintInput" name="file" type="file" accept=".xlsx,.xlsm" required>
        </div>
        <div id="applyBlueprintUploadStatus" class="status"></div>
      </form>

      <button id="applyButton" type="button" {% if not can_apply %}disabled{% endif %}>Apply Blueprint</button>
      <div id="applyStatus" class="status error">{{ error }}</div>

      <hr>

      <h2>References</h2>
      <button id="saveReferencesButton" class="secondary" type="button" disabled>Save Manual References</button>
      <div id="referencesStatus" class="status"></div>
    </section>

    <section>
      <div class="output-block">
        <h2>Cleaning Output</h2>
        <div id="cleanProgressPanel" class="progress-panel">
          <div class="progress-heading">
            <span>Cleaning Progress</span>
            <span id="cleanProgressSummary">Waiting...</span>
          </div>
          <div id="cleanProgressList" class="progress-list"></div>
        </div>
        <div id="cleanResult" class="blueprint-result"></div>
        <details id="cleanRawLogDetails" class="raw-logs">
          <summary>Raw cleaning logs</summary>
          <div id="cleanLogs" class="log-screen"></div>
        </details>
      </div>

      <div class="output-block">
        <h2>Apply Output</h2>
        <div id="applyResult" class="blueprint-result"></div>
        <details id="applyRawLogDetails" class="raw-logs">
          <summary>Raw apply logs</summary>
          <div id="applyLogs" class="log-screen"></div>
        </details>
      </div>
    </section>
  </main>

  <script>
    window.MASTERMAP_CONFIG = {
      cleanPath: {{ clean_path|tojson }},
      applyWorkbookPath: {{ apply_workbook_path|tojson }},
      applyBlueprintPath: {{ apply_blueprint_path|tojson }},
      defaultOutputSheet: {{ default_output_sheet|tojson }}
    };
  </script>
  <script src="{{ url_for('static', filename='app.js') }}"></script>

</body>
</html>