forked from brianschardt/ng-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored util service turned into Util helper
- Loading branch information
1 parent
f4575e0
commit c83ad85
Showing
16 changed files
with
315 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { UtilService } from './../services/util.service'; | ||
import { AppInjector } from './../app.module'; | ||
import * as _ from 'underscore'; | ||
import { LoginOptions } from 'ngx-facebook'; | ||
import {Util} from './util.helper'; | ||
|
||
export class API { | ||
|
||
constructor(){ | ||
} | ||
|
||
|
||
//************************************ | ||
//********* STATIC METHODS *********** | ||
//************************************ | ||
|
||
static get util(){ | ||
return AppInjector.get(UtilService); | ||
} | ||
|
||
static async save(model, uri:string, update_data?:any){ | ||
let err, res:any; | ||
|
||
if(!update_data){ | ||
let differences = model.instanceDifference(); | ||
if(_.isEmpty(differences)) Util.TE('Nothing Updated'); | ||
update_data = _.pick(differences, (value, key, object) => model.apiUpdateValues.includes(key) ); | ||
if(_.isEmpty(update_data)) Util.TE('Nothing Updated'); | ||
} | ||
|
||
[err, res] = await Util.to(Util.put(uri, update_data )); | ||
|
||
if(err) Util.TE(err, true); | ||
if(!res.success) Util.TE(res.error, true); | ||
|
||
model.emit('saveApi', update_data, true); | ||
model.save(); | ||
return true; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.