update
This commit is contained in:
parent
09fa8fc604
commit
b378c73152
@ -99,24 +99,29 @@ namespace PSTW_CentralSystem.Controllers.API
|
|||||||
return Json(qcList);
|
return Json(qcList);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("addData")]
|
[HttpPost("AddModule")]
|
||||||
public async Task<IActionResult> addData([FromBody] ModuleSettingModel modelSettingList)
|
public async Task<IActionResult> AddModule([FromBody] ModuleSettingModel module)
|
||||||
{
|
{
|
||||||
var existingModule = await _authDbContext.ModuleSettings.Where(x => x.ModuleName.ToLower() == modelSettingList.ModuleName.ToLower()).FirstOrDefaultAsync();
|
if (!ModelState.IsValid)
|
||||||
|
|
||||||
if (existingModule != null)
|
|
||||||
{
|
{
|
||||||
return BadRequest("Module name already exists."); // Return a 400 Bad Request
|
return BadRequest(ModelState);
|
||||||
|
}
|
||||||
|
if (module == null)
|
||||||
|
{
|
||||||
|
return NotFound("Module is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new module
|
try
|
||||||
modelSettingList.ModuleStatus = 1; // Default status
|
{
|
||||||
|
_authDbContext.ModuleSettings.Add(module);
|
||||||
_authDbContext.ModuleSettings.Add(modelSettingList);
|
await _authDbContext.SaveChangesAsync();
|
||||||
await _authDbContext.SaveChangesAsync();
|
var updatedList = await _authDbContext.ModuleSettings.ToListAsync();
|
||||||
|
return Json(updatedList);
|
||||||
|
}
|
||||||
return Json(modelSettingList);
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return BadRequest(ex.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,37 +50,37 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-3 mt-3">Add Method Rules</label>
|
<label class="col-md-3 mt-3">Add Method Rules</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
<li class="nav-item" role="presentation" v-for="(setMethod, index) in moduleData.methodAllowedUserType" :key="index">
|
<li class="nav-item" role="presentation" v-for="(setMethod, index) in moduleData.methodAllowedUserType" :key="index">
|
||||||
<a :class="['nav-link', activeTab === index ? 'active' : '']"
|
<a :class="['nav-link', activeTab === index ? 'active' : '']"
|
||||||
:id="'simple-tab-' + index"
|
:id="'simple-tab-' + index"
|
||||||
data-bs-toggle="tab"
|
data-bs-toggle="tab"
|
||||||
:href="'#simple-tabpanel-' + index"
|
:href="'#simple-tabpanel-' + index"
|
||||||
role="tab"
|
role="tab"
|
||||||
:aria-controls="'simple-tabpanel-' + index"
|
:aria-controls="'simple-tabpanel-' + index"
|
||||||
:aria-selected="activeTab === index ? 'true' : 'false'">
|
:aria-selected="activeTab === index ? 'true' : 'false'">
|
||||||
{{ setMethod.methodName }}
|
{{ setMethod.methodName }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content pt-5" id="tab-content">
|
<div class="tab-content pt-5" id="tab-content">
|
||||||
<div :class="['tab-pane', activeTab === index ? 'active' : '']" :id="'simple-tabpanel-' + index" role="tabpanel" :aria-labelledby="'simple-tab-' + index" v-for="(setMethod, index) in moduleData.methodAllowedUserType" :key="index">
|
<div :class="['tab-pane', activeTab === index ? 'active' : '']" :id="'simple-tabpanel-' + index" role="tabpanel" :aria-labelledby="'simple-tab-' + index" v-for="(setMethod, index) in moduleData.methodAllowedUserType" :key="index">
|
||||||
<p>Tab {{ setMethod.methodName }} selected</p>
|
<p>Tab {{ setMethod.methodName }} selected</p>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-1">Role:</label>
|
<label class="col-md-1">Role:</label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<select class="select2 form-select shadow-none mt-3" multiple="multiple" style="height: 36px; width: 100%" v-model="moduleData.methodAllowedUserType[index].allowedUserTypesArray">
|
<select class="select2 form-select shadow-none mt-3" multiple="multiple" style="height: 36px; width: 100%" v-model="moduleData.methodAllowedUserType[index].allowedUserTypesArray">
|
||||||
<option v-for="(roleType, index) in roleData" :key="index" :value="roleType.name">{{ roleType.name }}</option>
|
<option v-for="(roleType, index) in roleData" :key="index" :value="roleType.name">{{ roleType.name }}</option>
|
||||||
</select>
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="border-top">
|
<div class="border-top">
|
||||||
<div class="card-body" v-on:click="saveData">
|
<div class="card-body" v-on:click="saveData">
|
||||||
@ -158,20 +158,20 @@
|
|||||||
fetchXModule() {
|
fetchXModule() {
|
||||||
var id = @Model.SettingId
|
var id = @Model.SettingId
|
||||||
fetch('/ModuleAPI/GetXModuleInformation?id=' + id, {
|
fetch('/ModuleAPI/GetXModuleInformation?id=' + id, {
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
})
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
console.log(data);
|
|
||||||
if (data != null) {
|
|
||||||
this.moduleData = data;
|
|
||||||
|
|
||||||
this.fetchRoleList();
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.then(response => response.json())
|
||||||
console.error('There was a problem with the fetch operation:', error);
|
.then(data => {
|
||||||
});
|
console.log(data);
|
||||||
|
if (data != null) {
|
||||||
|
this.moduleData = data;
|
||||||
|
|
||||||
|
this.fetchRoleList();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('There was a problem with the fetch operation:', error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
fetchRoleList() {
|
fetchRoleList() {
|
||||||
fetch('/RoleAPI/GetRoleList', {
|
fetch('/RoleAPI/GetRoleList', {
|
||||||
@ -196,7 +196,7 @@
|
|||||||
},
|
},
|
||||||
fetchControllerMethodList() {
|
fetchControllerMethodList() {
|
||||||
var moduleName = '@Model.ModuleName'
|
var moduleName = '@Model.ModuleName'
|
||||||
fetch('/AdminAPI/GetClassAndMethodInformation?moduleName=' + moduleName, {
|
fetch('/AdminAPI/GetClassAndMethodInformation?moduleName=' + moduleName, {
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user