Merge branch 'dev' of https://github.com/abpframework/abp into feat/replaceable-layouts

pull/3384/head
mehmet-erim 6 years ago
commit 818438ef50

@ -26,7 +26,7 @@ The constructor does not get any parameters.
### How to Add New Nodes
There are a few methods to create new nodes in a linked list and all of them are separately available as well as revealed from an `add` method.
There are several methods to create new nodes in a linked list and all of them are separately available as well as revealed by `add` and `addMany` methods.
@ -50,6 +50,22 @@ list.addHead('c');
#### addManyHead(values: T\[\]): ListNode\<T\>\[\]
Adds multiple nodes with given values as the first nodes in list:
```js
list.addManyHead(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
list.addManyHead(['x', 'y', 'z']);
// "x" <-> "y" <-> "z" <-> "a" <-> "b" <-> "c"
```
#### addTail(value: T): ListNode\<T\>
Adds a node with given value as the last node in list:
@ -70,6 +86,22 @@ list.addTail('c');
#### addManyTail(values: T\[\]): ListNode\<T\>\[\]
Adds multiple nodes with given values as the last nodes in list:
```js
list.addManyTail(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
list.addManyTail(['x', 'y', 'z']);
// "a" <-> "b" <-> "c" <-> "x" <-> "y" <-> "z"
```
#### addAfter(value: T, previousValue: T, compareFn = compare): ListNode\<T\>
Adds a node with given value after the first node that has the previous value:
@ -109,6 +141,40 @@ list.addAfter({ x: 0 }, { x: 2 }, (v1, v2) => v1.x === v2.x);
#### addManyAfter(values: T\[\], previousValue: T, compareFn = compare): ListNode\<T\>\[\]
Adds multiple nodes with given values after the first node that has the previous value:
```js
list.addManyTail(['a', 'b', 'b', 'c']);
// "a" <-> "b" <-> "b" <-> "c"
list.addManyAfter(['x', 'y'], 'b');
// "a" <-> "b" <-> "x" <-> "y" <-> "b" <-> "c"
```
You may pass a custom compare function to detect the searched value:
```js
list.addManyTail([{ x: 1 },{ x: 2 },{ x: 3 }]);
// {"x":1} <-> {"x":2} <-> {"x":3}
list.addManyAfter([{ x: 4 }, { x: 5 }], { x: 2 }, (v1, v2) => v1.x === v2.x);
// {"x":1} <-> {"x":2} <-> {"x":4} <-> {"x":5} <-> {"x":3}
```
> The default compare function checks deep equality, so you will rarely need to pass that parameter.
#### addBefore(value: T, nextValue: T, compareFn = compare): ListNode\<T\>
Adds a node with given value before the first node that has the next value:
@ -148,6 +214,40 @@ list.addBefore({ x: 0 }, { x: 2 }, (v1, v2) => v1.x === v2.x);
#### addManyBefore(values: T\[\], nextValue: T, compareFn = compare): ListNode\<T\>\[\]
Adds multiple nodes with given values before the first node that has the next value:
```js
list.addManyTail(['a', 'b', 'b', 'c']);
// "a" <-> "b" <-> "b" <-> "c"
list.addManyBefore(['x', 'y'], 'b');
// "a" <-> "x" <-> "y" <-> "b" <-> "b" <-> "c"
```
You may pass a custom compare function to detect the searched value:
```js
list.addManyTail([{ x: 1 },{ x: 2 },{ x: 3 }]);
// {"x":1} <-> {"x":2} <-> {"x":3}
list.addManyBefore([{ x: 4 }, { x: 5 }], { x: 2 }, (v1, v2) => v1.x === v2.x);
// {"x":1} <-> {"x":4} <-> {"x":5} <-> {"x":2} <-> {"x":3}
```
> The default compare function checks deep equality, so you will rarely need to pass that parameter.
#### addByIndex(value: T, position: number): ListNode\<T\>
Adds a node with given value at the specified position in the list:
@ -166,6 +266,52 @@ list.addByIndex('x', 2);
It works with negative index too:
```js
list.addTail('a');
list.addTail('b');
list.addTail('c');
// "a" <-> "b" <-> "c"
list.addByIndex('x', -1);
// "a" <-> "b" <-> "x" <-> "c"
```
#### addManyByIndex(values: T\[\], position: number): ListNode\<T\>\[\]
Adds multiple nodes with given values at the specified position in the list:
```js
list.addManyTail(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
list.addManyByIndex(['x', 'y'], 2);
// "a" <-> "b" <-> "x" <-> "y" <-> "c"
```
It works with negative index too:
```js
list.addManyTail(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
list.addManyByIndex(['x', 'y'], -1);
// "a" <-> "b" <-> "x" <-> "y" <-> "c"
```
#### add(value: T).head(): ListNode\<T\>
Adds a node with given value as the first node in list:
@ -314,10 +460,172 @@ list.add('x').byIndex(2);
It works with negative index too:
```js
list.add('a').tail();
list.add('b').tail();
list.add('c').tail();
// "a" <-> "b" <-> "c"
list.add('x').byIndex(-1);
// "a" <-> "b" <-> "x" <-> "c"
```
> This is an alternative API for `addByIndex`.
#### addMany(values: T\[\]).head(): ListNode\<T\>\[\]
Adds multiple nodes with given values as the first nodes in list:
```js
list.addMany(['a', 'b', 'c']).head();
// "a" <-> "b" <-> "c"
list.addMany(['x', 'y', 'z']).head();
// "x" <-> "y" <-> "z" <-> "a" <-> "b" <-> "c"
```
> This is an alternative API for `addManyHead`.
#### addMany(values: T\[\]).tail(): ListNode\<T\>\[\]
Adds multiple nodes with given values as the last nodes in list:
```js
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
list.addMany(['x', 'y', 'z']).tail();
// "a" <-> "b" <-> "c" <-> "x" <-> "y" <-> "z"
```
> This is an alternative API for `addManyTail`.
#### addMany(values: T\[\]).after(previousValue: T, compareFn = compare): ListNode\<T\>\[\]
Adds multiple nodes with given values after the first node that has the previous value:
```js
list.addMany(['a', 'b', 'b', 'c']).tail();
// "a" <-> "b" <-> "b" <-> "c"
list.addMany(['x', 'y']).after('b');
// "a" <-> "b" <-> "x" <-> "y" <-> "b" <-> "c"
```
You may pass a custom compare function to detect the searched value:
```js
list.addMany([{ x: 1 }, { x: 2 }, { x: 3 }]).tail();
// {"x":1} <-> {"x":2} <-> {"x":3}
list.addMany([{ x: 4 }, { x: 5 }]).after({ x: 2 }, (v1, v2) => v1.x === v2.x);
// {"x":1} <-> {"x":2} <-> {"x":4} <-> {"x":5} <-> {"x":3}
```
> This is an alternative API for `addManyAfter`.
>
> The default compare function checks deep equality, so you will rarely need to pass that parameter.
#### addMany(values: T\[\]).before(nextValue: T, compareFn = compare): ListNode\<T\>\[\]
Adds multiple nodes with given values before the first node that has the next value:
```js
list.addMany(['a', 'b', 'b', 'c']).tail();
// "a" <-> "b" <-> "b" <-> "c"
list.addMany(['x', 'y']).before('b');
// "a" <-> "x" <-> "y" <-> "b" <-> "b" <-> "c"
```
You may pass a custom compare function to detect the searched value:
```js
list.addMany([{ x: 1 }, { x: 2 }, { x: 3 }]).tail();
// {"x":1} <-> {"x":2} <-> {"x":3}
list.addMany([{ x: 4 }, { x: 5 }]).before({ x: 2 }, (v1, v2) => v1.x === v2.x);
// {"x":1} <-> {"x":4} <-> {"x":5} <-> {"x":2} <-> {"x":3}
```
> This is an alternative API for `addManyBefore`.
>
> The default compare function checks deep equality, so you will rarely need to pass that parameter.
#### addMany(values: T\[\]).byIndex(position: number): ListNode\<T\>\[\]
Adds multiple nodes with given values at the specified position in the list:
```js
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
list.addMany(['x', 'y']).byIndex(2);
// "a" <-> "b" <-> "x" <-> "y" <-> "c"
```
It works with negative index too:
```js
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
list.addMany(['x', 'y']).byIndex(-1);
// "a" <-> "b" <-> "x" <-> "y" <-> "c"
```
> This is an alternative API for `addManyByIndex`.
### How to Remove Nodes
There are a few methods to remove nodes from a linked list and all of them are separately available as well as revealed from a `drop` method.
@ -329,9 +637,7 @@ There are a few methods to remove nodes from a linked list and all of them are s
Removes the first node from the list:
```js
list.addTail('a');
list.addTail('b');
list.addTail('c');
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
@ -342,14 +648,28 @@ list.dropHead();
#### dropManyHead(count: number): ListNode\<T\>\[\]
Removes the first nodes from the list based on given count:
```js
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
list.dropManyHead(2);
// "c"
```
#### dropTail(): ListNode\<T\> | undefined
Removes the last node from the list:
```js
list.addTail('a');
list.addTail('b');
list.addTail('c');
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
@ -360,14 +680,28 @@ list.dropTail();
#### dropManyTail(count: number): ListNode\<T\>\[\]
Removes the last nodes from the list based on given count:
```js
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
list.dropManyTail(2);
// "a"
```
#### dropByIndex(position: number): ListNode\<T\> | undefined
Removes the node with the specified position from the list:
```js
list.addTail('a');
list.addTail('b');
list.addTail('c');
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
@ -378,16 +712,56 @@ list.dropByIndex(1);
It works with negative index too:
```js
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
list.dropByIndex(-2);
// "a" <-> "c"
```
#### dropManyByIndex(count: number, position: number): ListNode\<T\>\[\]
Removes the nodes starting from the specified position from the list based on given count:
```js
list.addMany(['a', 'b', 'c', 'd']).tail();
// "a" <-> "b" <-> "c" <-> "d
list.dropManyByIndex(2, 1);
// "a" <-> "d"
```
It works with negative index too:
```js
list.addMany(['a', 'b', 'c', 'd']).tail();
// "a" <-> "b" <-> "c" <-> "d
list.dropManyByIndex(2, -2);
// "a" <-> "d"
```
#### dropByValue(value: T, compareFn = compare): ListNode\<T\> | undefined
Removes the first node with given value from the list:
```js
list.addTail('a');
list.addTail('x');
list.addTail('b');
list.addTail('x');
list.addTail('c');
list.addMany(['a', 'x', 'b', 'x', 'c']).tail();
// "a" <-> "x" <-> "b" <-> "x" <-> "c"
@ -401,11 +775,7 @@ list.dropByValue('x');
You may pass a custom compare function to detect the searched value:
```js
list.addTail({ x: 1 });
list.addTail({ x: 0 });
list.addTail({ x: 2 });
list.addTail({ x: 0 });
list.addTail({ x: 3 });
list.addMany([{ x: 1 }, { x: 0 }, { x: 2 }, { x: 0 }, { x: 3 }]).tail();
// {"x":1} <-> {"x":0} <-> {"x":2} <-> {"x":0} <-> {"x":3}
@ -425,11 +795,7 @@ list.dropByValue({ x: 0 }, (v1, v2) => v1.x === v2.x);
Removes all nodes with given value from the list:
```js
list.addTail('a');
list.addTail('x');
list.addTail('b');
list.addTail('x');
list.addTail('c');
list.addMany(['a', 'x', 'b', 'x', 'c']).tail();
// "a" <-> "x" <-> "b" <-> "x" <-> "c"
@ -443,11 +809,7 @@ list.dropByValueAll('x');
You may pass a custom compare function to detect the searched value:
```js
list.addTail({ x: 1 });
list.addTail({ x: 0 });
list.addTail({ x: 2 });
list.addTail({ x: 0 });
list.addTail({ x: 3 });
list.addMany([{ x: 1 }, { x: 0 }, { x: 2 }, { x: 0 }, { x: 3 }]).tail();
// {"x":1} <-> {"x":0} <-> {"x":2} <-> {"x":0} <-> {"x":3}
@ -467,9 +829,7 @@ list.dropByValue({ x: 0 }, (v1, v2) => v1.x === v2.x);
Removes the first node in list:
```js
list.add('a').tail();
list.add('b').tail();
list.add('c').tail();
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
@ -489,9 +849,7 @@ list.drop().head();
Removes the last node in list:
```js
list.add('a').tail();
list.add('b').tail();
list.add('c').tail();
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
@ -511,9 +869,7 @@ list.drop().tail();
Removes the node with the specified position from the list:
```js
list.add('a').tail();
list.add('b').tail();
list.add('c').tail();
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
@ -524,6 +880,20 @@ list.drop().byIndex(1);
It works with negative index too:
```js
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
list.drop().byIndex(-2);
// "a" <-> "c"
```
> This is an alternative API for `dropByIndex`.
@ -533,11 +903,7 @@ list.drop().byIndex(1);
Removes the first node with given value from the list:
```js
list.add('a').tail();
list.add('x').tail();
list.add('b').tail();
list.add('x').tail();
list.add('c').tail();
list.addMany(['a', 'x', 'b', 'x', 'c']).tail();
// "a" <-> "x" <-> "b" <-> "x" <-> "c"
@ -551,11 +917,7 @@ list.drop().byValue('x');
You may pass a custom compare function to detect the searched value:
```js
list.add({ x: 1 }).tail();
list.add({ x: 0 }).tail();
list.add({ x: 2 }).tail();
list.add({ x: 0 }).tail();
list.add({ x: 3 }).tail();
list.addMany([{ x: 1 }, { x: 0 }, { x: 2 }, { x: 0 }, { x: 3 }]).tail();
// {"x":1} <-> {"x":0} <-> {"x":2} <-> {"x":0} <-> {"x":3}
@ -577,11 +939,7 @@ list.drop().byValue({ x: 0 }, (v1, v2) => v1.x === v2.x);
Removes all nodes with given value from the list:
```js
list.add('a').tail();
list.add('x').tail();
list.add('b').tail();
list.add('x').tail();
list.add('c').tail();
list.addMany(['a', 'x', 'b', 'x', 'c']).tail();
// "a" <-> "x" <-> "b" <-> "x" <-> "c"
@ -595,11 +953,7 @@ list.drop().byValueAll('x');
You may pass a custom compare function to detect the searched value:
```js
list.add({ x: 1 }).tail();
list.add({ x: 0 }).tail();
list.add({ x: 2 }).tail();
list.add({ x: 0 }).tail();
list.add({ x: 3 }).tail();
list.addMany([{ x: 1 }, { x: 0 }, { x: 2 }, { x: 0 }, { x: 3 }]).tail();
// {"x":1} <-> {"x":0} <-> {"x":2} <-> {"x":0} <-> {"x":3}
@ -616,6 +970,80 @@ list.drop().byValueAll({ x: 0 }, (v1, v2) => v1.x === v2.x);
#### dropMany(count: number).head(): ListNode\<T\>\[\]
Removes the first nodes from the list based on given count:
```js
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
list.dropMany(2).head();
// "c"
```
> This is an alternative API for `dropManyHead`.
#### dropMany(count: number).tail(): ListNode\<T\>\[\]
Removes the last nodes from the list based on given count:
```js
list.addMany(['a', 'b', 'c']).tail();
// "a" <-> "b" <-> "c"
list.dropMany(2).tail();
// "a"
```
> This is an alternative API for `dropManyTail`.
#### dropMany(count: number).byIndex(position: number): ListNode\<T\>\[\]
Removes the nodes starting from the specified position from the list based on given count:
```js
list.addMany(['a', 'b', 'c', 'd']).tail();
// "a" <-> "b" <-> "c" <-> "d
list.dropMany(2).byIndex(1);
// "a" <-> "d"
```
It works with negative index too:
```js
list.addMany(['a', 'b', 'c', 'd']).tail();
// "a" <-> "b" <-> "c" <-> "d
list.dropMany(2).byIndex(-2);
// "a" <-> "d"
```
> This is an alternative API for `dropManyByIndex`.
### How to Find Nodes
There are a few methods to find specific nodes in a linked list.
@ -627,10 +1055,7 @@ There are a few methods to find specific nodes in a linked list.
Finds the first node from the list that matches the given predicate:
```js
list.addTail('a');
list.addTail('b');
list.addTail('b');
list.addTail('c');
list.addTailMany(['a', 'b', 'b', 'c']);
// "a" <-> "b" <-> "b" <-> "c"
@ -650,10 +1075,7 @@ found.next.value === "b"
Finds the position of the first node from the list that matches the given predicate:
```js
list.addTail('a');
list.addTail('b');
list.addTail('b');
list.addTail('c');
list.addTailMany(['a', 'b', 'b', 'c']);
// "a" <-> "b" <-> "b" <-> "c"
@ -677,9 +1099,7 @@ i3 === -1
Finds and returns the node with specific position in the list:
```js
list.addTail('a');
list.addTail('b');
list.addTail('c');
list.addTailMany(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
@ -699,10 +1119,7 @@ found.next.value === "c"
Finds the position of the first node from the list that has the given value:
```js
list.addTail('a');
list.addTail('b');
list.addTail('b');
list.addTail('c');
list.addTailMany(['a', 'b', 'b', 'c']);
// "a" <-> "b" <-> "b" <-> "c"
@ -724,11 +1141,7 @@ i3 === -1
You may pass a custom compare function to detect the searched value:
```js
list.addTail({ x: 1 });
list.addTail({ x: 0 });
list.addTail({ x: 2 });
list.addTail({ x: 0 });
list.addTail({ x: 3 });
list.addTailMany([{ x: 1 }, { x: 0 }, { x: 2 }, { x: 0 }, { x: 3 }]);
// {"x":1} <-> {"x":0} <-> {"x":2} <-> {"x":0} <-> {"x":3}
@ -764,9 +1177,7 @@ There are a few ways to iterate over or display a linked list.
Runs a callback function on all nodes in a linked list from head to tail:
```js
list.addTail('a');
list.addTail('b');
list.addTail('c');
list.addTailMany(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
@ -784,9 +1195,7 @@ list.forEach((node, index) => console.log(node.value + index));
A linked list is iterable. In other words, you may use methods like `for...of` on it.
```js
list.addTail('a');
list.addTail('b');
list.addTail('c');
list.addTailMany(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
@ -801,14 +1210,12 @@ for(const node of list) {
#### toArray(): T[]
#### toArray(): T\[\]
Converts a linked list to an array:
Converts a linked list to an array of values:
```js
list.addTail('a');
list.addTail('b');
list.addTail('c');
list.addTailMany(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
@ -821,15 +1228,32 @@ arr === ['a', 'b', 'c']
#### toNodeArray(): T\[\]
Converts a linked list to an array of nodes:
```js
list.addTailMany(['a', 'b', 'c']);
// "a" <-> "b" <-> "c"
const arr = list.toNodeArray();
/*
arr[0].value === 'a'
arr[1].value === 'a'
arr[2].value === 'a'
*/
```
#### toString(): string
Converts a linked list to a string representation of nodes and their relations:
```js
list.addTail('a');
list.addTail(2);
list.addTail('c');
list.addTail({ k: 4, v: 'd' });
list.addTailMany(['a', 2, 'c', { k: 4, v: 'd' }]);
// "a" <-> 2 <-> "c" <-> {"k":4,"v":"d"}
@ -842,3 +1266,19 @@ str === '"a" <-> 2 <-> "c" <-> {"k":4,"v":"d"}'
You may pass a custom mapper function to map values before stringifying them:
```js
list.addMany([{ x: 1 }, { x: 2 }, { x: 3 }, { x: 4 }, { x: 5 }]).tail();
// {"x":1} <-> {"x":2} <-> {"x":3} <-> {"x":4} <-> {"x":5}
const str = list.toString(value => value.x);
/*
str === '1 <-> 2 <-> 3 <-> 4 <-> 5'
*/
```

@ -25,9 +25,9 @@ The files generated with the `--module all` option like below:
### Services
Each generated service matches a back-end controller. The services methods call back-end APIs via [RestService](./HTTP-Requests.md#restservice).
Each generated service matches a back-end controller. The services methods call back-end APIs via [RestService](./Http-Requests.md#restservice).
A variable named `apiName` (available as of v2.4) is defined in each service. `apiName` matches the module's RemoteServiceName. This variable passes to the `RestService` as a parameter at each request. If there is no microservice API defined in the environment, `RestService` uses the default. See [getting a specific API endpoint from application config](HTTP-Requests#how-to-get-a-specific-api-endpoint-from-application-config)
A variable named `apiName` (available as of v2.4) is defined in each service. `apiName` matches the module's RemoteServiceName. This variable passes to the `RestService` as a parameter at each request. If there is no microservice API defined in the environment, `RestService` uses the default. See [getting a specific API endpoint from application config](./Http-Requests.md#how-to-get-a-specific-api-endpoint-from-application-config)
The `providedIn` property of the services is defined as `'root'`. Therefore no need to add a service as a provider to a module. You can use a service by injecting it into a constructor as shown below:
@ -64,4 +64,4 @@ Initial values can optionally be passed to each class constructor.
## What's Next?
* [Http Requests](./Http-Requests.md)
* [HTTP Requests](./Http-Requests.md)

@ -5,7 +5,7 @@
"items": [
{
"text": "From Startup Templates",
"path": "Getting-Started-With-Startup-Templates.md"
"path": "Getting-Started-With-Startup-Templates.md",
"items": [
{
"text": "Application with MVC (Razor Pages) UI",

@ -7,6 +7,8 @@ import { RegisterResponse, RegisterRequest, TenantIdResponse } from '../models';
providedIn: 'root',
})
export class AccountService {
apiName = 'AbpAccount';
constructor(private rest: RestService) {}
findTenant(tenantName: string): Observable<TenantIdResponse> {
@ -15,7 +17,7 @@ export class AccountService {
url: `/api/abp/multi-tenancy/tenants/by-name/${tenantName}`,
};
return this.rest.request<null, TenantIdResponse>(request);
return this.rest.request<null, TenantIdResponse>(request, { apiName: this.apiName });
}
register(body: RegisterRequest): Observable<RegisterResponse> {
@ -25,6 +27,9 @@ export class AccountService {
body,
};
return this.rest.request<RegisterRequest, RegisterResponse>(request, { skipHandleError: true });
return this.rest.request<RegisterRequest, RegisterResponse>(request, {
skipHandleError: true,
apiName: this.apiName,
});
}
}

@ -3,12 +3,18 @@ import { Observable } from 'rxjs';
import { Rest } from '../models/rest';
import { ApplicationConfiguration } from '../models/application-configuration';
import { RestService } from './rest.service';
import { Store } from '@ngxs/store';
import { ConfigState } from '../states/config.state';
@Injectable({
providedIn: 'root',
})
export class ApplicationConfigurationService {
constructor(private rest: RestService) {}
get apiName(): string {
return this.store.selectSnapshot(ConfigState.getDeep('environment.application.name'));
}
constructor(private rest: RestService, private store: Store) {}
getConfiguration(): Observable<ApplicationConfiguration.Response> {
const request: Rest.Request<null> = {
@ -16,6 +22,8 @@ export class ApplicationConfigurationService {
url: '/api/abp/application-configuration',
};
return this.rest.request<null, ApplicationConfiguration.Response>(request);
return this.rest.request<null, ApplicationConfiguration.Response>(request, {
apiName: this.apiName,
});
}
}

@ -7,6 +7,8 @@ import { Profile, Rest } from '../models';
providedIn: 'root',
})
export class ProfileService {
apiName = 'AbpIdentity';
constructor(private rest: RestService) {}
get(): Observable<Profile.Response> {
@ -15,7 +17,7 @@ export class ProfileService {
url: '/api/identity/my-profile',
};
return this.rest.request<null, Profile.Response>(request);
return this.rest.request<null, Profile.Response>(request, { apiName: this.apiName });
}
update(body: Profile.Response): Observable<Profile.Response> {
@ -25,16 +27,24 @@ export class ProfileService {
body,
};
return this.rest.request<Profile.Response, Profile.Response>(request);
return this.rest.request<Profile.Response, Profile.Response>(request, {
apiName: this.apiName,
});
}
changePassword(body: Profile.ChangePasswordRequest, skipHandleError: boolean = false): Observable<null> {
changePassword(
body: Profile.ChangePasswordRequest,
skipHandleError: boolean = false,
): Observable<null> {
const request: Rest.Request<Profile.ChangePasswordRequest> = {
method: 'POST',
url: '/api/identity/my-profile/change-password',
body,
};
return this.rest.request<Profile.ChangePasswordRequest, null>(request, { skipHandleError });
return this.rest.request<Profile.ChangePasswordRequest, null>(request, {
skipHandleError,
apiName: this.apiName,
});
}
}

@ -81,7 +81,7 @@ export class ConfigState {
static getApiUrl(key?: string) {
const selector = createSelector([ConfigState], (state: Config.State): string => {
return state.environment.apis[key || 'default'].url;
return (state.environment.apis[key || 'default'] || state.environment.apis.default).url;
});
return selector;

@ -27,65 +27,107 @@ export class LinkedList<T = any> {
return this.size;
}
private linkWith(
private attach(
value: T,
previousNode: ListNode<T> | undefined,
nextNode: ListNode<T> | undefined,
): ListNode<T> {
const node = new ListNode(value);
if (!previousNode) return this.addHead(value);
if (!nextNode) return this.addTail(value);
const node = new ListNode(value);
node.previous = previousNode;
previousNode.next = node;
node.next = nextNode;
nextNode.previous = node;
this.size += 1;
this.size++;
return node;
}
private attachMany(
values: T[],
previousNode: ListNode<T> | undefined,
nextNode: ListNode<T> | undefined,
): ListNode<T>[] {
if (!values.length) return [];
if (!previousNode) return this.addManyHead(values);
if (!nextNode) return this.addManyTail(values);
const list = new LinkedList<T>();
list.addManyTail(values);
list.first!.previous = previousNode;
previousNode.next = list.first;
list.last!.next = nextNode;
nextNode.previous = list.last;
this.size += values.length;
return list.toNodeArray();
}
private detach(node: ListNode<T>) {
if (!node.previous) return this.dropHead();
if (!node.next) return this.dropTail();
node.previous.next = node.next;
node.next.previous = node.previous;
this.size--;
return node;
}
add(value: T) {
return {
after: (previousValue: T, compareFn = compare) => {
return this.addAfter(value, previousValue, compareFn);
},
before: (nextValue: T, compareFn = compare) => {
return this.addBefore(value, nextValue, compareFn);
},
byIndex: (position: number): ListNode<T> => {
return this.addByIndex(value, position);
},
head: (): ListNode<T> => {
return this.addHead(value);
},
tail: (): ListNode<T> => {
return this.addTail(value);
},
after: (previousValue: T, compareFn: ListComparisonFn<T> = compare) =>
this.addAfter(value, previousValue, compareFn),
before: (nextValue: T, compareFn: ListComparisonFn<T> = compare) =>
this.addBefore(value, nextValue, compareFn),
byIndex: (position: number) => this.addByIndex(value, position),
head: () => this.addHead(value),
tail: () => this.addTail(value),
};
}
addMany(values: T[]) {
return {
after: (previousValue: T, compareFn: ListComparisonFn<T> = compare) =>
this.addManyAfter(values, previousValue, compareFn),
before: (nextValue: T, compareFn: ListComparisonFn<T> = compare) =>
this.addManyBefore(values, nextValue, compareFn),
byIndex: (position: number) => this.addManyByIndex(values, position),
head: () => this.addManyHead(values),
tail: () => this.addManyTail(values),
};
}
addAfter(value: T, previousValue: T, compareFn = compare): ListNode<T> {
addAfter(value: T, previousValue: T, compareFn: ListComparisonFn<T> = compare): ListNode<T> {
const previous = this.find(node => compareFn(node.value, previousValue));
return previous ? this.linkWith(value, previous, previous.next) : this.addTail(value);
return previous ? this.attach(value, previous, previous.next) : this.addTail(value);
}
addBefore(value: T, nextValue: T, compareFn = compare): ListNode<T> {
addBefore(value: T, nextValue: T, compareFn: ListComparisonFn<T> = compare): ListNode<T> {
const next = this.find(node => compareFn(node.value, nextValue));
return next ? this.linkWith(value, next.previous, next) : this.addHead(value);
return next ? this.attach(value, next.previous, next) : this.addHead(value);
}
addByIndex(value: T, position: number): ListNode<T> {
if (position < 0) position += this.size;
else if (position >= this.size) return this.addTail(value);
if (position <= 0) return this.addHead(value);
if (position >= this.size) return this.addTail(value);
const next = this.get(position)!;
return this.linkWith(value, next.previous, next);
return this.attach(value, next.previous, next);
}
addHead(value: T): ListNode<T> {
@ -97,7 +139,7 @@ export class LinkedList<T = any> {
else this.last = node;
this.first = node;
this.size += 1;
this.size++;
return node;
}
@ -114,51 +156,92 @@ export class LinkedList<T = any> {
this.last = node;
}
this.size += 1;
this.size++;
return node;
}
addManyAfter(
values: T[],
previousValue: T,
compareFn: ListComparisonFn<T> = compare,
): ListNode<T>[] {
const previous = this.find(node => compareFn(node.value, previousValue));
return previous ? this.attachMany(values, previous, previous.next) : this.addManyTail(values);
}
addManyBefore(
values: T[],
nextValue: T,
compareFn: ListComparisonFn<T> = compare,
): ListNode<T>[] {
const next = this.find(node => compareFn(node.value, nextValue));
return next ? this.attachMany(values, next.previous, next) : this.addManyHead(values);
}
addManyByIndex(values: T[], position: number): ListNode<T>[] {
if (position < 0) position += this.size;
if (position <= 0) return this.addManyHead(values);
if (position >= this.size) return this.addManyTail(values);
const next = this.get(position)!;
return this.attachMany(values, next.previous, next);
}
addManyHead(values: T[]): ListNode<T>[] {
return values.reduceRight<ListNode<T>[]>((nodes, value) => {
nodes.unshift(this.addHead(value));
return nodes;
}, []);
}
addManyTail(values: T[]): ListNode<T>[] {
return values.map(value => this.addTail(value));
}
drop() {
return {
byIndex: (position: number) => this.dropByIndex(position),
byValue: (value: T, compareFn = compare) => this.dropByValue(value, compareFn),
byValueAll: (value: T, compareFn = compare) => this.dropByValueAll(value, compareFn),
byValue: (value: T, compareFn: ListComparisonFn<T> = compare) =>
this.dropByValue(value, compareFn),
byValueAll: (value: T, compareFn: ListComparisonFn<T> = compare) =>
this.dropByValueAll(value, compareFn),
head: () => this.dropHead(),
tail: () => this.dropTail(),
};
}
dropMany(count: number) {
return {
byIndex: (position: number) => this.dropManyByIndex(count, position),
head: () => this.dropManyHead(count),
tail: () => this.dropManyTail(count),
};
}
dropByIndex(position: number): ListNode<T> | undefined {
if (position === 0) return this.dropHead();
else if (position === this.size - 1) return this.dropTail();
if (position < 0) position += this.size;
const current = this.get(position);
if (current) {
current.previous!.next = current.next;
current.next!.previous = current.previous;
this.size -= 1;
return current;
}
return undefined;
return current ? this.detach(current) : undefined;
}
dropByValue(value: T, compareFn = compare): ListNode<T> | undefined {
dropByValue(value: T, compareFn: ListComparisonFn<T> = compare): ListNode<T> | undefined {
const position = this.findIndex(node => compareFn(node.value, value));
if (position < 0) return undefined;
return this.dropByIndex(position);
return position < 0 ? undefined : this.dropByIndex(position);
}
dropByValueAll(value: T, compareFn = compare): ListNode<T>[] {
dropByValueAll(value: T, compareFn: ListComparisonFn<T> = compare): ListNode<T>[] {
const dropped: ListNode<T>[] = [];
for (let current = this.first, position = 0; current; position += 1, current = current.next) {
for (let current = this.first, position = 0; current; position++, current = current.next) {
if (compareFn(current.value, value)) {
dropped.push(this.dropByIndex(position - dropped.length)!);
}
@ -176,7 +259,7 @@ export class LinkedList<T = any> {
if (this.first) this.first.previous = undefined;
else this.last = undefined;
this.size -= 1;
this.size--;
return head;
}
@ -193,7 +276,7 @@ export class LinkedList<T = any> {
if (this.last) this.last.next = undefined;
else this.first = undefined;
this.size -= 1;
this.size--;
return tail;
}
@ -201,24 +284,66 @@ export class LinkedList<T = any> {
return undefined;
}
find(predicate: ListIteratorFunction<T>): ListNode<T> | undefined {
for (let current = this.first, position = 0; current; position += 1, current = current.next) {
dropManyByIndex(count: number, position: number): ListNode<T>[] {
if (count <= 0) return [];
if (position < 0) position = Math.max(position + this.size, 0);
else if (position >= this.size) return [];
count = Math.min(count, this.size - position);
const dropped: ListNode<T>[] = [];
while (count--) {
const current = this.get(position);
dropped.push(this.detach(current!)!);
}
return dropped;
}
dropManyHead(count: Exclude<number, 0>): ListNode<T>[] {
if (count <= 0) return [];
count = Math.min(count, this.size);
const dropped: ListNode<T>[] = [];
while (count--) dropped.unshift(this.dropHead()!);
return dropped;
}
dropManyTail(count: Exclude<number, 0>): ListNode<T>[] {
if (count <= 0) return [];
count = Math.min(count, this.size);
const dropped: ListNode<T>[] = [];
while (count--) dropped.push(this.dropTail()!);
return dropped;
}
find(predicate: ListIteratorFn<T>): ListNode<T> | undefined {
for (let current = this.first, position = 0; current; position++, current = current.next) {
if (predicate(current, position, this)) return current;
}
return undefined;
}
findIndex(predicate: ListIteratorFunction<T>): number {
for (let current = this.first, position = 0; current; position += 1, current = current.next) {
findIndex(predicate: ListIteratorFn<T>): number {
for (let current = this.first, position = 0; current; position++, current = current.next) {
if (predicate(current, position, this)) return position;
}
return -1;
}
forEach<R = boolean>(callback: ListIteratorFunction<T, R>) {
for (let node = this.first, position = 0; node; position += 1, node = node.next) {
forEach<R = boolean>(callback: ListIteratorFn<T, R>) {
for (let node = this.first, position = 0; node; position++, node = node.next) {
callback(node, position, this);
}
}
@ -227,7 +352,7 @@ export class LinkedList<T = any> {
return this.find((_, index) => position === index);
}
indexOf(value: T, compareFn = compare): number {
indexOf(value: T, compareFn: ListComparisonFn<T> = compare): number {
return this.findIndex(node => compareFn(node.value, value));
}
@ -239,20 +364,32 @@ export class LinkedList<T = any> {
return array;
}
toString(): string {
toNodeArray(): ListNode<T>[] {
const array = new Array(this.size);
this.forEach((node, index) => (array[index!] = node));
return array;
}
toString(mapperFn: ListMapperFn<T> = JSON.stringify): string {
return this.toArray()
.map(value => JSON.stringify(value))
.map(value => mapperFn(value))
.join(' <-> ');
}
*[Symbol.iterator]() {
for (let node = this.first, position = 0; node; position += 1, node = node.next) {
for (let node = this.first, position = 0; node; position++, node = node.next) {
yield node.value;
}
}
}
export type ListIteratorFunction<T = any, R = boolean> = (
export type ListMapperFn<T = any> = (value: T) => any;
export type ListComparisonFn<T = any> = (value1: T, value2: T) => boolean;
export type ListIteratorFn<T = any, R = boolean> = (
node: ListNode<T>,
index?: number,
list?: LinkedList,

@ -8,6 +8,8 @@ import { FeatureManagement } from '../models';
providedIn: 'root',
})
export class FeatureManagementService {
apiName = 'FeatureManagement';
constructor(private rest: RestService, private store: Store) {}
getFeatures(params: FeatureManagement.Provider): Observable<FeatureManagement.Features> {
@ -16,7 +18,9 @@ export class FeatureManagementService {
url: '/api/abp/features',
params,
};
return this.rest.request<FeatureManagement.Provider, FeatureManagement.Features>(request);
return this.rest.request<FeatureManagement.Provider, FeatureManagement.Features>(request, {
apiName: this.apiName,
});
}
updateFeatures({
@ -30,6 +34,6 @@ export class FeatureManagementService {
body: { features },
params: { providerKey, providerName },
};
return this.rest.request<FeatureManagement.Features, null>(request);
return this.rest.request<FeatureManagement.Features, null>(request, { apiName: this.apiName });
}
}

@ -7,6 +7,8 @@ import { Identity } from '../models/identity';
providedIn: 'root',
})
export class IdentityService {
apiName = 'AbpIdentity';
constructor(private rest: RestService) {}
getRoles(params = {} as ABP.PageQueryParams): Observable<Identity.RoleResponse> {
@ -16,7 +18,7 @@ export class IdentityService {
params,
};
return this.rest.request<null, Identity.RoleResponse>(request);
return this.rest.request<null, Identity.RoleResponse>(request, { apiName: this.apiName });
}
getAllRoles(): Observable<Identity.RoleResponse> {
@ -25,7 +27,7 @@ export class IdentityService {
url: '/api/identity/roles/all',
};
return this.rest.request<null, Identity.RoleResponse>(request);
return this.rest.request<null, Identity.RoleResponse>(request, { apiName: this.apiName });
}
getRoleById(id: string): Observable<Identity.RoleItem> {
@ -34,7 +36,7 @@ export class IdentityService {
url: `/api/identity/roles/${id}`,
};
return this.rest.request<null, Identity.RoleItem>(request);
return this.rest.request<null, Identity.RoleItem>(request, { apiName: this.apiName });
}
deleteRole(id: string): Observable<Identity.RoleItem> {
@ -43,7 +45,7 @@ export class IdentityService {
url: `/api/identity/roles/${id}`,
};
return this.rest.request<null, Identity.RoleItem>(request);
return this.rest.request<null, Identity.RoleItem>(request, { apiName: this.apiName });
}
createRole(body: Identity.RoleSaveRequest): Observable<Identity.RoleItem> {
@ -53,7 +55,9 @@ export class IdentityService {
body,
};
return this.rest.request<Identity.RoleSaveRequest, Identity.RoleItem>(request);
return this.rest.request<Identity.RoleSaveRequest, Identity.RoleItem>(request, {
apiName: this.apiName,
});
}
updateRole(body: Identity.RoleItem): Observable<Identity.RoleItem> {
@ -66,7 +70,9 @@ export class IdentityService {
body,
};
return this.rest.request<Identity.RoleItem, Identity.RoleItem>(request);
return this.rest.request<Identity.RoleItem, Identity.RoleItem>(request, {
apiName: this.apiName,
});
}
getUsers(params = {} as ABP.PageQueryParams): Observable<Identity.UserResponse> {
@ -76,7 +82,7 @@ export class IdentityService {
params,
};
return this.rest.request<null, Identity.UserResponse>(request);
return this.rest.request<null, Identity.UserResponse>(request, { apiName: this.apiName });
}
getUserById(id: string): Observable<Identity.UserItem> {
@ -85,7 +91,7 @@ export class IdentityService {
url: `/api/identity/users/${id}`,
};
return this.rest.request<null, Identity.UserItem>(request);
return this.rest.request<null, Identity.UserItem>(request, { apiName: this.apiName });
}
getUserRoles(id: string): Observable<Identity.RoleResponse> {
@ -94,7 +100,7 @@ export class IdentityService {
url: `/api/identity/users/${id}/roles`,
};
return this.rest.request<null, Identity.RoleResponse>(request);
return this.rest.request<null, Identity.RoleResponse>(request, { apiName: this.apiName });
}
deleteUser(id: string): Observable<null> {
@ -103,7 +109,7 @@ export class IdentityService {
url: `/api/identity/users/${id}`,
};
return this.rest.request<null, null>(request);
return this.rest.request<null, null>(request, { apiName: this.apiName });
}
createUser(body: Identity.UserSaveRequest): Observable<Identity.UserItem> {
@ -113,7 +119,9 @@ export class IdentityService {
body,
};
return this.rest.request<Identity.UserSaveRequest, Identity.UserItem>(request);
return this.rest.request<Identity.UserSaveRequest, Identity.UserItem>(request, {
apiName: this.apiName,
});
}
updateUser(body: Identity.UserItem): Observable<Identity.UserItem> {
@ -126,6 +134,8 @@ export class IdentityService {
body,
};
return this.rest.request<Identity.UserItem, Identity.UserItem>(request);
return this.rest.request<Identity.UserItem, Identity.UserItem>(request, {
apiName: this.apiName,
});
}
}

@ -7,16 +7,23 @@ import { PermissionManagement } from '../models/permission-management';
providedIn: 'root',
})
export class PermissionManagementService {
apiName = 'AbpPermissionManagement';
constructor(private rest: RestService) {}
getPermissions(params: PermissionManagement.GrantedProvider): Observable<PermissionManagement.Response> {
getPermissions(
params: PermissionManagement.GrantedProvider,
): Observable<PermissionManagement.Response> {
const request: Rest.Request<PermissionManagement.GrantedProvider> = {
method: 'GET',
url: '/api/abp/permissions',
params,
};
return this.rest.request<PermissionManagement.GrantedProvider, PermissionManagement.Response>(request);
return this.rest.request<PermissionManagement.GrantedProvider, PermissionManagement.Response>(
request,
{ apiName: this.apiName },
);
}
updatePermissions({
@ -31,6 +38,8 @@ export class PermissionManagementService {
params: { providerKey, providerName },
};
return this.rest.request<PermissionManagement.UpdateRequest, null>(request);
return this.rest.request<PermissionManagement.UpdateRequest, null>(request, {
apiName: this.apiName,
});
}
}

@ -7,6 +7,8 @@ import { TenantManagement } from '../models/tenant-management';
providedIn: 'root',
})
export class TenantManagementService {
apiName = 'AbpTenantManagement';
constructor(private rest: RestService) {}
getTenant(params = {} as ABP.PageQueryParams): Observable<TenantManagement.Response> {
@ -16,7 +18,7 @@ export class TenantManagementService {
params,
};
return this.rest.request<null, TenantManagement.Response>(request);
return this.rest.request<null, TenantManagement.Response>(request, { apiName: this.apiName });
}
getTenantById(id: string): Observable<ABP.BasicItem> {
@ -25,7 +27,7 @@ export class TenantManagementService {
url: `/api/multi-tenancy/tenants/${id}`,
};
return this.rest.request<null, ABP.BasicItem>(request);
return this.rest.request<null, ABP.BasicItem>(request, { apiName: this.apiName });
}
deleteTenant(id: string): Observable<null> {
@ -34,7 +36,7 @@ export class TenantManagementService {
url: `/api/multi-tenancy/tenants/${id}`,
};
return this.rest.request<null, null>(request);
return this.rest.request<null, null>(request, { apiName: this.apiName });
}
createTenant(body: TenantManagement.AddRequest): Observable<ABP.BasicItem> {
@ -44,7 +46,9 @@ export class TenantManagementService {
body,
};
return this.rest.request<TenantManagement.AddRequest, ABP.BasicItem>(request);
return this.rest.request<TenantManagement.AddRequest, ABP.BasicItem>(request, {
apiName: this.apiName,
});
}
updateTenant(body: TenantManagement.UpdateRequest): Observable<ABP.BasicItem> {
@ -57,7 +61,9 @@ export class TenantManagementService {
body,
};
return this.rest.request<TenantManagement.UpdateRequest, ABP.BasicItem>(request);
return this.rest.request<TenantManagement.UpdateRequest, ABP.BasicItem>(request, {
apiName: this.apiName,
});
}
getDefaultConnectionString(id: string): Observable<string> {
@ -68,7 +74,9 @@ export class TenantManagementService {
responseType: Rest.ResponseType.Text,
url,
};
return this.rest.request<TenantManagement.DefaultConnectionStringRequest, string>(request);
return this.rest.request<TenantManagement.DefaultConnectionStringRequest, string>(request, {
apiName: this.apiName,
});
}
updateDefaultConnectionString(
@ -81,7 +89,9 @@ export class TenantManagementService {
url,
params: { defaultConnectionString: payload.defaultConnectionString },
};
return this.rest.request<TenantManagement.DefaultConnectionStringRequest, any>(request);
return this.rest.request<TenantManagement.DefaultConnectionStringRequest, any>(request, {
apiName: this.apiName,
});
}
deleteDefaultConnectionString(id: string): Observable<string> {
@ -91,6 +101,8 @@ export class TenantManagementService {
method: 'DELETE',
url,
};
return this.rest.request<TenantManagement.DefaultConnectionStringRequest, any>(request);
return this.rest.request<TenantManagement.DefaultConnectionStringRequest, any>(request, {
apiName: this.apiName,
});
}
}

Loading…
Cancel
Save