Commit 65daa5a4 authored by Daniel Eggert's avatar Daniel Eggert
Browse files

added minimalistic hello world example

parent 95953644
import PulsarConnection from 'dasf-web/lib/messaging/PulsarConnection'
import { PulsarModuleResponse, PulsarModuleRequest, PulsarModuleRequestReceipt } from 'dasf-web/lib/messaging//PulsarMessages'
import { DefaultPulsarUrlBuilder } from 'dasf-web/lib/messaging//PulsarUrlBuilder'
export default class HelloWorldClient {
private pulsarConnection: PulsarConnection;
public constructor () {
this.pulsarConnection = new PulsarConnection(new DefaultPulsarUrlBuilder('localhost', '8080', 'default', 'hello-world-topic'))
}
private createHelloWorldRequest (): PulsarModuleRequest {
const request = PulsarModuleRequest.createRequestMessage()
request.payload = btoa(JSON.stringify({ func_name: 'hello_world' }))
return request
}
public helloWorld (): Promise<string> {
return new Promise((resolve: (value: string) => void, reject: (reason: string) => void) => {
this.pulsarConnection.sendRequest(this.createHelloWorldRequest(),
(response: PulsarModuleResponse) => {
if (response.properties.status === 'success') {
resolve(JSON.parse(atob(response.payload)))
} else {
reject(atob(response.payload))
}
},
null,
(receipt: PulsarModuleRequestReceipt) => {
reject(receipt.errorMsg)
})
})
}
}
<template>
<v-container
style="margin-bottom: 35px; padding-top: 100px; padding-bottom: 20px"
>
<v-card :loading="response.length===0">
<v-card-title>Hello World Example</v-card-title>
<v-card-text>The hello world backend module responded with: <b>{{ response }}</b></v-card-text>
</v-card>
</v-container>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import HelloWorldClient from '~/lib/HelloWorldClient'
@Component({})
export default class HelloWorldVis extends Vue {
protected response = '';
protected created (): void {
const hwClient: HelloWorldClient = new HelloWorldClient()
hwClient.helloWorld().then((moduleResponse: string) => {
this.response = moduleResponse
}).catch((reason) => {
this.response = reason
})
}
}
</script>
......@@ -23,7 +23,7 @@
<v-slide-item
v-for="(workflow,n) in filteredWorkflows"
:key="n"
v-slot:default="{ active, toggle }"
v-slot:default="{ toggle }"
>
<v-card
class="ma-2 pl-2 py-1 d-flex justify-space-between"
......@@ -66,7 +66,6 @@
</v-main>
</template>
<style scoped>
.inputSearch {
background-color: grey;
......@@ -75,10 +74,10 @@
</style>
<script lang='ts'>
import { Component, Vue } from 'vue-property-decorator';
import { Component, Vue } from 'vue-property-decorator'
class Workflow {
public constructor(
public constructor (
public color: string,
public icon: string,
public title: string,
......@@ -105,17 +104,17 @@ export default class Index extends Vue {
protected filteredWorkflows: Workflow[] = this.workflows;
protected filterWorkflows(search: string) {
this.search = search;
protected filterWorkflows (search: string) {
this.search = search
if (this.search) {
let exp = new RegExp(this.search.trim(), 'i');
const exp = new RegExp(this.search.trim(), 'i')
this.filteredWorkflows = this.workflows.filter(workflow =>
exp.test(workflow.title)
);
)
} else {
this.filteredWorkflows = this.workflows;
this.filteredWorkflows = this.workflows
}
}
}
</script>
\ No newline at end of file
</script>
......@@ -103,15 +103,15 @@
</style>
<script lang='ts'>
import { Component, Vue } from 'vue-property-decorator';
import { Component, Vue } from 'vue-property-decorator'
// import Demap from 'dasf-web/lib/map/Demap.vue';
// import RadarChart from 'dasf-web/lib/charts/RadarChart.vue';
import ProgressTree from 'dasf-web/lib/messaging/ProgressTree.vue';
import ExampleModuleMessaging from 'dasf-web/lib/messaging/ExampleModuleMessaging';
import { PulsarProgressReport } from 'dasf-web/lib/messaging/PulsarMessages';
import ProgressTree from 'dasf-web/lib/messaging/ProgressTree.vue'
import ExampleModuleMessaging from 'dasf-web/lib/messaging/ExampleModuleMessaging'
import { PulsarProgressReport } from 'dasf-web/lib/messaging/PulsarMessages'
@Component({
components: { ProgressTree },
components: { ProgressTree }
})
export default class Workflow extends Vue {
private exampleModule: ExampleModuleMessaging = new ExampleModuleMessaging();
......@@ -149,26 +149,26 @@ export default class Workflow extends Vue {
// ]);
// }
protected sendHelloWorldRequest(): void {
protected sendHelloWorldRequest (): void {
this.exampleModule
.sendHelloWorldRequest(this.greetMessage, this.repeatMessage, this.repeat)
.then((response: Record<string, unknown>) => {
this.helloWorldResponse = response;
this.helloWorldResponse = response
})
.catch((error: string) => {
console.error(error);
this.helloWorldResponse = { error: error };
});
console.error(error)
this.helloWorldResponse = { error: error }
})
}
protected sendProgressReportRequest(): void {
protected sendProgressReportRequest (): void {
this.exampleModule
.sendProgressReportRequest((progressReport: PulsarProgressReport) => {
this.progressReport = progressReport;
this.progressReport = progressReport
})
.catch((error: string) => {
console.error(error);
});
console.error(error)
})
}
}
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment