Skip to content
This repository has been archived by the owner on Feb 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #8 from ladybirdweb/devlopment-new
Browse files Browse the repository at this point in the history
Devlopment new
  • Loading branch information
Mallikarjun Hanagandi committed Aug 30, 2018
2 parents a1ee89d + e573fa9 commit 7f0ca0d
Show file tree
Hide file tree
Showing 32 changed files with 164 additions and 25 deletions.
Binary file modified .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@2x.png",
"filename" : "Icon-App-20x20@2x-1.png",
"scale" : "2x"
},
{
Expand All @@ -15,13 +15,13 @@
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@1x.png",
"filename" : "Icon-App-29x29@1x-1.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@2x.png",
"filename" : "Icon-App-29x29@2x-1.png",
"scale" : "2x"
},
{
Expand All @@ -33,7 +33,7 @@
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@2x.png",
"filename" : "Icon-App-40x40@2x-1.png",
"scale" : "2x"
},
{
Expand Down Expand Up @@ -147,7 +147,7 @@
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon-1024.png",
"filename" : "iTunesArtwork@2x.png",
"scale" : "1x"
}
],
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Faveo Helpdesk Community/GlobalVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,7 @@

@property (strong, nonatomic) NSDictionary *dependencyDataDict;

@property (strong, nonatomic) NSString *roleFromAuthenticateAPI;

@end

91 changes: 88 additions & 3 deletions Faveo Helpdesk Community/InboxViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#import "RMessageView.h"
#import "UIImageView+Letters.h"
#import "TableViewAnimationKitHeaders.h"

#import "LoginViewController.h"

@interface InboxViewController ()<RMessageProtocol>{
Utils *utils;
Expand Down Expand Up @@ -56,12 +56,23 @@ - (void)viewDidLoad {

_animationType = 5;


if([[userDefaults objectForKey:@"msgFromRefreshToken"] isEqualToString:@"credentialchanged"] || [globalVariables.roleFromAuthenticateAPI isEqualToString:@"user"] )
{
NSString *msg=@"";
globalVariables.roleFromAuthenticateAPI=@"";
// [utils showAlertWithMessage:@"Access Denied. Your credentials has been changed. Contact to Admin and try to login again." sendViewController:self];
[self->userDefaults setObject:msg forKey:@"msgFromRefreshToken"];

[self showMessageForLogout:@"Access Denied. Your credentials has been changed OR Your Role has been changed to user. Contact to Admin and try to login again." sendViewController:self];
[[AppDelegate sharedAppdelegate] hideProgressView];
}
else{

[[AppDelegate sharedAppdelegate] showProgressViewWithText:NSLocalizedString(@"Getting Tickets",nil)];
[self reload];

[self getDependencies];

}
}

- (void)loadAnimation {
Expand Down Expand Up @@ -162,6 +173,18 @@ -(void)reload{
return;
}

if ([msg isEqualToString:@"tokenNotRefreshed"]) {

NSString *msg=@"";
// [utils showAlertWithMessage:@"Access Denied. Your credentials has been changed. Contact to Admin and try to login again." sendViewController:self];
[self->userDefaults setObject:msg forKey:@"msgFromRefreshToken"];
[self showMessageForLogout:@"Access Denied. Your credentials has been changed OR Your Role has been changed to user. Contact to Admin and try to login again." sendViewController:self];
[[AppDelegate sharedAppdelegate] hideProgressView];

return;
}


if (json) {
//NSError *error;
NSLog(@"Thread-NO4--getInboxAPI--%@",json);
Expand Down Expand Up @@ -815,6 +838,68 @@ - (void)didReceiveMemoryWarning {
// Dispose of any resources that can be recreated.
}

-(void)showMessageForLogout:(NSString*)message sendViewController:(UIViewController *)viewController
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:APP_NAME message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Logout"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action)
{
[self logout];

if (self.navigationController.navigationBarHidden) {
[self.navigationController setNavigationBarHidden:NO];
}

[RMessage showNotificationInViewController:self.navigationController
title:NSLocalizedString(@" Faveo Helpdesk ", nil)
subtitle:NSLocalizedString(@"You've logged out, successfully...!", nil)
iconImage:nil
type:RMessageTypeSuccess
customTypeName:nil
duration:RMessageDurationAutomatic
callback:nil
buttonTitle:nil
buttonCallback:nil
atPosition:RMessagePositionNavBarOverlay
canBeDismissedByUser:YES];

LoginViewController *login=[self.storyboard instantiateViewControllerWithIdentifier:@"Login"];
[self.navigationController pushViewController: login animated:YES];
}];

[alertController addAction:cancelAction];

[viewController presentViewController:alertController animated:YES completion:nil];

}

-(void)logout
{

[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:[[NSBundle mainBundle] bundleIdentifier]];

NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
// get documents path
NSString *documentsPath = [paths objectAtIndex:0];
// get the path to our Data/plist file
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"faveoData.plist"];
NSError *error;

if(![[NSFileManager defaultManager] removeItemAtPath:plistPath error:&error])
{
NSLog(@"Error while removing the plist %@", error.localizedDescription);
//TODO: Handle/Log error
}

NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *each in cookieStorage.cookies) {
[cookieStorage deleteCookie:each];
}


}



@end
2 changes: 1 addition & 1 deletion Faveo Helpdesk Community/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3</string>
<string>1.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
49 changes: 35 additions & 14 deletions Faveo Helpdesk Community/LoginViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ - (void)viewDidLoad {

// end solution

// setting go button instead of next or donw on keyboard
[_urlTextfield setReturnKeyType:UIReturnKeyGo];

//this for password eye icon
[self.passcodeTextField addPasswordField];
//end
Expand All @@ -75,6 +78,17 @@ - (IBAction)textFieldFinished:(id)sender
// [sender resignFirstResponder];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{

if(textField == _urlTextfield)
{
[self URLValidationMethod];
NSLog(@"Clicked on go");
}

return YES;
}


-(void)viewWillAppear:(BOOL)animated{
Expand All @@ -98,7 +112,8 @@ - (void)didReceiveMemoryWarning {



- (IBAction)urlButton:(id)sender {
-(void)URLValidationMethod{

[self.urlTextfield resignFirstResponder];


Expand All @@ -121,7 +136,7 @@ - (IBAction)urlButton:(id)sender {

if ([[Reachability reachabilityForInternetConnection]currentReachabilityStatus]==NotReachable)
{

[RMessage
showNotificationWithTitle:NSLocalizedString(@"Something failed", nil)
subtitle:NSLocalizedString(@"The internet connection seems to be down. Please check it.", nil)
Expand Down Expand Up @@ -193,7 +208,7 @@ - (IBAction)urlButton:(id)sender {
}


// NSString *replyStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
// NSString *replyStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

NSDictionary *jsonData=[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];

Expand All @@ -203,17 +218,17 @@ - (IBAction)urlButton:(id)sender {
if ([respMessage containsString:@"success"]) {

NSLog(@"Success");
dispatch_async(dispatch_get_main_queue(), ^{

[self.companyURLview setHidden:YES];
[self.loginView setHidden:NO];
[self->utils viewSlideInFromRightToLeft:self.loginView];
[[AppDelegate sharedAppdelegate] hideProgressView];

[self->userdefaults setObject:[self->baseURL stringByAppendingString:@"api/v1/"] forKey:@"companyURL"];
[self->userdefaults synchronize];

});
dispatch_async(dispatch_get_main_queue(), ^{
[self.companyURLview setHidden:YES];
[self.loginView setHidden:NO];
[self->utils viewSlideInFromRightToLeft:self.loginView];
[[AppDelegate sharedAppdelegate] hideProgressView];
[self->userdefaults setObject:[self->baseURL stringByAppendingString:@"api/v1/"] forKey:@"companyURL"];
[self->userdefaults synchronize];
});
}else{

[[AppDelegate sharedAppdelegate] hideProgressView];
Expand Down Expand Up @@ -242,6 +257,12 @@ - (IBAction)urlButton:(id)sender {
}else
[utils showAlertWithMessage:NSLocalizedString(@"Please Enter a valid URL",nil) sendViewController:self];
}

}
- (IBAction)urlButton:(id)sender {

[self URLValidationMethod];

}

-(void)viewDidAppear:(BOOL)animated{
Expand Down
4 changes: 2 additions & 2 deletions Faveo Helpdesk Community/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -1555,8 +1555,8 @@
<constraint firstItem="FFT-Qh-q8f" firstAttribute="top" secondItem="l0J-Ff-JNZ" secondAttribute="bottom" constant="6" id="tQw-d6-zMa"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="version: 1.3" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nDL-nU-2T4">
<rect key="frame" x="125.33333333333333" y="61" width="62.666666666666671" height="15"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="version: 1.4" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nDL-nU-2T4">
<rect key="frame" x="125.33333333333331" y="61" width="63" height="15"/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="12"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
Expand Down
31 changes: 31 additions & 0 deletions Faveo Helpdesk Community/MyWebservices.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
#import "MyWebservices.h"
#import "AppConstanst.h"
#import "AppDelegate.h"
#import "GlobalVariables.h"


@interface MyWebservices(){

NSString *tokenRefreshed;
GlobalVariables *globalVariables;
}

@property (nonatomic,strong) NSUserDefaults *userDefaults;
Expand All @@ -37,7 +40,9 @@ -(NSString*)refreshToken{
dispatch_semaphore_t sem;
__block NSString *result=nil;
sem = dispatch_semaphore_create(0);

_userDefaults=[NSUserDefaults standardUserDefaults];
globalVariables=[GlobalVariables sharedInstance];

NSString *url=[NSString stringWithFormat:@"%@authenticate",[_userDefaults objectForKey:@"companyURL"]];

Expand Down Expand Up @@ -77,6 +82,22 @@ -(NSString*)refreshToken{

NSLog(@"Thread--refreshToken--Get your response == %@", replyStr);

if([replyStr containsString:@"error"]){

NSError *error=nil;
NSDictionary *jsonData=[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
if (error) {
return;
}

if([[jsonData objectForKey:@"error"] isEqualToString:@"invalid_credentials"]){

NSString * msg = @"credentialchanged";

[self->_userDefaults setObject:msg forKey:@"msgFromRefreshToken"];
}
}
else
if ([replyStr containsString:@"token"]) {

NSError *error=nil;
Expand All @@ -89,6 +110,15 @@ -(NSString*)refreshToken{
[_userDefaults setObject:[jsonData1 objectForKey:@"id"] forKey:@"user_id"];
[_userDefaults setObject:[jsonData1 objectForKey:@"role"] forKey:@"role"];


NSString *role123=[NSString stringWithFormat:@"%@",[jsonData1 objectForKey:@"role"]];//role
NSLog(@"Role from Web Services class : %@",role123);

self->globalVariables.roleFromAuthenticateAPI=role123;
[self->_userDefaults setObject:role123 forKey:@"msgFromRefreshToken"];



NSString *clientName=[jsonData1 objectForKey:@"first_name"];

if ([clientName isEqualToString:@""]) {
Expand All @@ -100,6 +130,7 @@ -(NSString*)refreshToken{

[_userDefaults setObject:clientName forKey:@"profile_name"];


// [_userDefaults setObject:baseURL forKey:@"baseURL"];

[_userDefaults synchronize];
Expand Down

0 comments on commit 7f0ca0d

Please sign in to comment.