Commit 1a5eaac6 authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Alain Takoudjou

[erp5_web_monitoring] when needed import opml configuration before run dispatch

parent 666586b8
......@@ -74,6 +74,7 @@
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting")
/////////////////////////////////////////////////////////////////
// declared methods
......@@ -118,29 +119,50 @@
} else {
portal_type = pt_result[1];
}
} else {
portal_type = "promise";
}
return gadget.changeState({
original_query: original_query,
query: options.query,
page_title: page_title,
portal_type: portal_type
});
return gadget.getUrlFor({command: 'display', options: {page: 'ojsm_status_list'}})
.push(function (back_url) {
return gadget.updateHeader({
page_title: page_title,
back_url: back_url
});
})
.push(function () {
return gadget.changeState({
original_query: original_query,
query: options.query,
portal_type: portal_type || "promise",
import_opml: portal_type === undefined ? false : options.import_opml || true
});
});
})
.onStateChange(function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.getUrlFor({command: 'display', options: {page: 'ojsm_status_list'}});
})
.push(function (back_url) {
return gadget.updateHeader({
page_title: gadget.state.page_title,
back_url: back_url
});
if (gadget.state.import_opml) {
return gadget.getSetting('latest_import_date')
.push(function (import_date) {
// If import was never done, or was done more than 2 weeks ago
// 1209600000 = 1000*60*60*24*14
var current_date = new Date().getTime();
if (import_date === undefined ||
(import_date + 1209600000) < current_date) {
return gadget.setSetting('sync_redirect_options', {
query: gadget.state.original_query,
page: 'ojsm_dispatch'
})
.push(function () {
return gadget.redirect({command: 'change', options: {
page: "ojsm_erp5_configurator",
type: "erp5"
}});
});
}
});
}
})
.push(function () {
return gadget.getDeclaredGadget('erp5_searchfield');
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.33811.1739.59187</string> </value>
<value> <string>963.38063.22401.1996</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1510935658.24</float>
<float>1511190866.88</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -19,7 +19,7 @@
Your ERP5 Connection parameters
</h3>
</section>
<p>You have to be logged in this ERP5 prior to synchronising</p>
<p>You have to be logged in this ERP5 prior to import OPML</p>
</article>
<br>
<form class="save_form ui-body-c" novalidate>
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.54628.50882.58453</string> </value>
<value> <string>963.27666.8050.30907</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1508258766.54</float>
<float>1511257051.71</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -590,10 +590,13 @@
status: "error"
});
}
return gadget.notifySubmitted({
message: "Configuration Saved!",
status: "success"
});
return RSVP.all([
gadget.setSetting("latest_import_date", new Date().getTime()),
gadget.notifySubmitted({
message: "Configuration Saved!",
status: "success"
})
]);
})
.push(function () {
if (!has_failed) {
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.27984.14453.52343</string> </value>
<value> <string>963.37770.32649.6058</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1510833881.21</float>
<float>1511174176.26</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -110,7 +110,7 @@
"lines": lines_limit,
"list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=portal_type%3A%22" +
"Software Instance" + "%22",
"Software%20Instance" + "%22",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.32354.21099.3054</string> </value>
<value> <string>963.33701.38666.63044</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1510928975.35</float>
<float>1511187464.03</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -9,6 +9,8 @@
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting")
.declareMethod("render", function () {
var gadget = this;
......@@ -23,10 +25,20 @@
});
})
.push(function () {
return gadget.redirect({
command: "change",
options: {page: "ojsm_status_list"}
});
var redirect_options = {"page": "ojsm_status_list"};
return gadget.getSetting('sync_redirect_options')
.push(function (redirect_dict) {
if (redirect_options) {
redirect_options = redirect_dict;
return gadget.setSetting("sync_redirect_options", undefined);
}
})
.push(function () {
return gadget.redirect({
"command": "display",
"options": redirect_options
});
});
});
});
}(window, rJS));
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.29336.22296.43468</string> </value>
<value> <string>963.37808.2626.47837</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1510668189.54</float>
<float>1511175451.34</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