Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-webui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-webui
Commits
de53f4ee
Commit
de53f4ee
authored
3 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
ENH: finished initial implementation of data analysis extension
parent
81a4a21f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/js/ext_data_analysis.js
+65
-33
65 additions, 33 deletions
src/core/js/ext_data_analysis.js
with
65 additions
and
33 deletions
src/core/js/ext_data_analysis.js
+
65
−
33
View file @
de53f4ee
/*
* ** header with license infoc
* ...
* ** header v3.0
* This file is a part of the CaosDB Project.
*
* Copyright (C) 2021 Alexander Schlemmer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* ** end header
*/
'
use strict
'
;
/**
* description of the module ...
* Module that adds data analysis buttons to records of a specified record type.
* These record types are configured in a file called data_analysis.json. The record type
* usually has Dataset as Parent and contains references to multiple datasets that are used
* as input for the data analysis script.
*
* @module ext_flight_preview
* Currently this module supports only one analysis script. It is planned to expand this for
* multiple configured analysis scripts.
*
* @module ext_data_analysis
* @version 0.1
*
* @requires somelibrary
* (pass the dependencies as arguments)
*/
var
ext_
flight_preview
=
function
(
somelibrary
)
{
var
ext_
data_analysis
=
function
(
somelibrary
)
{
var
init
=
function
(
toolbox
)
{
/* initialization of the module */
this
.
add_ui
();
}
/**
* doc string
* Add the analysis buttons to the correct records.
*/
var
add_ui
=
async
function
()
{
// load configuration for data analysis module
var
config
=
await
load_config
(
"
data_analysis.json
"
);
var
ents
=
getEntities
();
for
(
ent
of
ents
)
{
// Check parents for configured parent:
var
parents
=
getParents
(
ent
);
var
found
=
false
;
for
(
parent
of
parents
)
{
if
(
parents
[
0
].
name
==
config
[
"
supported_dataset_parent
"
])
{
found
=
true
;
break
;
}
}
if
(
found
==
true
)
{
var
button
=
$
(
"
<button>
"
+
config
[
"
data_analysis_title
"
]
+
"
</button>
"
);
let
entity_id
=
getEntityID
(
ent
);
let
analysis_script
=
config
[
"
analysis_script_file
"
];
button
.
click
(
_
=>
runCorrAnalysis
(
entity_id
,
analysis_script
));
$
(
ent
).
find
(
"
.caosdb-v-entity-header-buttons-list
"
).
prepend
(
button
);
}
}
}
/**
* Run the analysis script. This function is run by the
* analysis button and runs the configured python script in the background.
* The current entity id (which is usually a sub record type of a dataset is passed
* as argument "--entity" to the script file.
*/
var
some_function
=
function
(
arg1
,
arg2
)
{
function
runAnalysis
(
entity_id
,
analysis_script
)
{
connection
.
runScript
(
analysis_script
,
{
"
-Oentity
"
:
entity_id
});
}
/* the main function must return the initialization of the module */
...
...
@@ -38,29 +92,7 @@ $(document).ready(function() {
// use a variable starting with `BUILD_MODULE_` to enable your module
// the build variable has to be enabled in the `build.properties.d/` directory.
// Otherwise the module will not be activated.
if
(
"
${BUILD_MODULE_EXT_
BOTTOM_LINE
}
"
===
"
ENABLED
"
)
{
caosdb_modules
.
register
(
ext_
flight_preview
);
if
(
"
${BUILD_MODULE_EXT_
DATA_ANALYSIS
}
"
===
"
ENABLED
"
)
{
caosdb_modules
.
register
(
ext_
data_analysis
);
}
});
// -------------------------
function
runCorrAnalysis
(
entity_id
)
{
console
.
log
(
entity_id
);
connection
.
runScript
(
""
,
{
"
-Oentity
"
:
entity_id
});
}
var
ents
=
getEntities
();
for
(
ent
of
ents
)
{
var
parents
=
getParents
(
ent
);
if
(
parents
.
length
>
0
&&
parents
[
0
].
name
==
""
)
{
var
button
=
$
(
"
<button>Data Analysis</button>
"
);
button
.
click
((
function
(
entity_id
){
return
()
=>
runCorrAnalysis
(
entity_id
);})(
getEntityID
(
ent
)));
$
(
ent
).
find
(
"
.caosdb-v-entity-header-buttons-list
"
).
prepend
(
button
);
}
}
// load configuration for data analysis module
var
config
=
await
load_config
(
"
data_analysis.json
"
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment