Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mentat-test
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
713
Mentat
mentat-test
Commits
f5b63bf1
Commit
f5b63bf1
authored
5 years ago
by
Jan Mach
Browse files
Options
Downloads
Patches
Plain Diff
Moved AODS JS code to Hawat module.
(Redmine issue:
#5278
)
parent
5de62c53
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/hawat/blueprints/design/static/js/hawat-jquery.js
+0
-94
0 additions, 94 deletions
lib/hawat/blueprints/design/static/js/hawat-jquery.js
lib/hawat/templates/hawat-main.js
+85
-6
85 additions, 6 deletions
lib/hawat/templates/hawat-main.js
lib/mentat/__init__.py
+1
-1
1 addition, 1 deletion
lib/mentat/__init__.py
with
86 additions
and
101 deletions
lib/hawat/blueprints/design/static/js/hawat-jquery.js
+
0
−
94
View file @
f5b63bf1
...
@@ -162,22 +162,6 @@ $(function() {
...
@@ -162,22 +162,6 @@ $(function() {
popup
.
toggleClass
(
"
hidden static-popover
"
);
popup
.
toggleClass
(
"
hidden static-popover
"
);
});
});
/*
$('body').popover({
selector: ".popover-html[data-toggle=popover]",
html: true,
trigger: 'hover click',
content: function() {
var content = $(this).attr("data-popover-content");
return $(content).children(".popover-body").html();
},
title: function() {
var title = $(this).attr("data-popover-content");
return $(title).children(".popover-heading").html();
}
});
*/
// Callback for triggering re-render of NVD3 charts within the bootstrap tabs.
// Callback for triggering re-render of NVD3 charts within the bootstrap tabs.
// Without this function the charts on invisible tabs are rendered incorrectly.
// Without this function the charts on invisible tabs are rendered incorrectly.
// References:
// References:
...
@@ -215,84 +199,6 @@ $(function() {
...
@@ -215,84 +199,6 @@ $(function() {
//window.dispatchEvent(new Event('resize'));
//window.dispatchEvent(new Event('resize'));
});
});
function
get_additional_data
(
url
,
param
,
elem
,
ident
,
snippets
)
{
// Append element for query result and populate it with AJAX spinner.
$
(
elem
).
append
(
'
<div class="query-result
'
+
ident
+
'
"><i class="fas fa-cog fa-spin" data-toggle="tooltip" title="
'
+
ident
+
'
"></i></div>
'
);
// Obtain reference for recently created element for query result.
elem
=
$
(
elem
).
children
(
'
.query-result.
'
+
ident
);
// Perform asynchronous request.
console
.
log
(
"
Request URL
"
+
url
+
"
, snippets:
"
+
snippets
);
var
jqxhr
=
$
.
get
(
url
)
.
done
(
function
(
data
)
{
if
(
data
.
search_result
&&
((
Array
.
isArray
(
data
.
search_result
)
&&
data
.
search_result
.
length
>
0
)
||
!
Array
.
isArray
(
data
.
search_result
)))
{
console
.
log
(
"
Result for
"
+
ident
+
"
query for:
"
+
param
);
console
.
debug
(
data
);
$
(
elem
).
children
().
tooltip
(
'
destroy
'
);
$
(
elem
).
empty
();
snippets
.
forEach
(
function
(
snippet
)
{
$
(
elem
).
append
(
data
.
snippets
[
snippet
]);
});
}
else
{
console
.
log
(
"
Empty result for
"
+
ident
+
"
query for:
"
+
param
);
console
.
debug
(
data
);
// Either insert information about empty query result.
//$(elem).html(
// '<i class="fas fa-check" data-toggle="tooltip" title="Empty result for ' + ident + ' query for ' + param + '"></i>'
//);
// Or remove the result element to reduce display clutter.
$
(
elem
).
children
().
tooltip
(
'
destroy
'
);
$
(
elem
).
remove
();
}
})
.
fail
(
function
(
data
)
{
console
.
log
(
"
Failed
"
+
ident
+
"
query for:
"
+
param
);
console
.
debug
(
data
);
// Either insert information about error query result.
$
(
elem
).
html
(
'
<i class="fas fa-times" data-toggle="tooltip" title="Error for
'
+
ident
+
'
query for
'
+
param
+
'
"></i>
'
);
// Or remove the result element to reduce display clutter.
//$(elem).children().tooltip('destroy');
//$(elem).remove();
})
.
always
(
function
()
{
//console.log("Finished " + ident + " query for: " + param);
});
}
function
fetch_aods
(
index
,
elem
)
{
obj_type
=
$
(
elem
).
data
(
'
object-type
'
);
obj_name
=
$
(
elem
).
data
(
'
object-name
'
);
aods
=
Hawat
.
get_aods
(
obj_type
);
console
.
log
(
"
Fetching additional data for object '
"
+
obj_type
+
"
--
"
+
obj_name
+
"
':
"
+
aods
.
reduce
(
function
(
sum
,
item
)
{
return
sum
+
'
'
+
item
.
endpoint
},
''
));
console
.
debug
(
aods
);
aods
.
forEach
(
function
(
aods_item
)
{
get_additional_data
(
Flask
.
url_for
(
aods_item
.
endpoint
,
aods_item
.
params
(
obj_name
)),
obj_name
,
elem
,
aods_item
.
ident
,
aods_item
.
snippets
);
});
}
$
(
"
.object-additional-data.onload
"
).
each
(
fetch_aods
);
$
(
'
.object-additional-data.ondemand
'
).
on
(
"
click
"
,
function
()
{
var
ref
=
$
(
this
);
ref
.
children
().
tooltip
(
'
destroy
'
);
ref
.
removeClass
(
'
ondemand
'
);
ref
.
empty
();
ref
.
off
(
'
click
'
);
fetch_aods
(
0
,
ref
);
});
// Special handling of '__EMPTY__' and '__ANY__' options in event search form
// Special handling of '__EMPTY__' and '__ANY__' options in event search form
// selects. This method stil can be improved, so that 'any' is capable of disabling
// selects. This method stil can be improved, so that 'any' is capable of disabling
// 'empty'.
// 'empty'.
...
...
This diff is collapsed.
Click to expand it.
lib/hawat/templates/hawat-main.js
+
85
−
6
View file @
f5b63bf1
// Global application module.
// Global
JS
application module
for Hawat
.
var
Hawat
=
(
function
()
{
var
Hawat
=
(
function
()
{
function
_build_param_builder
(
skeleton
,
rules
)
{
function
_build_param_builder
(
skeleton
,
rules
)
{
...
@@ -15,6 +15,55 @@ var Hawat = (function () {
...
@@ -15,6 +15,55 @@ var Hawat = (function () {
}
}
}
}
function
_get_aod
(
url
,
param
,
elem
,
ident
,
snippets
)
{
// Append element for query result and populate it with AJAX spinner.
$
(
elem
).
append
(
'
<div class="query-result
'
+
ident
+
'
"><i class="fas fa-cog fa-spin" data-toggle="tooltip" title="
'
+
ident
+
'
"></i></div>
'
);
// Obtain reference for recently created element for query result.
elem
=
$
(
elem
).
children
(
'
.query-result.
'
+
ident
);
// Perform asynchronous request.
console
.
log
(
"
Request URL
"
+
url
+
"
, snippets:
"
+
snippets
);
var
jqxhr
=
$
.
get
(
url
)
.
done
(
function
(
data
)
{
if
(
data
.
search_result
&&
((
Array
.
isArray
(
data
.
search_result
)
&&
data
.
search_result
.
length
>
0
)
||
!
Array
.
isArray
(
data
.
search_result
)))
{
console
.
log
(
"
Result for
"
+
ident
+
"
query for:
"
+
param
);
console
.
debug
(
data
);
$
(
elem
).
children
().
tooltip
(
'
destroy
'
);
$
(
elem
).
empty
();
snippets
.
forEach
(
function
(
snippet
)
{
$
(
elem
).
append
(
data
.
snippets
[
snippet
]);
});
}
else
{
console
.
log
(
"
Empty result for
"
+
ident
+
"
query for:
"
+
param
);
console
.
debug
(
data
);
// Either insert information about empty query result.
//$(elem).html(
// '<i class="fas fa-check" data-toggle="tooltip" title="Empty result for ' + ident + ' query for ' + param + '"></i>'
//);
// Or remove the result element to reduce display clutter.
$
(
elem
).
children
().
tooltip
(
'
destroy
'
);
$
(
elem
).
remove
();
}
})
.
fail
(
function
(
data
)
{
console
.
log
(
"
Failed
"
+
ident
+
"
query for:
"
+
param
);
console
.
debug
(
data
);
// Either insert information about error query result.
$
(
elem
).
html
(
'
<i class="fas fa-times" data-toggle="tooltip" title="Error for
'
+
ident
+
'
query for
'
+
param
+
'
"></i>
'
);
// Or remove the result element to reduce display clutter.
//$(elem).children().tooltip('destroy');
//$(elem).remove();
})
.
always
(
function
()
{
//console.log("Finished " + ident + " query for: " + param);
});
}
var
_configs
=
{
var
_configs
=
{
'
APPLICATION_ROOT
'
:
'
{{ hawat_current_app.config[
'
APPLICATION_ROOT
'
] }}
'
'
APPLICATION_ROOT
'
:
'
{{ hawat_current_app.config[
'
APPLICATION_ROOT
'
] }}
'
};
};
...
@@ -60,10 +109,14 @@ var Hawat = (function () {
...
@@ -60,10 +109,14 @@ var Hawat = (function () {
};
};
return
{
return
{
get_csags
:
function
()
{
get_
all_
csags
:
function
()
{
return
_csag
;
return
_csag
;
},
},
get_all_aodss
:
function
()
{
return
_aods
;
},
get_csag
:
function
(
name
)
{
get_csag
:
function
(
name
)
{
try
{
try
{
return
_csag
[
name
];
return
_csag
[
name
];
...
@@ -73,10 +126,6 @@ var Hawat = (function () {
...
@@ -73,10 +126,6 @@ var Hawat = (function () {
}
}
},
},
get_aodss
:
function
()
{
return
_aods
;
},
get_aods
:
function
(
name
)
{
get_aods
:
function
(
name
)
{
try
{
try
{
return
_aods
[
name
];
return
_aods
[
name
];
...
@@ -84,6 +133,36 @@ var Hawat = (function () {
...
@@ -84,6 +133,36 @@ var Hawat = (function () {
catch
(
err
)
{
catch
(
err
)
{
return
null
return
null
}
}
},
fetch_aods
:
function
(
index
,
elem
)
{
obj_type
=
$
(
elem
).
data
(
'
object-type
'
);
obj_name
=
$
(
elem
).
data
(
'
object-name
'
);
aods
=
Hawat
.
get_aods
(
obj_type
);
console
.
log
(
"
Fetching additional data for object '
"
+
obj_type
+
"
--
"
+
obj_name
+
"
':
"
+
aods
.
reduce
(
function
(
sum
,
item
)
{
return
sum
+
'
'
+
item
.
endpoint
},
''
));
console
.
debug
(
aods
);
aods
.
forEach
(
function
(
aods_item
)
{
_get_aod
(
Flask
.
url_for
(
aods_item
.
endpoint
,
aods_item
.
params
(
obj_name
)),
obj_name
,
elem
,
aods_item
.
ident
,
aods_item
.
snippets
);
});
}
}
};
};
})();
})();
$
(
function
()
{
$
(
"
.object-additional-data.onload
"
).
each
(
Hawat
.
fetch_aods
);
$
(
'
.object-additional-data.ondemand
'
).
on
(
"
click
"
,
function
()
{
var
ref
=
$
(
this
);
ref
.
children
().
tooltip
(
'
destroy
'
);
ref
.
removeClass
(
'
ondemand
'
);
ref
.
empty
();
ref
.
off
(
'
click
'
);
Hawat
.
fetch_aods
(
0
,
ref
);
});
});
This diff is collapsed.
Click to expand it.
lib/mentat/__init__.py
+
1
−
1
View file @
f5b63bf1
...
@@ -20,4 +20,4 @@ open-source project.
...
@@ -20,4 +20,4 @@ open-source project.
__author__
=
"
Jan Mach <jan.mach@cesnet.cz>
"
__author__
=
"
Jan Mach <jan.mach@cesnet.cz>
"
__credits__
=
"
Pavel Kácha <pavel.kacha@cesnet.cz>, Andrea Kropáčová <andrea.kropacova@cesnet.cz>
"
__credits__
=
"
Pavel Kácha <pavel.kacha@cesnet.cz>, Andrea Kropáčová <andrea.kropacova@cesnet.cz>
"
__version__
=
"
2.4.1
0
"
__version__
=
"
2.4.1
1
"
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