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 @@ ...@@ -108,6 +108,9 @@
var response = data.target.response || data.target.responseText; var response = data.target.response || data.target.responseText;
return PARSER.parseFromString(response, "text/xml") return PARSER.parseFromString(response, "text/xml")
.getElementsByTagName("total_code_lines")[0].childNodes[0].nodeValue; .getElementsByTagName("total_code_lines")[0].childNodes[0].nodeValue;
})
.push(undefined, function () {
return "0";
}); });
} }
...@@ -138,14 +141,14 @@ ...@@ -138,14 +141,14 @@
} }
function retrieveTotalLinesFromPublisher(publisher) { function retrieveTotalLinesFromPublisher(publisher) {
/*
var unique_software_list = []; var unique_software_list = [];
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all(publisher.free_software_list.map(function (software) { return RSVP.all(publisher.free_software_list.map(function (software) {
var profile_url; var profile_url;
if (isValidProfileUrl(software.source_code_profile)) { 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) { if (unique_software_list.indexOf(profile_url) === -1) {
unique_software_list.push(profile_url); unique_software_list.push(profile_url);
return retrieveOpenHubAnalysisTotalLines(software); return retrieveOpenHubAnalysisTotalLines(software);
...@@ -156,8 +159,6 @@ ...@@ -156,8 +159,6 @@
.push(function (line_list) { .push(function (line_list) {
return totalLines(line_list); return totalLines(line_list);
}); });
*/
return 0;
} }
function retrieveSuccessCaseFromSoftware(publisher, path_list) { function retrieveSuccessCaseFromSoftware(publisher, path_list) {
...@@ -239,7 +240,6 @@ ...@@ -239,7 +240,6 @@
return response; return response;
}) })
.push(null, function (error) { .push(null, function (error) {
console.log(error);
throw error; throw error;
}); });
} }
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.10719.32474.19694</string> </value> <value> <string>961.11807.49120.23261</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1501772147.39</float> <float>1501837447.71</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -3,23 +3,32 @@ ...@@ -3,23 +3,32 @@
(function (window, RSVP, rJS) { (function (window, RSVP, rJS) {
"use strict"; "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) 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("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
/////////////////////////////////////////////////////////////////
// published methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition('updateHeader', function () { .allowPublicAcquisition('updateHeader', function () {
return; return;
}) })
...@@ -27,60 +36,50 @@ ...@@ -27,60 +36,50 @@
.allowPublicAcquisition('getUrlParameter', function (argument_list) { .allowPublicAcquisition('getUrlParameter', function (argument_list) {
return this.getUrlParameter(argument_list) return this.getUrlParameter(argument_list)
.push(function (result) { .push(function (result) {
if ((result === undefined) && (argument_list[0] === SORT_STRING)) { if ((result === undefined) && (argument_list[0] === SORT)) {
return [['lines', 'descending']]; return [['title', 'ascending']];
} }
return result; return result;
}); });
}) })
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function () { .declareMethod("render", function () {
var gadget = this; var gadget = this;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return gadget.updateHeader({ return RSVP.all([
page_title: "Statistics" gadget.updateHeader({page_title: "Statistics"}),
}); gadget.getDeclaredGadget("form_list")
}) ]);
.push(function () {
return gadget.getDeclaredGadget("form_list");
}) })
.push(function (form_gadget) { .push(function (result_list) {
var column_list = [ return result_list[1].render({
['title', 'Title'], erp5_document: {
['country', 'Country'], "_embedded": {
['lines', 'Total Lines of Code'] "_view": {
],
sort_column_list = [
['lines', 'Total Lines of Code']
];
return form_gadget.render({
erp5_document: {"_embedded": {"_view": {
"listbox": { "listbox": {
"column_list": column_list, "column_list": COLUMN_LIST,
"show_anchor": 0, "show_anchor": 0,
"default_params": {}, "default_params": {},
"editable": 0, "editable": 0,
"key": "field_listbox", "key": "field_listbox",
"lines": 20, "lines": 20,
"list_method": "portal_catalog", "list_method": "portal_catalog",
"query": 'urn:jio:allDocs?query=' + 'portal_type:"publisher"', "query": QUERY,
"portal_type": [], "portal_type": [],
"search_column_list": column_list, "search_column_list": COLUMN_LIST,
"sort_column_list": sort_column_list, "sort_column_list": SORT_LIST,
"sort_on": ["lines", "descending"], "sort_on": ["total_lines", "descending"],
"title": "Documents", "title": "Documents",
"type": "ListBox" "type": "ListBox"
} }
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
} }
}, },
"_links": {"type": {name: STR}}
},
form_definition: { form_definition: {
group_list: [ group_list: [
["bottom", [["listbox"]]], ["bottom", [["listbox"]]],
...@@ -90,4 +89,5 @@ ...@@ -90,4 +89,5 @@
}); });
}); });
}); });
}(window, RSVP, rJS)); }(window, RSVP, rJS));
...@@ -214,7 +214,7 @@ ...@@ -214,7 +214,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>3</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>959.45388.59712.6178</string> </value> <value> <string>961.9243.54613.9181</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1496074387.69</float> <float>1501837210.55</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -337,7 +337,7 @@ ...@@ -337,7 +337,7 @@
</item> </item>
<item> <item>
<key> <string>configuration_content_security_policy</string> </key> <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>
<item> <item>
<key> <string>configuration_default_view_action_reference</string> </key> <key> <string>configuration_default_view_action_reference</string> </key>
...@@ -600,7 +600,7 @@ ...@@ -600,7 +600,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>3</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -614,7 +614,7 @@ ...@@ -614,7 +614,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>959.30886.17996.5358</string> </value> <value> <string>961.9243.54613.9181</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -632,7 +632,7 @@ ...@@ -632,7 +632,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1495226845.13</float> <float>1501835836.9</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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