Merge branch 'hub-redesign' into hub-redesign-contact-seller
diff --git a/erpnext/hub_node/__init__.py b/erpnext/hub_node/__init__.py
index 6ac0aba..f3a0098 100644
--- a/erpnext/hub_node/__init__.py
+++ b/erpnext/hub_node/__init__.py
@@ -108,6 +108,7 @@
if response:
frappe.db.set_value('Hub Settings', 'Hub Settings', 'sync_in_progress', 0)
+ frappe.db.set_value('Hub Settings', 'Hub Settings', 'last_sync_datetime', frappe.utils.now())
else:
frappe.throw('Unable to update remote activity')
diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.json b/erpnext/hub_node/doctype/hub_settings/hub_settings.json
index 10bb959..a0d8188 100644
--- a/erpnext/hub_node/doctype/hub_settings/hub_settings.json
+++ b/erpnext/hub_node/doctype/hub_settings/hub_settings.json
@@ -538,7 +538,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "publish",
+ "depends_on": "",
"fieldname": "last_sync_datetime",
"fieldtype": "Datetime",
"hidden": 0,
@@ -555,7 +555,7 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
- "read_only": 1,
+ "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
@@ -675,7 +675,7 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-07-30 08:01:09.024358",
+ "modified": "2018-07-30 10:43:28.818498",
"modified_by": "Administrator",
"module": "Hub Node",
"name": "Hub Settings",
diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.py b/erpnext/hub_node/doctype/hub_settings/hub_settings.py
index 66dd560..81264dd 100644
--- a/erpnext/hub_node/doctype/hub_settings/hub_settings.py
+++ b/erpnext/hub_node/doctype/hub_settings/hub_settings.py
@@ -37,11 +37,11 @@
'doctype': 'Data Migration Run',
'data_migration_plan': 'Hub Sync',
'data_migration_connector': 'Hub Connector',
- 'remote_id': remote_id
+ 'remote_id': remote_id,
+ 'trigger_name': 'items-sync'
}).insert()
self.sync_in_progress = 1
- # time.sleep(10)
doc.run()
else:
frappe.throw("No remote ID specified")
diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js
index 2c2a29d..83c13a0 100644
--- a/erpnext/public/js/hub/marketplace.js
+++ b/erpnext/public/js/hub/marketplace.js
@@ -861,6 +861,21 @@
this.items_to_publish = [];
this.unpublished_items = [];
this.fetched_items = [];
+
+ frappe.realtime.on("items-sync", (data) => {
+ this.$wrapper.find('.progress-bar').css('width', data.progress_percent+'%');
+
+ if(data.progress_percent === 100 || data.progress_percent === '100') {
+ setTimeout(() => {
+ hub.settings.sync_in_progress = 0;
+ frappe.db.get_doc('Hub Settings')
+ .then(doc => {
+ hub.settings = doc;
+ this.refresh();
+ });
+ }, 500);
+ }
+ });
}
refresh() {
@@ -886,8 +901,8 @@
this.setup_publishing_events();
- if(hub.settings.last_sync) {
- this.show_message(`Last sync was <a href="#marketplace/profile">${hub.settings.last_sync}</a>.
+ if(hub.settings.last_sync_datetime) {
+ this.show_message(`Last sync was <a href="#marketplace/profile">${hub.settings.last_sync_datetime}</a>.
<a href="#marketplace/my-products">See your Published Products</a>.`);
}
@@ -995,7 +1010,7 @@
const $publish_progress = $(`<div class="sync-progress">
<p><b>${__(`Syncing ${items_to_publish.length} Products`)}</b></p>
<div class="progress">
- <div class="progress-bar" style="width: 12.875%"></div>
+ <div class="progress-bar" style="width: 1%"></div>
</div>
</div>`);
@@ -1057,18 +1072,29 @@
});
this.items_to_publish = items_to_publish;
+ return this.set_sync(items_to_publish)
+ .then(frappe.call(
+ 'erpnext.hub_node.publish_selected_items',
+ {
+ items_to_publish: item_codes_to_publish
+ }
+ ));
+ }
+
+ set_sync(items_to_publish) {
+ hub.settings.sync_in_progress = 1;
return frappe.db.set_value("Hub Settings", "Hub Settings", {
custom_data: JSON.stringify(items_to_publish),
- // sync_in_progress: 1
- }).then(() => {
- hub.settings.sync_in_progress = 1;
+ sync_in_progress: 1
})
- // .then(frappe.call(
- // 'erpnext.hub_node.publish_selected_items',
- // {
- // items_to_publish: item_codes_to_publish
- // }
- // ));
+ }
+
+ reset_sync() {
+ hub.settings.sync_in_progress = 0;
+ return frappe.db.set_value("Hub Settings", "Hub Settings", {
+ custom_data: '',
+ sync_in_progress: 0
+ })
}
}