mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-02 11:49:23 +00:00
Merge pull request #1135 from theseyi/async-updates
updates async chunking scheduler to use rAF. misc minor updates
This commit is contained in:
commit
1856df006f
@ -1,5 +1,6 @@
|
||||
import Component from '@ember/component';
|
||||
import { get, set } from '@ember/object';
|
||||
import { alias } from '@ember/object/computed';
|
||||
import { task } from 'ember-concurrency';
|
||||
import { DatasetPlatform, nodeToQueryParams } from 'wherehows-web/constants';
|
||||
import { IBrowserRouteParams } from 'wherehows-web/routes/browse/entity';
|
||||
@ -65,6 +66,12 @@ export default class BrowserRail extends Component {
|
||||
*/
|
||||
params: IBrowserRouteParams;
|
||||
|
||||
/**
|
||||
* Text to be displayed at the top of the rail
|
||||
* @type {string}
|
||||
*/
|
||||
header = alias('params.platform');
|
||||
|
||||
/**
|
||||
* Maintains a list the nodes platforms or prefixes available in the selected entity
|
||||
* @type {Array<IRailNode>}
|
||||
@ -87,12 +94,14 @@ export default class BrowserRail extends Component {
|
||||
* @type {TaskProperty<Promise<string[]>> & {perform: (a?: {} | undefined) => TaskInstance<Promise<string[]>>}}
|
||||
* @memberof BrowserRail
|
||||
*/
|
||||
getNodesTask = task(function*(this: BrowserRail): IterableIterator<Promise<Array<string>>> {
|
||||
getNodesTask = task(function*(
|
||||
this: BrowserRail
|
||||
): IterableIterator<Promise<Array<string>> | Promise<Array<IRailNode>>> {
|
||||
const { prefix, platform, entity } = get(this, 'params');
|
||||
const nodes: Array<IRailNode> = mapNodeToRoute(<DatasetPlatform>platform, entity)(
|
||||
yield readPlatforms({ platform, prefix })
|
||||
);
|
||||
|
||||
set(this, 'nodes', nodes);
|
||||
}).drop();
|
||||
}).restartable();
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ export default class BrowserViewport extends Component {
|
||||
});
|
||||
|
||||
return response;
|
||||
}).drop();
|
||||
}).restartable();
|
||||
|
||||
/**
|
||||
* Async requests for the list of entities and sets the value on class
|
||||
@ -113,7 +113,7 @@ export default class BrowserViewport extends Component {
|
||||
yield (<IGetEntityTaskStrategy>{
|
||||
datasets: get(this, 'getDatasetsTask').perform('set', offset)
|
||||
})[entity];
|
||||
});
|
||||
}).restartable();
|
||||
|
||||
/**
|
||||
* The max possible entities that can currently be requested up to this.count
|
||||
|
||||
@ -171,7 +171,7 @@ export default class DatasetAclAccessContainer extends Component {
|
||||
const userAcl: Array<IAccessControlEntry> = yield isUserInAcl(userName)(acls);
|
||||
|
||||
return get(this, 'userAcl').setObjects(userAcl);
|
||||
}).drop();
|
||||
}).restartable();
|
||||
|
||||
/**
|
||||
* Requests the current user be added to the acl
|
||||
|
||||
@ -253,6 +253,7 @@
|
||||
|
||||
&__edit {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__prop {
|
||||
|
||||
@ -36,7 +36,8 @@ $pad-width: 16px;
|
||||
.nacho-filter-card {
|
||||
@include restyle(filter-card);
|
||||
max-height: 625px;
|
||||
overflow: scroll;
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
|
||||
@ -1 +1 @@
|
||||
{{browser/browser-rail nodes=nodes nodesTask=getNodesTask}}
|
||||
{{browser/browser-rail nodes=nodes nodesTask=getNodesTask header=header}}
|
||||
|
||||
@ -1,3 +1,10 @@
|
||||
<div>
|
||||
{{more-info
|
||||
link="http://go/jitaclfaq"
|
||||
tooltip="Click for more information on ACL Access"
|
||||
}}
|
||||
</div>
|
||||
|
||||
<header class="acl-permission__header">
|
||||
{{#if userHasAclAccess}}
|
||||
<i class="fa fa-check-circle-o fa-lg acl-permission__success" title="You are in this dataset's ACL"></i>
|
||||
@ -7,17 +14,6 @@
|
||||
You have access to this dataset
|
||||
</strong>
|
||||
</div>
|
||||
{{else}}
|
||||
<i class="fa fa-ban fa-lg acl-permission__reject" title="You are not in this dataset's ACL"></i>
|
||||
|
||||
<div class="acl-permission__meta">
|
||||
<strong class="acl-permission__reject acl-permission__meta__header">
|
||||
You currently do not have access to this dataset
|
||||
</strong>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if userHasAclAccess}}
|
||||
|
||||
<button
|
||||
class="nacho-button--large nacho-button--inverse remove-acl-access-button"
|
||||
@ -30,8 +26,16 @@
|
||||
Remove My Access
|
||||
{{/if}}
|
||||
</button>
|
||||
{{else}}
|
||||
<i class="fa fa-ban fa-lg acl-permission__reject" title="You are not in this dataset's ACL"></i>
|
||||
|
||||
<div class="acl-permission__meta">
|
||||
<strong class="acl-permission__reject acl-permission__meta__header">
|
||||
You currently do not have access to this dataset
|
||||
</strong>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
class="nacho-breadcrumbs__crumb__grain"}}
|
||||
|
||||
<span class="nacho-breadcrumbs__crumb__text">
|
||||
{{crumb.crumb}}
|
||||
{{split-text crumb.crumb 18}}
|
||||
</span>
|
||||
|
||||
{{/link-to}}
|
||||
|
||||
@ -123,18 +123,17 @@
|
||||
|
||||
{{#row.cell}}
|
||||
<div class="dataset-compliance-fields__id-field-wrap">
|
||||
{{#if isReadOnly}}
|
||||
{{#if (and isReadOnly (not row.isReadonly))}}
|
||||
<div class="dataset-compliance-fields__id-field-wrap__edit">
|
||||
<span class="nacho-tooltip" title="Edit Fields">
|
||||
<button
|
||||
class="nacho-button nacho-button--tertiary dataset-compliance-fields__rollup-toggle"
|
||||
onclick={{action row.onEditPolicy (action "nextStep")}}>
|
||||
|
||||
<button
|
||||
class="nacho-button nacho-button--tertiary dataset-compliance-fields__rollup-toggle"
|
||||
onclick={{action row.onEditPolicy (action "nextStep")}}>
|
||||
<i class="fa fa-pencil" aria-label="Edit Fields"></i>
|
||||
|
||||
<span class="nacho-tooltip" title="Edit Policy">
|
||||
<i class="fa fa-pencil" aria-label="Edit Policy"></i>
|
||||
</span>
|
||||
|
||||
</button>
|
||||
</button>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
{{/if}}
|
||||
@ -214,20 +213,18 @@
|
||||
{{/row.cell}}
|
||||
|
||||
{{#row.cell}}
|
||||
<span class="nacho-tooltip" title="{{if row.isRowExpanded 'Collapse field' 'Expand field'}}">
|
||||
<button
|
||||
class="nacho-button nacho-button--tertiary dataset-compliance-fields__rollup-toggle"
|
||||
onclick={{action row.onToggleRowExpansion}}>
|
||||
<span class="nacho-tooltip" text="{{if row.isRowExpanded 'Collapse field' 'Expand field'}}">
|
||||
|
||||
{{#if row.isRowExpanded}}
|
||||
<i class="glyphicon glyphicon-menu-up" aria-label="Expand field"></i>
|
||||
{{else}}
|
||||
<i class="glyphicon glyphicon-menu-down" aria-label="Collapse field"></i>
|
||||
{{/if}}
|
||||
|
||||
</span>
|
||||
|
||||
{{#if row.isRowExpanded}}
|
||||
<i class="glyphicon glyphicon-menu-up" aria-label="Expand field"></i>
|
||||
{{else}}
|
||||
<i class="glyphicon glyphicon-menu-down" aria-label="Collapse field"></i>
|
||||
{{/if}}
|
||||
</button>
|
||||
</span>
|
||||
{{/row.cell}}
|
||||
</tr>
|
||||
|
||||
|
||||
@ -88,19 +88,18 @@ const chunkArrayAsync = <T, U>(
|
||||
) => (list: Array<T>) =>
|
||||
new Promise<U>(function(resolve) {
|
||||
const queue = list.slice(0); // creates a shallow copy of the original list
|
||||
const delay = 25;
|
||||
let result: U;
|
||||
|
||||
setTimeout(function chunk() {
|
||||
requestAnimationFrame(function chunk() {
|
||||
const startTime = +new Date();
|
||||
|
||||
do {
|
||||
result = accumulator(iterateeSync.call(context, queue.splice(0, chunkSize)));
|
||||
} while (queue.length && +new Date() + startTime < 50);
|
||||
} while (queue.length && +new Date() + startTime < 18);
|
||||
|
||||
// recurse through list if there are more items left
|
||||
return queue.length ? setTimeout(chunk, delay) : resolve(result);
|
||||
}, delay);
|
||||
return queue.length ? requestAnimationFrame(chunk) : resolve(result);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
@ -114,7 +113,7 @@ const iterateArrayAsync = <T, U = T>(iteratee: (arr?: Array<T>) => Array<U>) =>
|
||||
list: Array<T>,
|
||||
context = null
|
||||
): Promise<Array<U>> => {
|
||||
const accumulator = (base: Array<U>) => (arr: Array<U>) => [...base, ...arr];
|
||||
const accumulator = (base: Array<U>) => (arr: Array<U>) => (base = [...base, ...arr]);
|
||||
return chunkArrayAsync(iteratee, accumulator([]), { chunkSize: 50, context })(list);
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user