add frontend frame and service logic
This commit is contained in:
60
frontend-frame/src/components/HelloWorld.vue
Normal file
60
frontend-frame/src/components/HelloWorld.vue
Normal file
@ -0,0 +1,60 @@
|
||||
<template>
|
||||
<div class="hello">
|
||||
<h1>{{ msg }}</h1>
|
||||
<p>
|
||||
For a guide and recipes on how to configure / customize this project,<br>
|
||||
check out the
|
||||
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
|
||||
</p>
|
||||
<h3>Installed CLI Plugins</h3>
|
||||
<ul>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-typescript" target="_blank" rel="noopener">typescript</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa" target="_blank" rel="noopener">pwa</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
|
||||
</ul>
|
||||
<h3>Essential Links</h3>
|
||||
<ul>
|
||||
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
|
||||
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
|
||||
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
|
||||
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
|
||||
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
|
||||
</ul>
|
||||
<h3>Ecosystem</h3>
|
||||
<ul>
|
||||
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
|
||||
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
|
||||
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
|
||||
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from 'vue-property-decorator';
|
||||
|
||||
@Component
|
||||
export default class HelloWorld extends Vue {
|
||||
@Prop() private msg!: string;
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
<style scoped>
|
||||
h3 {
|
||||
margin: 40px 0 0;
|
||||
}
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
li {
|
||||
display: inline-block;
|
||||
margin: 0 10px;
|
||||
}
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<div class="{{component}}-editor">
|
||||
<div class="property-row">
|
||||
<label>Grant Name: </label>
|
||||
<div>grant.name</div>
|
||||
</div>
|
||||
|
||||
<!-- SYSTEM-BUILDER-property-row -->
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from 'vue-property-decorator';
|
||||
import { {{Component}}Config } from './{{component}}Types.ts';
|
||||
|
||||
@Component
|
||||
export default class {{Component}}Editor extends Vue {
|
||||
@Prop() private {{component}}!: {{Component}}Config;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="css">
|
||||
.errorMessage {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<div class="{{component}}-editor">
|
||||
<div class="input-row">
|
||||
<label>Grant Name: </label>
|
||||
<input class="form-control" type="text" ref="name" placeholder="Grant Name" v-model="grant.name" />
|
||||
</div>
|
||||
|
||||
<!-- SYSTEM-BUILDER-input-row -->
|
||||
|
||||
<div class="errorMessage" v-if="errorMessage != ''">{{errorMessage}}</div>
|
||||
<div class="action-buttons">
|
||||
<button class="btn" @click="close()">Cancel</button>
|
||||
<button class="btn btn-secondary" :disabled="!isComplete" @click="isComplete && save{{Component}}()">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from 'vue-property-decorator';
|
||||
import { {{component}}Service } from './{{component}}Service.ts';
|
||||
import { {{Component}}Config } from './{{component}}Types.ts';
|
||||
|
||||
@Component
|
||||
export default class {{Component}}Editor extends Vue {
|
||||
@Prop() private {{component}}!: {{Component}}Config;
|
||||
private loading: boolean = false;
|
||||
private errorMessage: string = '';
|
||||
|
||||
get isComplete() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private save{{Component}}() {
|
||||
this.loading = true;
|
||||
this.errorMessage = '';
|
||||
// either create or update...
|
||||
if (this.{{component}}.id === '') { // TODO: use the primary key instead of 'id' here
|
||||
{{component}}Service.create{{Component}}(this.{{component}}).then(() => {
|
||||
// success
|
||||
this.loading = false;
|
||||
this.errorMessage = '';
|
||||
this.close();
|
||||
}).catch(this.handleError.bind(this));
|
||||
} else {
|
||||
{{component}}Service.update{{Component}}(this.{{component}}).then(() => {
|
||||
// success
|
||||
this.loading = false;
|
||||
this.errorMessage = '';
|
||||
this.close();
|
||||
}).catch(this.handleError.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
private handleError(err: any) {
|
||||
// error
|
||||
this.loading = false;
|
||||
this.errorMessage = err.message;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="css">
|
||||
.errorMessage {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<div class="{{component}}-editor">
|
||||
<div>TODO: search</div>
|
||||
|
||||
<div v-for="item in items" :key="item.id" class="input-row">
|
||||
<div class="">{{ item.id }}</div>
|
||||
</div>
|
||||
|
||||
<div class="errorMessage" v-if="errorMessage != ''">{{errorMessage}}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from 'vue-property-decorator';
|
||||
import { {{component}}Service } from './{{component}}Service.ts';
|
||||
import { {{Component}}Config } from './{{component}}Types.ts';
|
||||
|
||||
@Component
|
||||
export default class {{Component}}Editor extends Vue {
|
||||
private items!: {{Component}}Config[];
|
||||
private loading: boolean = false;
|
||||
private errorMessage: string = '';
|
||||
// SYSTEM-BUILDER-component-variables
|
||||
|
||||
// SYSTEM-BUILDER-component-functions
|
||||
|
||||
private get{{Component}}s() {
|
||||
this.loading = true;
|
||||
this.errorMessage = '';
|
||||
{{component}}Service.get{{Component}}s().then((listItems: {{Component}}Config[]) => {
|
||||
// success
|
||||
this.loading = false;
|
||||
this.errorMessage = '';
|
||||
this.items = listItems;
|
||||
}).catch(this.handleError.bind(this));
|
||||
}
|
||||
|
||||
// TODO: add a search function if there is an endpoint with type 'search'
|
||||
|
||||
private handleError(err: any) {
|
||||
// error
|
||||
this.loading = false;
|
||||
this.errorMessage = err.message;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="css">
|
||||
.errorMessage {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,13 @@
|
||||
import { del, get, post, put } from '@/services/fetch';
|
||||
|
||||
class {{Component}}Service {
|
||||
// SYSTEM-BUILDER-service-variables
|
||||
// SYSTEM-BUILDER-service-functions
|
||||
}
|
||||
|
||||
let {{component}}Service = new {{Component}}Service();
|
||||
|
||||
export {
|
||||
{{component}}Service,
|
||||
{{Component}}Service
|
||||
};
|
@ -0,0 +1,10 @@
|
||||
|
||||
// SYSTEM-BUILDER-{{component}}-interfaces
|
||||
|
||||
// e.g.
|
||||
// interface {{Component}}Config {
|
||||
// }
|
||||
|
||||
export {
|
||||
// SYSTEM-BUILDER-{{component}}-exports
|
||||
};
|
Reference in New Issue
Block a user