Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<b-navbar-brand href="#">Sample App</b-navbar-brand>
<b-collapse is-nav id="nav_collapse">
<b-navbar-nav>
<b-nav-item href="/sample-component">First Module</b-nav-item>
<b-nav-item href="/user-login">Second Module</b-nav-item>
<b-nav-item href="/sample-component">Sample Component</b-nav-item>
<b-nav-item href="/user-login">Login Component</b-nav-item>
</b-navbar-nav>
</b-collapse>
</b-navbar>
Expand Down
7 changes: 7 additions & 0 deletions src/app/baluster/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { HTTP, CLIENT } from '../../http';

export const api = {
fetchPickets(params: any) {
return HTTP.get('https://api.adviceslip.com/advice', {responseType: 'json'});
},
};
19 changes: 19 additions & 0 deletions src/app/baluster/components/BalusterMasterCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<div>
<router-view></router-view>
<router-view name="paramount"></router-view>
<router-view name="pronouncement"></router-view>
</div>
</template>

<script lang="ts">
import Component from 'vue-class-component';
import Vue from 'vue';

@Component
export default class BalusterMasterCard extends Vue {
public created() {
console.log('creating....');
}
}
</script>
17 changes: 17 additions & 0 deletions src/app/baluster/components/DefaultCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<h4> <b>Default:</b> Default Card</h4>
</div>
</template>

<script lang="ts">
import Component from 'vue-class-component';
import Vue from 'vue';

@Component
export default class DefaultCard extends Vue {
public created() {
console.log('default created.');
}
}
</script>
17 changes: 17 additions & 0 deletions src/app/baluster/components/ParamountCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<h4> <b>Paramount: </b> a long, sturdy piece of timber or metal set upright in the ground and used as a support or marker.</h4>
</div>
</template>

<script lang="ts">
import Component from 'vue-class-component';
import Vue from 'vue';

@Component
export default class ParamountCard extends Vue {
public created() {
console.log('paramount created.');
}
}
</script>
17 changes: 17 additions & 0 deletions src/app/baluster/components/PronouncementCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<h3><b>Pronouncement: </b> formal or authoritative announcement or declaration.</h3>
</div>
</template>

<script lang="ts">
import Component from 'vue-class-component';
import Vue from 'vue';

@Component
export default class PronouncementCard extends Vue {
public created() {
console.log('pronounced created.');
}
}
</script>
4 changes: 4 additions & 0 deletions src/app/baluster/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { default as BalusterMasterCard } from './BalusterMasterCard.vue';
export { default as ParamountCard } from './ParamountCard.vue';
export { default as PronouncementCard } from './PronouncementCard.vue';
export { default as DefaultCard } from './DefaultCard.vue';
2 changes: 2 additions & 0 deletions src/app/baluster/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as routes } from './routes';
export { jamb as vuex } from './vuex';
19 changes: 19 additions & 0 deletions src/app/baluster/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { DefaultCard, BalusterMasterCard, ParamountCard, PronouncementCard } from './components';

export default [
{
path: '/baluster',
component: BalusterMasterCard,
children: [
{
path: '/',
components: {
default: DefaultCard,
paramount: ParamountCard,
pronouncement: PronouncementCard,
},
name: 'baluster',
},
],
},
];
11 changes: 11 additions & 0 deletions src/app/baluster/vuex/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ActionTree } from 'vuex';
import { JambState } from './types';
import { RootState } from '@/app/types';
import { api } from '../api';
export const actions: ActionTree<JambState, RootState> = {
pickets({commit}): any {
api.fetchPickets({}).then((response: any) => {
console.log(response);
});
},
};
10 changes: 10 additions & 0 deletions src/app/baluster/vuex/getters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { GetterTree } from 'vuex';
import { JambState } from './types';
import { RootState } from '../../types';

export const getters: GetterTree<JambState, RootState> = {
columns(state): string {
const {message} = state;
return message;
},
};
22 changes: 22 additions & 0 deletions src/app/baluster/vuex/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Module } from 'vuex';
import { getters } from './getters';
import { actions } from './actions';
import { mutations } from './mutations';

import { RootState } from '../../types';
import { JambState } from './types';

export const state: JambState = {
message: '',
error: false,
};

const namespaced: boolean = true;

export const jamb: Module<JambState, RootState> = {
namespaced,
state,
getters,
actions,
mutations,
};
14 changes: 14 additions & 0 deletions src/app/baluster/vuex/mutations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { MutationTree } from 'vuex';
import { JambState } from './types';

export const mutations: MutationTree<JambState> = {
sampleDataLoaded(state, payload: string) {
state.message = payload;
state.error = false;
},

sampleError(state) {
state.error = true;
state.message = '';
},
};
4 changes: 4 additions & 0 deletions src/app/baluster/vuex/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface JambState {
message: string;
error: boolean;
}
1 change: 0 additions & 1 deletion src/app/mixins/vuex/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { MixinState, QuoteState, FeedState, CountryState } from './types';

export const mutations: MutationTree<MixinState> = {
sampleLocationLoaded(state, payload: any) {
console.log(payload);
for (const c of payload) {
const country: CountryState = {
name: c.name,
Expand Down
2 changes: 2 additions & 0 deletions src/app/routes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { routes as login } from './login';
import { routes as sample } from './sample';
import { routes as jamb } from './baluster';

export default [
...login,
...sample,
...jamb,
];
12 changes: 10 additions & 2 deletions src/app/sample/components/SampleComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<p class="card-text">
{{message}}
</p>
<b-button href="/user-login" variant="primary">Second Module</b-button>
<b-button href="/user-login" variant="primary">Login Component</b-button>
</b-card>
<b-card tag="article" style="max-width: 100%" class="mb-2">
<b-carousel id="carousel1"
Expand Down Expand Up @@ -47,7 +47,15 @@
import { Mixins } from 'vue-mixin-decorator';
const namespace: string = 'sample';

@Component
/**
* router callback wont be called if you define them inside component class.
* You need to register them before component resolve.
*/
@Component({
beforeRouteEnter: (to, from , next) => {
next();
},
})
export default class SampleComponent extends Mixins<LocationMixin>(LocationMixin) {
@Action('sampleData', {namespace}) private sampleData: any;
@State('sample') private sample!: SampleState;
Expand Down
5 changes: 5 additions & 0 deletions src/app/sample/routes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { SampleComponent } from './components';
import { Route } from 'vue-router';

export default [
{
path: '/sample-component',
component: SampleComponent,
name: 'sample.component',
beforeEnter: (to: Route, from: Route, next: any) => {
next();
},
},
{
path: '',
Expand Down
3 changes: 3 additions & 0 deletions src/app/vuex.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { vuex as login } from './login';
import { vuex as sample } from './sample';
import { vuex as mixins } from './mixins';
import { vuex as jamb } from './baluster';

export default {
login,
sample,
mixins,
jamb,
};
12 changes: 10 additions & 2 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from 'vue';
import Router from 'vue-router';
import Router, { Route } from 'vue-router';
import { routes } from './app';

Vue.use(Router);
Expand All @@ -14,8 +14,16 @@ const router = new Router({
* Configure pre request checks and router validations.
* Access control.
*/
router.beforeEach((to, from, next) => {
router.beforeEach((to: Route, from: Route, next: any) => {
next();
});

router.beforeResolve((to: Route, from: Route, next: any) => {
next();
});

router.afterEach((to: Route, from: Route) => {
// Here do something after everything is ready.
});

export default router;