Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Added findNodes
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedElmdary committed Nov 22, 2021
1 parent f7558ca commit dbe8769
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 18 deletions.
2 changes: 1 addition & 1 deletion easy-docs/public/build/elements/base.wc.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion easy-docs/public/build/elements/caprover.wc.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion easy-docs/public/build/elements/deployedlist.wc.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions easy-docs/public/build/elements/kubernetes.wc.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions easy-docs/public/build/elements/vm.wc.js

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions easy-docs/src/views/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ import { parse } from "marked";
class Weblet {
private _md: string;
public html: string;
public constructor(public name: string, symbol: string) {
public constructor(public name: string, symbol: string, deployment?: string) {
this._md = `<tf-${symbol}></tf-${symbol}>`;
if (deployment) {
this._md += `<tf-deployedlist tab="${deployment}"></tf-deployedlist>`;
}
this.html = parse(this._md, {
sanitize: false,
});
Expand All @@ -53,9 +56,9 @@ export default class Editor extends Vue {
public weblets: Weblet[] = [
new Weblet("Profile Manager", "profiles"),
new Weblet("Farming Calculator", "farming-calculator"),
new Weblet("CapRover", "caprover"),
new Weblet("Virtual Machine", "vm"),
new Weblet("Kubernetes", `kubernetes`),
new Weblet("CapRover", "caprover", "caprover"), // "k8s" | "vm" | "caprover"
new Weblet("Virtual Machine", "vm", "vm"),
new Weblet("Kubernetes", `kubernetes`, "k8s"),
new Weblet("Deployments", "deployedlist"),
// new Weblet("Peertube", "peertube"),
];
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function buildElements() {
const outDir = `.build/build/elements/`;
// return fs
// .readdirSync(dir)
return ['DeployedList']
return ["base"]
.map(f => {
const name = f.replace(".wc.svelte", "").toLocaleLowerCase();
return build({
Expand Down
6 changes: 5 additions & 1 deletion src/elements/DeployedList/DeployedList.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@
function _reloadTab() {
const x = active;
active = "";
const y = tab;
tab = undefined;
requestAnimationFrame(() => {
active = x;
tab = y;
});
}
Expand All @@ -68,7 +72,7 @@
let _sub: any;
onMount(() => {
_sub = deployedStore.subscribe(() => {
_sub = deployedStore.subscribe((data) => {
_reloadTab();
});
});
Expand Down
6 changes: 5 additions & 1 deletion src/elements/caprover/Caprover.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
let success = false;
let failed = false;
const configs = window.configs?.baseConfig;
const deploymentStore = window.configs?.deploymentStore;
let profileIdx: number = 0;
$: profiles = $configs;
Expand Down Expand Up @@ -50,7 +51,10 @@
events.addListener("logs", onLogInfo);
deployCaprover(data, profile)
.then(() => (success = true))
.then(() => {
deploymentStore.set(0);
success = true;
})
.catch((err: string) => {
failed = true;
message = err;
Expand Down
5 changes: 3 additions & 2 deletions src/elements/kubernetes/Kubernetes.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
let success = false;
let failed = false;
const configs = window.configs?.baseConfig;
const deploymentStore = window.configs?.deploymentStore;
let profileIdx: number = 0;
$: profiles = $configs;
Expand All @@ -62,8 +63,8 @@
events.addListener("logs", onLogInfo);
deployKubernetes(data, profile)
.then((data) => {
console.log(JSON.stringify(data, undefined, 4));
.then(() => {
deploymentStore.set(0);
success = true;
})
.catch((err: Error) => {
Expand Down
6 changes: 5 additions & 1 deletion src/elements/vm/Vm.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import deployVM from "../../utils/deployVM";
const configs = window.configs?.baseConfig;
const deploymentStore = window.configs?.deploymentStore;
const tabs = [
{ label: "Config" },
Expand Down Expand Up @@ -71,7 +72,10 @@
events.addListener("logs", onLogInfo);
deployVM(data, profile)
.then(() => (success = true))
.then(() => {
deploymentStore.set(0);
success = true;
})
.catch((err: Error) => {
failed = true;
Expand Down
16 changes: 15 additions & 1 deletion src/stores/deploymentStore.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
import { writable } from "svelte/store";

export default writable(0);
function createDeploymentStore() {
const { subscribe, set, update } = writable(0);

return {
subscribe,
set(x: number) {
update((value) => {
value = value + 1;
return value;
});
},
};
}

export default createDeploymentStore();
21 changes: 21 additions & 0 deletions src/utils/findNodes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { GridClient, Nodes } = window.configs?.grid3_client ?? {};

export default function findNodes() {
const nodes = new Nodes(
GridClient.config.graphqlURL,
GridClient.config.rmbClient["proxyURL"]
);

return nodes.filterNodes({
accessNodeV4: false,
accessNodeV6: false,
city: "",
country: "",
cru: 0,
farmId: 0,
gateway: false,
hru: 0,
mru: 0,
sru: 0,
});
}

0 comments on commit dbe8769

Please sign in to comment.