How to use the sweetalert2 function in sweetalert2

To help you get started, we’ve selected a few sweetalert2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chrisleekr / yii2-angular-boilerplate / backend / src / app / user / user-list.component.ts View on Github external
public confirmDeleteUser(user: User): void {
        // Due to sweet alert scope issue, define as function variable and pass to swal

        const parent = this;
        // let getUsers = this.getUsers;
        this.errorMessage = '';

        swal({
            title: 'Are you sure?',
            text: 'Once delete, you won\'t be able to revert this!',
            type: 'question',
            showLoaderOnConfirm: true,
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, delete it!',
            preConfirm: function () {
                parent.loading = true;
                return new Promise(function (resolve, reject) {
                    parent.userDataService.deleteUserById(user.id)
                        .subscribe(
                            result => {
                                parent.getUsers();
                                parent.loading = false;
github TronLink / tronlink-extension / app / popup / src / pages / Accounts / index.js View on Github external
async createAccount() {
        // Check for bip44 account gap (20 empty accounts)
        const emptyAccounts = 
            Object.values(this.props.accounts)
                .filter(account => account.internal && !account.transactions.length)
                .sort((a, b) => b.accountIndex - a.accountIndex);

        if(emptyAccounts.length >= 2 && (emptyAccounts[0].accountIndex - 20 >= emptyAccounts[emptyAccounts.length - 2].accountIndex)) {
            return Swal({
                title: this.translate({ id: 'accounts.create.tooMany' }),
                type: 'error'
            });
        }

        const { value: name } = await Swal({
            title: this.translate({ id: 'accounts.create.title' }),
            input: 'text',
            inputPlaceholder: this.translate({ id: 'accounts.create.placeholder' }),
            showCancelButton: true,
            inputValidator: name => {
                if(!name)
                    return this.translate({ id: 'accounts.create.requiresName' });

                if(name.trim().length > 32)
                    return this.translate({ id: 'accounts.create.nameTooLong' })
github apispots / apispots-extension / src / modules / stories / story-player.js View on Github external
const _processStoryOutput = (story) => {
    try {

      const {output} = story;

      if ((output.data instanceof Blob) &&
           (output.data.size > 0)) {

        // output type is Blob,
        // so download now
        const blob = output.data;

        swal({
          title: 'Enter a filename',
          input: 'text',
          showCancelButton: true,
          confirmButtonText: 'Save',
          allowOutsideClick: false
        }).then((filename) => {

          FileSaver.saveAs(blob, filename);
        })
          .catch(() => {
            // silent
            FileSaver.saveAs(blob);
          });
      } else if ((typeof output.data !== 'undefined')
                || (!_.isEmpty(output.text))
                || (!_.isEmpty(output.data))) {
github OpenStackweb / openstack-org / summit / ui / source / js / components / sync-calendar.js View on Github external
handleSubmit(event) {
        event.preventDefault();
        let cal_type = this.state.cal_type;
        console.log(`handleSubmit - cal_type ${cal_type}`);
        if (cal_type) {
            if (cal_type != 'apple' || (this.state.ios_user && this.state.ios_pass)) {
                this.props.syncCalendar(cal_type, this.state.ios_user, this.state.ios_pass);
            }
        } else {
            swal('Validation error', 'Please complete all fields', 'warning');
        }
    }
github poanetwork / poa-dapps-voting / src / components / NewBallot / index.js View on Github external
onClick = async () => {
    const { commonStore, contractsStore, ballotStore, ballotsStore } = this.props
    const { push } = this.props.routing

    if (!contractsStore.votingKey) {
      swal('Warning!', messages.NO_METAMASK_MSG, 'warning')
      return
    } else if (!contractsStore.networkMatch) {
      swal('Warning!', messages.networkMatchError(contractsStore.netId), 'warning')
      return
    } else if (!contractsStore.isValidVotingKey) {
      swal('Warning!', messages.invalidVotingKeyMsg(contractsStore.votingKey), 'warning')
      return
    }

    commonStore.showLoading()

    const isFormValid = this.checkValidation()

    if (isFormValid) {
      if (ballotStore.ballotType === ballotStore.BallotType.keys) {
        const inputToAreBallotParamsValid = {
github poanetwork / token-wizard / src / utils / alerts.js View on Github external
export function warningOnFinalizeCrowdsale() {
  return sweetAlert2({
    title: "Finalize Crowdsale",
    html: "Are you sure to finalize the crowdsale? After finalization, it's not possible to buy tokens, all tokens will be movable, reserved tokens will be issued. Press <strong>Yes</strong> to finalize, and <strong>NO</strong> to close this dialog.",
    type: "warning",
    showCancelButton: true,
    cancelButtonText: "NO",
    confirmButtonText: "Yes",
    reverseButtons: true
  })
}
github poanetwork / token-wizard / src / utils / alerts.js View on Github external
export function notTheOwner() {
  sweetAlert2({
    title: "Not The Owner",
    html: "Current user is not the owner of the Crowdsale, thus you won't be able to modify it",
    type: "warning"
  })
}
github TronLink / tronlink-extension / app / popup / src / components / Queue / index.js View on Github external
this.setState({
            error
        });

        const config = {
            type: 'success',
            title: this.translate({ id: 'queue.transaction.sent' })
        };

        if (error) {
            config.type = 'error';
            config.title = this.translate({ id: 'queue.transaction.failed' });
            config.text = error;
        }

        return Swal(config).then(res => {
            this.setState({
                loading: false
            });

            updateConfirmations();
        });
    }
github bknds / ng-pi-admin / src / app / pages / ui / components / notification / notification.component.ts View on Github external
alertImg() {
    swal({
      title: 'Sweet!',
      text: 'Modal with a custom image.',
      imageUrl: 'https://unsplash.it/400/200',
      imageWidth: 400,
      imageHeight: 200,
      imageAlt: 'Custom image',
      animation: false
    });
  }
}
github Robertvera / rent-manager / rent-manager / src / components / Admin / AdminProperties / AdminEditProperties / admin-edit-properties.js View on Github external
.then((result)=> {
                    if (result.data.status === 'OK') {
                        swal({
                            title: 'Property updated!',
                            text: 'You are being redirected',
                            type: 'success',
                            showConfirmButton: false,
                            timer: 2500,
                            onOpen: () => {
                                swal.showLoading()
                              }                         
                         })
                         .then(()=> {
                            this.props.history.push("/back/admin/properties")
                         })
                    } else {
                        swal({
                            type: 'error',
                            title: 'Oops...',