From 8b0e00a6d81c09401503356f7c148d5f8de50bbe Mon Sep 17 00:00:00 2001 From: TrystanLea <trystan.lea@gmail.com> Date: Sat, 4 Nov 2023 11:54:03 +0000 Subject: [PATCH] improve feedback --- sync-module/sync_model.php | 7 ++++++- sync-module/sync_view.php | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sync-module/sync_model.php b/sync-module/sync_model.php index 3ee388e..b1b143e 100644 --- a/sync-module/sync_model.php +++ b/sync-module/sync_model.php @@ -84,9 +84,14 @@ public function get_feed_list($userid) { $localfeeds = json_decode(json_encode($this->feed->get_user_feeds_with_meta($userid))); // 2. Load remote settings $remote = $this->remote_load($userid); - if (is_array($remote) && isset($remote['success']) && $remote['success']==false) return false; + if (is_array($remote) && isset($remote['success']) && $remote['success']==false) { + return array("success"=>false, "message"=>"Could not load remote configuration"); + } // 3. Load remote feeds $remotefeeds = json_decode(file_get_contents($remote->host."/feed/listwithmeta.json?apikey=".$remote->apikey_read)); + if (!$remotefeeds) { + return array("success"=>false, "message"=>"No response from remote server"); + } $feeds = array(); diff --git a/sync-module/sync_view.php b/sync-module/sync_view.php index 77f595f..d197155 100644 --- a/sync-module/sync_view.php +++ b/sync-module/sync_view.php @@ -23,6 +23,7 @@ <span class="add-on">Host</span><input id="remote-host" type="text" value="https://emoncms.org"> <span class="add-on">Username</span><input id="remote-username" type="text" style="width:150px" > <span class="add-on">Password</span><input id="remote-password" type="password" style="width:150px" > + <span class="add-on">Apikey</span><input id="remote-apikey" type="text" style="width:250px" disabled > <button id="remote-save" class="btn">Connect</button> </div> @@ -187,6 +188,10 @@ function syncList() dataType: 'json', async: true, success(result){ + if (result.success!=undefined) { + alert(result.message) + return false; + } out=jsonfeedsTohtml(result); feeds=result; $("#all_feed_datas").html(out); @@ -212,6 +217,7 @@ function remoteLoad() $(".alert").hide(); $("#remote-host").val(result.host); $("#remote-username").val(result.username); + $("#remote-apikey").val(result.apikey_write); if (subaction=="feeds") { $(".feed-view").show(); syncList();