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
66024bac
Commit
66024bac
authored
8 years ago
by
Jaden Diefenbaugh
Browse files
Options
Downloads
Patches
Plain Diff
add aliases to groups, save report item objs instead of just ids
parent
f98eda52
No related branches found
No related tags found
1 merge request
!223
Reports overhaul
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/reports/static/reports/app/services/groupsService.js
+79
-33
79 additions, 33 deletions
.../web/reports/static/reports/app/services/groupsService.js
with
79 additions
and
33 deletions
beat/web/reports/static/reports/app/services/groupsService.js
+
79
−
33
View file @
66024bac
...
...
@@ -39,7 +39,8 @@ angular.module('reportApp').factory('GroupsService', ['$http', function($http){
this
.
_name
=
name
;
this
.
_analyzer
=
''
;
this
.
_experimentNames
=
new
Set
();
this
.
_reportItemIds
=
new
Set
();
this
.
_reportItems
=
[];
this
.
_aliases
=
{};
}
// get the experiment names in this group
...
...
@@ -47,9 +48,9 @@ angular.module('reportApp').factory('GroupsService', ['$http', function($http){
return
Array
.
from
(
this
.
_experimentNames
);
}
// get the
ids of
report items
that use
this group
get
reportItem
Id
s
()
{
return
Array
.
from
(
this
.
_reportItem
Id
s
);
// get the report items
in
this group
get
reportItems
()
{
return
Array
.
from
(
this
.
_reportItems
);
}
// get the group name
...
...
@@ -62,40 +63,87 @@ angular.module('reportApp').factory('GroupsService', ['$http', function($http){
return
this
.
_analyzer
;
}
// gets the aliases for the experiments in the group
get
aliases
()
{
return
this
.
_aliases
;
}
set
analyzer
(
analyzer
)
{
console
.
log
(
`setting anayzler =
${
analyzer
}
`
);
this
.
_analyzer
=
analyzer
;
}
// add an exp to this group
addExperiment
(
expName
)
{
return
this
.
_experimentNames
.
add
(
expName
);
addExperiment
(
expName
,
analyzer
)
{
let
res
=
this
.
_experimentNames
.
add
(
expName
);
if
(
this
.
_experimentNames
.
size
===
0
&&
analyzer
){
this
.
analyzer
=
analyzer
;
}
if
(
!
this
.
aliases
[
expName
]){
let
autoAlias
=
expName
.
split
(
'
/
'
).
pop
();
this
.
setAliasToExperiment
(
autoAlias
,
expName
);
}
return
res
;
}
// rm an exp from this group
removeExperiment
(
expName
)
{
return
this
.
_experimentNames
.
delete
(
expName
);
let
res
=
this
.
_experimentNames
.
delete
(
expName
);
if
(
this
.
_experimentNames
.
size
===
0
){
this
.
analyzer
=
''
;
}
this
.
unsetExperimentAlias
(
expName
);
return
res
;
}
// add an exp to this group
addReportItem
(
id
)
{
return
this
.
_reportItemIds
.
add
(
id
);
// add an item (table or plot) to this group
// if the id already exists, it just replaces the old
// element with the new one
addReportItem
(
id
,
content
)
{
let
newEl
=
{
id
,
content
};
let
alreadyAddedEl
=
this
.
_reportItems
.
find
(
i
=>
i
.
id
===
id
);
if
(
alreadyAddedEl
){
let
idx
=
this
.
_reportItems
.
indexOf
(
alreadyAddedEl
);
return
this
.
_reportItems
.
splice
(
idx
,
1
,
newEl
);
}
else
{
return
this
.
_reportItems
.
push
(
newEl
);
}
}
// rm an exp from this group
removeReportItem
(
id
)
{
return
this
.
_reportItemIds
.
delete
(
id
);
let
idx
=
this
.
_reportItems
.
indexOf
(
this
.
_reportItems
.
find
(
o
=>
o
.
id
===
id
));
return
this
.
_reportItems
.
splice
(
idx
,
1
);
}
// (re)sets an alias to an experiment in the group
setAliasToExperiment
(
alias
,
expName
)
{
if
(
!
this
.
experiments
.
includes
(
expName
)){
return
false
;
}
this
.
_aliases
[
expName
]
=
alias
;
}
// unsets an alias for an experiment
unsetExperimentAlias
(
expName
)
{
return
delete
this
.
_aliases
[
expName
];
}
};
// gets groups
groupsServiceInstance
.
groups
=
groupData
;
// TODO: move this hacky state to the addReportItem miniwindows
groupsServiceInstance
.
activeGroup
=
''
;
// serializes groups as an object with form:
// {
// <group name 1>: { experiments: [], reportItem
Id
s: [], analyzer: '' },
// <group name 1>: { experiments: [], reportItems: [], analyzer: '' },
// ...
// }
groupsServiceInstance
.
serializeGroups
=
()
=>
{
...
...
@@ -103,8 +151,9 @@ angular.module('reportApp').factory('GroupsService', ['$http', function($http){
.
map
(
g
=>
{
return
{
[
g
.
name
]:
{
experiments
:
g
.
experiments
,
reportItemIds
:
g
.
reportItemIds
,
analyzer
:
g
.
analyzer
reportItems
:
g
.
reportItems
,
analyzer
:
g
.
analyzer
,
aliases
:
g
.
aliases
}
};
})
...
...
@@ -126,8 +175,6 @@ angular.module('reportApp').factory('GroupsService', ['$http', function($http){
let
g
=
new
Group
(
name
);
groupData
.
push
(
g
);
// change active group to newest group by default
groupsServiceInstance
.
activeGroup
=
g
.
name
;
return
g
;
};
...
...
@@ -141,27 +188,26 @@ angular.module('reportApp').factory('GroupsService', ['$http', function($http){
// load group info from the serialized format:
// {
// <group name 1>: { experiments: [], reportItem
Id
s: [], analyzer: '' },
// <group name 1>: { experiments: [], reportItems: [], analyzer: '' },
// ...
// }
groupsServiceInstance
.
loadGroups
=
(
data
)
=>
{
// wipe data and load groups
groupData
.
splice
(
0
,
groupData
.
length
);
// if there's no group data, create a default one
if
(
!
data
||
Object
.
keys
(
data
).
length
===
0
){
groupsServiceInstance
.
createGroup
(
'
default
'
);
return
;
}
Object
.
entries
(
data
)
Object
.
entries
(
data
||
{})
// sometimes we get an empty string for name for some reason
.
filter
(([
groupName
,
gData
])
=>
groupName
.
length
>
0
)
.
forEach
(([
groupName
,
gData
])
=>
{
let
g
=
groupsServiceInstance
.
createGroup
(
groupName
);
g
.
analyzer
=
gData
.
analyzer
;
gData
.
experiments
.
forEach
(
n
=>
g
.
addExperiment
(
n
));
gData
.
reportItemIds
.
forEach
(
id
=>
g
.
addReportItem
(
id
));
let
analyzer
=
gData
.
analyzer
||
''
;
let
experiments
=
gData
.
experiments
||
[];
let
reportItems
=
gData
.
reportItems
||
[];
let
aliases
=
gData
.
aliases
||
{};
g
.
analyzer
=
analyzer
;
experiments
.
forEach
(
n
=>
g
.
addExperiment
(
n
));
reportItems
.
forEach
(
i
=>
g
.
addReportItem
(
i
.
id
,
i
.
content
));
Object
.
entries
(
aliases
).
forEach
(([
e
,
a
])
=>
g
.
setAliasToExperiment
(
a
,
e
));
});
};
...
...
@@ -198,11 +244,11 @@ angular.module('reportApp').factory('GroupsService', ['$http', function($http){
};
// add report item to group
groupsServiceInstance
.
addReportItemToGroup
=
(
id
,
groupName
)
=>
{
groupsServiceInstance
.
addReportItemToGroup
=
(
id
,
content
,
groupName
)
=>
{
checkForGroup
(
groupName
);
let
group
=
groupData
.
find
(
g
=>
g
.
name
===
groupName
);
group
.
addReportItem
(
id
);
group
.
addReportItem
(
id
,
content
);
};
// rm report item id from group
...
...
@@ -214,7 +260,7 @@ angular.module('reportApp').factory('GroupsService', ['$http', function($http){
// gets group for a report item's id
groupsServiceInstance
.
getReportItemGroup
=
(
id
)
=>
{
return
groupData
.
find
(
g
=>
g
.
reportItem
Id
s
.
in
cludes
(
id
));
return
groupData
.
find
(
g
=>
g
.
reportItems
.
f
in
d
(
i
=>
i
.
id
===
id
));
};
// helper to assert that a group exists
...
...
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