-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Vespa Explorer and syntax highlighting
- Loading branch information
Showing
14 changed files
with
768 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { AppContent } from './AppContent'; | ||
import { VespaAppId } from './VespaAppId'; | ||
import { VespaStatus } from './VespaStatus'; | ||
|
||
|
||
describe('AppContent', function () { | ||
describe('given localhost cluster', function () { | ||
it('should return valid list of files', function () { | ||
|
||
// FIXME: This needs to be in a integration test where we start a vespa cluster to test :-) | ||
|
||
// const configEndpoint = "http://localhost:19071"; | ||
// const appContent = new AppContent(); | ||
// appContent.fetchAppDir(configEndpoint, "") | ||
// .then(content => { | ||
// console.log("content: ", content); | ||
|
||
// content.map(f => { | ||
// if (f.endsWith("/")) { | ||
// appContent.fetchAppDir(configEndpoint, f) | ||
// .then(content => { | ||
// console.log(f + ", content: ", content); | ||
// }); | ||
// } else { | ||
// console.log("FILE: " + f); | ||
// } | ||
// }); | ||
// }); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { vespaConfig } from '../VespaConfig'; | ||
import { fetchWithTimeout } from '../vespaUtils'; | ||
import { VespaAppId } from './VespaAppId'; | ||
import { VespaStatus } from './VespaStatus'; | ||
|
||
|
||
|
||
export class AppContent { | ||
|
||
configEndpoint: string = undefined; | ||
status: VespaStatus = undefined; | ||
appId: VespaAppId = undefined; | ||
|
||
async fetchAppDir(configEndpoint: string, path: string): Promise<string[]> { | ||
const timeoutMs = vespaConfig.httpTimeoutMs(); | ||
|
||
if(this.status === undefined) { | ||
this.status = await VespaStatus.fetchVespaStatus(configEndpoint); | ||
} | ||
if(this.appId === undefined) { | ||
this.appId = await VespaAppId.fetchAppId(configEndpoint); | ||
} | ||
|
||
const contentRoot = this.appId.getVespaContentURL(configEndpoint, this.status, "").toString(); | ||
const contentPath = `${contentRoot}/${path}`; | ||
|
||
return fetchWithTimeout(contentPath, timeoutMs) | ||
.then(urlResponse => urlResponse.json()) | ||
.then(files => (files as string[]).map(f => f.replace(contentRoot, ""))); | ||
} | ||
|
||
async fetchAppFile(configEndpoint: string, path: string): Promise<any> { | ||
|
||
if(path.endsWith("/")) { | ||
return Promise.reject("Cannot get 'content' of a dir!"); | ||
} | ||
|
||
const timeoutMs = vespaConfig.httpTimeoutMs(); | ||
|
||
if(this.status === undefined) { | ||
this.status = await VespaStatus.fetchVespaStatus(configEndpoint); | ||
} | ||
if(this.appId === undefined) { | ||
this.appId = await VespaAppId.fetchAppId(configEndpoint); | ||
} | ||
|
||
const contentRoot = this.appId.getVespaContentURL(configEndpoint, this.status, "").toString(); | ||
const contentPath = `${contentRoot}/${path}`; | ||
|
||
|
||
// Assuming text data :-) | ||
return fetchWithTimeout(contentPath, timeoutMs) | ||
.then(urlResponse => urlResponse.text()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.