[hub] test progress trigger
This commit is contained in:
parent
efbd2ee3f5
commit
46df72d55d
@ -73,14 +73,18 @@ def publish_selected_items(items_to_publish):
|
|||||||
if not len(items_to_publish):
|
if not len(items_to_publish):
|
||||||
return
|
return
|
||||||
|
|
||||||
for item_code in items_to_publish:
|
# TODO: sync
|
||||||
frappe.db.set_value('Item', item_code, 'publish_in_hub', 1)
|
# for item_code in items_to_publish:
|
||||||
|
# frappe.db.set_value('Item', item_code, 'publish_in_hub', 1)
|
||||||
|
|
||||||
|
# hub_settings = frappe.get_doc('Hub Settings')
|
||||||
|
# remote_id = item_sync_preprocess()
|
||||||
|
# hub_settings.sync(remote_id)
|
||||||
|
|
||||||
|
# return remote_id
|
||||||
|
|
||||||
hub_settings = frappe.get_doc('Hub Settings')
|
hub_settings = frappe.get_doc('Hub Settings')
|
||||||
remote_id = item_sync_preprocess()
|
hub_settings.sync('TEST')
|
||||||
hub_settings.sync(remote_id)
|
|
||||||
|
|
||||||
return remote_id
|
|
||||||
|
|
||||||
def item_sync_preprocess():
|
def item_sync_preprocess():
|
||||||
# Call Hub to make a new activity
|
# Call Hub to make a new activity
|
||||||
@ -108,6 +112,7 @@ def item_sync_postprocess(obj):
|
|||||||
|
|
||||||
if response:
|
if response:
|
||||||
frappe.db.set_value('Hub Settings', 'Hub Settings', 'sync_in_progress', 0)
|
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:
|
else:
|
||||||
frappe.throw('Unable to update remote activity')
|
frappe.throw('Unable to update remote activity')
|
||||||
|
|
||||||
|
@ -538,7 +538,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"depends_on": "publish",
|
"depends_on": "",
|
||||||
"fieldname": "last_sync_datetime",
|
"fieldname": "last_sync_datetime",
|
||||||
"fieldtype": "Datetime",
|
"fieldtype": "Datetime",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -555,7 +555,7 @@
|
|||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 1,
|
"read_only": 0,
|
||||||
"remember_last_selected_value": 0,
|
"remember_last_selected_value": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -675,7 +675,7 @@
|
|||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-07-30 08:01:09.024358",
|
"modified": "2018-07-30 10:43:28.818498",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Hub Node",
|
"module": "Hub Node",
|
||||||
"name": "Hub Settings",
|
"name": "Hub Settings",
|
||||||
|
@ -37,12 +37,31 @@ class HubSettings(Document):
|
|||||||
'doctype': 'Data Migration Run',
|
'doctype': 'Data Migration Run',
|
||||||
'data_migration_plan': 'Hub Sync',
|
'data_migration_plan': 'Hub Sync',
|
||||||
'data_migration_connector': 'Hub Connector',
|
'data_migration_connector': 'Hub Connector',
|
||||||
'remote_id': remote_id
|
'remote_id': remote_id,
|
||||||
|
'trigger_name': 'items-sync'
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
self.sync_in_progress = 1
|
time.sleep(2)
|
||||||
# time.sleep(10)
|
frappe.publish_realtime('items-sync', {"progress_percent": 20})
|
||||||
doc.run()
|
print("=======================")
|
||||||
|
|
||||||
|
time.sleep(2)
|
||||||
|
frappe.publish_realtime('items-sync', {"progress_percent": 40})
|
||||||
|
print("=======================")
|
||||||
|
|
||||||
|
time.sleep(1)
|
||||||
|
frappe.publish_realtime('items-sync', {"progress_percent": 80})
|
||||||
|
print("=======================")
|
||||||
|
|
||||||
|
time.sleep(2)
|
||||||
|
frappe.publish_realtime('items-sync', {"progress_percent": 100})
|
||||||
|
print("=======================")
|
||||||
|
|
||||||
|
frappe.db.set_value('Hub Settings', 'Hub Settings', 'last_sync_datetime', frappe.utils.now())
|
||||||
|
|
||||||
|
# TODO: sync
|
||||||
|
# self.sync_in_progress = 1
|
||||||
|
# doc.run()
|
||||||
else:
|
else:
|
||||||
frappe.throw("No remote ID specified")
|
frappe.throw("No remote ID specified")
|
||||||
|
|
||||||
|
@ -828,6 +828,21 @@ erpnext.hub.Publish = class Publish extends SubPage {
|
|||||||
this.items_to_publish = [];
|
this.items_to_publish = [];
|
||||||
this.unpublished_items = [];
|
this.unpublished_items = [];
|
||||||
this.fetched_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) {
|
||||||
|
setTimeout(() => {
|
||||||
|
hub.settings.sync_in_progress = 0;
|
||||||
|
frappe.db.get_doc('Hub Settings')
|
||||||
|
.then(doc => {
|
||||||
|
hub.settings = doc;
|
||||||
|
this.refresh();
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
@ -853,8 +868,8 @@ erpnext.hub.Publish = class Publish extends SubPage {
|
|||||||
|
|
||||||
this.setup_publishing_events();
|
this.setup_publishing_events();
|
||||||
|
|
||||||
if(hub.settings.last_sync) {
|
if(hub.settings.last_sync_datetime) {
|
||||||
this.show_message(`Last sync was <a href="#marketplace/profile">${hub.settings.last_sync}</a>.
|
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>.`);
|
<a href="#marketplace/my-products">See your Published Products</a>.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -962,7 +977,7 @@ erpnext.hub.Publish = class Publish extends SubPage {
|
|||||||
const $publish_progress = $(`<div class="sync-progress">
|
const $publish_progress = $(`<div class="sync-progress">
|
||||||
<p><b>${__(`Syncing ${items_to_publish.length} Products`)}</b></p>
|
<p><b>${__(`Syncing ${items_to_publish.length} Products`)}</b></p>
|
||||||
<div class="progress">
|
<div class="progress">
|
||||||
<div class="progress-bar" style="width: 12.875%"></div>
|
<div class="progress-bar" style="width: 1%"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>`);
|
</div>`);
|
||||||
@ -1026,16 +1041,17 @@ erpnext.hub.Publish = class Publish extends SubPage {
|
|||||||
|
|
||||||
return frappe.db.set_value("Hub Settings", "Hub Settings", {
|
return frappe.db.set_value("Hub Settings", "Hub Settings", {
|
||||||
custom_data: JSON.stringify(items_to_publish),
|
custom_data: JSON.stringify(items_to_publish),
|
||||||
|
// TODO: sync
|
||||||
// sync_in_progress: 1
|
// sync_in_progress: 1
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
hub.settings.sync_in_progress = 1;
|
hub.settings.sync_in_progress = 1;
|
||||||
})
|
})
|
||||||
// .then(frappe.call(
|
.then(frappe.call(
|
||||||
// 'erpnext.hub_node.publish_selected_items',
|
'erpnext.hub_node.publish_selected_items',
|
||||||
// {
|
{
|
||||||
// items_to_publish: item_codes_to_publish
|
items_to_publish: item_codes_to_publish
|
||||||
// }
|
}
|
||||||
// ));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user