Skip to content

Commit

Permalink
improve feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
TrystanLea committed Nov 4, 2023
1 parent e1cc606 commit 8b0e00a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sync-module/sync_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 6 additions & 0 deletions sync-module/sync_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit 8b0e00a

Please sign in to comment.