Various fixes [stage]

This commit is contained in:
crschnick 2024-06-26 06:39:47 +00:00
parent 5f01430592
commit 7f0d9746d1
10 changed files with 260 additions and 12 deletions

View file

@ -1,6 +1,7 @@
package io.xpipe.app.beacon.impl;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.AppVersion;
import io.xpipe.beacon.api.DaemonVersionExchange;
import com.sun.net.httpserver.HttpExchange;
@ -20,6 +21,7 @@ public class DaemonVersionExchangeImpl extends DaemonVersionExchange {
var version = AppProperties.get().getVersion();
return Response.builder()
.version(version)
.canonicalVersion(AppVersion.parse(version).map(appVersion -> appVersion.toString()).orElse("?"))
.buildVersion(AppProperties.get().getBuild())
.jvmVersion(jvmVersion)
.build();

View file

@ -67,7 +67,8 @@ public class StoreNotesComp extends Comp<StoreNotesComp.Structure> {
});
n.addListener((observable, oldValue, s) -> {
prop.set(s.getCurrent());
if (s.getCurrent() != null && oldValue.getCommited() == null && oldValue.isCommited()) {
// Check for scene existence. If we exited the platform immediately after adding notes, this might throw an exception
if (s.getCurrent() != null && oldValue.getCommited() == null && oldValue.isCommited() && button.getScene() != null) {
Platform.runLater(() -> {
popover.set(createPopover(popover, prop));
popover.get().show(button);

View file

@ -27,6 +27,10 @@ public class AppVersion implements Comparable<AppVersion> {
}
}
public String toString() {
return major + "." + minor + "." + patch;
}
public boolean greaterThan(AppVersion other) {
return compareTo(other) > 0;
}

View file

@ -0,0 +1,43 @@
package io.xpipe.app.fxcomps.impl;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleCompStructure;
import javafx.beans.binding.Bindings;
import javafx.scene.control.ScrollBar;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.skin.ScrollPaneSkin;
import javafx.scene.layout.StackPane;
public class ScrollComp extends Comp<CompStructure<ScrollPane>> {
private final Comp<?> content;
public ScrollComp(Comp<?> content) {this.content = content;}
@Override
public CompStructure<ScrollPane> createBase() {
var stack = new StackPane(content.createRegion());
stack.getStyleClass().add("scroll-comp-content");
var sp = new ScrollPane(stack);
sp.setFitToWidth(true);
sp.getStyleClass().add("scroll-comp");
sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
sp.setSkin(new ScrollPaneSkin(sp));
ScrollBar bar = (ScrollBar) sp.lookup(".scroll-bar:vertical");
bar.opacityProperty()
.bind(Bindings.createDoubleBinding(
() -> {
var v = bar.getVisibleAmount();
return v < 1.0 ? 1.0 : 0.0;
},
bar.visibleAmountProperty()));
StackPane viewport = (StackPane) sp.lookup(".viewport");
var child = viewport.getChildren().getFirst();
child.getStyleClass().add("view");
return new SimpleCompStructure<>(sp);
}
}

View file

@ -2,11 +2,8 @@ package io.xpipe.app.fxcomps.impl;
import io.xpipe.app.comp.store.StoreCategoryWrapper;
import io.xpipe.app.fxcomps.SimpleComp;
import javafx.scene.layout.Region;
import java.util.List;
public class StoreCategoryListComp extends SimpleComp {
private final StoreCategoryWrapper root;
@ -17,10 +14,8 @@ public class StoreCategoryListComp extends SimpleComp {
@Override
protected Region createSimple() {
return new VerticalComp(List.of(new StoreCategoryComp(root)))
.apply(struc -> struc.get().setFillWidth(true))
.apply(struc -> struc.get().setSpacing(3))
.styleClass("store-category-bar")
.createRegion();
var sp = new ScrollComp(new StoreCategoryComp(root));
sp.styleClass("store-category-bar");
return sp.createRegion();
}
}

View file

@ -1782,6 +1782,140 @@ curl -X POST http://localhost:21723/fs/script \
</details>
## Query daemon version
<a id="opIddaemonVersion"></a>
`POST /daemon/version`
Retrieves version information from the daemon
> Example responses
> 200 Response
```json
{
"version": "string",
"canonicalVersion": "string",
"buildVersion": "string",
"jvmVersion": "string"
}
```
<h3 id="query-daemon-version-responses">Responses</h3>
|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|The operation was successful|[DaemonVersionResponse](#schemadaemonversionresponse)|
|400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request. Please check error message and your parameters.|[ClientErrorResponse](#schemaclienterrorresponse)|
|401|[Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1)|Authorization failed. Please supply a `Bearer` token via the `Authorization` header.|None|
|403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|Authorization failed. Please supply a valid `Bearer` token via the `Authorization` header.|None|
|404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The requested resource could not be found.|None|
|500|[Internal Server Error](https://tools.ietf.org/html/rfc7231#section-6.6.1)|Internal error.|[ServerErrorResponse](#schemaservererrorresponse)|
<aside class="warning">
To perform this operation, you must be authenticated by means of one of the following methods:
bearerAuth
</aside>
<details>
<summary>Code samples</summary>
```javascript
const headers = {
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('http://localhost:21723/daemon/version',
{
method: 'POST',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
```
```python
import requests
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {access-token}'
}
data = """
undefined
"""
r = requests.post('http://localhost:21723/daemon/version', headers = headers, data = data)
print(r.json())
```
```java
var uri = URI.create("http://localhost:21723/daemon/version");
var client = HttpClient.newHttpClient();
var request = HttpRequest
.newBuilder()
.uri(uri)
.header("Accept", "application/json")
.header("Authorization", "Bearer {access-token}")
.POST(HttpRequest.BodyPublishers.ofString("""
undefined
"""))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
```
```go
package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Accept": []string{"application/json"},
"Authorization": []string{"Bearer {access-token}"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "http://localhost:21723/daemon/version", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
```
```shell
# You can also use wget
curl -X POST http://localhost:21723/daemon/version \
-H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' \
--data '
undefined
'
```
</details>
# Schemas
<h2 id="tocS_ShellStartRequest">ShellStartRequest</h2>
@ -2147,6 +2281,32 @@ curl -X POST http://localhost:21723/fs/script \
|---|---|---|---|---|
|sessionToken|string|true|none|The generated bearer token that can be used for authentication in this session|
<h2 id="tocS_DaemonVersionResponse">DaemonVersionResponse</h2>
<a id="schemadaemonversionresponse"></a>
<a id="schema_DaemonVersionResponse"></a>
<a id="tocSdaemonversionresponse"></a>
<a id="tocsdaemonversionresponse"></a>
```json
{
"version": "string",
"canonicalVersion": "string",
"buildVersion": "string",
"jvmVersion": "string"
}
```
<h3>Properties</h3>
|Name|Type|Required|Restrictions|Description|
|---|---|---|---|---|
|version|string|true|none|The version of the running daemon|
|canonicalVersion|string|true|none|The canonical version of the running daemon|
|buildVersion|string|true|none|The build timestamp|
|jvmVersion|string|true|none|The version of the Java Virtual Machine in which the daemon is running|
<h2 id="tocS_AuthMethod">AuthMethod</h2>
<a id="schemaauthmethod"></a>

View file

@ -84,8 +84,8 @@
-fx-border-radius: 0;
}
.store-category-bar {
-fx-padding: 0.8em 0.5em 0.8em 0.5em;
.store-category-bar > .viewport > .view > .scroll-comp-content {
-fx-padding: 0.5em 0.1em 0.5em 0.5em;
}
.store-sort-bar {

View file

@ -24,6 +24,7 @@ public class DaemonVersionExchange extends BeaconInterface<DaemonVersionExchange
public static class Response {
String version;
String canonicalVersion;
String buildVersion;
String jvmVersion;
}

View file

@ -405,6 +405,28 @@ paths:
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
/daemon/version:
post:
summary: Query daemon version
description: Retrieves version information from the daemon
operationId: daemonVersion
responses:
'200':
description: The operation was successful
content:
application/json:
schema:
$ref: '#/components/schemas/DaemonVersionResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
components:
schemas:
ShellStartRequest:
@ -620,6 +642,26 @@ components:
description: The generated bearer token that can be used for authentication in this session
required:
- sessionToken
DaemonVersionResponse:
type: object
properties:
version:
type: string
description: The version of the running daemon
canonicalVersion:
type: string
description: The canonical version of the running daemon
buildVersion:
type: string
description: The build timestamp
jvmVersion:
type: string
description: The version of the Java Virtual Machine in which the daemon is running
required:
- version
- canonicalVersion
- buildVersion
- jvmVersion
AuthMethod:
discriminator:
propertyName: type

View file

@ -1 +1 @@
10.0-20
10.0-21