af414481 by Jeff Balicki

local add

1 parent 2931546b
...@@ -172,6 +172,19 @@ class ApiController extends Controller ...@@ -172,6 +172,19 @@ class ApiController extends Controller
172 return Response::json($response, $statusCode); 172 return Response::json($response, $statusCode);
173 173
174 } 174 }
175 public function getpdfgoogle($json)
176 {
177
178 $id = new pdfModel();
179 $id = $id->getpdfid($json)->get();
180
181 $rows = new pdfModel();
182 $rows = $rows->getpdf($id[0]->pdfid)->get();
183 $response = $rows;
184 $statusCode = 200;
185 return Response::json($response, $statusCode);
186
187 }
175 188
176 189
177 190
......
...@@ -77,8 +77,11 @@ class FileEntryController extends Controller { ...@@ -77,8 +77,11 @@ class FileEntryController extends Controller {
77 77
78 public function getApi($json) 78 public function getApi($json)
79 { 79 {
80 if($json == '1'){
80 $file = Storage::disk('public')->get('js/interface.js'); 81 $file = Storage::disk('public')->get('js/interface.js');
81 82 }elseif($json == '2'){
83 $file = Storage::disk('public')->get('js/interfaceGdrive.js');
84 }
82 return (new Response($file, 200)) 85 return (new Response($file, 200))
83 ->header('Content-Type', 'application/x-javascript'); 86 ->header('Content-Type', 'application/x-javascript');
84 } 87 }
......
...@@ -29,6 +29,7 @@ Route::group(array('prefix' => 'api/v1'), function($json) ...@@ -29,6 +29,7 @@ Route::group(array('prefix' => 'api/v1'), function($json)
29 Route::resource('get-list', 'ApiController@getList'); 29 Route::resource('get-list', 'ApiController@getList');
30 Route::resource('get-pdf', 'ApiController@getpdf'); 30 Route::resource('get-pdf', 'ApiController@getpdf');
31 Route::resource('api', 'FileEntryController@getApi'); 31 Route::resource('api', 'FileEntryController@getApi');
32 Route::resource('get-pdf-google', 'ApiController@getpdfgoogle');
32 33
33 34
34 }); 35 });
......
...@@ -14,6 +14,18 @@ class pdfModel extends Model ...@@ -14,6 +14,18 @@ class pdfModel extends Model
14 14
15 15
16 ///returns all pdf data 16 ///returns all pdf data
17
18
19 public function getPdfid($id){
20
21
22
23 $rows = DB::table('googleDriveID')
24 ->select('pdfid')
25 ->where('googleDriveID.googledriveId','=', $id);
26
27 return $rows;
28 }
17 29
18 public function getPdf($id){ 30 public function getPdf($id){
19 31
......
1 var pluginUrl = "http://localhost:8888/Forms/";
2
3
4 function getAuth(){
5
6 jQuery(document).ready(function($) {
7
8 var settings = {
9 "async": true,
10 "crossDomain": true,
11 "url": "http://localhost:8888/pdf-customizer/public/api/authenticate",
12 "method": "POST",
13
14 "processData": false,
15 "contentType": false,
16 "mimeType": "multipart/form-data",
17 "data": form,
18 "success": function (data) {
19 getJson(user_id);
20 },
21 error: function (xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
22 //alert(xhr.status);
23 document.getElementById('contentArea').innerHTML =xhr.responseText;
24 }
25
26 }
27
28 $.ajax(settings).done(function (response) {
29 console.log(response);
30 token = response;
31
32
33 });
34
35
36
37 });
38
39 }
40
41
42
43
44
45 function getJson(user_id){
46
47 jQuery(document).ready(function($) {
48
49 $.getJSON("http://localhost:8888/pdf-customizer/public/api/v1/get-list/"+user_id, function (data) {
50 // Get the element with id summary and set the inner text to the result.
51 var json = JSON.stringify(data);
52 pickPdfFromList(json);
53
54 });
55
56
57
58 });
59 }
60
61 function getOneJson(id){
62
63 jQuery(document).ready(function($) {
64
65 $.getJSON("http://localhost:8888/pdf-customizer/public/api/v1/get-pdf-google/"+id, function (data) {
66 // Get the element with id summary and set the inner text to the result.
67 var json = JSON.stringify(data);
68
69 changePdfOptions(json);
70
71 });
72
73
74
75 });
76 }
77
78 function pickPdfFromList(json){
79 json = JSON.parse(json);
80
81
82
83
84 var strVar="";
85
86
87 var i;
88 var pdflist = "";
89 for (i = 0; i < json.length; ++i) {
90 pdflist += "<div class=\"column\">";
91 pdflist += '<a href=\"#\" onclick=\"getOneJson(' +json[i].idPDF+');\"> <img class=\"thumbnail\" src="http://localhost:8888/pdf-customizer/public///fileentry/getImage/' + json[i].folder + '/' + json[i].image + '" height=\"270px\"></a>';
92 pdflist += " <h5>" + json[i].name + "<\/h5>";
93 pdflist += "<\/div>";
94 }
95
96
97 strVar += " <div class=\"callout primary\"><div class=\"row column\"> <h1>Welcome to Synapsus Online PDF Editor<\/h1>";
98 strVar += " <p class=\"lead\">Please pick a PDF<\/p> <\/div><\/div> <div class=\"row small-up-2 medium-up-3 large-up-4\">";
99 strVar += " <\/div>";
100
101
102
103
104 document.getElementById('contentArea').innerHTML = strVar;
105
106
107
108
109
110
111
112 }
113
114
115 function changePdfOptions(json){
116 json = JSON.parse(json);
117
118 var strVar2="";
119
120
121 var pdflist ="";
122 var pdfChange ="";
123 pdflist += "<div class=\"column\">";
124 pdflist += ' <img src=\"http://localhost:8888/pdf-customizer/public/fileentry/getImage/' + json[0].folder + '/' + json[0].image + '\" width=\"300px\">';
125 pdflist += "<\/div><br>";
126 pdfChange += "<form id=\"changes\" name=\"changes\" enctype=\"multipart/form-data\" action=\"#\" METHOD=\"POST\"><h4>" + json[0].name+"</h4>";
127 pdfChange += " <input type=\"hidden\" id=\"id\" name=\"id\" value=\""+json[0].idPDF+"\">";
128 for (i = 0; i < json.length; ++i) {
129 if(json[i].change_type == "text"){
130 pdfChange += " Text: <input id=\"content\" type=\"text\" name=\"content\" value=\""+json[i].content+"\">";
131 }if(json[i].change_type == "img"){
132 pdfChange += "Image: <input class=\"fileupload\" id=\"content\" style=\"display: block; box-sizing: border-box; width: 100%; height: 2.4375rem; padding: .5rem; border: 1px solid #cacaca; margin: 0 0 1rem; font-family: inherit; font-size: 1rem; color: #8a8a8a; background-color: #fefefe; box-shadow: inset 0 1px 2px rgba(10,10,10,.1); border-radius: 0; transition: box-shadow .5s,border-color .25s ease-in-out; -webkit-appearance: none; -moz-appearance: none;\" type=\"file\" name=\"content\" >";
133 }
134 }
135 pdfChange += " <input type=\"submit\" value=\"Submit\">";
136 pdfChange += "<\/form>";
137
138 strVar2 += " <div class=\"callout primary\"><div class=\"row column\"><h1>Welcome to Synapsus Online PDF Editor<\/h1>";
139 strVar2 += "<p class=\"lead\">Please make your changes or return <a href=\"#\" onclick=\"location.reload();\">back to the list</a><\/p>";
140 strVar2 += " <\/div><\/div><div class=\"row small-up-2 medium-up-3 large-up-3\">";
141 strVar2 += pdflist+"<div class=\"column\">"+pdfChange+"<\/div><\/div>";
142
143
144
145 document.getElementById('contentArea').innerHTML =strVar2;
146 document.getElementById('google_drive').innerHTML = " ";
147
148 jQuery(function ($) {
149 var files;
150
151 // Add events
152 $(".fileupload").change(function() { files = event.target.files; console.log(files); });
153
154
155 $("#changes").submit(function(e) {
156 e.preventDefault();
157
158 var form = $("#changes");
159 // var values = {};
160 //form.each(function() {
161 // values[this.name] = $(this).val();
162 //});
163 console.log(form);
164
165 returnfileOptions(files, form);
166 return false;});
167
168
169
170 });
171
172 }
173
174 function returnfileOptions(files,form) {
175 jQuery(function ($) {
176
177 var data = new FormData();
178 $.each(files, function(key, value)
179 {
180 data.append(key, value);
181 });
182
183 $.ajax({
184 url: 'http://contact.gotenzing.com/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files',
185 type: 'POST',
186 data: data,
187 cache: false,
188 dataType: 'json',
189 processData: false, // Don't process the files
190 contentType: false, // Set content type to false as jQuery will tell the server its a query string request
191 success: function(data, textStatus, jqXHR)
192 {
193 if(typeof data.error === 'undefined')
194 {
195 returnOptions(form);
196 }
197 else
198 {
199 // Handle errors here
200
201 console.log('ERRORS: ' + data.error);
202 }
203 },
204 error: function(jqXHR, textStatus, errorThrown)
205 {
206 // Handle errors here
207 console.log('ERRORS: ' + textStatus);
208 // STOP LOADING SPINNER
209 }
210 });
211
212 });
213 }
214
215
216 function returnOptions(form) {
217
218
219 // console.log(form[0][1].value);
220
221
222
223
224
225 jQuery(function ($) {
226
227 $.getJSON("http://localhost:8888/pdf-customizer/public/api/v1/get-pdf/" + id.value, function (dataReturnd) {
228 // Get the element with id summary and set the inner text to the result.
229 var json = dataReturnd;
230 //console.log(json);
231
232
233 var jsonReturn = '{"pdf":[{"name":"' + json[0].name + '", "folder":"' + json[0].folder + '", "pdfLocation":"' + json[0].file + '"}],"changes":['
234 var e = 1;
235 for (i = 0; i < json.length; ++i) {
236
237
238
239 var style = JSON.stringify(json[i].style);
240 var content = JSON.stringify(form[0][e].value);
241
242
243
244 jsonReturn += '{"label":"' + json[i].label + '", "locationUp":"' + json[i].locationUp + '", "locationRight":"' + json[i].locationRight + '","width":"' + json[i].width + '","height":"' + json[i].height + '", "pages":"' + json[i].pages + '", "content":' + content + ', "z-index":null, "idstylesPDF":"' + json[i].idstylesPDF + '", "style":' + style + ', "order":"' + json[i].order + '", "idchange_typePDF":"' + json[i].idchange_typePDF + '", "change_type":"' + json[i].change_type + '", "fileLocation":"http://contact.gotenzing.com/wp-content/plugins/pdf-customizer-plugin/admin/images"}';
245
246
247 if (i < json.length - 1){
248 jsonReturn += ',';
249 }
250 ++e
251 }
252 jsonReturn += ' ]}';
253 // console.log(jsonReturn);
254
255
256
257
258 $.ajax({
259 url: "http://localhost:8888/pdf-customizer/public/api/update",
260 type: "POST",
261 dataType: 'json',
262 data: jsonReturn,
263 processData: false,
264
265 contentType: "application/json",
266 CrossDomain:true,
267
268
269
270
271 async: true,
272 success: function (data) {
273 document.getElementById('contentArea').innerHTML ='<a href="http://localhost:8888/pdf-customizer/public/fileentry/getPDF/'+json[0].folder+'/new_'+json[0].file+'" download="'+json[0].file+'" >Download Here</a>';
274 },
275 error: function (xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
276 alert(xhr.status);
277 document.getElementById('contentArea').innerHTML =xhr.responseText;
278 }
279
280 });
281
282
283
284
285
286
287
288
289
290 });
291
292
293 });
294
295
296 }
297
298
299
300