Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 60 additions & 34 deletions modules/weko-admin/weko_admin/static/js/weko_admin/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
$scope.fetch=function(result){
$scope.dbJson = angular.fromJson(result.slice(2,-2).replace(/\n/g,'\\n'));
console.log($scope.dbJson);
for(var data in $scope.dbJson.site_license){
var b = {ipCheckFlg:false,ipRangeCheck:false};
$scope.ipCheckFlgArry.push(b);
for(let i=0;i < $scope.dbJson.site_license.length;i++){
$scope.ipCheckFlgArry[i] =[];
for(let j=0;j < $scope.dbJson.site_license[i].addresses.length; j++){
const b = {ipCheckFlg:false,ipRangeCheck:false};
$scope.ipCheckFlgArry[i][j]=b;
}
}
};

Expand All @@ -54,7 +57,15 @@
$scope.addNewRowRange = function(ipIndex) {
var ipAddressRange = {start_ip_address:[],finish_ip_address:[]};
$scope.dbJson.site_license[ipIndex].addresses.push(ipAddressRange);
const subCheckFlg = {ipCheckFlg:false,ipRangeCheck:false};
$scope.ipCheckFlgArry[ipIndex].push(subCheckFlg);
}

$scope.removeIpAddress = function(ipIndex,index,index2) {
index.addresses.splice(ipIndex,1);
$scope.ipCheckFlgArry[index2].splice(ipIndex,1);
}

//add a new site License
$scope.addNewRowSiteLicense = function() {
var siteLicenseJson = {
Expand All @@ -67,8 +78,7 @@
$scope.dbJson.site_license.push(siteLicenseJson);

var subCheckFlg = {ipCheckFlg:false,ipRangeCheck:false};
$scope.ipCheckFlgArry.push(subCheckFlg);

$scope.ipCheckFlgArry.push([subCheckFlg]);
}
// delete selected site License
$scope.deleteSiteLicense = function(ipIndex){
Expand Down Expand Up @@ -99,33 +109,19 @@
}
//commit
$scope.commitData=function(){
var dbjosn = $scope.dbJson;
for(var chk1 in dbjosn.site_license){
for(var chk2 in dbjosn.site_license[chk1].addresses){
var saddr = "";
var faddr = "";
for(var i=0; i<4; i++){
tmp_s=dbjosn.site_license[chk1].addresses[chk2].start_ip_address[i];
if (typeof tmp_s!=='undefined' && tmp_s.length > 0) {
saddr += ("00" + tmp_s).slice(-3);
}
tmp_f=dbjosn.site_license[chk1].addresses[chk2].finish_ip_address[i]
if (typeof tmp_f!=='undefined' && tmp_f.length > 0) {
faddr += ("00" + tmp_f).slice(-3);
}
}

if (!saddr || !faddr){
$scope.ipCheckFlgArry[chk1].ipCheckFlg = true;
}
else if (parseInt(saddr) > parseInt(faddr)){
$scope.ipCheckFlgArry[chk1].ipRangeCheck = true;
return;
}
}
$scope.ipCheckFlgArry[chk1].ipRangeCheck = false;
rangeCheck($scope);
let isError = false;

outerLoop:
for(let i=0;i < $scope.dbJson.site_license.length;i++){
for(let j=0;j < $scope.dbJson.site_license[i].addresses.length; j++){
if($scope.ipCheckFlgArry[i][j].ipCheckFlg === true || $scope.ipCheckFlgArry[i][j].ipRangeCheck === true ){
isError = true;
break outerLoop;
}
}
}
isError = $scope.ipCheckFlgArry.filter(function(item){ return item.ipCheckFlg === true || item.ipRangeCheck === true })[0];

if (!isError) {
var url = $location.path();
dbJson = $scope.dbJson;
Expand All @@ -139,13 +135,13 @@
}

//入力チェック
$scope.chcckStr=function(str,p_index){
$scope.checkStr=function(str,p_index,index){
var checkStr1 = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; //正整数
var flg = checkStr1.test(str);
if(!flg){
$scope.ipCheckFlgArry[p_index].ipCheckFlg = true;
$scope.ipCheckFlgArry[p_index][index].ipCheckFlg = true;
}else{
$scope.ipCheckFlgArry[p_index].ipCheckFlg = false;
$scope.ipCheckFlgArry[p_index][index].ipCheckFlg = false;
}
}
}
Expand All @@ -170,3 +166,33 @@
document.getElementById('siteLicense'), ['siteLicenseModule']);
});
})(angular);

function rangeCheck($scope){
const dbjosn = $scope.dbJson;
for(let chk1=0;chk1<dbjosn.site_license.length;chk1++){
for(let chk2=0;chk2<dbjosn.site_license[chk1].addresses.length;chk2++){
let saddr = "";
let faddr = "";
for(let i=0; i<4; i++){
let tmp_s=dbjosn.site_license[chk1].addresses[chk2].start_ip_address[i];
if (typeof tmp_s!=='undefined' && tmp_s.length > 0) {
saddr += ("00" + tmp_s).slice(-3);
}
let tmp_f=dbjosn.site_license[chk1].addresses[chk2].finish_ip_address[i]
if (typeof tmp_f!=='undefined' && tmp_f.length > 0) {
faddr += ("00" + tmp_f).slice(-3);
}
}

if (!saddr || !faddr){
$scope.ipCheckFlgArry[chk1][chk2].ipCheckFlg = true;
}
else if (parseInt(saddr) > parseInt(faddr)){
$scope.ipCheckFlgArry[chk1][chk2].ipRangeCheck = true;
}
else{
$scope.ipCheckFlgArry[chk1][chk2].ipRangeCheck = false;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $('#confirm_send_button').on('click', function () {
alert('Selected period is wrong!');
return;
}
let start_month = $("#from_year_select").val() + '-' + paddingLeft($("#from_month_select").val(), 2);
let start_month = $("#from_year_select").val() + '-' + paddingLeft($("#from_month_select").val(), 2);
let end_month = $("#to_year_select").val() + '-' + paddingLeft($("#to_month_select").val(), 2);
$.ajax({
url: '/api/admin/sitelicensesendmail/send/' + start_month + '/' + end_month,
Expand Down Expand Up @@ -41,7 +41,6 @@ $('input:checkbox[id^="send_mail_flag_"]').change(function() {

$('#save_settings').on('click', function() {
let auto_send_flag = $('input:radio[id="enable_auto_send"]')[0].checked ? true : false;
//let check_list = document.querySelectorAll("[id^=send_mail_flag_]");
let data = {};
data['auto_send_flag'] = auto_send_flag;
data['checked_list'] = checked_list
Expand All @@ -68,3 +67,29 @@ function paddingLeft(str,lenght){
else
return paddingLeft("0" +str,lenght);
}

$('#all-check').on('change', function () {
document.querySelectorAll('[id^="send_mail_flag_"]').forEach(el => {
if (!(el.disabled)) {
if ($('#all-check').prop('checked')) {
el.checked = true;
checked_list[el.name] = 'T';
}
else {
el.checked = false;
checked_list[el.name] = 'F';
}
}
})
});

$(document).ready(function() {
let checkList = Array.from(document.querySelectorAll("[id^=send_mail_flag_]")).filter(el => el.disabled === false);
const allChecked = checkList.length>0 && Array.from(checkList).every(el => el.checked);
if (allChecked) {
$('#all-check').prop('checked',true);
}
else{
$('#all-check').prop('checked',false);
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
<table class="table table-striped table-bordered">
<thead>
<tr>
<th></th>
<th>{{_('Organization')}}</th>
<th>{{_('Email Address')}}</th>
<th style="text-align: center; padding-top: 1px; padding-bottom: 1px;">{{_('Send')}}<br><input type="checkbox" id="all-check"> </th>
<th style="vertical-align: middle;">{{_('Organization')}}</th>
<th style="vertical-align: middle;">{{_('Email Address')}}</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -76,14 +76,14 @@
<h4>{{_('Automatic Send')}}</h4>
</td>
<td colspan="6">
<p>{{_('Select "Send" to automatically send a use of site license statistics email to the checked the organization.')}}</p>
<p>{{_('Select "Enable" to automatically send a use of site license statistics email to the checked the organization.')}}</p>
</td>
</tr>
<tr>
<td align="center" style="width:150px">
<label class="radio-inline" for="enable_auto_send">
<input type="radio" name="dis_enable_auto_send" id="enable_auto_send" value="True" {{ 'checked' if auto_send else '' }}>
{{_('Send')}}
{{_('Enable')}}
</label>
</td>
<td align="center" style="width:150px">
Expand All @@ -109,7 +109,7 @@ <h4>{{_('Manual Send')}}</h4>
</tr>
<tr>
<td>
{{_('Aggregation month')}}
{{_('Aggregation period')}}
</td>
<td>
<select class="form-control" id="from_year_select" name="year">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,43 +97,47 @@
{{_('(from - to)')}}
</th>
<td>
<div class="form-group" ng-repeat="ipAddressRangeDetail in ipDetail.addresses" ng-init="rangeIndex = $index">
<div class="form-group" ng-repeat="ipAddressRangeDetail in ipDetail.addresses">
<input type="text" class="form-control input-sm"
ng-model="ipAddressRangeDetail.start_ip_address[0]"
ng-keyup="chcckStr(ipAddressRangeDetail.start_ip_address[0],$parent.$index)"
ng-keyup="checkStr(ipAddressRangeDetail.start_ip_address[0],$parent.$index,$index)"
size="1" maxlength="3" placeholder="0"> .
<input type="text" class="form-control input-sm"
ng-model="ipAddressRangeDetail.start_ip_address[1]"
ng-keyup="chcckStr(ipAddressRangeDetail.start_ip_address[1],$parent.$index)"
ng-keyup="checkStr(ipAddressRangeDetail.start_ip_address[1],$parent.$index,$index)"
size="1" maxlength="3" placeholder="0"> .
<input type="text" class="form-control input-sm"
ng-model="ipAddressRangeDetail.start_ip_address[2]"
ng-keyup="chcckStr(ipAddressRangeDetail.start_ip_address[2],$parent.$index)"
ng-keyup="checkStr(ipAddressRangeDetail.start_ip_address[2],$parent.$index,$index)"
size="1" maxlength="3" placeholder="0"> .
<input type="text" class="form-control input-sm"
ng-model="ipAddressRangeDetail.start_ip_address[3]"
ng-keyup="chcckStr(ipAddressRangeDetail.start_ip_address[3],$parent.$index)"
ng-keyup="checkStr(ipAddressRangeDetail.start_ip_address[3],$parent.$index,$index)"
size="1" maxlength="3" placeholder="0"> -
<input type="text" class="form-control input-sm"
ng-model="ipAddressRangeDetail.finish_ip_address[0]"
ng-keyup="chcckStr(ipAddressRangeDetail.finish_ip_address[0],$parent.$index)"
ng-keyup="checkStr(ipAddressRangeDetail.finish_ip_address[0],$parent.$index,$index)"
size="1" maxlength="3" placeholder="0"> .
<input type="text" class="form-control input-sm"
ng-model="ipAddressRangeDetail.finish_ip_address[1]"
ng-keyup="chcckStr(ipAddressRangeDetail.finish_ip_address[1],$parent.$index)"
ng-keyup="checkStr(ipAddressRangeDetail.finish_ip_address[1],$parent.$index,$index)"
size="1" maxlength="3" placeholder="0"> .
<input type="text" class="form-control input-sm"
ng-model="ipAddressRangeDetail.finish_ip_address[2]"
ng-keyup="chcckStr(ipAddressRangeDetail.finish_ip_address[2],$parent.$index)"
ng-keyup="checkStr(ipAddressRangeDetail.finish_ip_address[2],$parent.$index,$index)"
size="1" maxlength="3" placeholder="0"> .
<input type="text" class="form-control input-sm"
ng-model="ipAddressRangeDetail.finish_ip_address[3]"
ng-keyup="chcckStr(ipAddressRangeDetail.finish_ip_address[3],$parent.$index)"
ng-keyup="checkStr(ipAddressRangeDetail.finish_ip_address[3],$parent.$index,$index)"
size="1" maxlength="3" placeholder="0">
<a type="button" class="btn btn-danger" style="margin-left: 8px;" ng-click="removeIpAddress($index,ipDetail,ipIndex)" ng-if="ipDetail.addresses.length>1">
<span class="glyphicon glyphicon-trash"></span>&nbsp
{{_('Delete')}}
</a>
<span id="span_[[$index]]" style="color:red" ng-show="ipCheckFlgArry[ipIndex][$index].ipCheckFlg" class="ng-hide">{{_('Please input a correct number.')}}</span>
<span style="color:red" ng-show="ipCheckFlgArry[ipIndex][$index].ipRangeCheck" class="ng-hide">{{_('The range of ipAddress is not correct.')}}</span>
<p></p>
</div>
<span id="span_[[$index]]" style="color:red" ng-show="ipCheckFlgArry[ipIndex].ipCheckFlg" class="ng-hide">{{_('Please input a correct number')}}</span>
<span style="color:red" ng-show="ipCheckFlgArry[ipIndex].ipRangeCheck" class="ng-hide">{{_('The range of ipAddress is not correct')}}</span>
<p></p>
<div class="form-group">
<button type="button" class="btn btn-success"
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ msgstr "Feedback email feature"

#: weko_admin/template/weko_admin/admin/feedback_mail.html:42
msgid "Send"
msgstr "Enable"
msgstr "Send"

#: weko_admin/template/weko_admin/admin/feedback_mail.html:43
msgid "Do not send"
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,8 @@ msgstr "定型レポート"

#: weko_admin/templates/weko_admin/admin/report.html:94
#: weko_admin/templates/weko_admin/admin/site_license_send_mail_settings.html:112
msgid "Aggregation month"
msgstr "月別集計"
msgid "Aggregation period"
msgstr "集計期間"

#: weko_admin/templates/weko_admin/admin/report.html:105
msgid "Type"
Expand Down Expand Up @@ -1468,30 +1468,29 @@ msgstr "注意書きの字数上限は1000字です。"
#: weko_admin/templates/weko_admin/admin/site_license_send_mail_settings.html:37
msgid ""
"Please classify a check into the organization send a use of site license "
"statistics eamil."
msgstr ""
"statistics email."
msgstr "サイトライセンス統計メールを送信する機関をチェックしてください。"

#: weko_admin/templates/weko_admin/admin/site_license_send_mail_settings.html:42
#, fuzzy
msgid "Organization"
msgstr "組織名"
msgstr "機関名"

#: weko_admin/templates/weko_admin/admin/site_license_send_mail_settings.html:76
msgid "Automatic Send"
msgstr ""
msgstr "メール自動送信"

#: weko_admin/templates/weko_admin/admin/site_license_send_mail_settings.html:79
msgid ""
"Select \"Send\" to automatically send a use of site license statistics "
"Select \"Enable\" to automatically send a use of site license statistics "
"email to the checked the organization."
msgstr ""
msgstr ""有効"を選択するとチェックされた機関にサイトライセンス統計メールが自動送信されます。"

#: weko_admin/templates/weko_admin/admin/site_license_send_mail_settings.html:107
msgid ""
"When manually send a use of site license statistics email to the checked "
"the organization, select the aggregation period and press the [Manual "
"Send] button."
msgstr ""
msgstr "チェックされた機関にサイトライセンス統計メールを手動送信する場合、集計期間を設定して[メール手動送信]ボタンを押してください。"

#: weko_admin/templates/weko_admin/admin/site_license_send_mail_settings.html:198
#, fuzzy
Expand Down Expand Up @@ -1528,12 +1527,12 @@ msgid "(from - to)"
msgstr ""

#: weko_admin/templates/weko_admin/admin/site_license_settings.html:135
msgid "Please input a correct number"
msgstr "正しい番号を入力してください"
msgid "Please input a correct number."
msgstr "正しい番号を入力してください"

#: weko_admin/templates/weko_admin/admin/site_license_settings.html:136
msgid "The range of ipAddress is not correct"
msgstr "IPアドレスの範囲が正しくありません"
msgid "The range of ipAddress is not correct."
msgstr "IPアドレスの範囲が正しくありません"

#: weko_admin/templates/weko_admin/admin/site_license_settings.html:142
#: weko_admin/templates/weko_admin/admin/site_license_settings.html:153
Expand Down
Loading
Loading