Skip to content

Commit d4b6fb1

Browse files
authored
menu drawer (#429)
1 parent f469a87 commit d4b6fb1

File tree

21 files changed

+502
-477
lines changed

21 files changed

+502
-477
lines changed

web/api/webrpc/sector.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package webrpc
22

33
import (
44
"context"
5-
"fmt"
65
"strconv"
76
"strings"
87
"time"
@@ -194,8 +193,6 @@ func (a *WebRPC) SectorInfo(ctx context.Context, sp string, intid int64) (*Secto
194193
return nil, xerrors.Errorf("invalid sp")
195194
}
196195

197-
fmt.Println("SPID", spid)
198-
199196
si := &SectorInfo{
200197
SpID: spid,
201198
Miner: maddr.String(),
@@ -226,10 +223,6 @@ func (a *WebRPC) SectorInfo(ctx context.Context, sp string, intid int64) (*Secto
226223
return nil, xerrors.Errorf("failed to fetch pipeline task info: %w", err)
227224
}
228225

229-
if len(tasks) == 0 {
230-
fmt.Println("NO PIPELINE")
231-
}
232-
233226
// Fetch SnapDeals pipeline data
234227
var snapTasks []SnapPipelineTask
235228

@@ -265,7 +258,6 @@ func (a *WebRPC) SectorInfo(ctx context.Context, sp string, intid int64) (*Secto
265258

266259
var sle *sectorListEntry
267260
if len(tasks) > 0 {
268-
fmt.Println("FOUND THE PIPELINE")
269261
task := tasks[0]
270262
if task.PreCommitMsgCid != nil {
271263
si.PreCommitMsg = *task.PreCommitMsgCid

web/static/config/edit.html

Lines changed: 147 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<title>JSON Schema Editor</title>
55
<script type="module" src="/ux/curio-ux.mjs"></script>
6+
<script type="module" src="/ux/components/Drawer.mjs"></script>
67
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js"></script>
78
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
89
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
@@ -13,167 +14,163 @@
1314
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
1415
</head>
1516
<body style="visibility: hidden;">
16-
<style>
17-
#saveButton {
18-
display: block;
19-
position: fixed;
20-
bottom: 20px;
21-
right: 30px;
22-
z-index: 99;
23-
font-size: 18px;
24-
border: none;
25-
outline: none;
26-
background-color: green;
27-
color: white;
28-
cursor: pointer;
29-
padding: 15px;
30-
border-radius: 4px;
31-
}
17+
<style>
18+
#saveButton {
19+
display: block;
20+
position: fixed;
21+
bottom: 20px;
22+
right: 30px;
23+
z-index: 99;
24+
font-size: 18px;
25+
border: none;
26+
outline: none;
27+
background-color: green;
28+
color: white;
29+
cursor: pointer;
30+
padding: 15px;
31+
border-radius: 4px;
32+
}
3233

33-
#saveButton:hover {
34-
background-color: #555;
35-
}
34+
#saveButton:hover {
35+
background-color: #555;
36+
}
3637

37-
.help-button button {
38-
font-size: 24px;
39-
border-radius: 50%;
40-
width: 50px;
41-
height: 50px;
42-
position: fixed;
43-
bottom: 20px;
44-
right: 120px;
45-
z-index: 99;
46-
}
38+
.help-button button {
39+
font-size: 24px;
40+
border-radius: 50%;
41+
width: 50px;
42+
height: 50px;
43+
position: fixed;
44+
bottom: 20px;
45+
right: 120px;
46+
z-index: 99;
47+
}
4748

48-
.help-text {
49-
display: none;
50-
position: fixed;
51-
border: 1px solid #ccc;
52-
background-color: gray;
53-
padding: 10px;
54-
width: 200px;
55-
bottom: 20px;
56-
right: 200px;
57-
z-index: 100;
58-
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
59-
}
49+
.help-text {
50+
display: none;
51+
position: fixed;
52+
border: 1px solid #ccc;
53+
background-color: gray;
54+
padding: 10px;
55+
width: 200px;
56+
bottom: 20px;
57+
right: 200px;
58+
z-index: 100;
59+
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
60+
}
6061

61-
.hidden {
62-
display: none;
63-
}
62+
.hidden {
63+
display: none;
64+
}
6465

65-
.show {
66-
display: block;
67-
}
66+
.show {
67+
display: block;
68+
}
6869

69-
/* Fix for dark mode */
70-
.card.bg-light {
71-
background-color: rgb(11, 22, 34) !important;
72-
}
73-
input.form-control {
74-
background: #111;
75-
color: white;
76-
font-weight: bold;
77-
}
78-
</style>
79-
<curio-ux>
80-
<section class="section container-fluid implementations">
81-
<div class="row justify-content-center content">
82-
<div class="col-md-8">
83-
<div>
84-
<button id="saveButton" class="saveButton">Save</button>
85-
</div>
86-
87-
<div class="help-button">
88-
<button id="helpBtn">?</button>
89-
<p id="helpText" class="hidden help-text">Checking a box and entering a non default value will uncomment the corresponding configuration variable.
90-
Unchecking a box will reset the value to default.</p>
91-
</div>
70+
/* Fix for dark mode */
71+
.card.bg-light {
72+
background-color: rgb(11, 22, 34) !important;
73+
}
74+
input.form-control {
75+
background: #111;
76+
color: white;
77+
font-weight: bold;
78+
}
79+
</style>
80+
<curio-ux>
81+
<section class="section container-fluid implementations">
82+
<div class="row justify-content-center content">
83+
<div class="col-md-8">
84+
<div>
85+
<button id="saveButton" class="saveButton">Save</button>
86+
</div>
9287

93-
<div id="editor" data-bs-theme="dark"></div>
94-
<script>
95-
var editor;
96-
var urlParams = new URLSearchParams(window.location.search);
97-
var layer = urlParams.get('layer');
98-
// Make simultaneous GET requests to fetch the existing data and JSON Schema
99-
const layerPath = layer === 'default' ? 'config/default' : `config/layers/${layer}`;
100-
Promise.all([
101-
axios.get(`/api/${layerPath}`),
102-
axios.get('/api/config/schema')
103-
])
104-
.then(responses => {
105-
const existingData = responses[0].data;
106-
const schema = responses[1].data;
88+
<div class="help-button">
89+
<button id="helpBtn">?</button>
90+
<p id="helpText" class="hidden help-text">Checking a box and entering a non default value will uncomment the corresponding configuration variable.
91+
Unchecking a box will reset the value to default.</p>
92+
</div>
10793

108-
// Create a JSON Editor instance and pass the schema and existing data
109-
const container = document.getElementById('editor');
110-
const options = {
111-
//mode: 'tree',
112-
schema: schema,
113-
startval: existingData,
114-
theme: 'bootstrap5',
115-
iconlib: 'jqueryui',
116-
show_opt_in: true,
117-
disable_edit_json: true,
118-
form_name_root: "Configuration",
119-
disable_properties: true,
120-
};
94+
<div id="editor" data-bs-theme="dark"></div>
95+
<script>
96+
var editor;
97+
var urlParams = new URLSearchParams(window.location.search);
98+
var layer = urlParams.get('layer');
99+
// Make simultaneous GET requests to fetch the existing data and JSON Schema
100+
const layerPath = layer === 'default' ? 'config/default' : `config/layers/${layer}`;
101+
Promise.all([
102+
axios.get(`/api/${layerPath}`),
103+
axios.get('/api/config/schema')
104+
])
105+
.then(responses => {
106+
const existingData = responses[0].data;
107+
const schema = responses[1].data;
121108

122-
editor = new JSONEditor(container, options);
109+
// Create a JSON Editor instance and pass the schema and existing data
110+
const container = document.getElementById('editor');
111+
const options = {
112+
mode: 'tree',
113+
schema: schema,
114+
startval: existingData,
115+
theme: 'bootstrap5',
116+
iconlib: 'jqueryui',
117+
show_opt_in: true,
118+
disable_edit_json: true,
119+
form_name_root: "Configuration",
120+
disable_properties: true,
121+
};
123122

124-
document.getElementById("helpBtn").addEventListener("click", function() {
125-
var helpText = document.getElementById("helpText");
126-
if (helpText.classList.contains("hidden")) {
127-
helpText.classList.remove("hidden");
128-
helpText.classList.add("show");
129-
} else {
130-
helpText.classList.remove("show");
131-
helpText.classList.add("hidden");
132-
}
133-
});
123+
editor = new JSONEditor(container, options);
134124

135-
// Attach function to saveButton click event
136-
var saveButton = document.getElementById('saveButton');
137-
saveButton.addEventListener('click', function() {
138-
if (layer === 'default'){
139-
alert('Error: cannot edit defaults');
140-
} else {
141-
const value = editor.getValue();
142-
function cleanEmptyArrays(json) {
143-
if (Array.isArray(json)) {
144-
return json.filter(item => item !== ""); // Remove empty strings from arrays
145-
} else if (typeof json === "object" && json !== null) {
146-
Object.keys(json).forEach(key => {
147-
json[key] = cleanEmptyArrays(json[key]); // Recursively clean nested structures
148-
});
125+
document.getElementById("helpBtn").addEventListener("click", function() {
126+
var helpText = document.getElementById("helpText");
127+
if (helpText.classList.contains("hidden")) {
128+
helpText.classList.remove("hidden");
129+
helpText.classList.add("show");
130+
} else {
131+
helpText.classList.remove("show");
132+
helpText.classList.add("hidden");
149133
}
150-
return json;
151-
}
152-
cleanEmptyArrays(value);
153-
console.log(value)
154-
axios.post('/api/config/layers/' + layer, value)
155-
.then(response => {
156-
// Set cookie named 'message' with the value 'Data saved successfully'
157-
document.cookie = 'message=The layer "' + layer + '" saved successfully. Please restart all nodes using the layer "' + layer + '".; path=/;';
158-
window.location.href = '/pages/config/list/';
159-
})
160-
.catch(error => {
161-
console.error('Error saving data:', error);
162-
if (error.response && error.response.data) {
163-
alert('Error saving data: ' + error.response.data.message);
164-
} else {
165-
alert('An unexpected error occurred. Please try again.');
134+
});
135+
136+
// Attach function to saveButton click event
137+
var saveButton = document.getElementById('saveButton');
138+
saveButton.addEventListener('click', function() {
139+
if (layer === 'default'){
140+
alert('Error: cannot edit defaults');
141+
} else {
142+
const value = editor.getValue();
143+
function cleanEmptyArrays(json) {
144+
if (Array.isArray(json)) {
145+
return json.filter(item => item !== ""); // Remove empty strings from arrays
146+
} else if (typeof json === "object" && json !== null) {
147+
Object.keys(json).forEach(key => {
148+
json[key] = cleanEmptyArrays(json[key]); // Recursively clean nested structures
149+
});
150+
}
151+
return json;
166152
}
167-
});
168-
}
169-
});
170-
})
171-
.catch(error => {
172-
console.error('Error fetching data:', error);
173-
});
174-
</script>
175-
</div>
176-
</div>
177-
</section></curio-ux>
153+
cleanEmptyArrays(value);
154+
console.log(value)
155+
axios.post('/api/config/layers/' + layer, value)
156+
.then(response => {
157+
// Set cookie named 'message' with the value 'Data saved successfully'
158+
document.cookie = 'message=The layer "' + layer + '" saved successfully. Please restart all nodes using the layer "' + layer + '".; path=/;';
159+
window.location.href = '/pages/config/list/';
160+
})
161+
.catch(error => {
162+
alert('Error saving data:', error);
163+
});
164+
}
165+
});
166+
})
167+
.catch(error => {
168+
console.error('Error fetching data:', error);
169+
});
170+
</script>
171+
</div>
172+
</div>
173+
</section>
174+
</curio-ux>
178175
</body>
179-
</html>
176+
</html>

web/static/gc/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
<head>
55
<title>Storage GC</title>
66
<script type="module" src="/ux/curio-ux.mjs"></script>
7+
<script type="module" src="/ux/components/Drawer.mjs"></script>
78
<script type="module" src="/storage-gc.mjs"></script>
89
<script type="module" src="gc-marks.mjs"></script>
910
</head>
1011

1112
<body style="visibility:hidden" data-bs-theme="dark">
1213
<curio-ux>
13-
<div class="page">
14+
<div class="page" style="margin-left: 20px; margin-right: 10px">
1415
<section class="section">
1516
<div class="row">
1617
<h1>Storage GC Info</h1>

web/static/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<script type="module" src="pipeline-stats.mjs"></script>
1919
<script type="module" src="actor-summary.mjs"></script>
2020
<script type="module" src="/ux/curio-ux.mjs"></script>
21+
<script type="module" src="/ux/components/Drawer.mjs"></script>
2122
<script type="module" src="/ux/components/Drawer.mjs"></script>
2223
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2"></script>
2324
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
@@ -45,7 +46,7 @@
4546
</head>
4647
<body style="visibility:hidden">
4748
<curio-ux>
48-
<div class="page">
49+
<div class="page" style="margin-left: 20px; margin-right: 10px">
4950
<div class="row">
5051
<div class="col-md-auto" style="max-width: 1000px">
5152
<div class="info-block">

0 commit comments

Comments
 (0)