20211219 - Dynamic Action 버튼 보이기/감추기


if (vTMD.v === "CD") 
{
  $('#btnOpenDialogTLT').show();
  $('#btnOpenDialogSAMPLE').show();
}
else
{
  $('#btnOpenDialogTLT').hide();
  $('#btnOpenDialogSAMPLE').hide();
}


참고

20211219 - 캘린더 일정 관리, 완료 일정 취소선 Strike 처리

1. Page - CSS - Inline


.apex-cal-default-strike div { background-color: #2578CF; border-color: #2578CF; color: #FFFFFF; text-decoration-line: line-through; }
.apex-cal-black-strike div { background-color: #303030; border-color: #303030; color: #FFFFFF; text-decoration-line: line-through; }
.apex-cal-blue-strike div { background-color: #4183D7; border-color: #4183D7; color: #FFFFFF; text-decoration-line: line-through; }
.apex-cal-bluesky-strike div { background-color: #6BB9F0; border-color: #6BB9F0; color: #404040; text-decoration-line: line-through; }
.apex-cal-brown-strike div { background-color: #D88935; border-color: #D88935; color: #404040; text-decoration-line: line-through; }
.apex-cal-cyan-strike div { background-color: #1ABC9C; border-color: #1ABC9C; color: #404040; text-decoration-line: line-through; }
.apex-cal-darkblue-strike div { background-color: #1F5F97; border-color: #1F5F97; color: #FFFFFF; text-decoration-line: line-through; }
.apex-cal-gray-strike div { background-color: #A0A0A0; border-color: #A0A0A0; color: #404040; text-decoration-line: line-through; }
.apex-cal-green-strike div { background-color: #2ECC71; border-color: #2ECC71; color: #404040;text-decoration-line: line-through; }
.apex-cal-lime-strike div { background-color: #28A346; border-color: #28A346; color: #FFFFFF; text-decoration-line: line-through; }
.apex-cal-orange-strike div { background-color: #F39C12; border-color: #F39C12; color: #404040; text-decoration-line: line-through; }
.apex-cal-red-strike div { background-color: #D91E18; border-color: #D91E18; color: #FFFFFF; text-decoration-line: line-through; }
.apex-cal-silver-strike div { background-color: #BDC3C7; border-color: #BDC3C7; color: #404040; text-decoration-line: line-through; }
.apex-cal-white-strike div { background-color: #F0F0F0; border-color: #F0F0F0; color: #404040; text-decoration-line: line-through; }
.apex-cal-yellow-strike div { background-color: #F1C40F; border-color: #F1C40F; color: #404040; text-decoration-line: line-through; }


2. Calendar 리전 - SQL Query


select a.cal_id
     , decode(nvl(a.complete_yn, 'N'), 'Y', nvl(b.css_cal,'')||'-strike', nvl(b.css_cal,'')) as css
     , a.sdt
     , a.edt
     , nvl(b.cal_type_nm||': ','') ||a.mst as mst
     , a.dtl
  from info_calendar     a
     , info_calendar_css b
 where a.css_id = b.css_id(+)


3. 구현된 화면



참고


 

20211209 - IG LOV 기본 값 셋팅하기 - 행 추가 후 기본 값

1. IG 컬럼 >> Advanced

JavaScript Initialization Code :


function( config ) {
    config.defaultGridColumnOptions = {
        defaultValue: function () {
            return {d:"관리자", v: "21"};
        }
    }
    return config;
}

이렇게 하지 않고 보통 다른 컬럼들 하는 것처럼 default 값을 셋팅하게 되면 value 는 셋팅이 되지만 Display 값은 셋팅되지 않아서 위와 같이 json 형식으로 셋팅하면 됨



참고

https://hardlikesoftware.com/weblog/2017/03/31/how-to-hack-apex-interactive-grid-part-4/

https://www.jmjcloud.com/blog/workaround-for-issue-setting-a-default-value-for-the-apex-192-popup-lov

https://community.oracle.com/tech/developers/discussion/4335748/how-to-set-default-value-for-popup-lov

https://docs.oracle.com/en/database/oracle/application-express/21.2/aexjs/model.html#.FieldMeta


    config.initActions = function(actions) {
        var addRow = actions.lookup("selection-add-row");
        var originalAction = addRow.action;
        addRow.action = function(event,el) {
            // do your own stuff before original action if needed
            originalAction(event,el);
            // do your own stuff after original action if needed. This is what page 17 does:
            // after the grid has had a chance to change the selection
            setTimeout(function() {
                apex.item("P17_ENAME").setFocus();
            }, 100);
            return true; // because focus was set
        }
    }


function( config ) {
    config.defaultGridColumnOptions = {
        defaultValue: function( model, record ) {
            return ...;
        }
    }
    return config;
}


var val,
    model = this.data.model,
    rec = this.data.record,
    meta = model.getRecordMetadata(this.data.recordId);

if ( meta.inserted ) {
    val = model.getValue(rec, "JOB")
    if ( val.v === val.d ) {
        model.setValue(rec,"JOB", {d:apex.item("C_JOB").displayValueFor("CLERK"), v: "CLERK"});
    }
    val = model.getValue(rec, "ONLEAVE"); 
    if ( val.v === val.d ) {
        model.setValue(rec,"ONLEAVE", {d:apex.item("C_ONLEAVE").displayValueFor("N"), v:"N"});
    }
}
function(config) {
    config.defaultGridColumnOptions = {
        defaultValue: function( model, srcRecord ) {
            let m,
                name = "";

            if ( srcRecord ) {
                name = model.getValue( srcRecord, "ENAME" ),
                m = /(.*)(\d+)$/.exec( name );

                if ( m ) {
                    name = m[1] + ( parseInt( m[2], 10 ) + 1 );
                } else {
                    name += "_1";
                }
            }
            return name;
        }
    }
    return config;
}

20211204 - Interactive Grid 더블 클릭해서 새로운 윈도우 창 열기

1. Dynamic Action

Name : DoubleClick_POMSTIG

When - Event : Double Click

Selection Type : Region


var ig$             = apex.region("myStaticIGPOMST").widget();
var grid            = ig$.interactiveGrid("getViews","grid");
var model           = grid.model;
var selectedRecords = grid.view$.grid("getSelectedRecords");
var record1         = selectedRecords[0];

var l_url = 'f?p=#APP_ID#:9:#SESSION#::NO:RP,9:P9_PO_ID:#POID#';

l_url = l_url.replace('#APP_ID#',  $v('pFlowId'));
l_url = l_url.replace('#SESSION#', $v('pInstance'));
l_url = l_url.replace('#POID#',    model.getValue(record1, "PO_ID"));

// execute PL/SQL API apex_uti.prepare_url to generate a valid Session State Protection checksum
apex.server.process(
    'BTN-popup',
    {x01: l_url},
    {success: function (pData) {
            apex.navigation.openInNewWindow(pData);
        },
        dataType: "text"
    }
);


2. Ajax Callback

Name : BTN-popup

Type : Execute Code

Source - Location : Local Database

Language : PL/SQL

PL/SQL Code


declare
    l_url    varchar2(2000);   
    l_result varchar2(4000);
begin
    l_result := apex_util.prepare_url(apex_application.g_x01);
    htp.prn(l_result);
end;



참고

https://docs.oracle.com/en/database/oracle/application-express/21.2/aexjs/apex.navigation.html#.openInNewWindow

20211120 - 로그인 인증 후 권한에 따른 메뉴 조회 Authorized Menu, Custom Navigation Menu

1. Shared Component >> Navigation Menu >> Create

Create List from Scratch



Name : Dynamic Navigation Menu

Type : Dynamic





2. User Interface Attribute

Navigation Menu >> Dynamic Navigation Menu 선택 


3. 로그인 후 권한에 따른 메뉴 구성




4. 권한별 메뉴 리스트에 대한 ERD 참고


SQL 참고

select level        "level"
     , page_nm      "label"
     , entry_target "target"
     , 'YES'        is_current
     , ''           image
  from (
         select mpage.page_nm, mpage.entry_target, mpage.dpseq, mgdtl.page_id, mgdtl.ppage_id
           from menu_grp_dtl mgdtl
              , menu_page    mpage
          where mgdtl.page_id  = mpage.page_id
            and mgdtl.mgrp_id in (
         select mgrp.mgrp_id
           from role_menu_grp rmgrp
              , user_mst      usermst
              , menu_grp      mgrp
          where upper(usermst.login_id) = :APP_USER
            and rmgrp.role = usermst.role
            and rmgrp.mgrp_id = mgrp.mgrp_id )
       ) menu_page
start with
    ppage_id = 1
connect by
    prior page_id = ppage_id
    order siblings by dpseq


참고.


20211120 - 커스텀 로그인 사용자 테이블 인증 Custom Authentication

1. 커스텀 인증 방식 생성

Name : CustomMyAuth

Scheme Type : Custom 

Authentication Function Name : F_AUTHENTICATE_USER



2. 함수 생성


create or replace FUNCTION F_AUTHENTICATE_USER
  (p_username in varchar2, 
   p_password in varchar2)
return boolean
is
  l_user_name       user_mst.login_id%type := upper(p_username);
  l_password        varchar2(255); --users.password%type;
  l_hashed_password varchar2(1000);
  l_count           number;
begin
-- Returns from the AUTHENTICATE_USER function 
--    0    Normal, successful authentication
--    1    Unknown User Name
--    2    Account Locked
--    3    Account Expired
--    4    Incorrect Password
--    5    Password First Use
--    6    Maximum Login Attempts Exceeded
--    7    Unknown Internal Error
--
-- First, check to see if the user exists
    select count(*) 
      into l_count 
      from user_mst
     where upper(login_id) = l_user_name
       and use_yn    = 'Y';
      
     if l_count > 0 then
          -- Hash the password provided
          l_hashed_password := '1';--hash_password(l_user_name, p_password);
          l_password := '1';
          -- Get the stored password
          /*
          select password 
            into l_password 
            from users 
           where user_name = l_user_name; */
  
          -- Compare the two, and if there is a match, return TRUE
          if l_hashed_password = l_password then
              -- Good result. 
              APEX_UTIL.SET_AUTHENTICATION_RESULT(0);
              return true;
          else
              -- The Passwords didn't match
              APEX_UTIL.SET_AUTHENTICATION_RESULT(4);
              return false;
          end if;
  
    else
          -- The username does not exist
          APEX_UTIL.SET_AUTHENTICATION_RESULT(1);
          return false;
    end if;
    -- If we get here then something weird happened. 
    APEX_UTIL.SET_AUTHENTICATION_RESULT(7);
    return false;
exception 
    when others then 
        -- We don't know what happened so log an unknown internal error
        APEX_UTIL.SET_AUTHENTICATION_RESULT(7);
        -- And save the SQL Error Message to the Auth Status.
        APEX_UTIL.SET_CUSTOM_AUTH_STATUS(sqlerrm);
        return false;
        
end f_authenticate_user;


3. 커스텀 인증 방식을 현재 인증 방식으로 설정


* 주의 : 로그인 ID 가 로그인 테이블에 소문자로 저장되어 있어도 세션에 저장되는 :APP_USER 값은 대문자임. 


참고.

https://blogs.oracle.com/apex/post/custom-authentication-and-authorization-using-built-in-apex-access-control-a-how-to


20211118 - Let's Encrypt SSL, certbot renewal

1. Let's Encrypt 무료 SSL을 사용하고 있고 조만간 만료가 예정되어 있음


2. 보안을 위해서 package 들을 최신 상태로 업데이트하고 certbot certonly 실행

아니면 certbot renew 로 하면 물어보는 창 없이 바로 실행됨


-- Let's Encrypt
-----------------
sudo su -
yum update -y

certbot certonly

pip install -U pip
pip install cryptography --upgrade

certbot certonly

nginx -t
nginx -s reload

-------------------
certbot renew

systemctl stop nginx
systemctl start nginx
systemctl status nginx











별개의 추가 설정 사항
vi /etc/nginx/conf.d/jkincloud.com.conf

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;






Cron Job

vi /root/othermonthrenew.sh

certbot renew --force-renewal

systemctl stop nginx

systemctl start nginx

systemctl status nginx


crontab -e

1 0 1 2,4,6,8,10,12 * /root/othermonthrenew.sh >> /tmp/othermonthrenew.log 2>&1


chmod +x /root/othermonthrenew.sh


ex)


1 11 3 * * <SHELL_PATH>
분 시 일 월 요일 쉘스크립트경로


매월 첫째주 일요일 새벽 1시

0 1 * * 0 [ "$(date +\%d)" -le 07 ] && /path/to/your/script.sh


------------------
timedatectl
sudo timedatectl set-timezone Asia/Seoul
timedatectl
sudo systemctl restart chronyd
date

sudo shutdown -r
------------------

sudo timedatectl set-timezone Asia/Kuala_Lumpur


참고1

certbot certificates

certbot update_account --email yourname+1@example.com


https://eff-certbot.readthedocs.io/en/stable/using.html#automated-renewals


참고2

http://dgielis.blogspot.com/2019/12/free-oracle-cloud-16-renewing-lets.html

https://docs.oracle.com/en/learn/oracle-linux-crontab/index.html#check-your-cron-entry-output

https://jdm.kr/blog/2

https://velog.io/@jay2u8809/Crontab%ED%81%AC%EB%A1%A0%ED%83%AD-%EC%8B%9C%EA%B0%84-%EC%84%A4%EC%A0%95


20250315 - 글로벌 변수 Global Variables

G_USER Specifies the currently logged in user. G_FLOW_ID Specifies the ID of the currently running application. G_FLOW_STEP_ID Specifi...