Core
Install Angular Auxiliary Library.
npm install @weplanx/ngWpxService
Weplanx Assisted Management Services
Public
assets
stringAssets loading address, default/assetsupload
AsyncSubject<UploadOption>Upload configuration statusscripts
Map<string, AsyncSubject<void>>Script loading status
Set Assets
setAssets(v: string): void
v
stringLocal or remote path
For example: the assets path is the address https://cdn.xxx.com of CDN distribution, add in app.component.ts
@Component({
selector: 'app-root',
template: ` <router-outlet></router-outlet> `
})
export class AppComponent implements OnInit {
constructor(
private app: AppService,
private wpx: WpxService,
private icon: NzIconService
) {}
ngOnInit(): void {
this.app.ping().subscribe(() => {
console.debug('XSRF:ok');
});
this.icon.changeAssetsSource(environment.cdn);
this.wpx.setAssets(environment.cdn);
}
}Set Upload
setUpload(v: UploadOption): void
v
UploadOptionUpload configurationUploadOption
type
stringplatformurl
stringurllimit
numberUpload size limit
Just get it from the backend
Create Model
setModel<T>(key: string, api: WpxApi<T>): WpxModel<T>
key
stringIndex, which automatically associates IndexedDBapi
WpxApi<T>Common API
Initialize a WpxModel
Set Locale
setLocale(id: string): void
id
stringidentificationzh-HansSimplified Chineseen-USAmerican English
Load Script
loadScript(key: string, url: string, plugins: string[]): void
key
stringscript identityurl
stringscript urlplugins
string[]plugins url of script
Example: import external UMD script
Get Values
getValues(keys?: string[]): Observable<R>
keys
string[]configuration keys
Update Values
setValues(update: R): Observable<R>
update
RUpdate data
Delete Values
deleteValue(key: string): Observable<R>
key
stringconfiguration key
Transaction
transaction(): Observable<TransactionResult>
Commit Transaction
commit(txn: string): Observable<void>
txn
stringTransaction ID
Get COS Pre-signed
cosPresigned(): Observable<R>
Get COS Picture Info
cosImageInfo(url: string): Observable<WpxImageInfo>
url
stringImage object
WpxStoreService
Local storage based on IndexedDB
Set
set<T>(key: string, value: T): Observable<void>
Get
get<T>(key: string): Observable<T | undefined>
Remove
remove(key: string): Observable<void>
Clear
clear(): Observable<R>
WpxApi<T>
Universal API abstract class
Create
create(doc: T, options?: CreateOption<T>): Observable<R>
doc
Tdataoptions
CreateOption<T>xdata
XDatadoc format conversiontxn
stringtransaction ID
BulkCreate
bulkCreate(docs: T[], options?: CreateOption<T>): Observable<R>
docs
T[]array dataoptions
CreateOption<T>xdata
XDatadocs.$ format conversiontxn
stringtransaction ID
Size
size(filter: Filter<T>, options?: FilterOption<T>): Observable<number>
filter
Filter<T>options
FilterOption<T>xfilter
XFilter<T>filter format conversion
Exists
exists(filter: Filter<T>, options?: FilterOption<T>): Observable<boolean>
filter
Filter<T>options
FilterOption<T>xfilter
XFilter<T>filter format conversion
Find
find(filter: Filter<T>, options?: FindOption<T>): Observable<FindResult<T>>
filter
Filter<T>options
FindOption<T>keys
Array<keyof AnyDto<T>>projectionsort
Sort<T>sortpage
numberpage indexpagesize
numberpage sizexfilter
XFilter<T>filter format conversion
FindOne
findOne(filter: Filter<T>, options?: FindOneOption<T>): Observable<AnyDto<T>>
filter
Filter<T>options
FindOneOption<T>keys
Array<keyof AnyDto<T>>projectionxfilter
XFilter<T>filter format conversion
FindById
findById(id: string, options?: FindByIdOption<T>): Observable<AnyDto<T>>
id
stringoptions
FindByIdOption<T>keys
Array<keyof AnyDto<T>>projection
Update
update(filter: Filter<T>, update: Update<T>, options?: UpdateOption<T>): Observable<R>
filter
Filter<T>update
Update<T>update dataoptions
UpdateOption<T>xfilter
XFilter<T>filter format conversionxdata
XDataupdate format conversiontxn
stringtransaction ID
UpdateById
updateById(id: string, update: Update<T>, options?: UpdateOneByIdOption<T>): Observable<R>
id
stringupdate
Update<T>update dataoptions
UpdateOneByIdOption<T>xdata
XDataupdate format conversiontxn
stringtransaction ID
Replace
replace(id: string, doc: T, options?: ReplaceOption<T>): Observable<R>
id
stringdoc
Tdataoptions
ReplaceOption<T>xdata
XDataupdate format conversiontxn
stringtransaction ID
Delete
delete(id: string, options?: DeleteOption<T>): Observable<R>
id
stringoptions
DeleteOption<T>txn
stringtransaction ID
BulkDelete
bulkDelete(filter: Filter<T>, options?: BulkDeleteOption<T>): Observable<R>
filter
Filter<T>options
BulkDeleteOption<T>xfilter
XFilter<T>filter format conversiontxn
stringtransaction ID
Sort
sort(key: string, values: string[], options?: SortOption<T>): Observable<R>
key
stringSort fieldvalues
string[]ID array, array index is sortedoptions
SortOption<T>txn
stringtransaction ID
WpxItems<T>
Universal tuple abstract class
Public
data
T[]loading
boolload statesearchText
stringkeyword search textchecked
booleanwhether all are selectedindeterminate
booleanwhether to select partselection
Map<string, T>selected value
Check
setSelection(data: T): void
data
T
Uncheck
removeSelection(id: string): void
id
string
Checked All
setCurrentSelections(checked: boolean): void
checked
boolean
WpxModel<T>
Universal data model abstract class
Public
data
signal<AnyDto<T>[]>dataFilter
AnyDto<T>[]not disabled dataloading
signal<boolean>load statetotal
numberdata totalpage
numbermodel page indexpagesize
numbermodel page sizeadvanced
signal<NzDrawerRef | null>search panelsearchText
stringkeyword search textkeywords
Any[]checked
booleanwhether all are selectedindeterminate
booleanwhether to select partselection
Map<string, T>selected value
Ready
ready(xfilter?: XFilter): Observable<R>
xfilter
XFilterdefault filter formatting
Fetch Data
fetch(search?: Filter<T>, sort?: Sort<T>): Observable<FindResult<T>>
search
Filter<T>custom filtersort
Sort<T>custom sort
Check
setSelection(data: T): void
data
T
Uncheck
removeSelection(id: string): void
id
string
Checked All
setCurrentSelections(checked: boolean): void
checked
boolean
Last updated
Was this helpful?