|
45 | 45 | } |
46 | 46 | } |
47 | 47 |
|
48 | | - function save(data, csrf, bfelog){ |
| 48 | + function save(data, csrf, bfelog, callback){ |
49 | 49 | var $messagediv = $('<div>', {id: "bfeditor-messagediv", class:"col-md-10 main"}); |
50 | 50 |
|
51 | 51 | var url = "/verso/api/bfs/upsertWithWhere?where=%7B%22name%22%3A%20%22"+data.name+"%22%7D"; |
|
63 | 63 | var $messagediv = $('<div>', {id: "bfeditor-messagediv"}); |
64 | 64 | var decimaltranslator = window.ShortUUID("0123456789"); |
65 | 65 | var resourceName = "e" + decimaltranslator.fromUUID(data.name); |
66 | | - $messagediv.append('<div class="alert alert-success"><strong>Record Created:</strong><a href='+data.url+'>'+resourceName+'</a></div>'); |
| 66 | + $messagediv.append('<div class="alert alert-info"><strong>Description saved:</strong><a href='+data.url+'>'+resourceName+'</a></div>') |
67 | 67 | $('#bfeditor-formdiv').empty(); |
68 | 68 | $('#save-btn').remove(); |
69 | | - $messagediv.insertBefore('#bfeditor-previewPanel'); |
| 69 | + $messagediv.insertBefore('.nav-tabs'); |
70 | 70 | $('#bfeditor-previewPanel').remove(); |
| 71 | + $('.nav-tabs a[href="#browse"]').tab('show') |
71 | 72 | bfeditor.bfestore.store = []; |
| 73 | + window.location.hash = ""; |
| 74 | + callback(true, data.name); |
72 | 75 | }).fail(function (XMLHttpRequest, textStatus, errorThrown){ |
73 | 76 | bfelog.addMsg(new Error(), "ERROR", "FAILED to save"); |
74 | 77 | bfelog.addMsg(new Error(), "ERROR", "Request status: " + textStatus + "; Error msg: " + errorThrown); |
75 | 78 | $messagediv.append('<div class="alert alert-danger"><strong>Save Failed:</strong>'+errorThrown+'</span>'); |
76 | | - $messagediv.insertBefore('#bfeditor-previewPanel'); |
| 79 | + $messagediv.insertBefore('.nav-tabs'); |
77 | 80 | }).always(function(){ |
78 | 81 | $('#table_id').DataTable().ajax.reload(); |
79 | 82 | }); |
|
83 | 86 | var $messagediv = $('<div>', {id: "bfeditor-messagediv", class:"col-md-10 main"}); |
84 | 87 |
|
85 | 88 | //var url = "http://mlvlp04.loc.gov:8201/bibrecs/bfe2mets.xqy"; |
86 | | - var url = "http://mlvlp04.loc.gov:3000/profile-edit/server/publish"; |
| 89 | + var url = config.url + "/profile-edit/server/publish"; |
87 | 90 | var saveurl = "/verso/api/bfs/upsertWithWhere?where=%7B%22name%22%3A%20%22"+savename+"%22%7D"; |
88 | 91 |
|
89 | 92 | var savedata = {}; |
|
115 | 118 | document.body.scrollTop = document.documentElement.scrollTop = 0; |
116 | 119 | bfelog.addMsg(new Error(), "INFO", "Published " + publishdata[0].name); |
117 | 120 | var $messagediv = $('<div>', {id: "bfeditor-messagediv"}); |
118 | | - $messagediv.append('<div class="alert alert-info"><strong>Description submitted for posting:</strong><a href=http://mlvlp04.loc.gov:8230/'+publishdata[0].objid+'>'+publishdata[0].id+'</a></div>'); |
| 121 | + $messagediv.append('<div class="alert alert-info"><strong>Description submitted for posting:</strong><a href=' + config.basedbURI + "/" + publishdata[0].objid+'>'+publishdata[0].lccn+'</a></div>'); |
119 | 122 | $('#bfeditor-formdiv').empty(); |
120 | 123 | $('#save-btn').remove(); |
121 | 124 | $messagediv.insertBefore('.nav-tabs'); |
122 | 125 | $('#bfeditor-previewPanel').remove(); |
123 | 126 | $('.nav-tabs a[href="#browse"]').tab('show') |
124 | 127 | bfeditor.bfestore.store = []; |
125 | | - callback(true, data.name); |
126 | | - |
| 128 | + window.location.hash = ""; |
| 129 | + callback(true, data.name); |
127 | 130 | }).fail(function (XMLHttpRequest, textStatus, errorThrown){ |
128 | 131 | bfelog.addMsg(new Error(), "ERROR", "FAILED to save"); |
129 | 132 | bfelog.addMsg(new Error(), "ERROR", "Request status: " + textStatus + "; Error msg: " + errorThrown); |
|
137 | 140 |
|
138 | 141 | function retrieve(uri, bfestore, loadtemplates, bfelog, callback){ |
139 | 142 |
|
140 | | - var url = "http://mlvlp04.loc.gov:3000/profile-edit/server/whichrt"; |
| 143 | + var url = config.url + "/profile-edit/server/whichrt"; |
141 | 144 |
|
142 | 145 | $.ajax({ |
143 | 146 | dataType: "json", |
|
162 | 165 | }); |
163 | 166 | } |
164 | 167 |
|
| 168 | + function retrieveLDS(uri, bfestore, loadtemplates, bfelog, callback){ |
| 169 | + |
| 170 | + var url = config.url + "/profile-edit/server/retrieveLDS"; |
| 171 | + |
| 172 | + $.ajax({ |
| 173 | + dataType: "json", |
| 174 | + type: "GET", |
| 175 | + async: false, |
| 176 | + data: { uri: uri}, |
| 177 | + url: url, |
| 178 | + success: function (data) { |
| 179 | + bfelog.addMsg(new Error(), "INFO", "Fetched external source baseURI" + url); |
| 180 | + bfelog.addMsg(new Error(), "DEBUG", "Source data", data); |
| 181 | + bfestore.store = bfestore.jsonldcompacted2store(data, function(expanded) { |
| 182 | + bfestore.store = []; |
| 183 | + tempstore = bfestore.jsonld2store(expanded); |
| 184 | + callback(loadtemplates); |
| 185 | + }); |
| 186 | + //bfestore.n32store(data, url, tempstore, callback); |
| 187 | + }, |
| 188 | + error: function(XMLHttpRequest, textStatus, errorThrown) { |
| 189 | + bfelog.addMsg(new Error(), "ERROR", "FAILED to load external source: " + url); |
| 190 | + bfelog.addMsg(new Error(), "ERROR", "Request status: " + textStatus + "; Error msg: " + errorThrown); |
| 191 | + } |
| 192 | + }); |
| 193 | + } |
| 194 | + |
| 195 | + |
165 | 196 | function deleteId(id, csrf, bfelog){ |
166 | 197 | var url = config.url + "/verso/api/bfs/" + id; |
167 | 198 |
|
|
192 | 223 | },*/ |
193 | 224 | "url" : "http://mlvlp04.loc.gov:3000", |
194 | 225 | "baseURI": "http://id.loc.gov/", |
| 226 | + "basedbURI": "http://mlvlp04.loc.gov:8230", |
195 | 227 | "resourceURI": "http://mlvlp04.loc.gov:8230/resources", |
196 | 228 | "profiles": [ |
197 | 229 | "static/profiles/bibframe/BIBFRAME 2.0 Agents.json", |
|
418 | 450 | "publish": { |
419 | 451 | "callback": publish |
420 | 452 | }, |
| 453 | + "retrieveLDS": { |
| 454 | + "callback":retrieveLDS |
| 455 | + }, |
421 | 456 | "retrieve": { |
422 | 457 | "callback": retrieve |
423 | 458 | }, |
|
0 commit comments