Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
279cdb70
Commit
279cdb70
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Remove a lot of code redundancy
parent
87cf04a8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/static/css/nopaque.css
+3
-0
3 additions, 0 deletions
app/static/css/nopaque.css
app/static/js/nopaque.lists.js
+30
-102
30 additions, 102 deletions
app/static/js/nopaque.lists.js
app/templates/main/dashboard.html.j2
+2
-2
2 additions, 2 deletions
app/templates/main/dashboard.html.j2
with
35 additions
and
104 deletions
app/static/css/nopaque.css
+
3
−
0
View file @
279cdb70
...
...
@@ -90,6 +90,9 @@ indicator will show up how the column is sorted right now.; */
.service
[
data-service
]
:before
{
content
:
"help"
;
}
.service
[
data-service
=
"corpus"
]
:before
{
content
:
"book"
;
}
.service
[
data-service
=
"merge_images"
]
:before
{
content
:
"burst_mode"
;
}
...
...
This diff is collapsed.
Click to expand it.
app/static/js/nopaque.lists.js
+
30
−
102
View file @
279cdb70
class
CorpusList
extends
List
{
constructor
(
idOrElement
,
subscriberList
,
options
=
{})
{
super
(
idOrElement
,
{...
CorpusList
.
DEFAULT_OPTIONS
,
...
options
});
class
RessourceList
extends
List
{
constructor
(
idOrElement
,
subscriberList
,
dataMapper
=
null
,
options
=
{})
{
super
(
idOrElement
,
{...
RessourceList
.
options
,
...
options
});
this
.
dataMapper
=
dataMapper
;
subscriberList
.
push
(
this
);
}
_init
(
corpora
)
{
this
.
add
Corpora
(
Object
.
values
(
corpora
));
_init
(
ressources
)
{
this
.
add
Ressources
(
Object
.
values
(
ressources
));
}
_update
(
patch
)
{
let
item
,
corpusStatusElement
,
operation
,
pathArray
;
let
item
,
pathArray
;
for
(
operation
of
patch
)
{
/* "/
corpus
Id/valueName" -> ["
corpus
Id", "valueName"] */
for
(
let
operation
of
patch
)
{
/* "/
ressource
Id/valueName" -> ["
ressource
Id", "valueName"] */
pathArray
=
operation
.
path
.
split
(
"
/
"
).
slice
(
1
);
switch
(
operation
.
op
)
{
case
"
add
"
:
this
.
addCorpora
([
operation
.
value
]);
break
;
case
"
remove
"
:
this
.
remove
(
"
id
"
,
pathArray
[
0
]);
break
;
case
"
replace
"
:
item
=
this
.
get
(
"
id
"
,
pathArray
[
0
])[
0
];
switch
(
pathArray
[
1
])
{
case
"
status
"
:
item
.
values
({
status
:
operation
.
value
,
_status
:
operation
.
value
});
break
;
default
:
break
;
}
default
:
break
;
}
}
}
addCorpora
(
corpora
)
{
let
data
=
[];
for
(
let
corpus
of
corpora
)
{
data
.
push
({
description
:
corpus
.
description
,
id
:
corpus
.
id
,
link
:
`/corpora/
${
corpus
.
id
}
`
,
status
:
corpus
.
status
,
title
:
corpus
.
title
});
}
this
.
add
(
data
);
}
}
CorpusList
.
DEFAULT_OPTIONS
=
{
item
:
`<tr>
<td>
<a class="btn-floating disabled">
<i class="material-icons">book</i>
</a>
</td>
<td>
<b class="title"></b><br>
<i class="description"></i>
</td>
<td>
<span class="badge new status" data-badge-caption=""></span>
</td>
<td class="right-align">
<a class="btn-small waves-effect waves-light link">View<i class="material-icons right">send</i>
</td>
</tr>`
,
page
:
4
,
pagination
:
{
innerWindow
:
8
,
outerWindow
:
1
},
valueNames
:
[
"
description
"
,
"
title
"
,
{
data
:
[
"
id
"
]},
{
name
:
"
link
"
,
attr
:
"
href
"
},
{
name
:
"
status
"
,
attr
:
"
data-status
"
}]};
class
JobList
extends
List
{
constructor
(
idOrElement
,
subscriberList
,
options
=
{})
{
super
(
idOrElement
,
{...
JobList
.
DEFAULT_OPTIONS
,
...
options
});
subscriberList
.
push
(
this
);
}
_init
(
jobs
)
{
this
.
addJobs
(
Object
.
values
(
jobs
));
}
_update
(
patch
)
{
let
item
,
jobStatusElement
,
operation
,
pathArray
;
for
(
operation
of
patch
)
{
/* "/jobId/valueName" -> ["jobId", "valueName"] */
pathArray
=
operation
.
path
.
split
(
"
/
"
).
slice
(
1
);
switch
(
operation
.
op
)
{
case
"
add
"
:
if
(
pathArray
.
includes
(
"
results
"
))
{
break
;}
this
.
addJobs
([
operation
.
value
]);
this
.
addRessources
([
operation
.
value
]);
break
;
case
"
remove
"
:
this
.
remove
(
"
id
"
,
pathArray
[
0
]);
...
...
@@ -121,20 +40,29 @@ class JobList extends List {
}
addJobs
(
jobs
)
{
let
data
=
[];
for
(
let
job
of
jobs
)
{
data
.
push
({
description
:
job
.
description
,
id
:
job
.
id
,
link
:
`/jobs/
${
job
.
id
}
`
,
service
:
job
.
service
,
status
:
job
.
status
,
title
:
job
.
title
});
addRessources
(
ressources
)
{
if
(
this
.
dataMapper
)
{
this
.
add
(
ressources
.
map
(
x
=>
this
.
dataMapper
(
x
)));
}
else
{
this
.
add
(
ressources
);
}
this
.
add
(
data
);
}
}
JobList
.
DEFAULT_OPTIONS
=
{
RessourceList
.
dataMapper
=
{
corpus
:
corpus
=>
({
description
:
corpus
.
description
,
id
:
corpus
.
id
,
link
:
`/corpora/
${
corpus
.
id
}
`
,
service
:
"
corpus
"
,
status
:
corpus
.
status
,
title
:
corpus
.
title
}),
job
:
job
=>
({
description
:
job
.
description
,
id
:
job
.
id
,
link
:
`/jobs/
${
job
.
id
}
`
,
service
:
job
.
service
,
status
:
job
.
status
,
title
:
job
.
title
})
};
RessourceList
.
options
=
{
item
:
`<tr>
<td>
<a class="btn-floating disabled">
...
...
This diff is collapsed.
Click to expand it.
app/templates/main/dashboard.html.j2
+
2
−
2
View file @
279cdb70
...
...
@@ -86,7 +86,7 @@
</div>
<script>
var corpusList = new
Corpus
List("corpora", nopaque.corporaSubscribers);
var jobList = new
Job
List("jobs", nopaque.jobsSubscribers);
var corpusList = new
Ressource
List("corpora", nopaque.corporaSubscribers
, RessourceList.dataMapper.corpus
);
var jobList = new
Ressource
List("jobs", nopaque.jobsSubscribers
, RessourceList.dataMapper.job
);
</script>
{% endblock %}
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