Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: REST Services #1864

Merged
merged 204 commits into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
204 commits
Select commit Hold shift + click to select a range
47ac813
start setting up UI screens for REST services
pmusaraj Feb 22, 2018
191c078
Merge branch 'master' into REST-UI
pmusaraj Mar 15, 2018
52016cc
more UI work for REST services
pmusaraj Mar 15, 2018
7bd05ae
Merge branch 'master' into REST-UI
magicznyleszek May 7, 2018
940c16b
cleanup whitespace
magicznyleszek May 9, 2018
69c9617
define bem form modal select
magicznyleszek May 9, 2018
4b810c0
move styles for new bem component
magicznyleszek May 9, 2018
f340cb6
half-width item styles
magicznyleszek May 9, 2018
e8fb26f
fix leftover change, add helpful comment
magicznyleszek May 9, 2018
7596cf8
wip radio styles
magicznyleszek May 9, 2018
4abd6ae
radio input styles according to desing
magicznyleszek May 9, 2018
741846b
start adding code for calling backend
magicznyleszek May 14, 2018
7d3b984
Merge branch 'master' into REST-UI
magicznyleszek Jun 12, 2018
944be5b
fix error pointed out by linter
magicznyleszek Jun 12, 2018
8bb6792
split rest services code
magicznyleszek Jun 13, 2018
cd7b474
style empty view
magicznyleszek Jun 13, 2018
9e57b39
style overall layout for services
magicznyleszek Jun 13, 2018
a279c97
work on rest form and passing data
magicznyleszek Jun 13, 2018
4486fb3
work on list styles
magicznyleszek Jun 13, 2018
a1bcbaf
use report menu icon for missing log icon
magicznyleszek Jun 13, 2018
e185840
add failed count and style columns
magicznyleszek Jun 13, 2018
a1a1e5a
add link
magicznyleszek Jun 14, 2018
de243c5
route for specific rest service
magicznyleszek Jun 14, 2018
efe43af
route for specific rest service
magicznyleszek Jun 14, 2018
d9a4ef2
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
magicznyleszek Jun 14, 2018
c17a43b
no hover for header
magicznyleszek Jun 14, 2018
6d061dd
service logs view render
magicznyleszek Jun 14, 2018
7e5674c
display formatted date
magicznyleszek Jun 14, 2018
1e2fcba
wip custom http headers
magicznyleszek Jun 14, 2018
8ffee88
custom http headers
magicznyleszek Jun 14, 2018
2e7f25c
move alertify-overrides to separate file, finish up custom http headers
magicznyleszek Jun 14, 2018
7052352
remove mock data
magicznyleszek Jun 14, 2018
2c9c8cf
Merge branch 'master' of github.com:kobotoolbox/kpi into REST-UI
noliveleger Jun 14, 2018
236322f
Added new APP 'hook' to handle submissions saved to external services
noliveleger Jun 15, 2018
46287a4
Added unittest for hooks creation and modification
noliveleger Jun 18, 2018
5bb9ac5
Removed duplicate code
noliveleger Jun 18, 2018
ef5f856
Added some API documentation
noliveleger Jun 19, 2018
454c539
Added link to hooks in AssetSerializer
noliveleger Jun 19, 2018
d6063c8
Update Kobocat.XForm as soon as Asset.hooks change
noliveleger Jun 21, 2018
f20374b
Merge branch 'master' into REST-UI
magicznyleszek Jun 22, 2018
76eb0bb
missing comma
magicznyleszek Jun 22, 2018
b98df65
bring back accidentaly removed file
magicznyleszek Jun 22, 2018
ed83df0
hooking up to endpoints
magicznyleszek Jun 22, 2018
2693402
managing loading service data to form
magicznyleszek Jun 22, 2018
9f7a182
display list of services from endpoint
magicznyleszek Jun 25, 2018
12e8a27
loading serbice in edit form
magicznyleszek Jun 25, 2018
b828ea9
finish up hooking modal form + feedback changes
magicznyleszek Jun 25, 2018
936e97d
refresh services list after CRUD
magicznyleszek Jun 26, 2018
ec65e05
delete external service with prompt
magicznyleszek Jun 27, 2018
f14f77b
fix saving and reading settings
magicznyleszek Jun 27, 2018
b0d3f4f
service modal active switch, checkbox styles
magicznyleszek Jun 27, 2018
b5c1834
add description comment for checkbox and radio usage, disable default…
magicznyleszek Jun 27, 2018
f8934be
proper quotes for type checkbox
magicznyleszek Jun 27, 2018
9da7020
proper cursor for service form inputs
magicznyleszek Jun 27, 2018
245caa2
Migrated KC rest services to KPI hook services, created celery tasks …
noliveleger Jun 27, 2018
6e35cb0
Added custom headers and basic auth to request of hook
noliveleger Jun 27, 2018
f3200b8
fix password editing and better active checkbox text
magicznyleszek Jun 28, 2018
5d361f5
work on error handling in account setttings
magicznyleszek Jun 28, 2018
580efad
Revert "work on error handling in account setttings"
magicznyleszek Jun 29, 2018
e655a0d
Moved hook app models to their own file
noliveleger Jun 29, 2018
976a175
Created model,serializer,viewset for hook logs
noliveleger Jun 29, 2018
2f49049
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
noliveleger Jun 29, 2018
cdc0a3f
Refactored success and failed count fields to Model property, added a
noliveleger Jun 29, 2018
35e5cc3
Prepared endpoints for retries
noliveleger Jun 29, 2018
a55b183
HookLog retry on PATCH, added djangoframework_rest_xml dependency
noliveleger Jul 4, 2018
1fef8f2
Modified import to be futureproof
noliveleger Jul 4, 2018
7cb8017
Removed useless imports
noliveleger Jul 4, 2018
d00853d
Changed response of submission endpoint on POST
noliveleger Jul 4, 2018
2690539
Added logging config when sentry is deactivated, added a new logger i…
noliveleger Jul 4, 2018
87209b1
Finished implementation of 'retry' endpoint
noliveleger Jul 4, 2018
e16206c
Refactoring to handle XML hooks, added instance_id field to retrieve …
noliveleger Jul 5, 2018
2152fd8
Removed hook.id from HookLog representation
noliveleger Jul 5, 2018
0f30c89
Fixed bad returned value in ServiceDefinitionInterface.send()
noliveleger Jul 5, 2018
cb05b52
Fixed hook logs success and fails totals when no requets have been ma…
noliveleger Jul 5, 2018
f225177
added a 30s timeout to external requests, fixed xml service, alter me…
noliveleger Jul 5, 2018
4e0af45
PEP8 compliance - Need 2 lines between classes
noliveleger Jul 6, 2018
2084600
Renamed the user-agent of the hooks
noliveleger Jul 6, 2018
1667d81
Block hook endpoints access to any users except the owner of the asset
noliveleger Jul 9, 2018
de046ed
Added some API documentation
noliveleger Jul 9, 2018
2f1ca23
Replaced instance_uid field by a kpiuidfield, used 'kc.logger_instanc…
noliveleger Jul 9, 2018
298c9ac
Merge branch 'master' into REST-UI
magicznyleszek Jul 9, 2018
776557f
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
magicznyleszek Jul 9, 2018
72d8f39
prepare data interfaces for services logs
magicznyleszek Jul 10, 2018
90586c9
display services logs from endpoint data
magicznyleszek Jul 10, 2018
0a19cd5
handle logs return data format
magicznyleszek Jul 10, 2018
c149b4d
Added a test to send data and retry if it fails
noliveleger Jul 10, 2018
2f388e7
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
noliveleger Jul 10, 2018
ff38a6f
code logs retrying
magicznyleszek Jul 11, 2018
2de56d7
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
magicznyleszek Jul 11, 2018
1e0a669
prettier logs header
magicznyleszek Jul 11, 2018
8a0283c
same message for fail and unsuccessful
magicznyleszek Jul 11, 2018
b376a09
allow for more success status codes
magicznyleszek Jul 11, 2018
df8bdfc
small columns tweaks
magicznyleszek Jul 11, 2018
8b33a8e
Added new tests for anonymous and not owner access, fixed issue with …
noliveleger Jul 11, 2018
24eaa9b
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
noliveleger Jul 11, 2018
671f8b1
hook logs are now ordered by date_modified DESC and viewset is pagina…
noliveleger Jul 11, 2018
9a97225
show modal with submission message
magicznyleszek Jul 11, 2018
117d045
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
magicznyleszek Jul 11, 2018
40a678c
tweak display
magicznyleszek Jul 11, 2018
9ab2c0a
avoid need for plularization
magicznyleszek Jul 11, 2018
3167d11
Merge branch 'master' into REST-UI
magicznyleszek Jul 12, 2018
d9ba51f
Order `HookLog`s by `date_created`
jnm Jul 23, 2018
eb2e4fe
Merge branch 'master' into REST-UI
magicznyleszek Jul 27, 2018
771dfc9
Merge branch 'master' into REST-UI
magicznyleszek Jul 29, 2018
db72ebc
fix iframeUrl error and use constants
magicznyleszek Jul 29, 2018
65ad132
move checkbox and radio to separate reusable components
magicznyleszek Jul 29, 2018
f6ddfff
Merge branch 'master' into REST-UI
magicznyleszek Jul 30, 2018
0d4a2d5
Merge branch 'master' into REST-UI
magicznyleszek Aug 2, 2018
5b2a02a
apply eslint quotes fixes and improve quotes rule
magicznyleszek Aug 2, 2018
5859cfc
tiny style change
magicznyleszek Aug 2, 2018
acee5f2
Restored missing import
noliveleger Aug 2, 2018
d19dbd3
Merge branch 'master' into REST-UI
magicznyleszek Aug 3, 2018
35db383
Refactoring: moved hook app into kobo directory
noliveleger Aug 6, 2018
d636cfc
Bugs fixes after hook refactoring
noliveleger Aug 6, 2018
44eccba
retry all submissions button and action
magicznyleszek Aug 6, 2018
8028048
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
magicznyleszek Aug 6, 2018
db26fff
fix retry all button displaying logic
magicznyleszek Aug 6, 2018
f04c6e9
Moved retry-all endpoint to hook viewSet
noliveleger Aug 6, 2018
db2d269
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
noliveleger Aug 6, 2018
efe4e96
use new status field for logs
magicznyleszek Aug 7, 2018
238c602
unify naming of logs for REST files
magicznyleszek Aug 7, 2018
0c7bfc5
rename esid (external service id) to hookUid for consistency with BE
magicznyleszek Aug 7, 2018
2061616
use hook nomenclature for consistency with BE
magicznyleszek Aug 7, 2018
31fbd7f
Added pending status for logs
noliveleger Aug 7, 2018
26d7e08
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
noliveleger Aug 7, 2018
7900fc8
Fixed bad copy&paste
noliveleger Aug 7, 2018
90f5a44
count tooltip
magicznyleszek Aug 7, 2018
6f9b6dd
human friendly log statuses
magicznyleszek Aug 7, 2018
f77aaa7
better icon for counters
magicznyleszek Aug 7, 2018
5308639
align tooltip
magicznyleszek Aug 7, 2018
ac3cdc5
Merge branch 'master' into REST-UI
magicznyleszek Aug 9, 2018
8b5205b
fix missing variable
magicznyleszek Aug 13, 2018
cd8f728
fix more copypasting
magicznyleszek Aug 14, 2018
1717200
improve column sizes
magicznyleszek Aug 14, 2018
13859c5
load all logs after retryLogs fails to get previous status
magicznyleszek Aug 14, 2018
7a37bd5
notify on create/update rest service
magicznyleszek Aug 14, 2018
2df5888
notify on successfully deleting rest service
magicznyleszek Aug 14, 2018
bd8d8c3
move most notifications to actions for more future friendly code
magicznyleszek Aug 14, 2018
22866b9
Draft: Retry all, json is working synchronously
noliveleger Aug 14, 2018
28bc41a
Refactoring: Moved get_submissions code to KobocatBackend class
noliveleger Aug 14, 2018
d2143b5
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
noliveleger Aug 14, 2018
413eb9e
fix infinite pending log on single retry, dont show ful html page err…
magicznyleszek Aug 15, 2018
d857c40
Fixed bad imports and retry all signature
noliveleger Aug 15, 2018
ed38f5d
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
noliveleger Aug 15, 2018
41a5c8f
Restored jsapp/fonts/.gitignore
noliveleger Aug 15, 2018
fb71b97
tiny changes
magicznyleszek Aug 15, 2018
00e9b3c
Fixed log staying in pending mode when not retrieving data
noliveleger Aug 15, 2018
c40d70b
Strip HTML response before saving in DB
noliveleger Aug 15, 2018
3432dbb
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
noliveleger Aug 15, 2018
2093679
Stripped white spaces
noliveleger Aug 15, 2018
185fc2c
update log message on failed retry attempt (without calling backend)
magicznyleszek Aug 15, 2018
c9c0aa6
better error names
magicznyleszek Aug 15, 2018
a8d8772
Changed response of retry all. Now, returns all pendings uid
noliveleger Aug 17, 2018
3e35620
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
noliveleger Aug 17, 2018
dfba23d
bring back deleted gitignore file (again)
magicznyleszek Aug 17, 2018
0173f15
use new backend response for retry all logs
magicznyleszek Aug 17, 2018
9bf4f43
Merge branch 'master' into REST-UI
noliveleger Aug 18, 2018
c97745e
Big refactoring. Removed SubmissionViewset calls from KobocatBackend,
noliveleger Aug 21, 2018
99ec825
Fixed issues with hook test
noliveleger Aug 21, 2018
ded1df5
Use Celery for retry all
noliveleger Aug 21, 2018
869f45d
Merge branch 'master' into REST-UI
noliveleger Aug 21, 2018
014f071
Change hooklogs statuses before sending them to Celery on retry
noliveleger Aug 21, 2018
605c5de
Merged migrations
noliveleger Aug 21, 2018
157b5dc
Removed old code and use Backend get_submissions()
noliveleger Aug 23, 2018
c57211b
Merge branch 'master' into REST-UI
noliveleger Aug 24, 2018
9d70c62
simplify modal styles a bit
magicznyleszek Aug 26, 2018
275bf5a
handle enter key better in adding custom header rows
magicznyleszek Aug 26, 2018
f41d4a8
Fixed bug when retreiving only one submission from KobocatBackend
noliveleger Aug 27, 2018
41d12db
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
noliveleger Aug 27, 2018
3d8c7d4
Bugfix for duplicated tasks in Celery
noliveleger Aug 30, 2018
c5d89d7
Send PK ids instead of models to Celery
noliveleger Aug 30, 2018
d7fafd8
Merge branch 'master' into REST-UI
magicznyleszek Sep 11, 2018
de28cd3
fix after merge
magicznyleszek Sep 11, 2018
014f018
update select
magicznyleszek Sep 11, 2018
09614b4
Updated TODO in SubmissionViewSet
noliveleger Sep 17, 2018
8e4efed
Merge branch 'master' into REST-UI
magicznyleszek Sep 25, 2018
daa54c0
Merge branch 'master' into REST-UI
noliveleger Sep 26, 2018
5d2b5f2
Merge branch 'master' into REST-UI
noliveleger Sep 26, 2018
aed510e
Merged migrations, changed DateField default value to Django timezone…
noliveleger Sep 26, 2018
64e53c5
Removed useless 'retry' method in Hook class
noliveleger Sep 26, 2018
f95065e
Moved retry equation to static method
noliveleger Sep 26, 2018
2ef709c
Changed the way authentication is tested prior to send username/passw…
noliveleger Sep 26, 2018
b2d083e
Fixed forgotten import
noliveleger Sep 26, 2018
4c1c89f
Catch requests errors to remote server with 'raise_for_status()'
noliveleger Sep 26, 2018
8f56b6f
Allow HookLog.status_code to be null, separate remote server status_c…
noliveleger Sep 27, 2018
4250523
Moved KOBO_INTERNAL_ERROR_STATUS_CODE to constant.py
noliveleger Sep 27, 2018
4064049
Moved HOOK_MAX_RETRIES to Constance config instead of Django settings
noliveleger Sep 27, 2018
232a9f8
Added public domain name is Hook User Agent
noliveleger Sep 27, 2018
e554091
Overload logging
noliveleger Sep 27, 2018
cd13bae
Merge branch 'master' into REST-UI
magicznyleszek Sep 27, 2018
ff463eb
Updated code to use overloaded logging
noliveleger Sep 27, 2018
d07bc73
fix undefined value JS error
magicznyleszek Sep 27, 2018
72c04d3
Use instance_id instead of instance_uuid to retrieve data from kc
noliveleger Sep 28, 2018
07b9c30
Merge REST-UI into REST_UI_logging
noliveleger Sep 28, 2018
44adb0e
Fixed forgotten replace of instance_uuid
noliveleger Sep 28, 2018
7c99d63
Merge branch 'REST-UI' into REST_UI_logging
noliveleger Sep 28, 2018
24ed9cd
fix few labels
magicznyleszek Oct 2, 2018
c7d0fd1
bigger label
magicznyleszek Oct 2, 2018
3e454df
fix auth level editing
magicznyleszek Oct 2, 2018
87d3c8b
Merge pull request #2008 from kobotoolbox/REST_UI_logging
jnm Oct 2, 2018
2195b3b
tweak some styles for rest services
magicznyleszek Oct 3, 2018
944d644
Merge branch 'REST-UI' of github.com:kobotoolbox/kpi into REST-UI
magicznyleszek Oct 3, 2018
f8c3927
use TextBox component in REST modal and add visual validation
magicznyleszek Oct 3, 2018
e2cb641
Merge branch 'master' into REST-UI
magicznyleszek Oct 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
}
},
"rules": {
"strict": 0,
"curly": 0,
"quotes": ["warn", "single"],
"quotes": ["warn", "single", {"avoidEscape": true}],
"no-underscore-dangle": 0,
"camelcase": [0],
"new-cap": 0,
Expand Down
2 changes: 2 additions & 0 deletions dependencies/pip/dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cookies==2.2.1 # via responses
cryptography==2.2.2 # via paramiko, pyopenssl
cssselect==1.0.3 # via pyquery
cyordereddict==1.0.0
defusedxml==0.5.0 # via djangorestframework-xml
dj-database-url==0.4.2
dj-static==0.0.6
django-braces==1.11.0
Expand All @@ -44,6 +45,7 @@ django-taggit==0.22.0
django-toolbelt==0.0.1
django-webpack-loader==0.4.1
django==1.8.17
djangorestframework-xml==1.3.0
djangorestframework==3.5.4
docutils==0.13.1 # via botocore, statistics
drf-extensions==0.3.1
Expand Down
2 changes: 2 additions & 0 deletions dependencies/pip/external_services.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ cookies==2.2.1 # via responses
cryptography==2.2.2 # via pyopenssl
cssselect==1.0.3 # via pyquery
cyordereddict==1.0.0
defusedxml==0.5.0 # via djangorestframework-xml
dj-database-url==0.4.1
dj-static==0.0.6
django-braces==1.8.1
Expand All @@ -45,6 +46,7 @@ django-taggit==0.22.0
django-toolbelt==0.0.1
django-webpack-loader==0.3.0
django==1.8.13
djangorestframework-xml==1.3.0
djangorestframework==3.3.3
docutils==0.12 # via botocore, statistics
drf-extensions==0.3.1
Expand Down
1 change: 1 addition & 0 deletions dependencies/pip/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ django-taggit
django-storages
django-private-storage
djangorestframework
djangorestframework-xml
drf-extensions
gunicorn
jsonfield
Expand Down
2 changes: 2 additions & 0 deletions dependencies/pip/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cookies==2.2.1 # via responses
cryptography==2.2.2 # via pyopenssl
cssselect==1.0.3 # via pyquery
cyordereddict==1.0.0
defusedxml==0.5.0 # via djangorestframework-xml
dj-database-url==0.4.1
dj-static==0.0.6
django-braces==1.8.1
Expand All @@ -44,6 +45,7 @@ django-taggit==0.22.0
django-toolbelt==0.0.1
django-webpack-loader==0.3.0
django==1.8.13
djangorestframework-xml==1.3.0
djangorestframework==3.3.3
docutils==0.12 # via botocore, statistics
drf-extensions==0.3.1
Expand Down
157 changes: 157 additions & 0 deletions jsapp/js/actions.es6
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ actions.permissions = Reflux.createActions({
},
});

actions.hooks = Reflux.createActions({
getAll: {children: ['completed', 'failed']},
add: {children: ['completed', 'failed']},
update: {children: ['completed', 'failed']},
delete: {children: ['completed', 'failed']},
getLogs: {children: ['completed', 'failed']},
retryLog: {children: ['completed', 'failed']},
retryLogs: {children: ['completed', 'failed']},
});

actions.misc = Reflux.createActions({
checkUsername: {
asyncResult: true,
Expand Down Expand Up @@ -695,4 +705,151 @@ actions.resources.updateSubmissionValidationStatus.listen(function(uid, sid, dat
});
});

actions.hooks.getAll.listen((assetUid, callbacks = {}) => {
dataInterface.getHooks(assetUid)
.done((...args) => {
actions.hooks.getAll.completed(...args);
if (typeof callbacks.onComplete === 'function') {
callbacks.onComplete(...args);
}
})
.fail((...args) => {
actions.hooks.getAll.failed(...args);
if (typeof callbacks.onFail === 'function') {
callbacks.onFail(...args);
}
});
});

actions.hooks.add.listen((assetUid, data, callbacks = {}) => {
dataInterface.addExternalService(assetUid, data)
.done((...args) => {
actions.hooks.getAll(assetUid);
actions.hooks.add.completed(...args);
if (typeof callbacks.onComplete === 'function') {
callbacks.onComplete(...args);
}
})
.fail((...args) => {
actions.hooks.add.failed(...args);
if (typeof callbacks.onFail === 'function') {
callbacks.onFail(...args);
}
});
});
actions.hooks.add.completed.listen((response) => {
notify(t('REST Service added successfully'));
});
actions.hooks.add.failed.listen((response) => {
notify(t('Failed adding REST Service'), 'error');
});

actions.hooks.update.listen((assetUid, hookUid, data, callbacks = {}) => {
dataInterface.updateExternalService(assetUid, hookUid, data)
.done((...args) => {
actions.hooks.getAll(assetUid);
actions.hooks.update.completed(...args);
if (typeof callbacks.onComplete === 'function') {
callbacks.onComplete(...args);
}
})
.fail((...args) => {
actions.hooks.update.failed(...args);
if (typeof callbacks.onFail === 'function') {
callbacks.onFail(...args);
}
});
});
actions.hooks.update.completed.listen((response) => {
notify(t('REST Service updated successfully'));
});
actions.hooks.update.failed.listen((response) => {
notify(t('Failed saving REST Service'), 'error');
});

actions.hooks.delete.listen((assetUid, hookUid, callbacks = {}) => {
dataInterface.deleteExternalService(assetUid, hookUid)
.done((...args) => {
actions.hooks.getAll(assetUid);
actions.hooks.delete.completed(...args);
if (typeof callbacks.onComplete === 'function') {
callbacks.onComplete(...args);
}
})
.fail((...args) => {
actions.hooks.delete.failed(...args);
if (typeof callbacks.onFail === 'function') {
callbacks.onFail(...args);
}
});
});
actions.hooks.delete.completed.listen((response) => {
notify(t('REST Service deleted permanently'));
});
actions.hooks.delete.failed.listen((response) => {
notify(t('Could not delete REST Service'), 'error');
});

actions.hooks.getLogs.listen((assetUid, hookUid, callbacks = {}) => {
dataInterface.getHookLogs(assetUid, hookUid)
.done((...args) => {
actions.hooks.getLogs.completed(...args);
if (typeof callbacks.onComplete === 'function') {
callbacks.onComplete(...args);
}
})
.fail((...args) => {
actions.hooks.getLogs.failed(...args);
if (typeof callbacks.onFail === 'function') {
callbacks.onFail(...args);
}
});
});

actions.hooks.retryLog.listen((assetUid, hookUid, lid, callbacks = {}) => {
dataInterface.retryExternalServiceLog(assetUid, hookUid, lid)
.done((...args) => {
actions.hooks.getLogs(assetUid, hookUid);
actions.hooks.retryLog.completed(...args);
if (typeof callbacks.onComplete === 'function') {
callbacks.onComplete(...args);
}
})
.fail((...args) => {
actions.hooks.retryLog.failed(...args);
if (typeof callbacks.onFail === 'function') {
callbacks.onFail(...args);
}
});
});
actions.hooks.retryLog.completed.listen((response) => {
notify(t('Submission retried successfully'));
});
actions.hooks.retryLog.failed.listen((response) => {
notify(t('Retrying submission failed'), 'error');
});

actions.hooks.retryLogs.listen((assetUid, hookUid, callbacks = {}) => {
dataInterface.retryExternalServiceLogs(assetUid, hookUid)
.done((...args) => {
actions.hooks.retryLogs.completed(...args);
if (typeof callbacks.onComplete === 'function') {
callbacks.onComplete(...args);
}
})
.fail((...args) => {
actions.hooks.getLogs(assetUid, hookUid);
actions.hooks.retryLogs.failed(...args);
if (typeof callbacks.onFail === 'function') {
callbacks.onFail(...args);
}
});
});
actions.hooks.retryLogs.completed.listen((response) => {
notify(t(response.detail), 'warning');
});
actions.hooks.retryLogs.failed.listen((response) => {
notify(t('Retrying all submissions failed'), 'error');
});

module.exports = actions;
5 changes: 4 additions & 1 deletion jsapp/js/app.es6
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,11 @@ export var routes = (

<Route path='settings'>
<IndexRoute component={FormSubScreens} />
<Route path='kobocat' component={FormSubScreens} />
<Route path='media' component={FormSubScreens} />
<Route path='sharing' component={FormSubScreens} />
<Route path='rest' component={FormSubScreens} />
<Route path='rest/:hookUid' component={FormSubScreens} />
<Route path='kobocat' component={FormSubScreens} />
</Route>

{/* used to force refresh form screens */}
Expand Down
20 changes: 20 additions & 0 deletions jsapp/js/bem.es6
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ bem.Loading = BEM('loading');
bem.Loading__inner = bem.Loading.__('inner');
bem.Loading__msg = bem.Loading.__('msg');

bem.EmptyContent = BEM('empty-content', '<section>');
bem.EmptyContent__icon = bem.EmptyContent.__('icon', '<i>');
bem.EmptyContent__title = bem.EmptyContent.__('title', '<h1>');
bem.EmptyContent__message = bem.EmptyContent.__('message', '<p>');
bem.EmptyContent__button = bem.EmptyContent.__('button', '<button>');

bem.AssetRow = BEM('asset-row', '<li>');
bem.AssetRow__cell = bem.AssetRow.__('cell');
bem.AssetRow__cellmeta = bem.AssetRow.__('cellmeta');
Expand All @@ -22,6 +28,10 @@ bem.AssetRow__actionIcon = bem.AssetRow.__('action-icon', '<a>');
bem.AssetRow__buttons = bem.AssetRow.__('buttons');
bem.AssetRow__typeIcon = bem.AssetRow.__('type-icon', '<span>');

bem.ServiceRow = BEM('service-row');
bem.ServiceRow__column = bem.ServiceRow.__('column');
bem.ServiceRow__actionButton = bem.ServiceRow.__('action-button', '<button>');

bem.FormBuilder = bem('formBuilder');
bem.FormBuilder__row = bem.FormBuilder.__('row');
bem.FormBuilder__contents = bem.FormBuilder.__('contents');
Expand Down Expand Up @@ -239,6 +249,16 @@ bem.TextBox__input = bem.TextBox.__('input', '<input>');
bem.TextBox__description = bem.TextBox.__('description');
bem.TextBox__error = bem.TextBox.__('error');

bem.Checkbox = bem('checkbox');
bem.Checkbox__wrapper = bem.Checkbox.__('wrapper', '<label>');
bem.Checkbox__input = bem.Checkbox.__('input', '<input>');
bem.Checkbox__label = bem.Checkbox.__('label', '<span>');

bem.Radio = bem('radio');
bem.Radio__wrapper = bem.Radio.__('wrapper', '<label>');
bem.Radio__input = bem.Radio.__('input', '<input>');
bem.Radio__label = bem.Radio.__('label', '<span>');

bem.PrintOnly = BEM('print-only');

bem.GitRev = BEM('git-rev');
Expand Down
33 changes: 33 additions & 0 deletions jsapp/js/components/RESTServices.es6
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import autoBind from 'react-autobind';
import DocumentTitle from 'react-document-title';
import bem from '../bem';
import RESTServicesList from './RESTServices/RESTServicesList'
import RESTServiceLogs from './RESTServices/RESTServiceLogs'
import {t} from '../utils';

export default class RESTServices extends React.Component {
constructor(props){
super(props);
autoBind(this);
}

render() {
const docTitle = this.props.asset.name || t('Untitled');
if (this.props.hookUid) {
return (
<DocumentTitle title={`${docTitle} | KoboToolbox`}>
<bem.FormView m={'form-settings'} className='rest-services'>
<RESTServiceLogs assetUid={this.props.asset.uid} hookUid={this.props.hookUid} />
</bem.FormView>
</DocumentTitle>
);
} else {
return (
<DocumentTitle title={`${docTitle} | KoboToolbox`}>
<RESTServicesList assetUid={this.props.asset.uid} />
</DocumentTitle>
);
}
}
};
Loading