Case 2: integrate PROOFSCOPE in an external approval system
This case is an extension of case 1 and describes how to integrate PROOFSCOPE in an external approval system that keeps track of approvals.
In this case you can show the approval state of the assets in the external system.
1 api_async.proofscope.get_view_info(pToken, function(pResult) {
2 api.m_session = pResult.use_session;
3 api_sync.m_session = pResult.use_session;
4 api_async.m_session = pResult.use_session;
5
6 var viewerParameters = $.extend(pResult.view.parameters, {
7 standalone: {
8
9 approve: true,
10
11 getAssessment: function(pSession, pFileInfo, pSuccess, pFailed) {
12 pSuccess(assessment);
13 },
14
15 setAssessment: function(pSession, pFileInfo, pAssessment, pSuccess, pFailed) {
16 assessment = pAssessment;
17 pSuccess();
18 }
19 }
20 });
21
22 $('#proofscope').Proofscope(viewerParameters);
23 });
- Line 6 uses the $.extend jQuery function (see https://api.jquery.com/jquery.extend/). This function will merge two JSON
structures together and returns the merged results. It will add the JSON of lines 7 to 19
to the viewer parameters that were returned by the
get_view_info
call. - Line 7 will start a JSON structure called standalone. This JSON contains parameters specific to PROOFSCOPE integrations outside CLOUDFLOW.
- Line 9 will set the flag approve to true. It instructs not to use CLOUDFLOW approvals anymore, but to use an external system for approvals.
- Line 11 will set the getAssessment callback, which is
called by PROOFSCOPE. It should return the current approval state. Here you will need to
enter the integration code with the external system. You receive the session information
(first parameter) and the file information (second parameter). When you have received the
information the pSuccess function is called (line 12). It
takes one parameter: the current assessment. The current assessment is a string which can
be:
- pending: in this case the user needs to approve this file.
- accept: in this case the user has approved this file.
- reject: in this case the user has rejected this file.
- none: in this case the user doesn't need to approve this file.
- Line 15 is similar to line 11, but will send the assessment from PROOFSCOPE to the external system when the user clicks the approve or reject button. The assessment is encoded in pAssessment and is either accept or reject. Session and file information is passed in the first and second parameter. You can call the pSuccess or pFailed functions when the external back end is updated.
- Line 22 will create the PROOFSCOPE component with the described setup.
The Session object
The session object has two functions. Here is an example:
1 getAssessment: function(pSession, pFileInfo, pSuccess, pFailed) {
2 var email = pSession.getUserEmail();
3 ...
4 pSuccess(assessment);
5 },
Line 2 returns the users email for the session and stores it in the variable email.
There are two functions
for the Session object:
- getUserID: this function returns the ID of the user for the PROOFSCOPE session.
- getUserEmail: this function returns the email of the user for the PROOFSCOPE session.
The Fileinfo object
The functionality of the Fileinfo is identical to Session object.
There is one function for the Fileinfo object:
- getAssetID: this function returns the CLOUDFLOW asset ID that is currently viewed.