@imposium-hub/components 1.27.0 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imposium-hub/components",
3
- "version": "1.27.0",
3
+ "version": "1.28.0",
4
4
  "description": "React & Typescript component / asset library for Imposium front-ends",
5
5
  "main": "dist/components.js",
6
6
  "scripts": {
@@ -42,7 +42,7 @@ export const getAssets = (api : IImposiumAPI, storyId : string) : any => {
42
42
  dispatch(toggleLoading(true));
43
43
  }
44
44
 
45
- api.getAssets(assetFilters, storyId)
45
+ api.getAssets(assetFilters, storyId, true)
46
46
  .then((assetList : any) => {
47
47
  dispatch({type: assetActions.GET, assetList});
48
48
  dispatch(toggleLoading(false));
@@ -60,18 +60,16 @@ export const deleteAssets = (api : IImposiumAPI, ids : string[], storyId : strin
60
60
  return (dispatch) => {
61
61
  if (window.confirm(`Are you sure you want to delete ${ids.length} assets?`)) {
62
62
  return new Promise<void>((resolve, reject) => {
63
- const requests : Array<Promise<any | Error>> = ids.map((id : string) => (api.deleteAsset(id)));
64
-
65
63
  dispatch(toggleLoading(true));
66
- Promise.all(requests)
67
- .then(() => {
68
- dispatch(getAssets(api, storyId));
69
- resolve();
70
- })
71
- .catch((errors : Error[]) => {
72
- dispatch(toggleLoading(false));
73
- reject();
74
- });
64
+ api.deleteAssets(ids)
65
+ .then(() => {
66
+ dispatch(getAssets(api, storyId));
67
+ resolve();
68
+ })
69
+ .catch((errors : Error[]) => {
70
+ dispatch(toggleLoading(false));
71
+ reject();
72
+ });
75
73
  });
76
74
  }
77
75
  };
@@ -1,4 +1,5 @@
1
1
  import IImposiumAPI from '../../services/API';
2
+ import {doAssetTableHydration} from './asset-list';
2
3
 
3
4
  const assetUploadsActions : any = {
4
5
  TOGGLE_AUTO_TAG: 'assetUploads/TOGGLE_AUTO_TAG',
@@ -54,10 +55,13 @@ export const uploadAssets = (api : IImposiumAPI, files : File[], storyId : strin
54
55
  return {
55
56
  footageId: f[0].id,
56
57
  jobId: f[0].job_id,
57
- onProcessed: () => dispatch({
58
- type: assetUploadsActions.REMOVE_UPLOAD,
59
- filename: uploadBlobs[i].filename
60
- })
58
+ onProcessed: () => {
59
+ dispatch({
60
+ type: assetUploadsActions.REMOVE_UPLOAD,
61
+ filename: uploadBlobs[i].filename
62
+ });
63
+ doAssetTableHydration(api, storyId);
64
+ }
61
65
  };
62
66
  });
63
67
 
@@ -69,6 +73,7 @@ export const uploadAssets = (api : IImposiumAPI, files : File[], storyId : strin
69
73
  type: assetUploadsActions.REMOVE_UPLOAD,
70
74
  filename: uploadBlobs[i].filename
71
75
  });
76
+ doAssetTableHydration(api, storyId);
72
77
  }
73
78
 
74
79
  return jobIdExists;
@@ -94,7 +99,8 @@ const pollAssetJobs = (api, ongoingJobs : any[], timeout : number) : void => {
94
99
  let processedJob : any;
95
100
 
96
101
  ongoingJobResults.forEach((ongoingJobResult : any) => {
97
- if (!ongoingJobResult.processing) {
102
+
103
+ if (ongoingJobResult.status === 'processing' || ongoingJobResult.status === 'completed') {
98
104
  processedJob = ongoingJobs
99
105
  .find((ongoingJob : any) => (ongoingJob.jobId === ongoingJobResult.id));
100
106
 
@@ -104,6 +110,7 @@ const pollAssetJobs = (api, ongoingJobs : any[], timeout : number) : void => {
104
110
  .filter((ongoingJob : any) => (ongoingJob.jobId !== ongoingJobResult.id));
105
111
  }
106
112
  }
113
+ // TODO: handle errored out
107
114
  });
108
115
 
109
116
  if (ongoingJobs.length > 0) {
package/services/API.ts CHANGED
@@ -8,6 +8,7 @@ export interface IImposiumAPI {
8
8
  getAssetItem(assetId : string);
9
9
  uploadAsset(storyId : string, tags : string, file : File);
10
10
  deleteAsset(assetId : string);
11
+ deleteAssets(assetIds : string[]);
11
12
  copyAsset(assetId : string, data);
12
13
  addAssetTag(assetId : string, tag : string);
13
14
  deleteAssetTag(assetId : string, tag : string);
@@ -251,10 +252,9 @@ export default class API {
251
252
  });
252
253
  }
253
254
 
254
- public getAssets = (filters : any, storyId : string) : Promise<any | Error> => {
255
+ public getAssets = (filters : any, storyId : string, unprocessed = false) : Promise<any | Error> => {
255
256
 
256
- // TODO: add story_id filtering
257
- let parameterizedRoute : string = `/assets?items_per_page=50&optional_story_id=${storyId}`;
257
+ let parameterizedRoute : string = `/assets?items_per_page=50&optional_story_id=${storyId}&unprocessed=${unprocessed}`;
258
258
  let tagsSplit : string[];
259
259
 
260
260
  for (const key in filters) {
@@ -348,6 +348,16 @@ export default class API {
348
348
  });
349
349
  }
350
350
 
351
+ public deleteAssets = (assetIds : string[]) : Promise<any | Error> => {
352
+ return this.doRequest({
353
+ method: 'DELETE',
354
+ url: `/assets`,
355
+ data: {
356
+ ids: assetIds
357
+ }
358
+ });
359
+ }
360
+
351
361
  public copyAsset = (assetId : string, data : any) : Promise<any | Error> => {
352
362
 
353
363
  return this.doRequest({