Skip to content

Commit

Permalink
feat(postgres): improve wing console ui (#238)
Browse files Browse the repository at this point in the history
* feat(postgres): improve wing console ui

* Hide internal nodes
* Add `Connection` link to inspector

* Update api.w

* Update api.w

* Update api.w
  • Loading branch information
eladb authored May 18, 2024
1 parent 3444cc7 commit c09cb43
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion containers/api.w
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ pub struct ContainerOpts {

pub struct WorkloadProps extends ContainerOpts {

}
}
12 changes: 8 additions & 4 deletions postgres/lib.w
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,19 @@ pub class Database {
let sim = new DatabaseSim(props);
this.connection = sim.connection;
this.inner = sim;
new ui.ValueField("Port", sim.port) as "port";

new ui.Field("Connection", inflight () => {
return "postgresql://{sim.connection.user}:{sim.connection.password}@localhost:{sim.port}/{sim.connection.database}";
}, link: true) as "connection";

nodeof(sim).hidden = true;
} elif target == "tf-aws" {
let tfawsParams = RequiredTFAwsProps.fromJson(app.parameters.read(schema: RequiredTFAwsProps.schema()));
if tfawsParams.postgresEngine == "rds" {
let aurora = new DatabaseRDS(props);
this.connection = aurora.connection;
this.inner = aurora;

} elif tfawsParams.postgresEngine == "neon" {
let neon = new DatabaseNeon(props);
this.connection = neon.connection;
Expand Down Expand Up @@ -284,7 +290,7 @@ class DatabaseRDS impl IDatabase {
}

class DatabaseSim impl IDatabase {
port: str;
pub port: str;

pub connection: ConnectionOptions;

Expand Down Expand Up @@ -323,8 +329,6 @@ class DatabaseSim impl IDatabase {
port: this.port,
ssl: false,
};

new ui.ValueField("Postgres Port", this.port);
}

pub inflight connectionOptions(): ConnectionOptions {
Expand Down
4 changes: 2 additions & 2 deletions postgres/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion postgres/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@winglibs/postgres",
"version": "0.1.5",
"version": "0.1.6",
"description": "Postgres support for Wing",
"repository": {
"type": "git",
Expand Down

0 comments on commit c09cb43

Please sign in to comment.