From d450c0ac0819b74a265a93808d12dd304968827f Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Thu, 26 Jul 2018 17:24:33 +0530 Subject: [PATCH] [hub][publish] in_progress/empty state --- erpnext/hub_node/__init__.py | 12 ++++++----- .../doctype/hub_settings/hub_settings.py | 8 +++++--- erpnext/public/js/hub/hub_listing.js | 20 +++++++++---------- erpnext/public/less/hub.less | 5 +++++ 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/erpnext/hub_node/__init__.py b/erpnext/hub_node/__init__.py index f9132397c0..7d846d1b94 100644 --- a/erpnext/hub_node/__init__.py +++ b/erpnext/hub_node/__init__.py @@ -55,13 +55,15 @@ def get_valid_items(search_value=''): @frappe.whitelist() def publish_selected_items(items_to_publish): - # for item_code in json.loads(items_to_publish): - # frappe.db.set_value('Item', item_code, 'publish_in_hub', 1) + for item_code in json.loads(items_to_publish): + frappe.db.set_value('Item', item_code, 'publish_in_hub', 1) - time.sleep(3) + # frappe.db.set_value("Hub Settings", "Hub Settings", "sync_in_progress", 1) + # time.sleep(10) + # frappe.db.set_value("Hub Settings", "Hub Settings", "sync_in_progress", 0) - # hub_settings = frappe.get_doc('Hub Settings') - # hub_settings.sync() + hub_settings = frappe.get_doc('Hub Settings') + hub_settings.sync() return diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.py b/erpnext/hub_node/doctype/hub_settings/hub_settings.py index 551423c8a2..52fdb8c522 100644 --- a/erpnext/hub_node/doctype/hub_settings/hub_settings.py +++ b/erpnext/hub_node/doctype/hub_settings/hub_settings.py @@ -46,10 +46,12 @@ class HubSettings(Document): doc = frappe.get_doc({ 'doctype': 'Data Migration Run', 'data_migration_plan': 'Hub Sync', - 'data_migration_connector': 'Hub Connector' + 'data_migration_connector': 'Hub Connector', }).insert() + self.sync_in_progress = 1 doc.run() + self.sync_in_progress = 0 def pre_reg(self): site_name = frappe.local.site + ':' + str(frappe.conf.webserver_port) @@ -86,9 +88,9 @@ class HubSettings(Document): post_url = hub_url + '/api/method/hub.hub.api.register' response = requests.post(post_url, data=data, headers = {'accept': 'application/json'}) - + response.raise_for_status() - + if response.ok: message = response.json().get('message') else: diff --git a/erpnext/public/js/hub/hub_listing.js b/erpnext/public/js/hub/hub_listing.js index 7a71c11ea4..bde1e8fe54 100644 --- a/erpnext/public/js/hub/hub_listing.js +++ b/erpnext/public/js/hub/hub_listing.js @@ -670,9 +670,9 @@ erpnext.hub.Publish = class Publish extends SubPage { setup_events() { this.$wrapper.find('.publish-items').on('click', () => { + this.load_publishing_state(); this.publish_selected_items() .then(r => { - this.load_publishing_state(); frappe.msgprint('check'); }); }); @@ -716,12 +716,6 @@ erpnext.hub.Publish = class Publish extends SubPage { const more_than_one = total_items > 1; this.$wrapper.find('.publish-items') .html(__('Publish ' + total_items + ' item' + (more_than_one ? 's' : ''))); - - // if($target.hasClass('active')) { - // $target.addClass('active'); - // } else { - // $target.removeClass('active'); - // } }); this.$wrapper.append(items_container); @@ -737,9 +731,9 @@ erpnext.hub.Publish = class Publish extends SubPage { } load_publishing_state() { - this.$wrapper.html(`
- Publishing -
`); + this.$wrapper.html(get_empty_state( + 'Publishing items ... You will be notified once published.' + )); } publish_selected_items() { @@ -757,6 +751,12 @@ erpnext.hub.Publish = class Publish extends SubPage { } } +function get_empty_state(message) { + return `
+

${message}

+
` +} + function get_item_card_container_html(items, title='') { const items_html = (items || []).map(item => get_item_card_html(item)).join(''); diff --git a/erpnext/public/less/hub.less b/erpnext/public/less/hub.less index 8c7392ad49..bd503fe1e3 100644 --- a/erpnext/public/less/hub.less +++ b/erpnext/public/less/hub.less @@ -156,6 +156,11 @@ body[data-route^="marketplace/"] { padding: 15px 25px; } + .empty-state { + justify-content: center; + padding-top: 159px; + } + .form-container { .frappe-control { max-width: 100% !important;