Skip to content

Commit

Permalink
Merge pull request #300 from harena-lab/development
Browse files Browse the repository at this point in the history
Feat: Logger messages for case summary
  • Loading branch information
HeitorMatt authored Nov 24, 2021
2 parents 3d6b57e + 3d9cc70 commit d4260e8
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 22 deletions.
38 changes: 38 additions & 0 deletions src/adonisjs/public/infra/dcc-logger-manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Logger DCC
***********/

class DCCLoggerManager extends DCCLight {
constructor() {
super()

this._notifyLogger = this._notifyLogger.bind(this)
this._subscribe('case/summary/#', this._notifyLogger)
}

async _notifyLogger (topic, message, track) {
if (track) {
console.log('=== logger DCC: ' + topic)
console.log(message)

console.log('========== creating logger ==========')
let logger = await MessageBus.i.request('logger/create/post',
{
caseId: message.caseId,
instanceId: MessageBus.extractLevel(topic, 3),
log: JSON.stringify(message.knotTrack)
}
)
if (logger.message.error) {
console.log('--- error')
console.log(logger.message.error)
} else {
console.log('=== success ===')
console.log(logger.message)
}
}
}
}

(function () {
DCCLoggerManager.i = new DCCLoggerManager()
})()
29 changes: 29 additions & 0 deletions src/adonisjs/public/infra/dcc-rest-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,33 @@
}
)

DCC.component(
'harena-create-logger',
'dcc-rest',
{
environment: {
'url-manager': HarenaConfig.manager.url + HarenaConfig.manager.api
},
oas: {
paths: {
'{url-manager}/logger': {
'post': {
operationId: 'create-logger',
parameters: [
{name: 'url-manager',
in: 'path'},
{name: 'caseId',
in: 'query'},
{name: 'instanceId',
in: 'query'},
{name: 'log',
in: 'query'}
]
}
}
}
}
}
)

})()
2 changes: 2 additions & 0 deletions src/adonisjs/public/player/case/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<script src="/infra/dcc-rest-proxy.js"></script>
<script src="/infra/dcc-basic.js"></script>
<script src="/infra/dcc-logger.js"></script>
<script src="/infra/dcc-logger-manager.js"></script>

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
Expand Down Expand Up @@ -112,6 +113,7 @@
<body onload="PlayerManager.player.startPlayer()">
<!-- <div class="d-flex flex-column vh-100 vw-100 hidden-overflow"> -->

<dcc-rest id="harena-create-logger" bind="harena-create-logger" subscribe="logger/create/post"></dcc-rest>
<main role="main">
<div id="main-panel" class="d-flex flex-column vh-100 vw-100 scroll-y index-boot-padding">
<dcc-rest id="harena-case" bind="harena-case" subscribe="service/request/get"></dcc-rest>
Expand Down
26 changes: 21 additions & 5 deletions src/adonisjs/public/player/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ class PlayerManager {
this._state.historyRecord(startKnot)
this.knotLoad(startKnot)
break
case 'knot/navigate/>': const nextKnot = this._state.nextKnot()
case 'knot/navigate/>':
const nextKnot = this._state.nextKnot()
this._state.historyRecord(nextKnot)
this.knotLoad(nextKnot)
break
case 'flow/navigate/>': const flowNext = this._nextFlowKnot()
case 'flow/navigate/>':
const flowNext = this._nextFlowKnot()
if (flowNext != null) {
// console.log('=== flow next')
// console.log(flowNext)
this._state.historyRecord(flowNext.target)
this.knotLoad(flowNext.target)
}
Expand Down Expand Up @@ -144,6 +144,7 @@ class PlayerManager {
result.message)
}
this._state.historyRecord(target)
// this._updateFlowKnot(target)
if (message.value) {
this._state.parameter = message.value
this.knotLoad(target, message.value)
Expand Down Expand Up @@ -173,6 +174,20 @@ class PlayerManager {
return next
}

_updateFlowKnot (knot) {
// console.log('=== knot & flow')
// console.log(knot)
// console.log(this._state.flow.slice())
if (this._state.flow) {
let next
do {
next = this._state.flow.shift()
} while (this._state.flow.length > 0 && next.target != knot)
if (this._state.flow.length == 0) { delete this._state.flow }
}
// console.log(this._state.flow.slice())
}

async startPlayer (caseid) {
const preCaseOff = true
this._mainPanel = document.querySelector('#player-panel')
Expand Down Expand Up @@ -330,7 +345,8 @@ class PlayerManager {
}
c++
}
if (flow != null && flow.length > 0) { this._state.flow = flow }
if (flow != null && flow.length > 0)
this._state.flow = flow
}
}

Expand Down
26 changes: 16 additions & 10 deletions src/adonisjs/public/templates/simple/case/tbl-dynamic.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,14 @@ Write here the **stem**.
**Complementary Exams**

> Choose the 3 most relevant complementary exams to solve this case:
+ Exam 1 <-> Exam 1
+ Exam 2 <-> Exam 2
+ Exam 3 <-> Exam 3
+ Exam 4 <-> Exam 4
+ Exam 5 <-> Exam 5
? exams
* type: choice
* reveal: partial
* Exam 1 <-> Exam 1
* Exam 2 <-> Exam 2
* Exam 3 <-> Exam 3
* Exam 4 <-> Exam 4
* Exam 5 <-> Exam 5

* Next -> Conclusion

Expand Down Expand Up @@ -234,11 +237,14 @@ Write here the **stem**.
**Complementary Exams**

> Choose the 3 most relevant complementary exams to solve this case:
+ Exam 1 <-> Exam 1
+ Exam 2 <-> Exam 2
+ Exam 3 <-> Exam 3
+ Exam 4 <-> Exam 4
+ Exam 5 <-> Exam 5
? exams
* type: choice
* reveal: partial
* Exam 1 <-> Exam 1
* Exam 2 <-> Exam 2
* Exam 3 <-> Exam 3
* Exam 4 <-> Exam 4
* Exam 5 <-> Exam 5

* Next -> Conclusion

Expand Down
13 changes: 8 additions & 5 deletions src/adonisjs/public/templates/simple/knot/tbl_case.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ Write here the **stem**.
**Complementary Exams**

> Choose the 3 most relevant complementary exams to solve this case:
+ Exam 1 <-> Exam 1
+ Exam 2 <-> Exam 2
+ Exam 3 <-> Exam 3
+ Exam 4 <-> Exam 4
+ Exam 5 <-> Exam 5
? exams
* type: choice
* reveal: partial
* Exam 1 <-> Exam 1
* Exam 2 <-> Exam 2
* Exam 3 <-> Exam 3
* Exam 4 <-> Exam 4
* Exam 5 <-> Exam 5

* Next -> Conclusion

Expand Down
2 changes: 0 additions & 2 deletions src/adonisjs/public/translator/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,6 @@ class Translator {
for (let c = 1; c < compiled.length; c++) {
const pr = (c > 1 && compiled[c - 1].type == 'linefeed') ? c - 2 : c - 1
if (compiled[c].type == 'option') {
console.log('=== previous')
console.log(compiled[pr])
let stype = compiled[c].subtype
if (compiled[pr].type == 'input' && compiled[pr].subtype &&
compiled[pr].subtype == 'choice' && compiled[pr].options == null) {
Expand Down

0 comments on commit d4260e8

Please sign in to comment.