Skip to content

Commit

Permalink
#135 CouncilComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Feb 2, 2023
1 parent 0561324 commit a6b2668
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 4 deletions.
15 changes: 14 additions & 1 deletion src/components/elements/CouncilComponent.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<template>
<div align="center">
<div class="InfoContainer">
<council-participant-component
v-if="councilId != null"
class="ELement Info"
:council="council"
/>
<council-info-component
v-if="councilId != null"
class="ELement Info"
:council="council"
/>
<info-component
v-if="councilId != null"
class="ELement Info"
Expand Down Expand Up @@ -35,12 +45,14 @@
<script>
import CardComponent from "@/components/elements/CardComponent";
import InfoComponent from "@/components/elements/VotingComponents/InfoComponent.vue";
import CouncilParticipantComponent from "@/components/elements/VotingComponents/CouncilParticipantComponent.vue";
import CouncilInfoComponent from "@/components/elements/VotingComponents/CouncilInfoComponent.vue";
import { Council } from "@/model/Council";
import { Card } from "@/model/Card";
export default {
name: "CouncilComponent",
components: { InfoComponent, CardComponent },
components: { InfoComponent, CardComponent, CouncilParticipantComponent, CouncilInfoComponent },
props: {
councilId: {
type: Number,
Expand Down Expand Up @@ -72,6 +84,7 @@ export default {
this.$cardChain.getCouncil(this.councilId)
.then(res => {
this.council = res;
console.log("####", res)
this.$cardChain.getCard(this.council.cardId)
.then(res => {
this.card = res
Expand Down
51 changes: 51 additions & 0 deletions src/components/elements/VotingComponents/CouncilInfoComponent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<template>
<div>
<p>Voting finishes in: ... </p>
<br>
treasury: {{ council.treasury.normalize().pretty() }}
<h3>Revision history</h3>
</div>
</template>

<script>
import { Council } from "@/model/Council";
export default {
name: "CouncilInfoComponent",
components: {},
props: {
council: {
type: Council,
default() {
return new Council();
}
}
},
data() {
return {
voters: []
};
},
watch: {
council: {
handler() {
this.init();
},
deep: true
}
},
mounted() {
this.init();
},
methods: {
init() {
console.log(123)
}
}
};
</script>

<style scoped lang="scss">
</style>

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<template>
<div>
<h2>Council #{{ council.id }}</h2>
<div
v-for="(voter, address) in voters"
:key="address"
>
{{ voter.alias }} -
<router-link
:to="{ name: 'UserView', params: {id: address} }"
>
{{ address }}
</router-link>
<br>
</div>
</div>
</template>

<script>
import { Council } from "@/model/Council";
export default {
name: "CouncilParticipationComponent",
components: {},
props: {
council: {
type: Council,
default() {
return new Council();
}
}
},
data() {
return {
voters: {}
};
},
watch: {
council: {
handler() {
this.init();
},
deep: true
}
},
mounted() {
this.init();
},
methods: {
init() {
this.council.voters?.forEach(address => {
console.log(address)
this.$cardChain.getUserInfo(address).then(user => {
this.voters[address] = user
});
});
}
}
};
</script>
<style scoped lang="scss">
</style>
3 changes: 2 additions & 1 deletion src/model/Council.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Council {
this.hashResponses = [];
this.clearResponses = [];
}
static from(json) {
static from(json, id) {
let council = Object.assign(new Council(), json);
console.log(json);
council.hoshResponses = json.hoshResponses?.map(resp => {
Expand All @@ -18,6 +18,7 @@ class Council {
});
council.treasury = Coin_1.Coin.from(json.treasury);
council.status = CouncelingStatus[json.status];
council.id = id;
return council;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/model/Council.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Coin } from "./Coin";

export class Council {
id: number
cardId: number
voters: Array<string>
hashResponses: Array<WrapHashResponse> = []
Expand All @@ -9,7 +10,7 @@ export class Council {
status: CouncelingStatus
trialStart: number

static from(json) {
static from(json, id) {
let council = Object.assign(new Council(), json);
console.log(json)
council.hoshResponses = json.hoshResponses?.map(resp => {
Expand All @@ -20,6 +21,7 @@ export class Council {
})
council.treasury = Coin.from(json.treasury)
council.status = CouncelingStatus[json.status]
council.id = id
return council
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/cardChain.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export default {
this.vue.notifyFail('WTF', 'A council was looked up that does not exist in the blockchain.')
throw new Error('Council with ' + id + ' does not exist.')
} else {
return Council.from(res.data)
return Council.from(res.data, id)
}
})
handleGetCardList = R.curry((res, type) => {
Expand Down

0 comments on commit a6b2668

Please sign in to comment.