Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
beat
beat.web
Commits
f0155594
Commit
f0155594
authored
7 years ago
by
jaden
Browse files
Options
Downloads
Patches
Plain Diff
store plot widget configs in report state tree,
#33
parent
0d7c843a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!223
Reports overhaul
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beat/web/reports/static/reports/app/directives/edit/plotItem.js
+10
-2
10 additions, 2 deletions
...eb/reports/static/reports/app/directives/edit/plotItem.js
beat/web/reports/static/reports/app/services/plotService.js
+36
-17
36 additions, 17 deletions
beat/web/reports/static/reports/app/services/plotService.js
with
46 additions
and
19 deletions
beat/web/reports/static/reports/app/directives/edit/plotItem.js
+
10
−
2
View file @
f0155594
...
...
@@ -40,11 +40,19 @@ angular.module('reportApp')
// container for the plots applet to insert into
scope
.
renderDivId
=
`
${
scope
.
domId
}
-render`
;
// the callback for when the plot renders
// (called every time the plot re-renders, e.g. user changes config/merged
const
updatePlotConfig
=
(
selectedPlotter
,
selectedConfig
,
isMerged
)
=>
{
scope
.
content
.
merged
=
isMerged
;
scope
.
content
.
savedPlotter
=
selectedPlotter
;
scope
.
content
.
savedConfig
=
selectedConfig
;
};
// wait until the container html element is rendered.
// angular will run these functions called with $timeout
// after everything has been rendered
$timeout
(
function
()
{
PlotService
.
addPlot
(
scope
.
group
,
scope
.
itemId
,
scope
.
renderDivId
);
PlotService
.
addPlot
(
scope
.
group
,
scope
.
itemId
,
scope
.
renderDivId
,
updatePlotConfig
);
});
let
plotTimer
;
...
...
@@ -58,7 +66,7 @@ angular.module('reportApp')
// redo the render
if
(
el
&&
el
.
childNodes
.
length
>
0
){
el
.
innerHTML
=
''
;
PlotService
.
addPlot
(
scope
.
group
,
scope
.
itemId
,
scope
.
renderDivId
);
PlotService
.
addPlot
(
scope
.
group
,
scope
.
itemId
,
scope
.
renderDivId
,
updatePlotConfig
);
}
};
...
...
This diff is collapsed.
Click to expand it.
beat/web/reports/static/reports/app/services/plotService.js
+
36
−
17
View file @
f0155594
...
...
@@ -58,10 +58,10 @@ angular.module('reportApp').factory('PlotService', ['UrlService', function(UrlSe
}
// a plot obj can have different plotters,
let
plotter
=
content
.
savedPlotter
||
plotters
.
find
(
p
=>
p
.
name
===
defaults
.
plotter
);
let
plotter
=
plotters
.
find
(
p
=>
p
.
name
===
content
.
savedPlotter
)
||
plotters
.
find
(
p
=>
p
.
name
===
defaults
.
plotter
);
// which can each have different configurations (plotter parameter instances)
let
config
=
content
.
savedConfig
||
plotterParameters
.
find
(
pp
=>
pp
.
name
===
defaults
.
parameter
);
let
config
=
plotterParameters
.
find
(
pp
=>
pp
.
name
===
content
.
savedConfig
)
||
plotterParameters
.
find
(
pp
=>
pp
.
name
===
defaults
.
parameter
);
if
(
!
content
||
!
defaults
||
!
plotter
||
!
config
){
console
.
error
(
`plotter info not found: content:
${
content
}
defaults:
${
defaults
}
plotter:
${
plotter
}
config:
${
config
}
`
);
...
...
@@ -127,23 +127,17 @@ angular.module('reportApp').factory('PlotService', ['UrlService', function(UrlSe
return
returnStruct
;
};
// makes the call to the server, via some helper funcs found in the global namespace
const
fetchRenderUsingStruct
=
(
requestData
,
containerId
)
=>
{
// the 'url_prefix' field found throughout the BEAT code is confusing,
// but it seems to always be an empty string now
const
urlPrefix
=
''
;
//UrlService.getApiSegment().split('/').filter(s => s.length > 0).join('/');
const
fetchDownload
=
(
requestData
,
contentType
)
=>
{
const
urlPrefix
=
''
;
// promisify this utils func so we dont have to deal with callback hell
return
new
Promise
((
resolve
,
reject
)
=>
{
beat
.
experiments
.
utils
.
displayPlot
(
beat
.
experiments
.
utils
.
getPlotData
(
// url_prefix
urlPrefix
,
// element to append render to
document
.
querySelector
(
`#
${
containerId
}
`
),
// spread out the request data to fill the next 3 spots
...
requestData
,
//
dont replace inner content
fals
e
,
//
content type: png, jpeg, pdf
contentTyp
e
,
// callback
(...
args
)
=>
{
// resolve promise
...
...
@@ -153,18 +147,43 @@ angular.module('reportApp').factory('PlotService', ['UrlService', function(UrlSe
});
};
// makes the call to the server, via some helper funcs found in the global namespace
const
fetchRender
=
(
requestData
,
containerId
,
onRenderCallback
)
=>
{
// the 'url_prefix' field found throughout the BEAT code is confusing,
// but it seems to always be an empty string now
const
urlPrefix
=
''
;
//UrlService.getApiSegment().split('/').filter(s => s.length > 0).join('/');
// promisify this utils func so we dont have to deal with callback hell
beat
.
experiments
.
utils
.
displayPlot
(
// url_prefix
urlPrefix
,
// element to append render to
document
.
querySelector
(
`#
${
containerId
}
`
),
// spread out the request data to fill the next 3 spots
...
requestData
,
// dont replace inner content
false
,
// callback
(
plotter
,
config
,
merged
)
=>
{
onRenderCallback
(
plotter
,
config
,
merged
);
}
);
};
// helper func to process a request to plot
const
processItem
=
(
group
,
itemId
,
containerId
)
=>
{
const
processItem
=
(
group
,
itemId
,
containerId
,
onRenderCallback
)
=>
{
const
reqData
=
constructPlotInfo
(
group
,
itemId
);
return
fetchRenderUsingStruct
(
reqData
,
containerId
);
fetchRender
(
reqData
,
containerId
,
onRenderCallback
);
};
// used if we arent ready to directly service requests
const
addItemToQueue
=
(
group
,
itemId
,
containerId
)
=>
{
const
addItemToQueue
=
(
group
,
itemId
,
containerId
,
onRenderCallback
)
=>
{
queue
.
push
([
group
,
itemId
,
containerId
containerId
,
onRenderCallback
]);
};
...
...
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