@@ -111,7 +111,17 @@ export class MenuCtrl {
111111
112112 this . customer = this . WebSocketClientService . customer ;
113113
114- this . customers = await NoderedUtil . Query ( { collectionname : "users" , query : { _type : "customer" } , orderby : { "name" : 1 } } ) ;
114+ this . customers = await NoderedUtil . Query ( { collectionname : "users" , query : { _type : "customer" } , orderby : { "name" : 1 } , top : 20 } ) ;
115+ if ( ! NoderedUtil . IsNullEmpty ( this . user . selectedcustomerid ) ) {
116+ if ( this . customers . filter ( x => x . _id == this . user . selectedcustomerid ) . length == 0 ) {
117+ this . customers = ( await NoderedUtil . Query ( { collectionname : "users" , query : { _type : "customer" , _id : this . user . selectedcustomerid } } ) ) . concat ( this . customers ) ;
118+ }
119+ }
120+ if ( ! NoderedUtil . IsNullEmpty ( this . user . customerid ) ) {
121+ if ( this . customers . filter ( x => x . _id == this . user . customerid ) . length == 0 ) {
122+ this . customers = ( await NoderedUtil . Query ( { collectionname : "users" , query : { _type : "customer" , _id : this . user . customerid } } ) ) . concat ( this . customers ) ;
123+ }
124+ }
115125 if ( ! this . $scope . $$phase ) { this . $scope . $apply ( ) ; }
116126 this . StartNewFeaturesTour ( null ) ;
117127 } ) ;
@@ -124,7 +134,17 @@ export class MenuCtrl {
124134 this . customer = null ;
125135 } else {
126136 this . customer = this . WebSocketClientService . customer ;
127- this . customers = await NoderedUtil . Query ( { collectionname : "users" , query : { _type : "customer" } , orderby : { "name" : 1 } } ) ;
137+ this . customers = await NoderedUtil . Query ( { collectionname : "users" , query : { _type : "customer" } , orderby : { "name" : 1 } , top : 20 } ) ;
138+ if ( ! NoderedUtil . IsNullEmpty ( this . user . selectedcustomerid ) ) {
139+ if ( this . customers . filter ( x => x . _id == this . user . selectedcustomerid ) . length == 0 ) {
140+ this . customers = ( await NoderedUtil . Query ( { collectionname : "users" , query : { _type : "customer" , _id : this . user . selectedcustomerid } } ) ) . concat ( this . customers ) ;
141+ }
142+ }
143+ if ( ! NoderedUtil . IsNullEmpty ( this . user . customerid ) ) {
144+ if ( this . customers . filter ( x => x . _id == this . user . customerid ) . length == 0 ) {
145+ this . customers = ( await NoderedUtil . Query ( { collectionname : "users" , query : { _type : "customer" , _id : this . user . customerid } } ) ) . concat ( this . customers ) ;
146+ }
147+ }
128148 if ( this . customers && this . customers . length > 0 ) {
129149 for ( let cust of this . customers ) {
130150 if ( cust . _id == this . user . selectedcustomerid ) {
@@ -149,7 +169,17 @@ export class MenuCtrl {
149169 this . $scope . $on ( 'menurefresh' , async ( event , data ) => {
150170 if ( event && data ) { }
151171 this . customer = this . WebSocketClientService . customer ;
152- this . customers = await NoderedUtil . Query ( { collectionname : "users" , query : { _type : "customer" } , orderby : { "name" : 1 } } ) ;
172+ this . customers = await NoderedUtil . Query ( { collectionname : "users" , query : { _type : "customer" } , orderby : { "name" : 1 } , top : 20 } ) ;
173+ if ( ! NoderedUtil . IsNullEmpty ( this . user . selectedcustomerid ) ) {
174+ if ( this . customers . filter ( x => x . _id == this . user . selectedcustomerid ) . length == 0 ) {
175+ this . customers = ( await NoderedUtil . Query ( { collectionname : "users" , query : { _type : "customer" , _id : this . user . selectedcustomerid } } ) ) . concat ( this . customers ) ;
176+ }
177+ }
178+ if ( ! NoderedUtil . IsNullEmpty ( this . user . customerid ) ) {
179+ if ( this . customers . filter ( x => x . _id == this . user . customerid ) . length == 0 ) {
180+ this . customers = ( await NoderedUtil . Query ( { collectionname : "users" , query : { _type : "customer" , _id : this . user . customerid } } ) ) . concat ( this . customers ) ;
181+ }
182+ }
153183 if ( this . customers . length > 0 ) {
154184 for ( let cust of this . customers )
155185 if ( cust . _id == this . user . selectedcustomerid ) this . customer = cust ;
@@ -2990,6 +3020,8 @@ export class EntitiesCtrl extends entitiesCtrl<Base> {
29903020 }
29913021 this . loadData ( ) ;
29923022 this . collections = await NoderedUtil . ListCollections ( { } ) ;
3023+ console . log ( this . collections ) ;
3024+ this . collections . push ( { name : "fs.files" } ) ;
29933025 } catch ( error ) {
29943026 this . errormessage = error ;
29953027 }
@@ -5668,7 +5700,7 @@ export class DuplicatesCtrl extends entitiesCtrl<Base> {
56685700 const item = ( this . models [ x ] as any ) ;
56695701 ids . push ( item . items [ 0 ] . _id ) ;
56705702 }
5671- await NoderedUtil . DeleteMany ( { collectionname : this . collection , ids } ) ;
5703+ if ( ids . length > 0 ) await NoderedUtil . DeleteMany ( { collectionname : this . collection , ids } ) ;
56725704 this . loading = false ;
56735705 this . loadData ( ) ;
56745706 }
@@ -5681,7 +5713,7 @@ export class DuplicatesCtrl extends entitiesCtrl<Base> {
56815713 ids . push ( item . items [ y ] . _id ) ;
56825714 }
56835715 }
5684- await NoderedUtil . DeleteMany ( { collectionname : this . collection , ids } ) ;
5716+ if ( ids . length > 0 ) await NoderedUtil . DeleteMany ( { collectionname : this . collection , ids } ) ;
56855717 this . loading = false ;
56865718 this . loadData ( ) ;
56875719 }
@@ -5694,7 +5726,7 @@ export class DuplicatesCtrl extends entitiesCtrl<Base> {
56945726 ids . push ( item . items [ y ] . _id ) ;
56955727 }
56965728 }
5697- await NoderedUtil . DeleteMany ( { collectionname : this . collection , ids } ) ;
5729+ if ( ids . length > 0 ) await NoderedUtil . DeleteMany ( { collectionname : this . collection , ids } ) ;
56985730 this . loading = false ;
56995731 this . loadData ( ) ;
57005732 }
@@ -5715,7 +5747,7 @@ export class DuplicatesCtrl extends entitiesCtrl<Base> {
57155747 for ( let i = 1 ; i < model . items . length ; i ++ ) {
57165748 ids . push ( model . items [ i ] . _id ) ;
57175749 }
5718- await NoderedUtil . DeleteMany ( { collectionname : this . collection , ids } ) ;
5750+ if ( ids . length > 0 ) await NoderedUtil . DeleteMany ( { collectionname : this . collection , ids } ) ;
57195751 this . loading = false ;
57205752 this . loadData ( ) ;
57215753 }
@@ -5727,7 +5759,7 @@ export class DuplicatesCtrl extends entitiesCtrl<Base> {
57275759 for ( let i = 0 ; i < model . items . length ; i ++ ) {
57285760 ids . push ( model . items [ i ] . _id ) ;
57295761 }
5730- await NoderedUtil . DeleteMany ( { collectionname : this . collection , ids } ) ;
5762+ if ( ids . length > 0 ) await NoderedUtil . DeleteMany ( { collectionname : this . collection , ids } ) ;
57315763 this . loading = false ;
57325764 this . loadData ( ) ;
57335765 }
@@ -5863,6 +5895,7 @@ export class CustomersCtrl extends entitiesCtrl<Provider> {
58635895 console . debug ( "CustomersCtrl" ) ;
58645896 this . basequery = { _type : "customer" } ;
58655897 this . collection = "users" ;
5898+ this . skipcustomerfilter = true ;
58665899 WebSocketClientService . onSignedin ( ( user : TokenUser ) => {
58675900 this . loadData ( ) ;
58685901 } ) ;
@@ -5993,8 +6026,11 @@ export class CustomerCtrl extends entityCtrl<Customer> {
59936026 this . errormessage = "" ;
59946027 if ( this . model != null ) {
59956028 if ( WebSocketClient . instance . user . selectedcustomerid != this . model . _id ) {
6029+ console . log ( "update selected customer to id #" + this . model . _id )
59966030 WebSocketClient . instance . user . selectedcustomerid = this . model . _id ;
59976031 this . $rootScope . $broadcast ( "menurefresh" ) ;
6032+ } else {
6033+ console . log ( "user already have selected customer id #" + this . model . _id )
59986034 }
59996035 }
60006036 if ( this . $routeParams . action != null ) {
0 commit comments