Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/naming convention #372

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 27 additions & 32 deletions src/bin/super/superapp/src/Remotes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@
let name = "";
let vanity_address = "";
let domain = ".sphinx.chat";
let swarm_name_suffix = "-Swarm";
let swarm_name_prefix = "s-";
const max_input_with = 600;
let vanity_input_width = max_input_with;
let swarm_name_width = max_input_with;
let aws_instance_types = [];
let selected_instance = "";
let vanity_address_error = "";
Expand Down Expand Up @@ -470,7 +469,6 @@
vanity_address = "";
selected_instance = "";
vanity_input_width = max_input_with;
swarm_name_width = max_input_with;
}

async function handleSubmitCreateEc2() {
Expand All @@ -482,7 +480,7 @@

try {
const data = {
name: `${name}${swarm_name_suffix}`,
name: `${swarm_name_prefix}${name}`,
vanity_address,
instance_type: selected_instance,
};
Expand All @@ -495,7 +493,6 @@
vanity_address = "";
selected_instance = "";
vanity_input_width = max_input_with;
swarm_name_width = max_input_with;
show_notification = true;

await getConfig();
Expand Down Expand Up @@ -524,11 +521,6 @@

function updateSwarmnameWidth(event) {
name = event.target.value.replace(/\s+/g, "");
const span = document.querySelector(".swarm_name_measure");
swarm_name_width = span.offsetWidth;
if (!swarm_name_width) {
swarm_name_width = max_input_with;
}
}
</script>

Expand Down Expand Up @@ -718,20 +710,16 @@
<div class="custom_text_input_container">
<label class="customlabel" for="label">Swarm Name</label>
<div class="custom_input_container">
<div>
<span class="swarm_name_measure">{name}</span>
<input
type="text"
bind:value={name}
on:input={updateSwarmnameWidth}
placeholder="Enter Swarm Name"
style="width: {swarm_name_width}px;"
class="custom_input"
/>
</div>
{#if name.length > 0}
<span class="suffix">{swarm_name_suffix}</span>
<span class="prefix">{swarm_name_prefix}</span>
{/if}
<input
type="text"
bind:value={name}
on:input={updateSwarmnameWidth}
placeholder="Enter Swarm Name"
class="instance_name_input"
/>
</div>
</div>
<div class="select_instance_container">
Expand Down Expand Up @@ -810,30 +798,37 @@
margin-left: -2px;
}

.custom_input {
.prefix {
font-size: 1rem;
font-family: "Barlow";
color: #49c998;
}

.instance_name_input {
border: none;
outline: none;
margin: 0;
font-size: 1rem;
font-family: "Barlow";
background-color: transparent;
width: auto;
width: 100%;
color: white;
padding: 0;
}

.vanity_address_measure {
visibility: hidden;
position: absolute;
white-space: nowrap;
font-family: "Barlow";
font-size: 1rem;
padding: 0;
.custom_input {
border: none;
outline: none;
margin: 0;
font-size: 1rem;
font-family: "Barlow";
background-color: transparent;
width: auto;
color: white;
padding: 0;
}

.swarm_name_measure {
.vanity_address_measure {
visibility: hidden;
position: absolute;
white-space: nowrap;
Expand Down
4 changes: 4 additions & 0 deletions src/bin/super/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,10 @@ pub async fn create_swarm_ec2(
info: &CreateEc2InstanceInfo,
state: &mut Super,
) -> Result<(), Error> {
if !&info.name.starts_with("s-") {
return Err(anyhow!("swarm name does not match naming convention"));
}

let daily_limit = getenv("EC2_DAILY_LIMIT")
.unwrap_or("5".to_string())
.parse()
Expand Down