diff --git a/modules/weko-admin/weko_admin/assets/bootstrap3/js/weko_admin/restricted_access.js b/modules/weko-admin/weko_admin/assets/bootstrap3/js/weko_admin/restricted_access.js
index 2e23c6fbec..fa1de5a4d3 100644
--- a/modules/weko-admin/weko_admin/assets/bootstrap3/js/weko_admin/restricted_access.js
+++ b/modules/weko-admin/weko_admin/assets/bootstrap3/js/weko_admin/restricted_access.js
@@ -1,666 +1,1380 @@
-import $ from 'jquery';
-import angular from 'angular';
-
-const SPECIFIC_INDEX_VALUE = '1';
-(function (angular) {
- // Bootstrap it!
- angular.element(document).ready(function () {
- angular.module('searchManagement.controllers', []);
- function searchManagementCtrl($scope, $rootScope, $http, $location) {
- var regist = [];
- var disp = [];
- var frm_cnt = 0;
- $scope.initData = function (data) {
- $scope.dataJson = angular.fromJson(data);
- $scope.clearNullDataInSortOption();
- $scope.initDispSettingOpt = {}
- $scope.treeData = [];
- $scope.rowspanNum = $scope.dataJson.detail_condition.length + 1;
- // Set Data
- $scope.setData();
- // $scope.setSearchKeyOptions();
- }
- // set selected data to allow
- $scope.setAllow = function (data) {
- if (data && $scope.dataJson.sort_options.deny.length > data) {
- if (data.length == 1) {
- let obj = $scope.dataJson.sort_options.deny[data[0]]
- $scope.dataJson.sort_options.allow.push(obj)
- $scope.dataJson.sort_options.deny.splice(data[0], 1)
- } else {
- for (var i = data.length - 1; i >= 0; i--) {
- let obj = $scope.dataJson.sort_options.deny[data[i]]
- $scope.dataJson.sort_options.allow.push(obj)
- $scope.dataJson.sort_options.deny.splice(data[i], 1)
- }
- }
- $scope.setSearchKeyOptions();
- }
- $scope.setDefaultSortKey();
- }
- // set selected data to deny
- $scope.setDeny = function (data) {
- if (data && $scope.dataJson.sort_options.allow.length > data) {
- if (data.length == 1) {
- let obj = $scope.dataJson.sort_options.allow[data[0]]
- $scope.dataJson.sort_options.deny.push(obj)
- $scope.dataJson.sort_options.allow.splice(data[0], 1)
- } else {
- for (var i = data.length - 1; i >= 0; i--) {
- let obj = $scope.dataJson.sort_options.allow[data[i]]
- $scope.dataJson.sort_options.deny.push(obj)
- $scope.dataJson.sort_options.allow.splice(data[i], 1)
- }
- }
- $scope.setSearchKeyOptions();
- }
- $scope.setDefaultSortKey();
- }
- //
- function addAlert(message) {
- $('#alerts').append(
- '
' +
- '' + message + '
');
- }
-
- $scope.saveData = function () {
- var url = $location.path();
- let initialDisplayIndex = $("#init_disp_index").val();
- if (initialDisplayIndex && this.isSpecificIndex()) {
- $scope.dataJson['init_disp_setting']['init_disp_index'] = initialDisplayIndex;
- } else {
- $scope.dataJson['init_disp_setting']['init_disp_index'] = '';
- }
-
- var cnt = 0;
- const contants_lang = document.getElementById("label_contents_0").lang
-
- for (cnt; cnt < $scope.dataJson.detail_condition.length; cnt++) {
- let labelname = $("#label_contents_" + cnt).val();
- let labelsubname = $("#hidden_contents_" + cnt).val();
-
- $scope.dataJson['detail_condition'][cnt]['contents'] = '';
- if (contants_lang == 'ja') {
- $scope.dataJson['detail_condition'][cnt]['contents_value']['ja'] = labelname;
- $scope.dataJson['detail_condition'][cnt]['contents_value']['en'] = labelsubname;
- }
- else {
- $scope.dataJson['detail_condition'][cnt]['contents_value']['en'] = labelname;
- $scope.dataJson['detail_condition'][cnt]['contents_value']['ja'] = labelsubname;
- }
- }
-
- if (regist.length != 0) {
- var formshape = { path: { type: '', coordinates: '' }, path_type: { type: 'json', coordinates: 'json' } }
- var formrange = { path: { gte: '', lte: '' }, path_type: { gte: 'json', lte: 'json' } }
- var formpoint = { path: { lat: '', lon: '' }, path_type: { lat: 'json', lon: 'json' } }
- var formtext = { path: '', path_type: 'json' }
-
- for (var count = 0; count < $scope.dataJson['detail_condition'].length; count++) {
- for (var cnt = 0; cnt < regist.length; cnt++) {
- if (count == regist[cnt].index) {
- let itemtype_id = regist[cnt].item_type_id
-
- if (regist[cnt].input_type == 'text') {
- if (!$scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]) {
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id] = JSON.parse(JSON.stringify(formtext));;
- }
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path'] = regist[cnt].path1;
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path_type'] = regist[cnt].pathtype1;
- }
-
- if (regist[cnt].input_type == 'range') {
- if (!$scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]) {
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id] = JSON.parse(JSON.stringify(formrange));;
- }
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path']['gte'] = regist[cnt].path1;
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path_type']['gte'] = regist[cnt].pathtype1;
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path']['lte'] = regist[cnt].path2;
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path_type']['lte'] = regist[cnt].pathtype2;
- }
- if (regist[cnt].input_type == 'geo_point') {
- if (!$scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]) {
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id] = JSON.parse(JSON.stringify(formpoint));;
- }
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path']['lat'] = regist[cnt].path1;
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path_type']['lat'] = regist[cnt].pathtype1;
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path']['lon'] = regist[cnt].path2;
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path_type']['lon'] = regist[cnt].pathtype2;
- }
- if (regist[cnt].input_type == 'geo_shape') {
- if (!$scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]) {
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id] = JSON.parse(JSON.stringify(formshape));;
- }
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path']['type'] = regist[cnt].path1;
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path_type']['type'] = regist[cnt].pathtype1;
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path']['coordinates'] = regist[cnt].path2;
- $scope.dataJson['detail_condition'][count]['item_value'][itemtype_id]['path_type']['coordinates'] = regist[cnt].pathtype2;
- }
- break;
- }
- }
- }
- }
- // Clear the registration target for advanced search items and allow registration to continue.
- regist.splice(0);
-
- let dbJson = $scope.dataJson;
-
- $http.post(url, dbJson).then(function successCallback(response) {
- // alert(response.data.message);
- $('html,body').scrollTop(0);
- addAlert(response.data.message);
- // Move to top
- }, function errorCallback(response) {
- alert(response.data.message);
- });
- }
- // search key setting
- $scope.setSearchKeyOptions = function () {
- // init
- var deny_flg = 0;
- angular.forEach($scope.dataJson.dlt_index_sort_options, function (item_sort_index, sort_index, sort_array) {
- deny_flg = 0;
- angular.forEach($scope.dataJson.sort_options.deny, function (item_deny, deny_index, deny_array) {
- if (item_sort_index.id.split('_')[0] == item_deny.id.split('_')[0]) {
- deny_flg = 1;
- }
- })
- if (deny_flg == 0) {
- item_sort_index.disableFlg = false;
- } else {
- item_sort_index.disableFlg = true;
- }
- })
- $scope.dataJson.dlt_keyword_sort_options = angular.copy($scope.dataJson.dlt_index_sort_options);
- }
- // setting default sort key
- $scope.setDefaultSortKey = function () {
- var loop_flg = 0;
- var sort_key = '';
- angular.forEach($scope.dataJson.dlt_index_sort_options, function (item, index, array) {
- if (loop_flg == 0 && !item.disableFlg) {
- sort_key = item.id;
- loop_flg = 1;
- }
- })
- angular.forEach($scope.dataJson.dlt_index_sort_options, function (item, index, array) {
- if ($scope.dataJson.dlt_index_sort_selected == item.id && item.disableFlg) {
- $scope.dataJson.dlt_index_sort_selected = sort_key;
- }
- if ($scope.dataJson.dlt_keyword_sort_selected == item.id && item.disableFlg) {
- $scope.dataJson.dlt_keyword_sort_selected = sort_key;
- }
- })
- }
-
- $scope.treeConfig = {
- core: {
- multiple: false,
- animation: false,
- error: function (error) {
- console.error('treeCtrl: error from js tree - ' + angular.toJson(error));
- },
- check_callback: true,
- themes: {
- dots: false,
- icons: false,
- },
- worker: false
- },
- checkbox: {
- three_state: false,
- whole_node: false
- },
- version: 1,
- plugins: ['checkbox']
- };
-
- $scope.setDefaultDataForInitDisplaySetting = function () {
- if (!$scope.dataJson.hasOwnProperty('init_disp_setting')) {
- $scope.dataJson['init_disp_setting'] = {
- 'init_disp_screen_setting': '0',
- 'init_disp_index_disp_method': '0',
- 'init_disp_index': ''
- }
- }
- }
-
- $scope.setData = function () {
- $scope.setDefaultDataForInitDisplaySetting();
- $scope.specificIndexText();
- $scope.getInitDisplayIndex();
- }
-
- $scope.specificIndexText = function () {
- if (this.isSpecificIndex()) {
- $scope.treeData.forEach(function (nodeData) {
- if (nodeData.hasOwnProperty('state')) {
- if (nodeData.state['selected']) {
- $("#init_disp_index_text").val(nodeData.text);
- $("#init_disp_index").val(nodeData.id);
- return null;
- }
- }
- });
- }
- }
-
- $scope.isSpecificIndex = function () {
- const dispIndexDispMethod = $scope.dataJson['init_disp_setting']['init_disp_index_disp_method'];
- return dispIndexDispMethod === SPECIFIC_INDEX_VALUE
- }
-
- $scope.specificIndex = function () {
- this.setDefaultInitDisplayIndex();
- }
-
- $scope.setDefaultInitDisplayIndex = function () {
- if (this.isSpecificIndex()) {
- // Reset tree data to default
- if (this.treeInstance && this.treeInstance.jstree) {
- let nodeChecked = this.treeInstance.jstree(true).get_checked([true]);
- if (nodeChecked.length === 0 && this.treeData.length > 0) {
- this.treeInstance.jstree(true).select_node({ id: "0" });
- $("#init_disp_index_text").val("Root Index");
- $("#init_disp_index").val("0");
- } else {
- let node = nodeChecked[0];
- if (node !== undefined) {
- $scope.setInitDisplayIndex(node)
- }
- }
- }
- }
- }
-
- $scope.setInitDisplayIndex = function (node) {
- $("#init_disp_index_text").val(node.text);
- $("#init_disp_index").val(node.id);
- }
-
- $scope.selectInitDisplayIndex = function (node, selected, event) {
- $scope.setInitDisplayIndex(selected.node);
- }
-
- $scope.disSelectInitDisplayIndex = function (node, selected, event) {
- if ($scope.treeInstance && $scope.treeInstance.jstree) {
- $scope.treeInstance.jstree(true).select_node(selected.node);
- }
- }
-
- $scope.getInitDisplayIndex = function () {
- let initDispIndex = $scope.dataJson['init_disp_setting']['init_disp_index']
- if (!initDispIndex) {
- initDispIndex = "0";
- }
- const currentTime = new Date().getTime();
- let url = "/api/admin/search/init_display_index/" + initDispIndex;
-
- $.get(url)
- .done(function (data) {
- let jstree = $scope.treeInstance.jstree(true);
- jstree.settings.core.data = data.indexes;
- jstree.refresh();
- let currentNode = jstree.get_node({ "id": initDispIndex });
- jstree.select_node(currentNode);
- $scope.setInitDisplayIndex(currentNode);
- })
- .fail(function () {
- alert("Fail to get index list.");
- })
- }
-
- $scope.clearNullDataInSortOption = function () {
- if ($scope.dataJson) {
- $scope.dataJson.sort_options.deny = $scope.dataJson.sort_options.deny.filter(function (element) {
- return element !== null;
- });
- $scope.dataJson.sort_options.allow = $scope.dataJson.sort_options.allow.filter(function (element) {
- return element !== null;
- });
- }
- }
-
- $("#save_button").click(function () {
- $('#search_contents_chg').trigger('click');
- let mainvalues = $("#labelname_text1").val();
- let subvalues = $("#labelname_text2").val();
- let index = $("#labelname_id").val();
- let lang = $("#labelname_lang").val();
- let select1 = $("#sel_lang1").val();
- let select2 = $("#sel_lang2").val();
-
- if (select1 == lang) {
- document.getElementById("label_contents_" + index).value = mainvalues;
- }
- else if (select2 == lang) {
- document.getElementById("label_contents_" + index).value = subvalues;
- }
- if (select1 != lang) {
- document.getElementById("hidden_contents_" + index).value = mainvalues;
- }
- else if (select2 != lang) {
- document.getElementById("hidden_contents_" + index).value = subvalues;
- }
- });
-
- $('#search_contents_chg').on('show.bs.modal', function (event) {
- var subGmn = $(event.relatedTarget);
- var contents = subGmn.data('contents');
- var subcontents = subGmn.data('subcontents');
- var index = subGmn.data('index');
- var language = subGmn.data('lang');
-
- let contvalues = $("#" + contents).val();
- let subvalues = $("#" + subcontents).val();
-
- document.getElementById("labelname_text1").value = contvalues;
- document.getElementById("labelname_text2").value = subvalues;
-
- document.getElementById("labelname_id").value = index;
- document.getElementById("labelname_lang").value = language;
-
- var select1 = document.getElementById("sel_lang1");
- var select2 = document.getElementById("sel_lang2");
-
- if (language == 'ja') {
- select1.options[1].selected = true;
- select2.options[0].selected = true;
- }
- else {
- select1.options[0].selected = true;
- select2.options[1].selected = true;
- }
-
- });
-
- $('#item-type-lists').change(function () {
- frm_cnt = 0;
- $(".tr_lists[id^='tr_lists']").each(function (index, formObj) {
- if ($(formObj).attr('id') != 'tr_lists' && $(formObj).attr('id') != 'tr_lists0') {
- $(formObj).remove();
- }
- });
-
- $scope.setItemTypeInfo();
-
- $("#tr_lists0 > #item_id > #search_item option[value='0']").prop('selected', true);
- var select_inputType = $("#tr_lists0 > #item_id > #search_item").val();
- $scope.setTextLabel(select_inputType, 'tr_lists0', true);
- });
-
- $('#search_item').change(function () {
- var select_inputType = $("#" + this.closest("tr").id).find("#search_item").val();
- $scope.setTextLabel(select_inputType, this.closest("tr").id, false);
- });
-
-
- $('#search_item_chg').on('show.bs.modal', function (event) {
- var subGmn = $(event.relatedTarget);
- var contents = subGmn.data('contents');
- document.getElementById("contents_word").value = contents;
-
- $("#tr_lists0").find("#button_remove").prop('disabled', true);
- $scope.setItemTypeInfo();
-
- $("#tr_lists0 > #item_id > #search_item option[value='0']").prop('selected', true);
- frm_cnt = 0;
- $(".tr_lists[id^='tr_lists']").each(function (index, formObj) {
- if ($(formObj).attr('id') != 'tr_lists' && $(formObj).attr('id') != 'tr_lists0') {
- $(formObj).remove();
- }
- });
-
- var select_inputType = $("#tr_lists0 > #item_id > #search_item").val();
- $scope.setTextLabel(select_inputType, 'tr_lists0', true);
- });
-
- $('button[type="button"]').on('click', function (ev) {
- let action = this.dataset.action;
-
- if ('add' == action) {
- frm_cnt++;
-
- $('#tr_lists0').clone(true).appendTo($('#t_keyword > #tb_keyword')).attr('id', 'tr_lists' + frm_cnt).end();
- $("#tr_lists" + frm_cnt).find("#button_remove").prop('disabled', false);
- $("#tr_lists" + frm_cnt + " > #item_id > #search_item option[value='0']").prop('selected', true);
-
- var select_inputType = $("#tr_lists" + frm_cnt + " > #item_id > #search_item").val();
- $scope.setTextLabel(select_inputType, 'tr_lists' + frm_cnt, true);
- }
-
- if ('del' == action) {
- this.closest("tr").remove();
-
- frm_cnt = 0;
- $(".tr_lists[id^='tr_lists']").each(function (index, formObj) {
- if ($(formObj).attr('id') != 'tr_lists' && $(formObj).attr('id') != 'tr_lists0') {
- frm_cnt++;
- $(formObj).attr('id', 'tr_lists' + frm_cnt).end();
- }
- });
-
- if (frm_cnt == 0) {
- $("#tr_lists0").find("#button_remove").prop('disabled', true);
- }
- }
-
- if ('save' == action) {
- $('#search_item_chg').trigger('click');
- var count = 0;
- var item_type_id = $("#item-type-lists").val();
-
- $(".tr_lists[id^='tr_lists']").each(function (index, formObj) {
- if (count <= frm_cnt) {
- if ($(formObj).attr('id', 'tr_lists' + count)) {
- var pathtype1 = $('#tr_lists' + count + ' > #setting_label > #setting_label1 > #label_list1 option:selected').text();
- var pathtype2 = $('#tr_lists' + count + ' > #setting_label > #setting_label2 > #label_list2 option:selected').text();
- var path1 = $('#tr_lists' + count + ' > #setting_label > #setting_label1 > #path_text1').val();
- var path2 = $('#tr_lists' + count + ' > #setting_label > #setting_label2 > #path_text2').val();
- var conditionpath = $('#tr_lists' + count + ' > #setting_label > #setting_label3 > #condition_path_text').val();
- var conditionvalue = $('#tr_lists' + count + ' > #setting_label > #setting_label4 > #condition_value_text').val();
- var select_contents = $('#tr_lists' + count + ' > #item_id > #search_item option:selected').text();
- var item_content = $('#tr_lists' + count + ' > #item_id > #contents_index').val();
- var item_input_type = $('#tr_lists' + count + ' > #item_id > #search_item option:selected').val();
-
- let reg_match = {
- item_type_id: item_type_id,
- contents: select_contents,
- index: item_content,
- input_type: item_input_type,
- path1: path1,
- path2: path2,
- pathtype1: pathtype1,
- pathtype2: pathtype2,
- conditionpath: conditionpath,
- conditionvalue: conditionvalue
- }
- regist.push(reg_match);
- }
- }
- count++;
- });
- }
- });
-
- $scope.setTextLabel = function (select_inputType, tr_id, initFlg) {
- var cnt = 0;
- var idx = 0;
- var obj = document.getElementById(tr_id);
- var selectobj = obj.firstElementChild.firstElementChild;
- if (!initFlg) {
- idx = selectobj.selectedIndex;
- }
-
- var select_contents = selectobj.options[idx].text;
-
- if (select_inputType == 'text') {
- $('#' + tr_id + ' > #label_id > div > #label_id1').text("");
- $('#' + tr_id + ' > #label_id > div > #label_id2').text("");
- $('#' + tr_id + ' > #setting_label > #setting_label2').hide();
- $('#' + tr_id + ' > #setting_label > #setting_label3').show();
- $('#' + tr_id + ' > #setting_label > #setting_label4').show();
- }
-
- if (select_inputType == 'range') {
- $('#' + tr_id + ' > #label_id > div > #label_id1').text($("#gte").val());
- $('#' + tr_id + ' > #label_id > div > #label_id2').text($("#lte").val());
- $('#' + tr_id + ' > #setting_label > #setting_label2').show();
- $('#' + tr_id + ' > #setting_label > #setting_label3').hide();
- $('#' + tr_id + ' > #setting_label > #setting_label4').hide();
- }
+import $ from "jquery";
+import ReactDOM from "react-dom";
+
+const {useState, useEffect ,useCallback} = React;
+const CONTENT_FILE_DOWNLOAD_LABEL = document.getElementById('content_file_download_label').value;
+const DOWNLOAD_LIMIT_LABEL = document.getElementById('download_limit_label').value;
+const EXPIRATION_DATE_LABEL = document.getElementById('expiration_date_label').value;
+const SECRET_LABEL_NAMES = $('#secret_label_names').data();
+const VALIDATION_ERROR_MESSAGES = $('#validation_error_messages').data();
+const MESSAGE_KEYWORDS = $('#message_keywords').data();
+const UNLIMITED_LABEL = document.getElementById('unlimited_label').value;
+const SAVE_LABEL = document.getElementById('save_label').value;
+const CHECK_INPUT_DOWNLOAD = document.getElementById('check_input_download').value;
+const CHECK_INPUT_EXPIRATION_DATE = document.getElementById('check_input_expiration_date').value;
+const EMPTY_DOWNLOAD = document.getElementById('empty_download').value;
+const EMPTY_ERROR_MESSAGE = document.getElementById('empty_error_message').value;
+const EMPTY_EXPIRATION_DATE = document.getElementById('empty_expiration_date').value;
+const USAGE_REPORT_WORKFLOW_ACCESS_LABEL = document.getElementById('usage_report_workflow_access_label').value
+const MAXINT = Number(document.getElementById('maxint').value)
+const MAX_DOWNLOAD_LIMIT = MAXINT;
+const MAX_EXPIRATION_DATE = MAXINT;
+
+const MESSAGE_MISSING_DATA = document.getElementById('message_miss_data').value;
+const LABEL_ENGLISH = document.getElementById("english").value;
+const LABEL_JAPANESE = document.getElementById("japanese").value;
+const LABEL_NEW = document.getElementById("new").value;
+const LABEL_TERMS_AND_CONDITIONS = document.getElementById("terms_and_conditions").value;
+
+const CONST_DEFAULT_ITEMS_PER_PAGE =parseInt(document.getElementById('const_items_per_page').value);
+const LABEL_ACTIVITY = document.getElementById('label_activity').value;
+const LABEL_ITEMS = document.getElementById("label_items").value;
+const LABEL_WORKFLOW = document.getElementById("label_workflow").value;
+const LABEL_STATUS = document.getElementById("label_status").value;
+const LABEL_USER = document.getElementById("label_user").value;
+const LABEL_CONFIRM = document.getElementById("label_confirm").value;
+const LABEL_CLOSE = document.getElementById("label_close").value;
+const LABEL_SEND = document.getElementById("label_send_mail").value;
+const LABEL_USAGE_REPORT_REMINDER_MAIL = document.getElementById("label_usage_report_reminder_mail").value;
+const LABEL_ACTION_DOING = document.getElementById("label_action_doing").value;
+const MSG_SEND_MAIL_SUCCESSFUL = document.getElementById("msg_sent_success").value;
+const MSG_SEND_MAIL_FAILED = document.getElementById("msg_sent_failed").value;
+const LABEL_SECRET_URL_DOWNLOAD = document.getElementById("label_secret_url_download").value;
+const LABEL_SECRET_URL_ENABLED = document.getElementById("label_secret_url_enabled").value;
+const LABEL_ERROR_MESSAGE = document.getElementById("error_message").value;
+const LABEL_PASSWORD_FOR_DOWNLOAD = document.getElementById("password_for_download").value;
+const LABEL_ITEM_APPLICATION = $("#item_application").first().val();
+const APPLICIABLE_ITEM_TYPES = $("#appliciable_item_types").first().val();
+const NOT_APPLICIABLE_ITEM_TYPES = $("#not_appliciable_item_types").first().val();
+const LABEL_PREVIEW_WORKFLOW_APPROVAL = $("#preview_workflow_approval").first().val();
+const LABEL_EDIT_MAIL_TEMPLATES = $("#edit_mail_templates").first().val();
+const LABEL_REQUEST_FORM = $("#request_form").first().val();
+
+const EMPTY_TERM = {
+ key: '',
+ content:
+ {
+ "en": {
+ "title": "",
+ "content": ""
+ },
+ "ja": {
+ "title": "",
+ "content": ""
+ }
+ }
+};
+
+const SECRET_URL_SETTINGS = {
+ minExpirationDays: 1,
+ maxExpirationDays: 30,
+ minDownloadLimit: 1,
+ maxDownloadLimit: 10
+};
+
+(function () {
+ let initValue = document.getElementById('init_data').value;
+ initValue = JSON.parse(initValue);
+
+ ReactDOM.render(
+ ,
+ document.getElementById('root')
+ )
+
+})();
+
+function InputComponent({
+ label,
+ currentValue,
+ checkboxValue,
+ canSetUnlimited=false,
+ value,
+ setValue,
+ inputId,
+ checkboxId,
+ disabledAll=false,
+ maxLength=String(MAXINT).length,
+ min=0,
+ max=MAXINT
+ }) {
+ const style = {marginRight: "5px", marginLeft: "15px"};
+ const containerStyle ={display: 'flex',gap:'15px',marginBottom:'2px'};
+
+ function handleChange(event) {
+ event.preventDefault();
+ let target = event.target;
+ let key = target.id;
+ let updateValue = target.value;
+
+ if (parseInt(updateValue) > max) {
+ updateValue = max;
+ }
+
+ if (!event.target.validity.valid) {
+ updateValue = value[key];
+ }
+ if (isNaN(updateValue)) {
+ try {
+ updateValue = parseInt(updateValue);
+ } catch (e) {
+ console.log(e);
+ }
+ }
+ setValue({...value, ...{[key]: updateValue}});
+ }
+
+ function handleUnlimited(event) {
+ let target = event.target;
+ let key = target.id;
+ let updateValue = target.type === 'checkbox' ? target.checked : target.value;
+ if (canSetUnlimited) {
+ if (!event.target.validity.valid) {
+ updateValue = value[key];
+ }
+ setValue({...value, ...{[key]: updateValue}});
+ }
+ }
+ return (
+
+
+
+ {canSetUnlimited && (
+
+ )}
+
+ )
+}
+
+function ItemApplicationSettingsLayout({enableItemApplication,setEnableItemApplication,applicationItemTypeList,setApplicationItemTypeList}) {
+ function convertItemTypeToOption(itemType) {
+ return (
+
+ )
+ }
+
+ const [itemTypes, setItemTypes] = useState([])
+
+ const enableSelected = () => {
+ let selectedItemTypes = [];
+ $('#select_hide option:selected').each(function () {
+ selectedItemTypes.push(parseInt($(this).val()));
+ $(this).prop('selected', false);
+ });
- if (select_inputType == 'geo_point') {
- $('#' + tr_id + ' > #label_id > div > #label_id1').text($("#lat").val());
- $('#' + tr_id + ' > #label_id > div > #label_id2').text($("#lon").val());
- $('#' + tr_id + ' > #setting_label > #setting_label2').show();
- $('#' + tr_id + ' > #setting_label > #setting_label3').hide();
- $('#' + tr_id + ' > #setting_label > #setting_label4').hide();
- }
+ if (selectedItemTypes.length > 0 && enableItemApplication) {
+ setApplicationItemTypeList([...applicationItemTypeList, ...selectedItemTypes]);
+ }
+ }
- if (select_inputType == 'geo_shape') {
- $('#' + tr_id + ' > #label_id > div > #label_id1').text($("#type").val());
- $('#' + tr_id + ' > #label_id > div > #label_id2').text($("#coordinates").val());
- $('#' + tr_id + ' > #setting_label > #setting_label2').show();
- $('#' + tr_id + ' > #setting_label > #setting_label3').hide();
- $('#' + tr_id + ' > #setting_label > #setting_label4').hide();
- }
+ const disableSelected = () => {
+ let selectedItemTypes = [];
+ $('#select_show option:selected').each(function () {
+ selectedItemTypes.push(parseInt($(this).val()));
+ $(this).prop('selected', false);
+ });
- var flg = false;
- for (cnt = 0; cnt < disp.length; cnt++) {
- if (disp[cnt].contents == select_contents) {
- $('#' + tr_id + ' > #setting_label > #setting_label1 > #path_text1').val(disp[cnt].path1);
- $('#' + tr_id + ' > #setting_label > #setting_label2 > #path_text2').val(disp[cnt].path2);
- $('#' + tr_id + ' > #item_id > #contents_index').val(disp[cnt].index);
- $('#' + tr_id + ' > #setting_label > #setting_label3 > #condition_path_text').val(disp[cnt].conditionpath);
- $('#' + tr_id + ' > #setting_label > #setting_label4 > #condition_value_text').val(disp[cnt].conditionvalue);
-
- if (disp[cnt].pathtype1 == 'xml') {
- $("#" + tr_id + " > #setting_label > #setting_label1 > #label_list1 option[value='1']").prop('selected', true);
- } else {
- $("#" + tr_id + " > #setting_label > #setting_label1 > #label_list1 option[value='0']").prop('selected', true);
- }
- if (disp[cnt].pathtype2 == 'xml') {
- $("#" + tr_id + " > #setting_label > #setting_label2 > #label_list2 option[value='1']").prop('selected', true);
- } else {
- $("#" + tr_id + " > #setting_label > #setting_label2 > #label_list2 option[value='0']").prop('selected', true);
- }
-
- flg = true;
- break;
- }
- }
- if (!flg) {
- $('#' + tr_id + ' > #setting_label > #setting_label1 > #path_text1').val("");
- $('#' + tr_id + ' > #setting_label > #setting_label2 > #path_text2').val("");
- $("#" + tr_id + " > #setting_label > #setting_label1 > #label_list1 option[value='0']").prop('selected', true);
- $("#" + tr_id + " > #setting_label > #setting_label2 > #label_list2 option[value='0']").prop('selected', true);
- $('#' + tr_id + ' > #setting_label > #setting_label3 > #condition_path_text').val("");
- $('#' + tr_id + ' > #setting_label > #setting_label4 > #condition_value_text').val("");
- }
+ if (selectedItemTypes.length > 0 && enableItemApplication) {
+ setApplicationItemTypeList(applicationItemTypeList.filter((item, index) => !selectedItemTypes.includes(item)));
+ }
+ }
+
+ useEffect(() => {
+ fetch('/api/itemtypes/lastest')
+ .then(response => response.json())
+ .then((data) => {
+ let results = []
+ for (const itemType of data) {
+ if (itemType.harvesting_type)
+ continue
+ else
+ results.push(itemType)
+ }
+ setItemTypes(results)
+ })
+ .catch(console.error)
+ }, [])
+
+ return (
+
+
+
+
+
+
{LABEL_ITEM_APPLICATION}
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+function FunctionEnableOnlyLayout({value, setValue, header_title, checkbox_id}) {
+ return (
+
+
+
+
+
+
{header_title}
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+function SecretURLFileDownloadLayout({value, setValue}) {
+ const {
+ secret_download_limit,
+ secret_expiration_date,
+ max_secret_expiration_date,
+ max_secret_download_limit,
+ secret_enable
+ } = value;
+
+ let checkboxValue = secret_enable;
+ let disabledAll = !checkboxValue;
+
+ function handleChange(event) {
+ event.preventDefault();
+ let target = event.target;
+ let key = target.id;
+ checkboxValue = target.checked
+ disabledAll = !checkboxValue;
+ setValue({...value, ...{[key]: checkboxValue}});
+ }
+
+ return (
+
+
+
+
+
+
{LABEL_SECRET_URL_DOWNLOAD}
+
+
+ {/* start enabled checkbox */}
+
+
+
+ {/* end enabled checkbox */}
+
+
+
+
+
+
+
+
+
+ )
+}
+
+function ContentFileDownloadLayout({value, setValue}) {
+ const {
+ download_limit,
+ expiration_date,
+ } = value;
+
+ return (
+
+
+
+
+
+
{CONTENT_FILE_DOWNLOAD_LABEL}
+
+
+
+
+
+
+
+
+
+ )
+}
+
+function UsageReportWorkflowAccessLayout({value, setValue}) {
+ const {expiration_date_access, expiration_date_access_unlimited_chk} = value
+ return (
+
+
+
+
+
+
{USAGE_REPORT_WORKFLOW_ACCESS_LABEL}
+
+
+
+
+
+
+
+
+ )
+}
+
+function TermsList({termList, setTermList, currentTerm, setCurrentTerm}) {
+
+ function handleOnTermClick(e) {
+ e.preventDefault();
+ // Set current term whenever an element is clicked
+ if (currentTerm === undefined || e.target.id !== currentTerm['key']) {
+ let newCurrentTerm;
+ newCurrentTerm = JSON.parse(JSON.stringify(termList.find(term => term['key'] === e.target.id)));
+ newCurrentTerm.existed = true;
+ setCurrentTerm(newCurrentTerm);
+ }
+ }
+
+ function handleCreateNewTerm(event) {
+ console.log("handleCreateNewTerm");
+ event.preventDefault();
+ let newTerm = JSON.parse(JSON.stringify(EMPTY_TERM));
+ newTerm['existed'] = true;
+ setCurrentTerm(newTerm);
+ }
+
+ function handleRemoveTerm(event) {
+ event.preventDefault();
+ setTermList(termList.filter(t => t.key !== event.target.id));
+ let newTerm = JSON.parse(JSON.stringify(EMPTY_TERM));
+ setCurrentTerm(newTerm)
+ }
+
+ return (
+
+
+
+
+ {
+ termList.map((term) => (
+
+ {term.content.en.title}
+
+
+
+ ))
}
- $scope.setItemTypeInfo = function () {
-
- var item_content;
- var item_content_id;
- var item_input_type = "";
- var item_val = "";
- var contents = $("#contents_word").val();
- disp = [];
-
- var item_type_id = $("#item-type-lists").val();
-
- $('#tr_lists0 > #item_id > #search_item').empty()
- for (let labelcnt = 0; labelcnt < $scope.dataJson.detail_condition.length; labelcnt++) {
-
- if ($scope.dataJson.detail_condition[labelcnt].item_value) {
- item_val = $scope.dataJson.detail_condition[labelcnt].item_value;
- item_content_id = contents + labelcnt;
- item_content = $("#" + item_content_id).val();
-
- item_input_type = $scope.dataJson.detail_condition[labelcnt].input_Type;
-
- var item_path1 = "";
- var item_path2 = "";
- var item_pathtype1 = "";
- var item_pathtype2 = "";
- var item_conditionpath = "";
- var item_conditionvalue = "";
-
- var item_val_sel = "";
- if (item_val[item_type_id]) {
- item_val_sel = item_val[item_type_id];
-
- if (item_input_type == 'text') {
- item_path1 = item_val_sel.path;
- item_pathtype1 = item_val_sel.path_type;
- item_conditionpath = item_val_sel.condition_path;
- item_conditionvalue = item_val_sel.condition_value;
- }
-
- if (item_input_type == 'range') {
- item_path1 = item_val_sel.path.gte;
- item_path2 = item_val_sel.path.lte;
- item_pathtype1 = item_val_sel.path_type.gte;
- item_pathtype2 = item_val_sel.path_type.lte;
- }
-
- if (item_input_type == 'geo_point') {
- item_path1 = item_val_sel.path.lat;
- item_path2 = item_val_sel.path.lon;
- item_pathtype1 = item_val_sel.path_type.lat;
- item_pathtype2 = item_val_sel.path_type.lon;
- }
-
- if (item_input_type == 'geo_shape') {
- item_path1 = item_val_sel.path.type;
- item_path2 = item_val_sel.path.coordinates;
- item_pathtype1 = item_val_sel.path_type.type;
- item_pathtype2 = item_val_sel.path_type.coordinates;
- }
- }
-
- var match = {
- item_type_id: item_type_id,
- contents: item_content,
- input_type: item_input_type,
- index: labelcnt,
- path1: item_path1,
- path2: item_path2,
- conditionpath: item_conditionpath,
- conditionvalue: item_conditionvalue,
- pathtype1: item_pathtype1,
- pathtype2: item_pathtype2
- };
-
- disp.push(match);
- var select = $('#tr_lists0 > #item_id > #search_item').append($('
+
+
+
+ )
+}
+
+function TermDetail({currentTerm, setCurrentTerm}) {
+ const {en, ja} = currentTerm.content;
+
+ function handleOnInputChanged(event, key) {
+ event.preventDefault();
+ let oldContent;
+ let content;
+
+ oldContent = currentTerm.content[key];
+ oldContent[event.target.name] = event.target.value;
+ content = {...currentTerm.content, ...{[key]: oldContent}};
+ setCurrentTerm({...currentTerm, content: content})
+ }
+
+ return (
+
+
+
+
+ handleOnInputChanged(e, "ja")}/>
+
+
+
+
+
+
+
+ handleOnInputChanged(e, "en")}/>
+
+
+
+
+
+ )
+}
+
+function TermsConditions({termList, setTermList, currentTerm, setCurrentTerm}) {
+ return (
+
+
+
+
+
+ {LABEL_TERMS_AND_CONDITIONS}
+
+
+
+
+
+
+ )
+}
+
+
+function ErrorMsgDetail({errorMsg, setErrorMsg}) {
+ const {en, ja} = errorMsg.content;
+
+ function InputChanged(event, key) {
+ let oldContent;
+ let content;
+
+ oldContent = errorMsg.content[key];
+ oldContent[event.target.name] = event.target.value;
+ content = {...errorMsg.content};
+ setErrorMsg({...errorMsg, content})
+ }
+
+ return (
+
+ )
+}
+
+function ErrorMsgConditions({errorMsg, setErrorMsg}) {
+ return (
+
+
+
+
+
+ {LABEL_ERROR_MESSAGE}
+
+
+
+
+
+
+
+
+ )
+}
+
+
+function RestrictedAccessLayout({
+ item_application,
+ preview_workflow_approval_enable,
+ edit_mail_templates_enable,
+ display_request_form,
+ password_enable,
+ secret_URL_file_download,
+ content_file_download,
+ terms_and_conditions,
+ usage_report_workflow_access,
+ error_msg,
+ restricted_access_display_flag
+ }) {
+
+ let itemApplicationSetting = item_application;
+ if (!itemApplicationSetting) {
+ itemApplicationSetting = {
+ item_application_enable: false,
+ application_item_types: []
+ };
+ }
+
+ const [itemApplicationEnable, setItemApplicationEnable] = useState(!!itemApplicationSetting.item_application_enable);
+ const [applicationItemTypeList, setApplicationItemTypeList] = useState(itemApplicationSetting.application_item_types);
+ const [workflowPreviewEnabled, setWorkflowPreviewEnabled] = useState(!!preview_workflow_approval_enable);
+ const [editMailTemplateEnabled, setEditMailTemplateEnabled] = useState(!!edit_mail_templates_enable);
+ const [requestFormEnabled, setRequestFormEnabled] = useState(!!display_request_form);
+ const [passwordEnable, setPasswordEnable] = useState(!!password_enable);
+ const [secretURLFileDownload , setSecretURLFileDownload] = useState(secret_URL_file_download);
+ const [contentFileDownload, setContentFileDownload] = useState(content_file_download);
+ const [usageReportWorkflowAccess, setUsageReportWorkflowAccess] = useState(usage_report_workflow_access);
+ const [termList, setTermList] = useState(terms_and_conditions);
+ const [currentTerm, setCurrentTerm] = useState(EMPTY_TERM);
+ const [errorMsg, setErrorMsg] = useState(error_msg);
+
+ const setPasswordEnableCallback = useCallback(setPasswordEnable , []);
+
+ function handleApply() {
+ let termListClone = [...termList];
+ if (!currentTerm.existed) {
+ return {
+ "valid": true,
+ "data": [...JSON.parse(JSON.stringify(termListClone))]
+ }
+ }
+
+ if (currentTerm.content.en.title.trim() === '' || currentTerm.content.en.content.trim() === '') {
+ return {
+ "valid": false,
+ "data": [...JSON.parse(JSON.stringify(termListClone))]
+ }
+ }
+
+ if (currentTerm['key'] === '') {
+ currentTerm['key'] = (Math.floor(Date.now() / 10)).toString();
+ setTermList([...termList, JSON.parse(JSON.stringify(currentTerm))])
+ return {
+ "valid": true,
+ "data": [...termList, JSON.parse(JSON.stringify(currentTerm))]
+ }
+ } else {
+ // for existed term
+ termListClone.map((term) => {
+ if (term.key === currentTerm.key)
+ term["content"] = JSON.parse(JSON.stringify(currentTerm)).content
+ });
+ setTermList(termListClone)
+ return {
+ "valid": true,
+ "data": [...JSON.parse(JSON.stringify(termListClone))]
+ }
+ }
+ }
+
+ function handleSave() {
+ const URL = "/api/admin/restricted_access/save";
+ // Validate Secret URL file download.
+ let errorMessage = validateSecretURLFileDownload()
+ if (errorMessage) {
+ showErrorMessage(errorMessage);
+ return false;
+ }
+ // Validate Content file download.
+ errorMessage = validateContentFileDownload();
+ if (errorMessage) {
+ showErrorMessage(errorMessage);
+ return false;
+ }
+ // Validate Usage report workflow access.
+ errorMessage = validateUsageReportWorkflowAccess();
+ if (errorMessage) {
+ showErrorMessage(errorMessage);
+ return false;
+ }
+ // Validate Term and condition
+ let terms_data = handleApply();
+ if (terms_data["valid"] === false) {
+ showErrorMessage(MESSAGE_MISSING_DATA);
+ return false;
+ }
+
+ // Ensure the values are integers
+ const parsedSecretURLFileDownload = {
+ ...secretURLFileDownload,
+ secret_download_limit: parseInt(secretURLFileDownload.secret_download_limit, 10),
+ max_secret_expiration_date: parseInt(secretURLFileDownload.max_secret_expiration_date, 10),
+ max_secret_download_limit: parseInt(secretURLFileDownload.max_secret_download_limit, 10),
+ secret_expiration_date: parseInt(secretURLFileDownload.secret_expiration_date, 10)
+ };
+
+ //Validate ErrorMsgConditions
+ errorMessage = validErrorMsgConditions();
+ if(errorMessage){
+ showErrorMessage(errorMessage);
+ return false;
+ }
+
+ let data = {
+ item_application: {
+ item_application_enable: itemApplicationEnable,
+ application_item_types: applicationItemTypeList
+ },
+ preview_workflow_approval_enable: workflowPreviewEnabled,
+ edit_mail_templates_enable: editMailTemplateEnabled,
+ display_request_form: requestFormEnabled,
+ password_enable:passwordEnable,
+ secret_URL_file_download:parsedSecretURLFileDownload,
+ content_file_download: contentFileDownload,
+ usage_report_workflow_access: usageReportWorkflowAccess,
+ terms_and_conditions: terms_data["data"],
+ error_msg:errorMsg
+ }
+
+ $.ajax({
+ url: URL,
+ method: 'POST',
+ contentType: 'application/json',
+ dataType: 'json',
+ data: JSON.stringify(data),
+ success: function (result) {
+ if (result.status) {
+ addAlert(result.msg, 2);
+ } else {
+ addAlert(result.msg, 1);
+ }
+ },
+ error: function (error) {
+ console.log(error);
+ }
+ });
+ }
+
+ function validateSecretURLFileDownload() {
+ const {
+ secret_download_limit,
+ secret_expiration_date,
+ max_secret_expiration_date,
+ max_secret_download_limit
+ } = secretURLFileDownload;
+
+ // Validate limitation values
+ // Check empty values
+ if (max_secret_expiration_date === "") {
+ return VALIDATION_ERROR_MESSAGES.emptyValue.replace(
+ "[label_name]", SECRET_LABEL_NAMES.maxExpirationDate);
+ }
+ if (max_secret_download_limit === "") {
+ return VALIDATION_ERROR_MESSAGES.emptyValue.replace(
+ "[label_name]", SECRET_LABEL_NAMES.maxDownloadLimit);
+ }
+
+ // Check input values range
+ const parsedMaxExpirationDays = parseInt(max_secret_expiration_date, 10);
+ if (parsedMaxExpirationDays < SECRET_URL_SETTINGS.minExpirationDays
+ || parsedMaxExpirationDays > SECRET_URL_SETTINGS.maxExpirationDays) {
+ const message = VALIDATION_ERROR_MESSAGES.outOfRange.replace(
+ "[label_name]", SECRET_LABEL_NAMES.maxExpirationDate
+ ).replace(
+ "[min]", SECRET_URL_SETTINGS.minExpirationDays
+ ).replace(
+ "[max]", SECRET_URL_SETTINGS.maxExpirationDays
+ );
+ return message;
+ }
+ const parsedMaxDownloadLimit = parseInt(max_secret_download_limit, 10);
+ if (parsedMaxDownloadLimit < SECRET_URL_SETTINGS.minDownloadLimit
+ || parsedMaxDownloadLimit > SECRET_URL_SETTINGS.maxDownloadLimit) {
+ const message = VALIDATION_ERROR_MESSAGES.outOfRange.replace(
+ "[label_name]", SECRET_LABEL_NAMES.maxDownloadLimit
+ ).replace(
+ "[min]", SECRET_URL_SETTINGS.minDownloadLimit
+ ).replace(
+ "[max]", SECRET_URL_SETTINGS.maxDownloadLimit
+ );
+ return message;
+ }
+
+ // Validate initial values
+ // Check empty values
+ if (secret_expiration_date === "") {
+ return VALIDATION_ERROR_MESSAGES.emptyValue.replace(
+ "[label_name]", SECRET_LABEL_NAMES.expirationDateInitial);
+ }
+ if (secret_download_limit === "") {
+ return VALIDATION_ERROR_MESSAGES.emptyValue.replace(
+ "[label_name]", SECRET_LABEL_NAMES.downloadLimitInitial);
+ }
+
+ // Check input values range
+ const parsedExpirationInitialDays = parseInt(secret_expiration_date, 10);
+ if (parsedExpirationInitialDays < SECRET_URL_SETTINGS.minExpirationDays
+ || parsedExpirationInitialDays > parsedMaxExpirationDays) {
+ const message = VALIDATION_ERROR_MESSAGES.outOfRange.replace(
+ "[label_name]", SECRET_LABEL_NAMES.expirationDateInitial
+ ).replace(
+ "[min]", SECRET_URL_SETTINGS.minExpirationDays
+ ).replace(
+ "[max]", MESSAGE_KEYWORDS.maximum
+ );
+ return message;
+ }
+ const parsedDownloadLimitInitial = parseInt(secret_download_limit, 10);
+ if (parsedDownloadLimitInitial < SECRET_URL_SETTINGS.minDownloadLimit
+ || parsedDownloadLimitInitial > parsedMaxDownloadLimit) {
+ const message = VALIDATION_ERROR_MESSAGES.outOfRange.replace(
+ "[label_name]", SECRET_LABEL_NAMES.downloadLimitInitial
+ ).replace(
+ "[min]", SECRET_URL_SETTINGS.minDownloadLimit
+ ).replace(
+ "[max]", MESSAGE_KEYWORDS.maximum
+ );
+ return message;
+ }
+
+ return;
+ }
+
+ function validateContentFileDownload() {
+ const {
+ download_limit,
+ expiration_date,
+ } = contentFileDownload;
+
+ let errorMessage;
+
+ if (expiration_date === "" ) {
+ errorMessage = EMPTY_EXPIRATION_DATE;
+ } else if (download_limit === "" ) {
+ errorMessage = EMPTY_DOWNLOAD;
+ } else if ((expiration_date < 1 )
+ || expiration_date > MAX_EXPIRATION_DATE) {
+ errorMessage = CHECK_INPUT_EXPIRATION_DATE;
+ } else if ((download_limit < 1 )
+ || download_limit > MAX_DOWNLOAD_LIMIT) {
+ errorMessage = CHECK_INPUT_DOWNLOAD;
+ }
+
+ return errorMessage;
+ }
+
+ function validateUsageReportWorkflowAccess() {
+ const {
+ expiration_date_access,
+ expiration_date_access_unlimited_chk,
+ } = usageReportWorkflowAccess;
+
+ let errorMessage;
+
+ if (expiration_date_access === "" && !expiration_date_access_unlimited_chk) {
+ errorMessage = EMPTY_EXPIRATION_DATE;
+ } else if ((expiration_date_access < 1 && !expiration_date_access_unlimited_chk)
+ || expiration_date_access > MAX_EXPIRATION_DATE) {
+ errorMessage = CHECK_INPUT_EXPIRATION_DATE;
+ }
+
+ return errorMessage;
+ }
+
+ function validErrorMsgConditions() {
+ let errorMessage;
+
+ if (error_msg.content.en.content == '' || error_msg.content.ja.content == '') {
+ errorMessage = EMPTY_ERROR_MESSAGE;
+ }
+ return errorMessage;
+ }
+
+
+ if (restricted_access_display_flag) {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+ } else {
+ return (
+
+
+
+
+
+
+ )
+ }
+}
+
+function showErrorMessage(errorMessage) {
+ $("#inputModal").html(errorMessage);
+ $("#allModal").modal("show");
+}
+
+function addAlert(message, type) {
+ let className = "alert alert-success alert-boder";
+ let closeButton = ''
+ if (type === 1) {
+ className = "alert alert-danger alert-dismissable alert-boder";
+ }
+ if (type === 2) {
+ className = "alert alert-info alert-dismissable alert-boder";
+ }
+ $('#alerts').append(
+ ''
+ + closeButton + message + '
');
+}
+
+function isSuperset (set, subset){
+ for (let elem of subset) {
+ if (!set.has(elem)) {
+ return false
+ }
+ }
+ return true
+}
+
+const queryUsageReportList = (method, data, setActivities, setTotalPage, extraParams) => {
+ const URL = "/api/admin/restricted_access/get_usage_report_activities";
+ let request;
+ if (method === 'GET') {
+ request = $.ajax({
+ url: URL + extraParams,
+ type: "GET",
+ });
+ } else {
+ request = $.ajax({
+ url: URL,
+ method: 'POST',
+ contentType: 'application/json',
+ dataType: 'json',
+ data: JSON.stringify(data)
+ });
+ }
+ request.success(
+ function (result) {
+ setActivities(result.activities)
+ setTotalPage(result.number_of_pages)
+ }
+ )
+ .error(function (error) {
+ console.log(error);
+ })
+}
+
+function ModalBodyConfirm ({selectedActivityIds}) {
+ const [activities, setActivities] = useState([])
+ const [currentPage, setCurrentPage] = useState(1)
+ const [totalPage, setTotalPage] = useState(1)
+
+ let startIndex = (currentPage - 1) * CONST_DEFAULT_ITEMS_PER_PAGE;
+
+ useEffect(() => {
+ let data = {
+ activity_ids: Array.from(selectedActivityIds),
+ page: currentPage,
+ size: CONST_DEFAULT_ITEMS_PER_PAGE
+ }
+ queryUsageReportList('POST', data, setActivities, setTotalPage, '')
+ startIndex = (currentPage - 1) * CONST_DEFAULT_ITEMS_PER_PAGE;
+ }, [currentPage])
+
+ const onPageChanged = (e) => {
+ if (parseInt(e.target.text) !== currentPage) {
+ setCurrentPage(parseInt(e.target.text))
+ }
+ }
+
+ return (
+
+
+
+
{LABEL_USAGE_REPORT_REMINDER_MAIL}
+
+
+
+
+
+
+
+ | No. |
+ {LABEL_ACTIVITY} |
+ {LABEL_ITEMS} |
+ {LABEL_WORKFLOW} |
+ {LABEL_STATUS} |
+ {LABEL_USER} |
+
+
+
+ {
+ activities.map((activity, index) => (
+
+ | {startIndex + index + 1} |
+ {activity.activity_id} |
+ {activity.item_name} |
+ {activity.workflow_name} |
+ {LABEL_ACTION_DOING} |
+ {activity.user_mail} |
+
+ ))
}
+
+
+
+
+
+
+
+ - {
+ if (currentPage > 1) setCurrentPage(currentPage - 1)
+ }}>
+ <
+
+ {Array.from(Array(totalPage), (e, i) => {
+ return (
+ -
+ {i + 1}
+
+ )
+ })}
+ - = totalPage ? `disabled` : ''} cursor={currentPage >= totalPage ?
+ 'not-allowed' : ''} onClick={() => {
+ if (currentPage < totalPage) setCurrentPage(currentPage + 1)
+ }}>
+ >
+
+
+
+
+
+ )
+}
+
+function ModalFooterConfirm({setShowConfirm,setSelectedActivityIds, selectedActivityIds}) {
+ function sendMailReminder() {
+ const URL = "/api/admin/restricted_access/send_mail_reminder";
+ const data = {
+ activity_ids: Array.from(selectedActivityIds)
+ }
+ $.ajax({
+ url: URL,
+ method: 'POST',
+ contentType: 'application/json',
+ dataType: 'json',
+ data: JSON.stringify(data),
+ success: function (result) {
+ if (result.status) {
+ addAlert(MSG_SEND_MAIL_SUCCESSFUL, 2)
+ } else {
+ addAlert(MSG_SEND_MAIL_FAILED, 1)
}
-
- // Inject depedencies
- searchManagementCtrl.$inject = [
- '$scope',
- '$rootScope',
- '$http',
- '$location'
- ];
- angular.module('searchManagement.controllers')
- .controller('searchManagementCtrl', searchManagementCtrl);
-
- angular.module('searchSettingModule', ['searchManagement.controllers']);
-
- angular.module('searchSettingModule', ['searchManagement.controllers']).config(['$interpolateProvider', function ($interpolateProvider) {
- $interpolateProvider.startSymbol('[[');
- $interpolateProvider.endSymbol(']]');
- }]);
-
- angular.bootstrap(
- document.getElementById('search_management'), ['searchSettingModule', 'ngJsTree']);
+ },
+ error: function (error) {
+ console.log(error);
+ }
});
-})(angular);
+ }
+
+ return (
+
+
+
+
+ )
+}
+
+function ConfirmModal({selectedActivityIds, setSelectedActivityIds, show, setShowConfirm}) {
+ return (
+
+
+
+
+
+
+
+
+ )
+}
+
+function UsageReportList() {
+ const [listActivities, setListActivities] = useState([]);
+ const [selectedActivityIds, setSelectedActivityIds] = useState(new Set())
+ const [isCheckedAll, setIsCheckedAll] = useState(false)
+ const [showConfirm, setShowConfirm] = useState(false)
+ const [enableBtnConfirm, setEnableBtnConfirm] = useState(true)
+ const [totalPage, setTotalPage] = useState(1)
+ const [currentPage, setCurrentPage] = useState(1)
+
+ let startIndex = (currentPage - 1) * CONST_DEFAULT_ITEMS_PER_PAGE;
+ let allCurrentPageIds = listActivities.map((activity) => {
+ return activity.activity_id
+ })
+
+ useEffect(() => {
+ updateCheckedAllState()
+ setEnableBtnConfirm(selectedActivityIds.size <= 0)
+ }, [selectedActivityIds]);
+
+ useEffect(() => {
+ let extraParams = `?page=${currentPage}&size=${CONST_DEFAULT_ITEMS_PER_PAGE}`
+ queryUsageReportList('GET', {},setListActivities, setTotalPage, extraParams);
+ startIndex = (currentPage - 1) * CONST_DEFAULT_ITEMS_PER_PAGE;
+ }, [currentPage])
+
+ useEffect(() => {
+ allCurrentPageIds = listActivities.map((activity) => {
+ return activity.activity_id
+ })
+ updateCheckedAllState()
+ }, [listActivities])
+
+ function updateCheckedAllState(){
+ if (allCurrentPageIds.length > 0) {
+ if (isSuperset(selectedActivityIds, new Set(allCurrentPageIds))) {
+ setIsCheckedAll(true)
+ } else {
+ setIsCheckedAll(false)
+ }
+ }
+ }
+
+ function onCheckedAll(e) {
+ let tempSelectedIds = new Set(selectedActivityIds);
+ if (e.target.checked) {
+ allCurrentPageIds.forEach(ids => tempSelectedIds.add(ids))
+ setSelectedActivityIds(tempSelectedIds)
+ setIsCheckedAll(true)
+ } else {
+ allCurrentPageIds.forEach(ids => tempSelectedIds.delete(ids))
+ setSelectedActivityIds(tempSelectedIds)
+ setIsCheckedAll(false)
+ }
+ }
+
+ function onChecked(e) {
+ let tempSelectedIds = new Set(selectedActivityIds);
+ if (e.target.checked) {
+ tempSelectedIds.add(e.target.id)
+ setSelectedActivityIds(tempSelectedIds)
+ } else {
+ tempSelectedIds.delete(e.target.id)
+ setSelectedActivityIds(tempSelectedIds)
+ }
+ }
+
+ function onChangePage(e) {
+ if (parseInt(e.target.text) !== currentPage) {
+ setCurrentPage(parseInt(e.target.text))
+ }
+ }
+
+ return (
+
+
+
+
+
+
+ {LABEL_USAGE_REPORT_REMINDER_MAIL}
+
+
+
+
+
+
+
+
+
+ - {
+ if (currentPage > 1) setCurrentPage(currentPage - 1)
+ }}>
+ <
+
+ {
+ Array.from(Array(totalPage), (e, i) => {
+ return (
+ -
+ {i + 1}
+
)
+ })
+ }
+ - = totalPage ? `disabled` : ''} cursor={currentPage >= totalPage ?
+ 'not-allowed' : ''} onClick={() => {
+ if (currentPage < totalPage)
+ setCurrentPage(currentPage + 1)
+ }}>
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
diff --git a/modules/weko-admin/weko_admin/templates/weko_admin/admin/restricted_access_settings.html b/modules/weko-admin/weko_admin/templates/weko_admin/admin/restricted_access_settings.html
index c1e94e98f3..4e4f3f5fba 100644
--- a/modules/weko-admin/weko_admin/templates/weko_admin/admin/restricted_access_settings.html
+++ b/modules/weko-admin/weko_admin/templates/weko_admin/admin/restricted_access_settings.html
@@ -35,6 +35,8 @@
+ {{ webpack['angular_js.js']}}
+ {{ webpack['admin_js_weko_admin_ng_js_tree_js.js']}}
{{ webpack['admin_js_weko_admin_restricted_access_js.js']}}
{%- endblock javascript %}