Commit 4c1c4420 by SHINDAESUB

1차 업데이트

parent eb020176
{}
\ No newline at end of file
{"admin":"관리자","aoiUid":281,"counter":3,"createDate":"2021-01-01","name":"테스트 프로젝트","state":true,"successDate":"2021-01-01","uid":191,"user":"작업자","updateDate":"2021-12-16T02:16:50.301Z"}
\ No newline at end of file
......@@ -4,40 +4,62 @@ const router = express.Router()
router.get('/',async (req,res) => {
const project = JSON.parse( fs.readFileSync('./json/project.json').toString() )
res.send(project)
const learning = JSON.parse( fs.readFileSync('./json/learning.json').toString() )
let result = {
'project':project,
'learning':learning
}
res.send(result)
})
router.post('/',async (req,res) => {
const project = JSON.parse( fs.readFileSync('./json/project.json').toString() )
const learning = JSON.parse( fs.readFileSync('./json/learning.json').toString() )
// 받아온 값이 있을경우
if(Object.keys(req.body).length !== 0 ){
project.admin = req.body.admin
project.aoiUid = req.body.aoiUid
project.counter = req.body.counter
project.createDate = req.body.createDate
project.name = req.body.name
project.state = req.body.state
project.successDate = req.body.successDate
project.uid = req.body.uid
project.user = req.body.user
project.infos = req.body.infos
project.admin = req.body.project.admin
project.aoiUid = req.body.project.aoiUid
project.counter = req.body.project.counter
project.createDate = req.body.project.createDate
project.name = req.body.project.name
project.state = req.body.project.state
project.successDate = req.body.project.successDate
project.uid = req.body.project.uid
project.user = req.body.project.user
project.updateDate = new Date()
project.total = req.body.total
project.success = req.body.success
project.fail = req.body.fail
project.result = req.body.result
project.total = req.body.project.total
project.success = req.body.project.success
project.fail = req.body.project.fail
project.result = req.body.project.result
learning.learning = req.body.learning
fs.writeFileSync('./json/project.json',JSON.stringify(project) , (err) =>{
if ( err ) return err;
})
fs.writeFileSync('./json/learning.json',JSON.stringify(learning) , (err) =>{
if ( err ) return err;
})
}else{
fs.writeFileSync('./json/project.json',JSON.stringify({}) , (err) =>{
if ( err ) return err;
})
fs.writeFileSync('./json/learning.json',JSON.stringify({}) , (err) =>{
if ( err ) return err;
})
}
let result = {
'project':project,
'learning':learning.learning
}
res.status(200).send(project)
res.status(200).send(result)
})
module.exports = router
\ No newline at end of file
......@@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title><%= htmlWebpackPlugin.options.title %></title>
<title>사용자 모드</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
......
......@@ -28,7 +28,6 @@ import Alert from './components/Alert.vue'
import Loading from './components/Loading.vue'
import Bluetooth from './components/Bluetooth.vue'
export default {
name: 'App',
......@@ -39,6 +38,8 @@ export default {
},
created() {
this.$store.dispatch('getSerial')
EventBus.$on('openAlert',( massage , type) => {
this.alertOpen = true,
this.message = massage,
......@@ -57,7 +58,6 @@ export default {
EventBus.$on('openBluetooth',() => { this.bluetoothModal = true }),
EventBus.$on('closeBluetooth',() => { this.bluetoothModal = false })
},
data: () => ({
......@@ -68,15 +68,12 @@ export default {
type:'',
}),
mounted(){
// this.$store.dispatch('getProjectList')
},
beforeDestroy(){
EventBus.$off('openAlert');
EventBus.$off('closeAlert');
EventBus.$off('openLoading');
EventBus.$off('closeLoading');
}
};
</script>
......
......@@ -9,7 +9,7 @@
</v-toolbar>
<v-row class='px-4'>
<v-col cols="6">
<v-subhaeder>안드로이드</v-subhaeder>
<v-subheader>안드로이드</v-subheader>
<v-card>
<v-row no-gutters>
<v-col cols="6">
......@@ -36,7 +36,7 @@
</v-card>
</v-col>
<v-col cols="6">
<v-subhaeder>아이폰</v-subhaeder>
<v-subheader>아이폰</v-subheader>
<v-card color="">
<v-row no-gutters>
<v-col cols="6">
......
import gql from 'graphql-tag' // eslint-disable-line no-unused-vars
import apolloProvider from '../plugins/apollo'
// import store from '@/store'
export default {
async conncetion(input){
async get(serial){
try{
const response = await apolloProvider.defaultClient.query({
query: gql`
query neuroAoiSerial($serial: String!) {
neuroAoiSerial(serial: $serial) {
uid
projectUid
name
state
serial
etc
updateDate
createDate
}
}`,
fetchPolicy: 'no-cache',
variables: { serial: input }
})
let aoi = response.data.neuroAoiSerial
console.log('aoi :',aoi)
return aoi
}catch (e) {
return false
}
},
async getAois(){
try{
const response = await apolloProvider.defaultClient.query({
query: gql`
{
neuroAois{
query aoiSerial($serial:String!){
aoiSerial(serial:$serial){
uid
name
state
serial
etc
projectUid
createDate
updateDate
}
}
`,
fetchPolicy: 'no-cache'
fetchPolicy: 'no-cache',
variables: { serial: serial }
})
console.log('gql 에서 생성하는 :', response.data.neuroAois)
let aoi = response.data.aoiSerial
let aois = response.data.neuroAois
if (!aoi) return ''
if (!aois) return ''
if (aois.errors) throw new Error(aois.errors[0])
if (aoi.errors) throw new Error(aoi.errors[0])
return aois
return aoi
}catch (e) {
console.log(e)
......@@ -70,29 +35,25 @@ export default {
}
},
async updateAoi(input){
async update(input){
try{
const response = await apolloProvider.defaultClient.mutate({
mutation: gql`
mutation updateNeuroAoi( $name: String! ,$state: Boolean! ,$createDate: String! , $serial:String! , $etc:String! ,$updateDate:String! ,$uid:Int! , $projectUid:Int ){
updateNeuroAoi(input:{
mutation updateAoi( $name: String! ,$state: Boolean! , $serial:String! ,$updateDate:String! ,$uid:Int! , $projectUid:Int ){
updateAoi(input:{
name:$name
state:$state
createDate:$createDate
serial:$serial
etc:$etc
updateDate:$updateDate
projectUid:$projectUid
uid:$uid
})
{
neuroAoi{
aoi{
uid
name
state
serial
etc
createDate
updateDate
projectUid
}
......@@ -103,15 +64,13 @@ export default {
uid:input.uid,
name:input.name,
state:input.state,
serial:input.serial,
etc:input.etc,
createDate:input.createDate,
serial:input.serial,
updateDate:new Date(),
projectUid:0
}
})
let aoi = response.data.updateNeuroAoi.neuroAoi
let aoi = response.data.updateAoi.aoi
if (!aoi) return ''
......@@ -126,5 +85,4 @@ export default {
throw e
}
},
}
\ No newline at end of file
......@@ -2,14 +2,12 @@ import gql from 'graphql-tag' // eslint-disable-line no-unused-vars
import apolloProvider from '../plugins/apollo'
export default {
async getLearning(projectUid){
console.log(projectUid)
async get(projectUid){
try{
const response = await apolloProvider.defaultClient.query({
query: gql`
query neuroInfo($projectUid: Int!) {
neuroInfo(projectUid: $projectUid) {
query learning($projectUid: Int!) {
learning(projectUid: $projectUid) {
projectUid
order
type
......@@ -26,10 +24,12 @@ export default {
}
}`,
fetchPolicy: 'no-cache',
variables: { projectUid: projectUid }
})
let learning = response.data.neuroInfo
let learning = response.data.learning
if (!learning) return ''
......
import gql from 'graphql-tag' // eslint-disable-line no-unused-vars
import apolloProvider from '../plugins/apollo'
// import store from '@/store'
export default {
async get(uid){
try{
const response = await apolloProvider.defaultClient.query({
query: gql`
query neuroProject($aoiUid:Int!) {
neuroProject(aoiUid:$aoiUid) {
query nProject($aoiUid:Int!) {
nProject(aoiUid:$aoiUid) {
name
admin
user
......@@ -25,7 +26,7 @@ export default {
variables: { aoiUid: uid }
})
let project = response.data.neuroProject
let project = response.data.nProject
if (!project) return ''
......@@ -42,7 +43,7 @@ export default {
try{
const response = await apolloProvider.defaultClient.mutate({
mutation: gql`
mutation updateNeuroProject(
mutation updateNproject(
$name: String! ,
$admin: String! ,
$user: String! ,
......@@ -58,7 +59,7 @@ export default {
$total:Int,
$result:Boolean
){
updateNeuroProject(input:{
updateNproject(input:{
name:$name
admin:$admin
user:$user
......@@ -75,7 +76,7 @@ export default {
result:$result
})
{
neuroProject{
nProject{
name
admin
user
......@@ -112,7 +113,7 @@ export default {
}
})
let project = response.data.updateNeuroProject.neuroProject
let project = response.data.updateNproject.nProject
if (!project) return ''
......
......@@ -11,12 +11,10 @@ export default {
}
},
async save(project , infos ) {
if(Object.keys(project).length !== 0) project.infos = infos
async save(data) {
try{
let repsone = await axios.post('/project',project)
return repsone
let response = await axios.post('/project', data )
return response.data
}catch(e){
console.error(e.message)
}
......
......@@ -2,19 +2,21 @@ import Vue from 'vue'
import Vuex from 'vuex'
// import projectStore from './modules/projectStore.js'
import aoiStore from './modules/aoiStore'
import projectStore from './modules/projectStore'
import createPersistedState from 'vuex-persistedstate';
Vue.use(Vuex)
export default new Vuex.Store({
modules:{
// project:projectStore,
project:projectStore,
aoi:aoiStore
},
plugins:[
createPersistedState({
paths:['aoi']
paths:['aoi' , 'project']
}),
]
})
import aoiGQL from '../../gql/aoi'
import aoiGql from '@/gql/aoi'
import wpoService from '@/service/wpo'
const state = {
aois: [],
aoi: {},
serial: '',
}
const getters = {
}
const actions = {
async getAois({commit}){
let result = await aoiGQL.getAois()
commit('GETAOIS' , result)
async getSerial({commit}){
let serial = await wpoService.getWpoId() //웹서버에 지정한 WPO ID 가져오기
commit('GETSERIAL' , serial)
},
async createAoi({commit} , input){
let result = await aoiGQL.createAoi(input)
commit('CREATEPAOI' , result)
async getAoi({commit}, serial){
let aoi = await aoiGql.get(serial)
commit('GETAOI' , aoi)
},
async updateAoi({commit} , input){
let result = await aoiGQL.updateAoi(input)
let result = await aoiGql.update(input)
commit('UPDATEAOI' , result)
},
async deleteAoi({commit} , uid){
let result = await aoiGQL.deleteAoi(uid)
commit('DELETEAOI' , result)
}
}
const mutations = {
GETAOIS(state,payload ){
state.aois = payload
},
CREATEPAOI(state,payload ){
state.aois.push(payload)
GETSERIAL(state,payload ){
state.serial = payload
},
GETAOI(state,payload ){
state.aoi = payload
},
UPDATEAOI(state,payload){
let updateIndex =state.aois.findIndex( aoi => aoi.uid === payload.uid )
state.aois.splice(updateIndex , 1 ,payload)
state.aoi = { ...payload};
},
DELETEAOI(state,payload ){
let removeIndex = state.aois.findIndex( aoi => aoi.uid === payload )
state.aois.splice(removeIndex , 1 )
}
}
export default {
......
import projectGql from '@/gql/project'
const state = {
project: [],
}
const getters = {
}
const actions = {
async setProject({commit}, project){
commit('SETPROJECT' , project)
},
async updateAoi({commit} , input){
let result = await projectGql.update(input)
commit('UPDATEAOI' , result)
},
}
const mutations = {
SETPROJECT(state,payload ){
state.project = payload
},
UPDATEAOI(state,payload){
state.aoi = { ...payload};
},
}
export default {
state: {
...state
},
getters,
mutations,
actions
}
\ No newline at end of file
......@@ -11,12 +11,12 @@
<Teaching
v-else-if="stepper === 2"
:project="project"
:infos="infos"
:learnings="learnings"
/>
<Project
v-else-if="stepper === 3"
:project="project"
:infos="infos"
:learnings="learnings"
/>
</v-row>
......@@ -26,6 +26,8 @@
<script>
// import wpoService from '../service/wpo'
import projectService from '../service/project'
// import learningService from '../service/learning'
// import teachingService from '@/service/teaching'
import projectGql from '@/gql/project'
......@@ -46,7 +48,7 @@ export default {
message:'Setting ...',
projectUid: 0 ,
project:{},
infos:[],
learnings:[],
}
},
......@@ -70,40 +72,53 @@ export default {
methods: {
async getProject(){
let response = await projectService.get()
let local = await projectService.get()
console.log('local :',local)
if(Object.keys(response).length === 0){
if(Object.keys(local.learning).length === 0 || Object.keys(local.project).length === 0){
this.stepper = 1
}else if(response.result){
}else if(local.project.result){
this.stepper = 3
this.project = response
}else if(!response.result){
this.project = response
this.infos = response.infos
this.project = local.project
this.learnings = local.learning.learning
this.$store.dispatch('setProject' ,this.project )
}else if(!local.project.result){
this.project = local.project
this.learnings = local.learning.learning
this.stepper = 2
this.$store.dispatch('setProject' ,this.project )
}
},
async setTeaching(step , aoiUid){
async setTeaching(aoiUid){
this.stepper = 0
this.message ="Setting..."
let project = await projectGql.get(aoiUid)
console.log('project :', project )
let learning = await learningGql.getLearning(project.uid)
if(Object.keys(project).length !== 0 && Object.keys(learning).length !== 0){
let localData = await projectService.save(project ,learning )
if(Object.keys(localData).length !== 0 ){
this.project = localData.data
this.infos = localData.data.infos
this.stepper = step
}
this.message ="프로젝트 세팅..."
let gqlProject = await projectGql.get(aoiUid)
this.$store.dispatch('setProject',gqlProject)
this.message ="학습 세팅..."
let gqlLearning = await learningGql.get(gqlProject.uid)
this.message ="프로젝트 저장..."
let saveData = {
'project':gqlProject,
'learning': gqlLearning
}
if(Object.keys(gqlProject).length !== 0 && gqlLearning.length !== 0){
let response = await projectService.save(saveData)
this.project = response.project
this.learnings = response.learning
if(Object.keys(this.project).length !== 0 && this.learnings.length !== 0) this.stepper = 2
}
},
async setProject(step , project){
this.stepper = step
async setProject( project){
this.stepper = 3
this.project = project
}
},
......
......@@ -112,8 +112,7 @@ export default {
props: {
step:Number,
wpo:String,
infos:Array,
learnings:Array,
project:Object,
counter:Number,
result:Array,
......@@ -128,7 +127,7 @@ export default {
result(current){
if(current.length !== 0){
this.rect =[]
this.rect = [...this.infos]
this.rect = [...this.learnings]
for(let i = 0; i < current.length; i++ ){
Number(current[i]) === 0 ? (this.rect[i].fill = '#0D47A1' , this.rect[i].stroke = '#0D47A1' ) : (this.rect[i].fill = '#B71C1C' , this.rect[i].stroke = '#B71C1C' )
......
......@@ -48,8 +48,6 @@ export default {
props: {
step:Number,
wpo:String,
infos:Array,
project:Object,
result:Array
},
......
......@@ -57,7 +57,7 @@
<span v-if="step > 1" class="text-h4">AOI 연결 <v-icon color="success" class="pb-4" x-large>mdi-check-bold</v-icon> </span>
<div v-else class="text-h4 "><strong>AOI 장비</strong>와 연결해주세요
<p class="text-h4 "><strong>S/N : {{id}}</strong></p></div>
<p class="text-h4 "><strong>S/N : {{serial}}</strong></p></div>
</v-col>
<v-col v-if="step === 1" cols="8">
<v-progress-linear
......@@ -106,40 +106,38 @@
</template>
<script>
import wpoService from '@/service/wpo'
import managerService from '@/service/manager'
import { mapActions } from 'vuex'
import { EventBus } from '@/event-bus'
export default {
data () {
return {
message: '준비중...',
step:0,
step:1, //테스트로 실행
// step:0,
id:'',
}
},
created(){
this.getAoi()
this.network()
this.getAois()
computed: {
serial() {
return this.$store.state.aoi.serial
},
aoi(){
return this.$store.state.aoi.aoi
}
},
methods: {
...mapActions([
'getAois',
]),
created(){
// this.network()
async getAoi(){
let id = await wpoService.getWpoId() //웹서버에 지정한 WPO ID 가져오기
this.id = id
},
this.getAoi() // 테스트로 실행
},
async network(){
methods: {
async network(){
EventBus.$emit('openBluetooth')
try{
......@@ -148,8 +146,9 @@ export default {
let response = await managerService.request(msg)
if(JSON.parse(response.data).status){
EventBus.$emit('closeBluetooth')
this.step = 1
setTimeout(() => {
this.step = 1
}, 1000);
}else{
this.network()
}
......@@ -158,39 +157,33 @@ export default {
}
},
aoi(){
getAoi(){
this.$store.dispatch('getAoi',this.serial)
let delay = 1000;
let timer = setInterval(()=> {
let test = this.$store.state.aoi.aois.filter( aoi => { return aoi.serial === this.id } )
console.log('test :',test)
console.log(' this.$store.state.aoi.aois :', this.$store.state.aoi.aois)
if(test.length !== 0){
if(this.aoi.serial === this.serial){
clearInterval(timer)
this.step = 2
setTimeout(() => {
this.step = 2
}, 2000);
}else{
this.getAois()
this.$store.dispatch('getAoi',this.serial)
}
},delay)
},
project(){
getAoiProject(){
let delay = 1000;
let timer = setInterval(()=> {
let test = this.$store.state.aoi.aois.filter( aoi => { return aoi.serial === this.id } )
console.log('test :',test[0].projectUid)
if(test[0].projectUid !== 0){
if(this.aoi.projectUid !== 0){
clearInterval(timer)
this.step = 3
setTimeout(EventBus.$emit('setTeaching' , 2 , test[0].uid ), 3000);
setTimeout(() => {
setTimeout(EventBus.$emit('setTeaching' , this.aoi.uid ), 3000);
}, 2000);
}else{
this.getAois()
this.$store.dispatch('getAoi',this.serial)
}
},delay)
}
......@@ -200,11 +193,11 @@ export default {
async step(current) {
switch(current) {
case 1:
this.aoi()
this.getAoi()
break;
case 2:
this.project()
this.getAoiProject()
break;
}
}
......
......@@ -105,15 +105,13 @@
</template>
<script>
import wpoService from '@/service/wpo'
import managerService from '@/service/manager'
import projectService from '@/service/project'
import projectGQL from '@/gql/project'
import aoiGQL from '@/gql/aoi'
import { mapActions } from 'vuex'
import { EventBus } from '@/event-bus'
export default {
......@@ -129,22 +127,17 @@ export default {
project: Object,
},
computed: {
aoi(){
return this.$store.state.aoi.aoi
}
},
created(){
this.getAoi()
this.getAois()
this.network()
},
methods: {
...mapActions([
'getAois',
]),
async getAoi(){
let id = await wpoService.getWpoId() //웹서버에 지정한 WPO ID 가져오기
this.id = id
},
async network(){
EventBus.$emit('openBluetooth')
......@@ -156,7 +149,7 @@ export default {
EventBus.$emit('closeBluetooth')
setTimeout(() => {
this.step = 1
}, 3000);
}, 1000);
}else{
this.network()
}
......@@ -165,7 +158,6 @@ export default {
}
},
async projectUpdate(){
let result = await projectGQL.update(this.project)
......@@ -177,10 +169,8 @@ export default {
}
},
async aoiInit(){
let aoi = this.$store.state.aoi.aois.filter( aoi => { return aoi.serial === this.id } )
let result = await aoiGQL.updateAoi(aoi[0])
async aoiInit(){
let result = await aoiGQL.update(this.aoi)
if(Object.keys(result).length !== 0){
setTimeout(() => {
......
......@@ -74,7 +74,6 @@
</v-row>
<Result
:step="step"
:infos="infos"
:project="project"
:result="result"
/>
......@@ -84,7 +83,7 @@
<v-col cols="9" >
<Board
:step="step"
:infos="infos"
:learnings="learnings"
:project="project"
:counter="success"
:result="resultRect"
......@@ -111,7 +110,6 @@ export default {
return {
step:0,
wpo:'',
aoi:{},
......@@ -132,7 +130,7 @@ export default {
props: {
project: Object,
infos: Array,
learnings: Array,
},
components:{
......@@ -194,7 +192,7 @@ export default {
try{
let teachingInfo = ''
this.infos.forEach((rect) => {
this.learnings.forEach((rect) => {
let str = `(${Math.ceil(rect.startX * 1.5)},${Math.ceil(rect.startY * 1.5)},${Math.ceil(rect.lastX * 1.5)},${Math.ceil( rect.lastY * 1.5) })`
teachingInfo= teachingInfo + "-" + str
})
......@@ -246,11 +244,16 @@ export default {
this.project.fail = this.fail
this.project.result = true
let localData = await projectService.save(this.project , this.infos)
let saveData = {
'project':this.project,
'learning': this.learnings
}
let response = await projectService.save(saveData)
if(Object.keys(localData.data).length !== 0 ){
if(Object.keys(response.project).length !== 0 ){
EventBus.$emit('closeLoading')
EventBus.$emit('setProject' , 3 , localData.data )
EventBus.$emit('setProject' , response.project )
}
}
}catch(e){
......
......@@ -8,6 +8,7 @@ module.exports = {
devServer: {
proxy: {
'/api/*': {
// target: 'http://192.168.53.34:3000' // 개발/서버
target: 'http://localhost:3000' // 개발서버
}
}
......
Markdown is supported
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