-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
189 lines (153 loc) · 7.17 KB
/
index.html
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Kudu Log File Listing Util</title>
</head>
<body>
<div>
<label for="jsonFileListingInput">JSON File Listing</label><br/>
<textarea cols="125" rows="10" id="jsonFileListingInput"></textarea>
</div>
<div>
<input type="checkbox" id="autoUpdateFiltersInput" checked/>
<label for="autoUpdateFiltersInput">Automatically update filters</label>
</div>
<div>
<label for="fileNameFilterInput">File Name Filter (regex)</label><br/>
<input type="text" id="fileNameFilterInput"/>
</div>
<div>
<button id="loadDummySampleDataBtn">Load Dummy / Sample Data</button>
<button id="applyFiltersBtn">Apply Filters</button>
</div>
<div id="outputContainer">
</div>
<script type="application/javascript">
/**
* Dummy data to demonstrate typical input.
* - Where your resource is accessible via: https://<RESOURCE-NAME>.azurewebsites.net/
* - Kudu domain will usually be in format: https://<RESOURCE-NAME>.scm.azurewebsites.net/
*/
const exampleDomain = 'https://example.com/';
// Note that in this example, the filename contains a guid of the application
// Note that `/api/vfs/` represent the root of your home directory
const sampleInputJson =
[
{
"name": "error-log.08c44e2b9c03e617eee297e95f72682218f55a65f6125e7da034005b0b1a16a9.2022-01-01.log",
"size": 23282,
"mtime": "2022-01-01T09:46:57.8137282+00:00",
"crtime": "2022-01-01T07:18:49.9091334+00:00",
"mime": "application/octet-stream",
"href": exampleDomain + "/api/vfs/LogFiles/Application/error-log.08c44e2b9c03e617eee297e95f72682218f55a65f6125e7da034005b0b1a16a9.2022-01-01.log",
"path": "D:\\home\\LogFiles\\Application\\error-log.08c44e2b9c03e617eee297e95f72682218f55a65f6125e7da034005b0b1a16a9.2022-01-01.log"
},
{
"name": "info-log.08c44e2b9c03e617eee297e95f72682218f55a65f6125e7da034005b0b1a16a9.2022-01-01.log",
"size": 23282,
"mtime": "2022-01-01T09:46:57.8137282+00:00",
"crtime": "2022-01-01T07:18:49.9091334+00:00",
"mime": "application/octet-stream",
"href": exampleDomain + "/api/vfs/LogFiles/Application/error-log.08c44e2b9c03e617eee297e95f72682218f55a65f6125e7da034005b0b1a16a9.2022-01-01.log",
"path": "D:\\home\\LogFiles\\Application\\error-log.08c44e2b9c03e617eee297e95f72682218f55a65f6125e7da034005b0b1a16a9.2022-01-01.log"
},
{
"name": "error-log.08c44e2b9c03e617eee297e95f72682218f55a65f6125e7da034005b0b1a16a9.2022-02-01.log",
"size": 23282,
"mtime": "2022-02-01T09:46:57.8137282+00:00",
"crtime": "2022-02-01T07:18:49.9091334+00:00",
"mime": "application/octet-stream",
"href": exampleDomain + "/api/vfs/LogFiles/Application/error-log.08c44e2b9c03e617eee297e95f72682218f55a65f6125e7da034005b0b1a16a9.2022-02-01.log",
"path": "D:\\home\\LogFiles\\Application\\error-log.08c44e2b9c03e617eee297e95f72682218f55a65f6125e7da034005b0b1a16a9.2022-02-01.log"
},
{
"name": "info-log.08c44e2b9c03e617eee297e95f72682218f55a65f6125e7da034005b0b1a16a9.2022-02-01.log",
"size": 23282,
"mtime": "2022-02-01T09:46:57.8137282+00:00",
"crtime": "2022-02-01T07:18:49.9091334+00:00",
"mime": "application/octet-stream",
"href": exampleDomain + "/api/vfs/LogFiles/Application/error-log.08c44e2b9c03e617eee297e95f72682218f55a65f6125e7da034005b0b1a16a9.2022-02-01.log",
"path": "D:\\home\\LogFiles\\Application\\error-log.08c44e2b9c03e617eee297e95f72682218f55a65f6125e7da034005b0b1a16a9.2022-02-01.log"
}
];
const sampleJsonInputString = JSON.stringify(sampleInputJson, null, 2);
//
const sampleFilterString = 'error.*2022-02-\\d{2}'; // Show results only for error logs in January 2022 within the file name
//
function loadDummySampleData() {
console.info('overwriting inputs with dummy/sample data', sampleJsonInputString, sampleFilterString);
jsonFileListingInputElem.value = sampleJsonInputString;
fileNameFilterElem.value = sampleFilterString;
inputChangeHandler();
}
//
const loadDummySampleDataBtn = document.getElementById('loadDummySampleDataBtn');
loadDummySampleDataBtn.addEventListener('click', loadDummySampleData);
</script>
<script type="application/javascript">
//
const jsonFileListingInputElem = document.getElementById('jsonFileListingInput');
const fileNameFilterElem = document.getElementById('fileNameFilterInput');
const autoUpdateFiltersInputElem = document.getElementById('autoUpdateFiltersInput');
const outputContainerElem = document.getElementById('outputContainer');
const applyFiltersBtnElem = document.getElementById('applyFiltersBtn');
//
jsonFileListingInputElem.addEventListener('change', inputChangeHandler);
fileNameFilterElem.addEventListener('keyup', inputChangeHandler);
fileNameFilterElem.addEventListener('change', inputChangeHandler);
applyFiltersBtnElem.addEventListener('click', applyFilters);
// Default to today's date
const defaultDate = new Date();
const defaultDateString = defaultDate.toISOString().split('T')[0];
fileNameFilterElem.value = defaultDateString;
function isAutoUpdateFilters() {
return autoUpdateFiltersInputElem.checked
}
//
function inputChangeHandler() {
if (isAutoUpdateFilters()) {
applyFilters();
}
}
//
function applyFilters() {
const jsonTextInput = jsonFileListingInputElem.value;
const fileNameFilter = fileNameFilterElem.value;
if (jsonTextInput !== '' && fileNameFilter !== '') {
const json = JSON.parse(jsonTextInput);
console.info('jsonFileListingInputElem', jsonFileListingInputElem);
console.info('json', json);
console.info('fileNameFilter', fileNameFilter);
updateOutput(json, fileNameFilter);
} else {
console.info('not all input present');
}
}
//
function updateOutput(json, fileNameFilter) {
const fileNameFilterRegex = new RegExp(fileNameFilter);
const filteredLogEntries = json.filter(e => {
let isMatch = fileNameFilterRegex.test(e.name);
console.info(e.name, fileNameFilter, isMatch);
return isMatch;
});
console.info('filteredLogEntries', filteredLogEntries);
let outputHtmlString = '';
outputHtmlString += '<ul style="font-family: monospace;">';
filteredLogEntries.forEach(logEntry => {
outputHtmlString += '' +
'<li>' +
'<a href="' + logEntry.href + '">' +
logEntry.name +
'</a>' +
'</li>';
});
outputHtmlString += '</ul>';
outputContainerElem.innerHTML = outputHtmlString;
}
//
inputChangeHandler();
</script>
</body>
</html>