Commit 97889676 authored by Sven Franck's avatar Sven Franck

erp5_officejs_afs_directory: fetch lines of code form openhub, handle loading failures

parent 56f24826
......@@ -108,6 +108,9 @@
var response = data.target.response || data.target.responseText;
return PARSER.parseFromString(response, "text/xml")
.getElementsByTagName("total_code_lines")[0].childNodes[0].nodeValue;
})
.push(undefined, function () {
return "0";
});
}
......@@ -138,14 +141,14 @@
}
function retrieveTotalLinesFromPublisher(publisher) {
/*
var unique_software_list = [];
return new RSVP.Queue()
.push(function () {
return RSVP.all(publisher.free_software_list.map(function (software) {
var profile_url;
if (isValidProfileUrl(software.source_code_profile)) {
profile_url = postFixProfileUrl(software.source_code_profile);
profile_url = software.source_code_profile =
postFixProfileUrl(software.source_code_profile);
if (unique_software_list.indexOf(profile_url) === -1) {
unique_software_list.push(profile_url);
return retrieveOpenHubAnalysisTotalLines(software);
......@@ -156,8 +159,6 @@
.push(function (line_list) {
return totalLines(line_list);
});
*/
return 0;
}
function retrieveSuccessCaseFromSoftware(publisher, path_list) {
......@@ -223,7 +224,7 @@
})
.push(function (result_list) {
var response;
publisher = result_list[0];
publisher.portal_type = "publisher";
publisher.uid = garble(publisher.title);
......@@ -239,7 +240,6 @@
return response;
})
.push(null, function (error) {
console.log(error);
throw error;
});
}
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.10719.32474.19694</string> </value>
<value> <string>961.11807.49120.23261</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1501772147.39</float>
<float>1501837447.71</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -3,23 +3,32 @@
(function (window, RSVP, rJS) {
"use strict";
var SORT_STRING = 'field_listbox_sort_list:json';
/////////////////////////////////////////////////////////////////
// some parameters
/////////////////////////////////////////////////////////////////
var STR = "",
QUERY = 'urn:jio:allDocs?query=' + 'portal_type:"publisher"',
SORT = 'field_listbox_sort_list:json',
COLUMN_LIST = [
['title', 'Title'],
['country', 'Country'],
['total_lines', 'Total Lines of Code']
],
SORT_LIST = [
['total_lines', 'Total Lines of Code']
];
rJS(window)
.ready(function (g) {
g.props = {};
return g.getElement()
.push(function (element) {
g.props.element = element;
});
})
.declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
/////////////////////////////////////////////////////////////////
// acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
/////////////////////////////////////////////////////////////////
// published methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition('updateHeader', function () {
return;
})
......@@ -27,60 +36,50 @@
.allowPublicAcquisition('getUrlParameter', function (argument_list) {
return this.getUrlParameter(argument_list)
.push(function (result) {
if ((result === undefined) && (argument_list[0] === SORT_STRING)) {
return [['lines', 'descending']];
if ((result === undefined) && (argument_list[0] === SORT)) {
return [['title', 'ascending']];
}
return result;
});
})
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.updateHeader({
page_title: "Statistics"
});
return RSVP.all([
gadget.updateHeader({page_title: "Statistics"}),
gadget.getDeclaredGadget("form_list")
]);
})
.push(function () {
return gadget.getDeclaredGadget("form_list");
})
.push(function (form_gadget) {
var column_list = [
['title', 'Title'],
['country', 'Country'],
['lines', 'Total Lines of Code']
],
sort_column_list = [
['lines', 'Total Lines of Code']
];
return form_gadget.render({
erp5_document: {"_embedded": {"_view": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 0,
"key": "field_listbox",
"lines": 20,
"list_method": "portal_catalog",
"query": 'urn:jio:allDocs?query=' + 'portal_type:"publisher"',
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": sort_column_list,
"sort_on": ["lines", "descending"],
"title": "Documents",
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
.push(function (result_list) {
return result_list[1].render({
erp5_document: {
"_embedded": {
"_view": {
"listbox": {
"column_list": COLUMN_LIST,
"show_anchor": 0,
"default_params": {},
"editable": 0,
"key": "field_listbox",
"lines": 20,
"list_method": "portal_catalog",
"query": QUERY,
"portal_type": [],
"search_column_list": COLUMN_LIST,
"sort_column_list": SORT_LIST,
"sort_on": ["total_lines", "descending"],
"title": "Documents",
"type": "ListBox"
}
}
}
},
"_links": {"type": {name: STR}}
},
form_definition: {
group_list: [
["bottom", [["listbox"]]],
......@@ -90,4 +89,5 @@
});
});
});
}(window, RSVP, rJS));
......@@ -214,7 +214,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>3</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>959.45388.59712.6178</string> </value>
<value> <string>961.9243.54613.9181</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1496074387.69</float>
<float>1501837210.55</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -337,7 +337,7 @@
</item>
<item>
<key> <string>configuration_content_security_policy</string> </key>
<value> <string>default-src \'self\'; img-src \'self\' https://images.unsplash.com * data:; media-src \'self\' blob:; connect-src \'self\' https://api.unsplash.com https://en.wikipedia.org https://fr.wikipedia.org https://raw.githubusercontent.com https://api.github.com data:; script-src \'self\' \'unsafe-eval\'; font-src \'self\'; style-src \'self\' data:; frame-src \'self\' data:</string> </value>
<value> <string>default-src \'self\'; img-src \'self\' https://images.unsplash.com * data:; media-src \'self\' blob:; connect-src \'self\' https://softinst56769.host.vifib.net/ https://api.unsplash.com https://en.wikipedia.org https://fr.wikipedia.org https://raw.githubusercontent.com https://api.github.com data:; script-src \'self\' \'unsafe-eval\'; font-src \'self\'; style-src \'self\' data:; frame-src \'self\' data:</string> </value>
</item>
<item>
<key> <string>configuration_default_view_action_reference</string> </key>
......@@ -600,7 +600,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>3</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -614,7 +614,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>959.30886.17996.5358</string> </value>
<value> <string>961.9243.54613.9181</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -632,7 +632,7 @@
</tuple>
<state>
<tuple>
<float>1495226845.13</float>
<float>1501835836.9</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment