rxcms-podio_plugin 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4d9e9625378def85b5a235ea67b13cf8838456f9
4
+ data.tar.gz: 7228e738162bad7d8c2c25fa6092d916965259c6
5
+ SHA512:
6
+ metadata.gz: 0070d969d43b2482bf59619b62e07e0289eda97e52a65adcb27a6055811cbda3d0a17ba7c85c178a2adfe46b963deae7e11f82f82a208f6bc0659078d7753e72
7
+ data.tar.gz: e1afbb855b6bfab30ed232d2ccf613a74fe7a8bffa3ba0d4f03f0e68409e556a158f5744c26643c1cd3f1867142f220a5fa87a4fdb8898ffbc5236aa6036f3d7
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = RubycmsPodio
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'RxcmsPodioPlugin'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
@@ -0,0 +1,413 @@
1
+ var const_key_regex = /^[a-zA-Z\-]+$/i;
2
+ var const_value_regex = /^[0-9]+$/i
3
+
4
+ $(function () {
5
+ var appToBeDelete = null;
6
+ var curListOfAppsFromWorkspace = []
7
+ var activeSystemCell = null;
8
+ var curTab = null;
9
+
10
+ Messenger.options = {
11
+ extraClasses: 'messenger-fixed messenger-on-bottom messenger-on-right',
12
+ theme: 'air'
13
+ };
14
+
15
+ $("#systemTabs a[data-toggle=\"tab\"]").on("click", function (e) {
16
+ var targetId = $(e.target).attr("href").replace("#", "");
17
+ curTab = targetId;
18
+
19
+ switch (targetId) {
20
+ case "serviceAccountConfig":
21
+ // Don't do anything at the moment
22
+ $.get("/podio/user/current",function (response) {
23
+ if (response.status == "success") {
24
+ $("#serviceAccountStatus").text("Service account \"" + response.data.trim() + "\" is currently active");
25
+ }
26
+ else
27
+ $("#serviceAccountStatus").text("No service account are currently active");
28
+ }).error(function () {
29
+ $("#serviceAccountStatus").text("No service account are currently active");
30
+ });
31
+ break;
32
+ case "podio":
33
+ // Ask server to return a list of apps
34
+ $("#podioTabLoadingText").fadeIn("fast");
35
+ $("#appTable tBody:first > tr:gt(1)").remove();
36
+ $("#newAppIdSelect").html($("<option value=\"\">loading...</option>"));
37
+
38
+ console.log("Hit 1");
39
+ $.getJSON("/manager/s/items/list/app",function (response) {
40
+
41
+ console.log("Hit 2");
42
+ // Populate all registered apps
43
+ if (response.length > 0)
44
+ for (var i = 0; i < response.length; i++) {
45
+ var cloned = $("#podioAppItemDummy").clone();
46
+ $($(cloned).find("td")[0]).attr("data-id", response[i].id);
47
+ $($(cloned).find("td")[0]).text((i + 1).toString());
48
+ $($($(cloned).find("td")[3]).find("span")[0]).text(response[i].key);
49
+ $($($(cloned).find("td")[4]).find("span")[0]).text(response[i].value);
50
+
51
+ $(cloned).removeAttr("id");
52
+ $(cloned).removeAttr("style");
53
+
54
+ $("#appTable tBody:first").append(cloned);
55
+ }
56
+ else
57
+ Messenger().post("No apps were registered!");
58
+
59
+ // Query server for current space and get a list of apps for it
60
+
61
+ $.getJSON("/podio/orgs/curspace",function (space) {
62
+ if (space.status == "success") {
63
+ console.log("Hit 3");
64
+ $.getJSON("/podio/orgs/space/" + space.data,function (data) {
65
+ if (data.length > 0) {
66
+ console.log("Hit 4");
67
+ for (var d = 0; d < data.length; d++) {
68
+ curListOfAppsFromWorkspace = data;
69
+ var appOptions = ""
70
+ for (var i = 0; i < curListOfAppsFromWorkspace.length; i++) {
71
+ var appOptionItem = "<option value=\"" + curListOfAppsFromWorkspace[i].id + "\">" + curListOfAppsFromWorkspace[i].name + "</option>";
72
+ appOptions += appOptionItem;
73
+ }
74
+ $("#newAppIdSelect").html(appOptions);
75
+ }
76
+ }
77
+ else {
78
+ $("#newAppIdSelect").html("<option value=\"\">no apps found</option>")
79
+ }
80
+
81
+
82
+ $("#podioTabLoadingText").fadeOut("fast");
83
+ }).error(function () {
84
+ $("#podioTabLoadingText").fadeOut("fast");
85
+ });
86
+ } else {
87
+ console.log("Hit 6");
88
+ Messenger().post("Default podio workspace wasn't set!");
89
+ $("#podioTabLoadingText").fadeOut("fast");
90
+ $("#newAppIdSelect").html($("<option value=\"\">error when retrieving</option>"))
91
+ }
92
+ }).error(function () {
93
+ Messenger().post("Default podio workspace wasn't set!");
94
+ $("#podioTabLoadingText").fadeOut("fast");
95
+ $("#newAppIdSelect").html($("<option value=\"\">error when retrieving</option>"))
96
+ });
97
+
98
+
99
+ }).error(function () {
100
+ $("#podioTabLoadingText").fadeOut("fast");
101
+ $("#newAppIdSelect").html($("<option value=\"\">error when retrieving</option>"))
102
+ });
103
+
104
+ break;
105
+ default:
106
+
107
+ }
108
+ });
109
+
110
+ //$("#systemTabs a:first").tab("show");
111
+
112
+ $("#appTableBody").on("click", "tr.appItem td:nth-child(2) a", function (e) {
113
+ appToBeDelete = $(this);
114
+ });
115
+
116
+ $("#appDeleteBtn").on("click", function () {
117
+ itemCounts = 0;
118
+
119
+ if (appToBeDelete != null) {
120
+ var appDeleteId = $($($(appToBeDelete).parents("td")[0]).prev()).attr("data-id");
121
+
122
+ //alert(appDeleteId);
123
+ $.ajax({
124
+ url: "/manager/configurations/" + appDeleteId,
125
+ type: "DELETE",
126
+ beforeSend: function () {
127
+ $("#overlay").fadeIn("fast");
128
+ },
129
+ error: function () {
130
+ $("#overlay").fadeOut("fast", function () {
131
+ Messenger().post("Cannot contact server!");
132
+ });
133
+ },
134
+ success: function (response) {
135
+ if (response.status == "success") {
136
+ $($(appToBeDelete).parents("tr")[0]).remove();
137
+
138
+ $("tr.appItem:visible").each(function (index) {
139
+ itemCounts++;
140
+ $($(this).find("td:first-child")).text(itemCounts);
141
+ });
142
+
143
+ $("#overlay").fadeOut("fast");
144
+ Messenger().post("App has just been unregistered");
145
+ }
146
+ else {
147
+ $("#overlay").fadeOut("fast");
148
+ Messenger().post("Failure - reason: " + response.message);
149
+ }
150
+ }
151
+ });
152
+ }
153
+ });
154
+
155
+ $("#appDelete").on("hidden", function () {
156
+ appToBeDelete = null;
157
+ });
158
+
159
+ $("#aNewApp").on("click", function (e) {
160
+ var newAppName = $("#newAppNameTxt").val(),
161
+ newAppId = $("#newAppIdSelect").val();
162
+
163
+ if (const_key_regex.test(newAppName) && const_value_regex.test(newAppId)) {
164
+
165
+ $.ajax({
166
+ url: "/manager/configurations",
167
+ type: "POST",
168
+ data: {
169
+ "key": newAppName,
170
+ "value": newAppId,
171
+ "cat": "app",
172
+ "mime": "text/plain"
173
+ },
174
+ beforeSend: function () {
175
+ $("#overlay").fadeIn("fast");
176
+ },
177
+ error: function () {
178
+ $("#overlay").fadeOut("fast", function () {
179
+ Messenger().post("Cannot contact server!");
180
+ });
181
+ },
182
+ success: function (response) {
183
+
184
+ if (response.status == "success") {
185
+ var cloned = $("#podioAppItemDummy").clone();
186
+
187
+ var listOfAppItem = $("#appTableBody").find("tr:visible").filter(function (index) {
188
+ return $(this).hasClass("appItem");
189
+ });
190
+
191
+ var newId = 1;
192
+ if (listOfAppItem.length > 0)
193
+ {
194
+ var itemIds = new Array();
195
+ listOfAppItem.each(function (index) {
196
+ curId = parseInt($($(this).find("td")[0]).text());
197
+ itemIds.push(curId);
198
+ });
199
+
200
+ newId = Math.max.apply(Math, itemIds) + 1;
201
+ }
202
+
203
+ $($(cloned).find("td")[0]).text(newId.toString());
204
+ $($(cloned).find("td")[0]).attr("data-id", response.data.newid);
205
+ $($($(cloned).find("td")[3]).find("span:first-child")).text($("#newAppNameTxt").val());
206
+ $($($(cloned).find("td")[4]).find("span:first-child")).text($("#newAppIdSelect").val());
207
+
208
+ $("#newAppNameTxt").val("");
209
+ $("#newAppIdSelect").val("");
210
+
211
+ $(cloned).insertAfter($(".appItem:last"));
212
+ $(cloned).fadeIn("fast");
213
+
214
+ $("#overlay").fadeOut("fast", function () {
215
+ Messenger().post("Your app has just been registered!");
216
+ });
217
+ } else if (response.status == "failure") {
218
+ $("#overlay").fadeOut("fast", function () {
219
+ Messenger().post("Failure - reason: " + response.message);
220
+ });
221
+ }
222
+
223
+ }
224
+ });
225
+
226
+ } else {
227
+ Messenger().post("Your input data were not valid!");
228
+ }
229
+
230
+ });
231
+
232
+ $("#activateServiceAccountBtn").on("click", function () {
233
+ var uid = $("#username").val(),
234
+ pass = $("#password").val();
235
+
236
+ if (uid.length > 0 && pass.length > 0) {
237
+ $("#orgsIndicator").fadeIn("fast");
238
+ $.post("/podio/user/login", {
239
+ "user": uid,
240
+ "pass": pass
241
+ },
242
+ function (response) {
243
+ if (response.status == "success") {
244
+ $("#serviceAccountStatus").html("Service account \"" + uid + "\" is currently active");
245
+
246
+ var userInfoObject = {
247
+ "value": uid.trim(),
248
+ "cat": "config",
249
+ "mime": "text/plain"
250
+ }
251
+
252
+ var userPassObject = {
253
+ "value": pass.trim(),
254
+ "cat": "config",
255
+ "mime": "text/plain"
256
+ }
257
+
258
+ $.post("/podio/user/manipulate", {
259
+ "userObject": userInfoObject,
260
+ "passObject": userPassObject
261
+ },function (response) {
262
+ if (response.status == "success") {
263
+ var optOrgs = "<option value=\"\"></option>";
264
+ $.get("/podio/auth/podio_change_user",function (response) {
265
+ if (response.status == "success") {
266
+ $.getJSON("/podio/data/orgs",function (orgs) {
267
+ for (var o = 0; o < orgs.length; o++) {
268
+ optOrgs += "<option value=\"" + orgs[o].id.toString() + "\" >" + orgs[o].name.trim() + "</option>";
269
+ }
270
+ $("#selectOrganization").html(optOrgs.trim());
271
+ $("#chooseOrganization").fadeIn("fast");
272
+ }).error(function () {
273
+ Messenger().post("Unable to retrieve a list of organization!");
274
+ });
275
+ } else {
276
+ Messenger().post("Unable to switch service account!");
277
+ }
278
+
279
+ $("#orgsIndicator").fadeOut("fast");
280
+ }).error(function () {
281
+ $("#orgsIndicator").fadeOut("fast");
282
+ Messenger().post("Unable to change service account!");
283
+ });
284
+ } else {
285
+ $("#orgsIndicator").fadeOut("fast");
286
+ Messenger().post("Unable to prepare service account!");
287
+ }
288
+ }).error(function () {
289
+ $("#orgsIndicator").fadeOut("fast");
290
+ Messenger().post("Unable to check service account!");
291
+ });
292
+
293
+ $("#username").val("");
294
+ $("#password").val("");
295
+ } else {
296
+ Messenger().post("Unable to authenticate you with podio!");
297
+ $("#orgsIndicator").fadeOut("fast");
298
+ }
299
+ }).error(function () {
300
+ Messenger().post("Cannot contact server!");
301
+ $("#orgsIndicator").fadeIn("fast");
302
+ });
303
+ } else
304
+ Messenger().post("Both podio username and passwords must not be blank!");
305
+ });
306
+
307
+ $("#selectOrganization").on("change", function () {
308
+ var $this = $(this);
309
+
310
+ var orgId = $this.val();
311
+
312
+ if (orgId.length > 0) {
313
+ $("#workspacesIndicator").fadeIn("fast");
314
+ $("#chooseWorkspace").css("display", "none");
315
+ $.getJSON("/podio/data/orgs",function (orgs) {
316
+ var org = $.grep(orgs, function (elem, index) {
317
+ return elem.id == orgId
318
+ });
319
+
320
+ var optSpaces = "<option value=\"\"></option>";
321
+
322
+ for (var s = 0; s < org[0].spaces.length; s++) {
323
+ optSpaces += "<option value=\"" + org[0].spaces[s].id.toString() + "\" >" + org[0].spaces[s].name.trim() + "</option>";
324
+ }
325
+
326
+ $("#selectPodioWorkspace").html(optSpaces.trim());
327
+ $("#chooseWorkspace").fadeIn("fast");
328
+ $("#workspacesIndicator").fadeOut("fast");
329
+ }).error(function () {
330
+ $("#workspacesIndicator").fadeOut("fast");
331
+ });
332
+ } else
333
+ $("#selectPodioWorkspace").html("");
334
+ });
335
+
336
+ $("#selectPodioWorkspace").on("change", function () {
337
+ // Set current workspace on server
338
+ $.post("/podio/orgs/space/manipulate", {
339
+ "space": $(this).val()
340
+ },function (response) {
341
+ Messenger().post("New default workspace has just been set!");
342
+ }).error(function () {
343
+ Messenger().post("Unabled to set new default workspace!");
344
+ });
345
+
346
+ $.getJSON("/podio/orgs/space/" + $(this).val(),
347
+ function (response) {
348
+ if (response.length > 0) {
349
+ // Set current workspace on server
350
+ curListOfAppsFromWorkspace = response;
351
+ }
352
+ }).error(function () {
353
+ Messenger().post("Unable to retrieve a list of apps for workspace!")
354
+ });
355
+ });
356
+
357
+ $("#aAppAccesses").on("click", function () {
358
+ // Initially load accessible apps in workspace
359
+ $("#accessibleApps").html("<li>Looking up...</li>");
360
+ $.getJSON("/podio/orgs/curspace",function (space) {
361
+ if (space.status == "success") {
362
+ $.getJSON("/podio/orgs/space/" + space.data,
363
+ function (response) {
364
+ if (response.length > 0) {
365
+ curListOfAppsFromWorkspace = response;
366
+
367
+ var accessibleAppListItems = "";
368
+ for (var a = 0; a < curListOfAppsFromWorkspace.length; a++) {
369
+ accessibleAppListItems += "<li>" + curListOfAppsFromWorkspace[a].name + " (" + curListOfAppsFromWorkspace[a].id + ")</li>"
370
+ }
371
+ $("#accessibleApps").html(accessibleAppListItems);
372
+ }
373
+ else {
374
+ $("#accessibleApps").html("<li>Sorry, nothing found...</li>");
375
+ }
376
+ }).error(function () {
377
+ $("#accessibleApps").html("<li>Non-applicable at the moment</li>");
378
+ });
379
+ } else {
380
+ $("#accessibleApps").html("<li>Non-applicable at the moment</li>");
381
+ }
382
+ }).error(function () {
383
+ $("#accessibleApps").html("<li>Non-applicable at the moment</li>");
384
+ });
385
+ //
386
+ });
387
+
388
+ $("#appAccesses").on("hidden", function () {
389
+ $("#accessibleApps").html("");
390
+ });
391
+
392
+ $("#username").on("focus", function () {
393
+ $("#selectOrganization").html("");
394
+ $("#selectWorkspace").html("");
395
+ $(".chooseSomething").fadeOut("fast");
396
+ });
397
+
398
+ $("#password").on("focus", function () {
399
+ $("#selectOrganization").html("");
400
+ $("#selectWorkspace").html("");
401
+ $(".chooseSomething").fadeOut("fast");
402
+ });
403
+
404
+ /*** Uninstaller Trigger ***/
405
+ $("#uninstall").on("click", function () {
406
+ $.post("/podio/installer/uninstall", function (response) {
407
+ if (response.status == "success")
408
+ location.reload();
409
+ else
410
+ alert("There was an unresolvable problem!");
411
+ });
412
+ });
413
+ });