Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support to add multi subscribers at once #15

Merged
merged 2 commits into from
Nov 29, 2021
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
24 changes: 11 additions & 13 deletions frontend/src/pages/Subscribers/SubscriberOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Button, Table } from "react-bootstrap";
import SubscriberModal from "./components/SubscriberModal";
import ApiHelper from "../../util/ApiHelper";


class SubscriberOverview extends Component {
state = {
subscriberModalOpen: false,
Expand Down Expand Up @@ -37,22 +38,19 @@ class SubscriberOverview extends Component {

async addSubscriber(subscriberData) {
this.setState({ subscriberModalOpen: false });

if (!await ApiHelper.createSubscriber(subscriberData)) {
alert("Error creating new subscriber");
let userNumber = subscriberData["userNumber"];
delete subscriberData["userNumber"];
let imsi = subscriberData["ueId"].substr(5, subscriberData["ueId"].length - 5);
for(let i = 0; i < userNumber; i++){
let newImsi = Number(imsi) + i;
subscriberData["ueId"] = `imsi-${newImsi}`;
if (!await ApiHelper.createSubscriber(subscriberData)) {
alert("Error creating new subscriber when create user");
}
ApiHelper.fetchSubscribers().then();
}
ApiHelper.fetchSubscribers().then();
}

// async updateSubscriber(subscriberData) {
// this.setState({subscriberModalOpen: false});

// if (!await ApiHelper.updateSubscriber(subscriberData)) {
// alert("Error creating new subscriber");
// }
// ApiHelper.fetchSubscribers().then();
// }

/**
* @param subscriberData
*/
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/pages/Subscribers/components/SubscriberModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class SubscriberModal extends Component {
// "description": "A simple form example.",
type: "object",
required: [
"userNumber",
"plmnID",
"ueId",
"authenticationMethod",
Expand All @@ -196,6 +197,13 @@ class SubscriberModal extends Component {
"SQN",
],
properties: {
userNumber: {
type: "integer",
title: "Subscriber data number (auto-increased with SUPI)",
default: 1,
maximum: 100000,
minimum: 1
},
plmnID: {
type: "string",
title: "PLMN ID",
Expand Down Expand Up @@ -528,6 +536,7 @@ class SubscriberModal extends Component {
const OPc = formData["OPOPcSelect"] === "OPc" ? formData["OPOPc"] : "";

let subscriberData = {
"userNumber": formData["userNumber"],
"plmnID": formData["plmnID"], // Change required
"ueId": "imsi-" + formData["ueId"], // Change required
"AuthenticationSubscription": {
Expand Down