Преглед на файлове

- 장치 상세 화면 작업

KaRam Kim преди 8 години
родител
ревизия
8fd2f6c1b6

+ 7 - 0
OneCable/Base.lproj/Localizable.strings

@@ -225,6 +225,13 @@
 "선택된 멤버가 없습니다" = "선택된 멤버가 없습니다";
 /* 이름을 입력해주세요 */
 "이름을 입력해주세요" = "이름을 입력해주세요";
+
+
+
+
+/* 두 비밀번호가 일치하지 않습니다 */
+"두 비밀번호가 일치하지 않습니다" = "두 비밀번호가 일치하지 않습니다";
+
 /* 두 비밀번호가 일치하지 않습니다 */
 "두 비밀번호가 일치하지 않습니다" = "두 비밀번호가 일치하지 않습니다";
 /* 추가 */

+ 2 - 0
OneCable/Classes/Definitions.h

@@ -135,6 +135,8 @@ static NSString *kWebLinkServer = @"http://61.40.220.23:7794";      //운영
 #define API_PUT_NODE_ORDER_RESET    @"/customer/%@/group/%@/device/seq/init"    //디바이스 노드 순서 초기화
 #define API_PUT_NODE_ORDER_CHANGE   @"/customer/%@/group/%@/device/seq"         //디바이스 노드 순서 변경
 
+#define API_GET_NODE_DETAIL         @"/customer/%@/group/%@/device/%@/node/%@"
+
 
 #define API_GET_DEVICE_ICONS    @"/devices/icons/%@"       //디바이스 아이콘
 #define API_GET_DEVICE_UPDATE   @"/devices/property/%@" //디바이스 수정

+ 7 - 42
OneCable/Classes/JDFacade.m

@@ -426,51 +426,16 @@ static NSString *const ksKeychainArchiveData = @"_archiveData";
     }];
     [alertController addAction:cancelAction];
 
+
+//    NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:alertController.view attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationLessThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:IPHONE_HEIGHT*.5f];
+//    [alertController.view addConstraint:constraint];
+    
+    [alertController.view mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.height.lessThanOrEqualTo(@(IPHONE_HEIGHT*.5f));
+    }];
     [target presentViewController:alertController animated:YES completion:nil];
 }
 
--(void)tempAction
-{
-//    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Gender:"
-//                                                                             message:nil
-//                                                                      preferredStyle:UIAlertControllerStyleActionSheet];
-//    for (NSDictionary *genderInfo in self.genderList) {
-//        NSString *gender = [[genderInfo objectForKey:@"description"] capitalizedString];
-//        UIAlertAction *action = [UIAlertAction actionWithTitle:gender
-//                                                         style:UIAlertActionStyleDefault
-//                                                       handler:^(UIAlertAction *action) {
-//                                                           NSString *title = action.title;
-//                                                           //you can check here on what button is pressed using title
-//                                                       }];
-//        [alertController addAction:action];
-//    }
-//    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
-//                                                           style:UIAlertActionStyleCancel
-//                                                         handler:^(UIAlertAction *action) {
-//                                                         }];
-//    [alertController addAction:cancelAction];
-//    [self presentViewController:alertController animated:YES completion:nil];
-    
-//    NSArray *numbersArrayList = @[@"One", @"Two", @"Three", @"Four", @"Five", @"Six"];
-//    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Numbers:"
-//                                                                             message:nil
-//                                                                      preferredStyle:UIAlertControllerStyleActionSheet];
-//    for (int j =0 ; j<numbersArrayList.count; j++){
-//        NSString *titleString = numbersArrayList[j];
-//        UIAlertAction *action = [UIAlertAction actionWithTitle:titleString style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
-//            NSLog(@"Selected Value: %@",numbersArrayList[j]);
-//            
-//        }];
-//        [action setValue:[[UIImage imageNamed:@"USA16.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forKey:@"image"];
-//        [alertController addAction:action];
-//    }
-//    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
-//                                                           style:UIAlertActionStyleCancel
-//                                                         handler:^(UIAlertAction *action) {
-//                                                         }];
-//    [alertController addAction:cancelAction];
-//    [self presentViewController:alertController animated:YES completion:nil];
-}
 
 - (void)fireLocalNotification:(NSString *)message {
     NSLog(@"fireLocalNotification %@", message);

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

@@ -113,7 +113,7 @@
 
 @interface DeviceDetailModel : DeviceModel
 
-@property (copy, nonatomic) NSArray<NodeModel> *nodes;
+@property (copy, nonatomic) NSArray<NodeModel> *cmdclsList;
 @property (copy, nonatomic) NSArray<DeviceModel> *relateDevice;
 
 @end

+ 27 - 10
OneCable/Classes/ViewControllers/HomeMemberScreens/HomeMemberAddViewController.m

@@ -141,11 +141,12 @@
     //Localization
     [_btnSend setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
     [_btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
+    
 }
 
 
 - (void)prepareViewDidLoad {
-
+    [self updateUI];
 }
 
 #pragma mark - Main Logic
@@ -328,7 +329,8 @@
         [_inviteList addObject:member];
         _txtTempEmail.text = ksEmptyString;
         
-        [_tableView reloadData];
+//        [_tableView reloadData];
+        [self updateUI];
     } else {
         [[JDFacade facade] alert:result.errorMessage];
     }
@@ -349,7 +351,8 @@
     HomeMemberModel *member = btnRemove.value;
     [_inviteList removeObject:member];
     
-    [_tableView reloadData];
+//    [_tableView reloadData];
+    [self updateUI];
 }
 
 
@@ -366,9 +369,21 @@
         [_inviteList removeObject:member];
     }];
 
-    [_tableView reloadData];
+//    [_tableView reloadData];
+    [self updateUI];
 }
 
+- (BOOL)isValidRequestInfo {
+    BOOL result = NO;
+    
+    return result;
+}
+
+
+- (void)updateUI {
+    _btnSend.enabled = [self isValidRequestInfo];
+    [_tableView reloadData];
+}
 
 - (IBAction)btnSendTouched:(id)sender {
     //1.validate
@@ -381,8 +396,13 @@
     if (![ValidateUtil validateTextfiled:_txtQuestion type:ValidateTypeNull title:NSLocalizedString(@"퀴즈", @"퀴즈")]) {
         return;
     }
+
+    if(!(!_txtQuestion.text || [_txtQuestion.text isEqualToString:ksEmptyString])) {
+        [[JDFacade facade] alert:@"멤버 인증 퀴즈를 선택해 주세요."];
+        return;
+    }
     
-    if (_txtQuestion.text.length > 60) {
+    if (_txtDirectQuiz.text.length > 60) {
         [[JDFacade facade] alert:@"퀴즈는 최대 60자까지 입력할 수 있습니다"];
         return;
     }
@@ -399,16 +419,13 @@
     [self dismissViewControllerAnimated:YES completion:nil];
 }
 
-- (IBAction)btnQuizSelectTouched:(id)sender {
-    
-}
 
 -(void)showQuizList{
-    // TODO : 퀴즈 직접 입력 부분 어떻게 처리할지 확인할것.(서버? 로컬?)
     [[JDFacade facade] selectDatas:self listInfo:_quizList completion:^(DataSelectModel *seleced) {
         _selectedQuiz = seleced;
         _txtQuestion.text = _selectedQuiz.title;
-        [_tableView reloadData];
+//        [_tableView reloadData];
+        [self updateUI];
     }];
 }
 

+ 19 - 10
OneCable/Classes/ViewControllers/ThingsScreens/ThingsDetailViewController.m

@@ -176,6 +176,15 @@
 }
 
 
+-(NSString *)getDeviceDetailUrl
+{
+    NSMutableArray *arr = [NSMutableArray array];
+    arr[0] = _refDevice.deviceId;
+    arr[1] = _refDevice.nodeId;
+    
+    return [[JDFacade facade] getUrlWithCustAndGroupIDWithArr:API_GET_NODE_DETAIL arguments:arr];
+}
+
 #pragma mark - Main Logic
 - (void)requestDeviceDetail:(id)arg {
     
@@ -184,7 +193,7 @@
         showLoadingView = [arg isKindOfClass:[NSTimer class]] ? [((NSTimer *)arg).userInfo boolValue] : [arg boolValue];
     }
 
-    NSString *path = [NSString stringWithFormat:API_GET_DEVICE_DETAIL, _refDevice.deviceId];
+    NSString *path = [NSString stringWithFormat:[self getDeviceDetailUrl], _refDevice.deviceId];
     
     [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestGET parameters:nil
                                            modelClass:[DeviceDetailModel class] showLoadingView:showLoadingView completion:^(id responseObject) {
@@ -193,7 +202,7 @@
         }
 
         _deviceDetail = (DeviceDetailModel *)responseObject;
-
+        NSLog(@"Device Detail : %@", _deviceDetail);
         if (_deviceDetail) {//API 성공 ,
             [self setDeviceContents];
             [self requestPollingDeviceStatusInBackground];
@@ -216,16 +225,16 @@
 - (void)requestPollingDeviceStatusInBackground {
     
     //schedul timer.
-    if (!_deviceBackgroundTimer) {
-        _deviceBackgroundTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(requestDeviceDetail:) userInfo:@NO repeats:YES];
-    }
+//    if (!_deviceBackgroundTimer) {
+//        _deviceBackgroundTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(requestDeviceDetail:) userInfo:@NO repeats:YES];
+//    }
 }
     
 - (void)setDeviceContents {
     [self updateTitle];
     
-    _mandatoryNodes = (NSArray<NodeModel> *)[_deviceDetail.nodes filteredArrayUsingPredicateFormat:@"cmdclsMandatoryYn == %@", @"Y"];
-    _optionalNodes = (NSArray<NodeModel> *)[_deviceDetail.nodes filteredArrayUsingPredicateFormat:@"cmdclsMandatoryYn == %@", @"N"];
+    _mandatoryNodes = (NSArray<NodeModel> *)[_deviceDetail.cmdclsList filteredArrayUsingPredicateFormat:@"cmdclsMandatoryYn == %@", @"Y"];
+    _optionalNodes = (NSArray<NodeModel> *)[_deviceDetail.cmdclsList filteredArrayUsingPredicateFormat:@"cmdclsMandatoryYn == %@", @"N"];
     
     [_tableView reloadData];
 }
@@ -287,7 +296,7 @@
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
     NSInteger count = 1;
     if (section == 1) {
-        count = _deviceDetail && _deviceDetail.nodes && _deviceDetail.nodes.count > 0;
+        count = _deviceDetail && _deviceDetail.cmdclsList && _deviceDetail.cmdclsList.count > 0;
     } else if (section == 2) {//optional nodes
         count = _optionalNodes.count; //두번째 이후부터 옵셔널 노드임.
     }
@@ -297,7 +306,7 @@
 
 - (CGFloat)heightForMandatoryNode {
     CGFloat height = 0;
-    NodeModel *node = _deviceDetail.nodes.firstObject;
+    NodeModel *node = _deviceDetail.cmdclsList.firstObject;
     if (node.cmdclsType == CmdClsTypeSwitchBinary || node.cmdclsType == CmdClsTypeValve) {
         height = 347.0f; //275 || 347
     } else {
@@ -400,7 +409,7 @@
     } else if (section == 2) {//option control
         ThingsDetailOptionTableViewCell *tcell = (ThingsDetailOptionTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"OptionCellIdentifier"];
         
-        NodeModel *node = _deviceDetail.nodes[indexPath.row + _mandatoryNodes.count];
+        NodeModel *node = _deviceDetail.cmdclsList[indexPath.row + _mandatoryNodes.count];
         tcell.lblNodeName.text = node.nodeName;
         tcell.lblNodeValue.text = node.contentValueMsg;