Преглед изворни кода

- 멀티 홈허브 환경 작업

KaRam Kim пре 8 година
родитељ
комит
fc1c036c4f

+ 3 - 1
OneCable/Classes/Handler/RequestHandler.m

@@ -258,7 +258,7 @@
         [self finishRequest];
 
         NSString *JSONString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
-
+        NSLog(@"Response : %@", JSONString);
 #ifndef PRODUCT_MODE
         NSLog(@"\n\nJSON=%@\n\n", JSONString);
 #endif
@@ -276,11 +276,13 @@
                     NSDictionary *JSONDic = @{@"list": rawJSON};
                     JSONModel = [[modelClass alloc] initWithDictionary:JSONDic error:&error];
                 } else {
+
                     JSONModel = [[modelClass alloc] initWithString:JSONString error:&error];
                 }
             } else {
                 JSONModel = rawJSON;
             }
+            NSLog(@"Result Json Mode : %@", JSONModel);
         }
 //        else {
 //            error = [NSError errorWithDomain:@"RequestHandler" code:-1 userInfo:@{NSLocalizedDescriptionKey: @"RESPONSE DATA is NULL"}];

+ 1 - 0
OneCable/Classes/Model/DeviceModel.h

@@ -88,6 +88,7 @@
 
 - (UIImage *)imgaeForAddDel;
 - (NSString *)manufacturerName;
+- (NSString *)getAddDelDescription;
 
 - (instancetype)initWithSubItem:(ItemSubModel *)subItem;
 + (NSString *)contentValueMsgByCmdClsCode:(NSString *)cmdclsCode cmdclsTypeId:(NSString *)cmdclsTypeId contentValue:(NSString *)contentValue;

+ 16 - 1
OneCable/Classes/Model/DeviceModel.m

@@ -30,6 +30,20 @@
 //
 //    return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
 //}
+- (NSString *)deviceName {
+    NSString *result = @"";
+    
+    if (![_prdName isEmptyString]) {
+        result = _prdName;
+    }
+    
+    if (![_prdUserName isEmptyString]) {
+        result = _prdUserName;
+    }
+    
+    return result;
+}
+
 
 - (NSString *)contentValueMsgOfSensorBinary {
     NSInteger typeId = [_cmdclsTypeId integerValue];
@@ -600,7 +614,7 @@
 }
 
 
-- (NSString *)description
+- (NSString *)getAddDelDescription
 {
     NSInteger typeId = [_cmdclsTypeId integerValue];
     NSString *result = @"";
@@ -632,6 +646,7 @@
     }
     
     return result;
+
 }
 
 - (instancetype)initWithSubItem:(ItemSubModel *)subItem {//mobile devices.

+ 5 - 2
OneCable/Classes/Model/LoginModel.h

@@ -155,9 +155,9 @@
 
 @property (strong, nonatomic) NSMutableArray<ContractGroupModel> *ctrtGrpList; //계약그룹 목록
 
-@property (copy, nonatomic) NSMutableArray<DeviceModel> *deviceList; //디바이스 목록
+@property (copy, nonatomic) NSMutableArray *deviceList; //디바이스 목록
 @property (strong, nonatomic) NSString *selectedHomeHubID;
-
+@property (weak, nonatomic) DeviceModel *modifyHomeHub;
 //@property (copy, nonatomic) NSString *deviceOnline;
 //@property (copy, nonatomic) NSString *deviceOnlineLastDatetime;
 //@property (copy, nonatomic) NSString *deviceConn;
@@ -182,6 +182,9 @@
 
 -(void)setHomeHubID:(NSString *)homeHubID;
 -(NSString *)getHomeHubID;
+-(DeviceModel *)getHomeHub;
+
+- (BOOL)isMultiHomeHub;
 
 @end
 

+ 28 - 3
OneCable/Classes/Model/LoginModel.m

@@ -128,12 +128,37 @@
 }
 
 -(NSString *)getHomeHubID {
-    if (_selectedHomeHubID == nil || [_selectedHomeHubID isEmptyString]) {
+    NSString *result = @"";
+    
+    DeviceModel *info = [self getHomeHub];
+    if (info != nil) {
+        result = info.deviceId;
+    }
+    return result;
+}
+
+-(DeviceModel *)getHomeHub {
+    NSLog(@"%@", _deviceList);
+    DeviceModel *result = nil;
+    
+    if (![self isMultiHomeHub]) {
+        if (_selectedHomeHubID == nil || [_selectedHomeHubID isEmptyString]) {
+            for (DeviceModel *info in _deviceList) {
+                result = info;
+                break;
+            }
+        }
+    } else {
         for (DeviceModel *info in _deviceList) {
-            return info.deviceId;
+            if ([info.deviceId isEquestToIgnoreCase:_selectedHomeHubID]) {
+                result = info;
+                break;
+            }
         }
     }
-    return _selectedHomeHubID;
+    NSLog(@"%@", result);
+    
+    return result;
 }
 
 - (BOOL)isExistHomeHubID:(NSString *)homeHubID {

+ 1 - 1
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddInitViewController.m

@@ -71,7 +71,7 @@
    
     _imgThings.image = [_addDevice imgaeForAddDel];
     _lblTitle.text = [NSString stringWithFormat:@"%@ 초기화", _addDevice.prdName];
-    _lblComment.text = [_addDevice description];
+    _lblComment.text = [_addDevice getAddDelDescription];
     
     [self requestExcludeDevice:YES];
 }

+ 2 - 0
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddViewController.h

@@ -21,6 +21,8 @@
 @property (weak, nonatomic) IBOutlet CustomTableView *tableView;
 @property (weak, nonatomic) IBOutlet CustomLabel *lblTitle;
 
+@property (weak, nonatomic) DeviceModel *selectHub;
+
 #pragma mark - Instance Methods
 - (IBAction)btnCloseTouched:(id)sender;
 

+ 1 - 1
OneCable/Classes/ViewControllers/ThingsScreens/ThingsGeneralDelStartViewController.m

@@ -68,7 +68,7 @@
     //    [self startLoading:NO];
     _imgThings.image = [_delDevice imgaeForAddDel];
     _lblTitle.text = [NSString stringWithFormat:@"%@ 삭제", _delDevice.prdName];
-    _lblComment.text = [_delDevice description];
+    _lblComment.text = [_delDevice getAddDelDescription];
     
     [self requestExcludeDevice:YES];
 }

+ 13 - 2
OneCable/Classes/ViewControllers/ThingsScreens/ThingsViewController.m

@@ -399,7 +399,8 @@
 }
 
 - (void)addNewDevice {
-    UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddViewController" storyboardName:@"Things"];
+    ThingsAddViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddViewController" storyboardName:@"Things"];
+    vc.selectHub = _selectHub;
     [self presentViewController:vc animated:YES completion:nil];
 }
 
@@ -430,6 +431,7 @@
     
     [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestGET parameters:nil
                                            modelClass:[DeviceListModel class] showLoadingView:NO completion:^(id responseObject) {
+                                               NSLog(@"Response : %@", responseObject);
                                                if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
                                                    return;
                                                }
@@ -548,8 +550,17 @@
 }
 
 - (void)updateTitle {
+    _imgvArrow.hidden = ![[JDFacade facade].loginUser isMultiHomeHub];
+    if (_imgvArrow.hidden) {
+        DeviceModel *info = [[JDFacade facade].loginUser getHomeHub];
+        _lblTitle.text = [NSString stringWithFormat:@"%@", info.deviceName];
+    } else {
+        // todo : 링크 걸기
+        DeviceModel *info = [[JDFacade facade].loginUser getHomeHub];
+        _lblTitle.text = [NSString stringWithFormat:@"%@", info.deviceName];
+    }
+
     
-//    _lblTitle.text = [NSString stringWithFormat:@"장치 전체 %zd", _deviceList.count];
     _lblCount.text = [NSString stringWithFormat:@"%zd", _deviceList.count];
     NSLog(@"HomeHubID : %@", [JDFacade facade].loginUser.homehubDeviceId);
     if (![JDFacade facade].loginUser.hasHomeHub) {//홈허브 아이디가 없는 경우,