Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
KnowageLabs
Knowage-Server
Commits
92cfee09
Commit
92cfee09
authored
May 26, 2022
by
dbulatovicx32
Browse files
implemented save method for monitoring
parent
6a9a8566
Changes
1
Hide whitespace changes
Inline
Side-by-side
knowage-vue/src/modules/managers/datasetManagement/detailView/typeCard/preparedDataset/DatasetManagementPreparedDataset.vue
View file @
92cfee09
...
...
@@ -2,121 +2,141 @@
<Card
class=
"p-m-2"
>
<template
#content
>
<form
class=
"p-fluid p-formgrid p-grid"
>
<div
class=
"p-field p-col-
6
"
>
<div
class=
"p-field p-col-
4
"
>
<Button
:label=
"$t('managers.datasetManagement.monitoring')"
class=
"kn-button kn-button--primary"
@
click=
"showMonitoringDialog = true"
/>
</div>
<div
class=
"p-field p-col-
6
"
>
<div
class=
"p-field p-col-
4
"
>
<Button
:label=
"$t('managers.datasetManagement.openDP')"
class=
"kn-button kn-button--primary"
@
click=
"prepareForDataPreparation"
/>
</div>
</form>
</
template
>
</Card>
<MonitoringDialog
:visibility=
"showMonitoringDialog"
:dataset=
"selectedDataset"
@
close=
"showMonitoringDialog = false"
/>
<MonitoringDialog
:visibility=
"showMonitoringDialog"
:dataset=
"selectedDataset"
@
close=
"showMonitoringDialog = false"
@
save=
"updateDatasetAndSave"
/>
</template>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
import
{
AxiosResponse
}
from
'
axios
'
import
descriptor
from
'
./DatasetManagementPreparedDataset.json
'
import
Card
from
'
primevue/card
'
import
MonitoringDialog
from
'
@/modules/workspace/dataPreparation/DataPreparationMonitoring/DataPreparationMonitoringDialog.vue
'
import
{
defineComponent
}
from
'
vue
'
import
{
AxiosResponse
}
from
'
axios
'
import
descriptor
from
'
./DatasetManagementPreparedDataset.json
'
import
Card
from
'
primevue/card
'
import
MonitoringDialog
from
'
@/modules/workspace/dataPreparation/DataPreparationMonitoring/DataPreparationMonitoringDialog.vue
'
export
default
defineComponent
({
components
:
{
Card
,
MonitoringDialog
},
props
:
{
selectedDataset
:
{
type
:
Object
as
any
},
dataSources
:
{
type
:
Array
as
any
}
},
emits
:
[
'
touched
'
],
data
()
{
return
{
descriptor
,
dataset
:
{}
as
any
,
availableDatasets
:
[]
as
any
,
avroDatasets
:
[]
as
any
,
showMonitoringDialog
:
false
}
},
created
()
{
export
default
defineComponent
({
components
:
{
Card
,
MonitoringDialog
},
props
:
{
selectedDataset
:
{
type
:
Object
as
any
},
dataSources
:
{
type
:
Array
as
any
}
},
emits
:
[
'
touched
'
],
data
()
{
return
{
descriptor
,
dataset
:
{}
as
any
,
availableDatasets
:
[]
as
any
,
avroDatasets
:
[]
as
any
,
showMonitoringDialog
:
false
}
},
created
()
{
this
.
dataset
=
this
.
selectedDataset
},
watch
:
{
selectedDataset
()
{
this
.
dataset
=
this
.
selectedDataset
}
},
methods
:
{
async
loadDataset
(
datasetId
:
Number
)
{
await
this
.
$http
.
get
(
process
.
env
.
VUE_APP_RESTFUL_SERVICES_PATH
+
`1.0/datasets/dataset/id/
${
datasetId
}
`
)
.
then
((
response
:
AxiosResponse
<
any
>
)
=>
{
this
.
dataset
=
response
.
data
[
0
]
})
.
catch
(()
=>
{})
},
watch
:
{
selectedDataset
()
{
this
.
dataset
=
this
.
selectedDataset
}
routeToDataPreparation
()
{
let
path
=
''
this
.
$confirm
.
require
({
header
:
this
.
$t
(
'
managers.datasetManagement.openDP
'
),
message
:
this
.
$t
(
'
managers.datasetManagement.confirmMsg
'
),
icon
:
'
pi pi-exclamation-triangle
'
,
accept
:
()
=>
{
this
.
$router
.
push
(
path
)
}
})
},
methods
:
{
routeToDataPreparation
()
{
let
path
=
''
this
.
$confirm
.
require
({
header
:
this
.
$t
(
'
managers.datasetManagement.openDP
'
),
message
:
this
.
$t
(
'
managers.datasetManagement.confirmMsg
'
),
icon
:
'
pi pi-exclamation-triangle
'
,
accept
:
()
=>
{
this
.
$router
.
push
(
path
)
}
})
},
async
getAllAvroDataSets
()
{
await
this
.
$http
.
get
(
process
.
env
.
VUE_APP_RESTFUL_SERVICES_PATH
+
`3.0/datasets/avro`
)
.
then
((
response
:
AxiosResponse
<
any
>
)
=>
{
this
.
avroDatasets
=
response
.
data
})
.
catch
(()
=>
{})
},
async
getAllAvroDataSets
()
{
await
this
.
$http
.
get
(
process
.
env
.
VUE_APP_RESTFUL_SERVICES_PATH
+
`3.0/datasets/avro`
)
.
then
((
response
:
AxiosResponse
<
any
>
)
=>
{
this
.
avroDatasets
=
response
.
data
})
.
catch
(()
=>
{})
},
async
prepareForDataPreparation
()
{
await
this
.
getAllAvroDataSets
()
await
this
.
openDataPreparation
(
this
.
selectedDataset
)
},
async
prepareForDataPreparation
()
{
await
this
.
getAllAvroDataSets
()
await
this
.
openDataPreparation
(
this
.
selectedDataset
)
},
isAvroReady
(
dsId
:
Number
)
{
if
(
this
.
avroDatasets
.
indexOf
(
dsId
)
>=
0
||
(
dsId
&&
this
.
avroDatasets
.
indexOf
(
dsId
.
toString
()))
>=
0
)
return
true
else
return
false
},
isAvroReady
(
dsId
:
Number
)
{
if
(
this
.
avroDatasets
.
indexOf
(
dsId
)
>=
0
||
(
dsId
&&
this
.
avroDatasets
.
indexOf
(
dsId
.
toString
()))
>=
0
)
return
true
else
return
false
},
openDataPreparation
(
dataset
:
any
)
{
if
(
dataset
.
dsTypeCd
==
'
Prepared
'
)
{
//edit existing data prep
this
.
$http
.
get
(
process
.
env
.
VUE_APP_RESTFUL_SERVICES_PATH
+
`3.0/datasets/advanced/
${
dataset
.
id
}
`
).
then
(
(
response
:
AxiosResponse
<
any
>
)
=>
{
let
instanceId
=
response
.
data
.
configuration
.
dataPrepInstanceId
this
.
$http
.
get
(
process
.
env
.
VUE_APP_DATA_PREPARATION_PATH
+
`1.0/process/by-instance-id/
${
instanceId
}
`
).
then
(
(
response
:
AxiosResponse
<
any
>
)
=>
{
let
transformations
=
response
.
data
.
definition
let
processId
=
response
.
data
.
id
let
datasetId
=
response
.
data
.
instance
.
dataSetId
if
(
this
.
isAvroReady
(
datasetId
))
// check if Avro file has been deleted or not
this
.
$router
.
push
({
name
:
'
data-preparation
'
,
params
:
{
id
:
datasetId
,
transformations
:
JSON
.
stringify
(
transformations
),
processId
:
processId
,
instanceId
:
instanceId
,
dataset
:
JSON
.
stringify
(
dataset
)
}
})
else
{
this
.
$store
.
commit
(
'
setInfo
'
,
{
title
:
'
Avro file is missing
'
,
msg
:
'
Generate it again and then retry
'
})
}
},
()
=>
{
this
.
$store
.
commit
(
'
setError
'
,
{
title
:
'
Save error
'
,
msg
:
'
Cannot create process
'
})
openDataPreparation
(
dataset
:
any
)
{
if
(
dataset
.
dsTypeCd
==
'
Prepared
'
)
{
//edit existing data prep
this
.
$http
.
get
(
process
.
env
.
VUE_APP_RESTFUL_SERVICES_PATH
+
`3.0/datasets/advanced/
${
dataset
.
id
}
`
).
then
(
(
response
:
AxiosResponse
<
any
>
)
=>
{
let
instanceId
=
response
.
data
.
configuration
.
dataPrepInstanceId
this
.
$http
.
get
(
process
.
env
.
VUE_APP_DATA_PREPARATION_PATH
+
`1.0/process/by-instance-id/
${
instanceId
}
`
).
then
(
(
response
:
AxiosResponse
<
any
>
)
=>
{
let
transformations
=
response
.
data
.
definition
let
processId
=
response
.
data
.
id
let
datasetId
=
response
.
data
.
instance
.
dataSetId
if
(
this
.
isAvroReady
(
datasetId
))
// check if Avro file has been deleted or not
this
.
$router
.
push
({
name
:
'
data-preparation
'
,
params
:
{
id
:
datasetId
,
transformations
:
JSON
.
stringify
(
transformations
),
processId
:
processId
,
instanceId
:
instanceId
,
dataset
:
JSON
.
stringify
(
dataset
)
}
})
else
{
this
.
$store
.
commit
(
'
setInfo
'
,
{
title
:
'
Avro file is missing
'
,
msg
:
'
Generate it again and then retry
'
})
}
)
},
()
=>
{
this
.
$store
.
commit
(
'
setError
'
,
{
title
:
'
Cannot open data preparation
'
})
}
)
}
else
if
(
this
.
isAvroReady
(
dataset
.
id
))
{
// original dataset already exported in Avro
this
.
$router
.
push
({
name
:
'
data-preparation
'
,
params
:
{
id
:
dataset
.
id
}
})
}
else
{
this
.
$store
.
commit
(
'
setInfo
'
,
{
title
:
'
Avro file is missing
'
,
msg
:
'
Generate it again and then retry
'
})
}
},
()
=>
{
this
.
$store
.
commit
(
'
setError
'
,
{
title
:
'
Save error
'
,
msg
:
'
Cannot create process
'
})
}
)
},
()
=>
{
this
.
$store
.
commit
(
'
setError
'
,
{
title
:
'
Cannot open data preparation
'
})
}
)
}
else
if
(
this
.
isAvroReady
(
dataset
.
id
))
{
// original dataset already exported in Avro
this
.
$router
.
push
({
name
:
'
data-preparation
'
,
params
:
{
id
:
dataset
.
id
}
})
}
else
{
this
.
$store
.
commit
(
'
setInfo
'
,
{
title
:
'
Avro file is missing
'
,
msg
:
'
Generate it again and then retry
'
})
}
},
async
updateDatasetAndSave
(
newConfig
)
{
this
.
showMonitoringDialog
=
false
await
this
.
$http
.
patch
(
process
.
env
.
VUE_APP_DATA_PREPARATION_PATH
+
'
1.0/instance/
'
+
newConfig
.
instanceId
,
{
config
:
newConfig
.
config
},
{
headers
:
{
Accept
:
'
application/json, */*
'
}
}).
then
(
()
=>
{
this
.
loadDataset
(
this
.
selectedDataset
.
id
)
},
()
=>
{
this
.
$store
.
commit
(
'
setError
'
,
{
title
:
this
.
$t
(
'
common.error.saving
'
),
msg
:
this
.
$t
(
'
managers.workspaceManagement.dataPreparation.errors.updatingSchedulation
'
)
})
}
)
}
})
}
})
</
script
>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment