Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Commit

Permalink
some suggestions + update to my test FS to fix this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmJSD committed Nov 29, 2019
1 parent fdaaafe commit dac5602
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/kubernetes-tool/templates/splash_screen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ limitations under the License.
<vue-autosuggest
v-model="helmId"
:suggestions="helmSuggestions"
:input-props="{id: 'helmInput', class: 'input', type: 'text', placeholder: i18n.templates.splashScreen.helmTitle, style: {width: '80%', textIndent: '30px'}, readonly: readonly}"
:input-props="{
id: 'helmInput', class: 'input', type: 'text',
placeholder: i18n.templates.splashScreen.helmTitle,
style: {width: '80%', textIndent: '30px'},
readonly: readonly
}"
:style="{width: '100%'}"
@input="inputChange"
@selected="inputSelect"
Expand Down Expand Up @@ -100,8 +105,7 @@ limitations under the License.
import { safeLoad } from "js-yaml"
import { VueAutosuggest } from "vue-autosuggest"
import i18n from "../i18n"
import { fs } from "../utils/helm"
import { HelmCoreParser } from "../utils/helm"
import { fs, HelmCoreParser } from "../utils/helm"
import svgTop from "../../../build/svg/top.svg"
import svgBottom from "../../../build/svg/bottom.svg"
Expand Down
30 changes: 29 additions & 1 deletion src/kubernetes-tool/utils/gitHttpMirrorFs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ limitations under the License.
export default class GitHTTPMirrorFS {
public alias: string
public hostname: string
private itemCache: Record<string, Response>

// Constructs the class.
public constructor(alias: string, hostname: string) {
this.alias = alias
this.hostname = hostname
this.itemCache = {}
}

// Lists the folder specified.
Expand All @@ -44,7 +46,12 @@ export default class GitHTTPMirrorFS {
}
const json = await res.json()
for (const item of json) {
const itemResult = await fetch(`${this.hostname}/${this.alias}/${folder}/${item}`)
const path = `${this.hostname}/${this.alias}/${folder}/${item}`
let itemResult = this.itemCache[path]
if (!this.itemCache[path]) {
itemResult = await fetch(path)
this.itemCache[path] = itemResult
}
items.push({
file: itemResult.headers.get("is-dir-listing") !== "true",
name: item,
Expand All @@ -60,4 +67,25 @@ export default class GitHTTPMirrorFS {
if (!res.ok) return undefined
return await res.text()
}

// Queries the start of the name.
public async queryStart(fp: string, start: string): Promise<string | undefined> {
const ls = await this.ls(fp)
for (const f of ls) {
if (f.name.startsWith(start)) return f.path
}
}

// Queries all with a certian start of their name.
public async queryStartAll(fp: string, start: string, limit: number): Promise<string[]> {
const items = []
const ls = await this.ls(fp)
for (const f of ls) {
if (f.name.startsWith(start)) {
items.push(f.path)
if (items.length === limit && limit !== 0) return items
}
}
return items
}
}

1 comment on commit dac5602

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been deployed to DigitalOcean Spaces for easy reviewing.

kubernetes-tool

Please sign in to comment.