小编Pet*_*sma的帖子

仅在特定div中运行jQuery代码

我有一个主页上有id组件主页的主页.此页面在页脚,导航和其他元素中有一些动画.这些元素在所有其他页面上具有相同的名称.

当元素在#component-homepage中时,我想执行jQuery代码(js文件将包含更多,然后只包含此代码).

// This could should be on all the pages
$("nav li:last-child").addClass('last-child');

// This code should only be used when the id #component-homepage is in the body

// Homepage navigatie fadeIn + contentblok animatie
$('#content_home').hide();
$('nav').hide().fadeIn(1200, function(){
    var result = $("#content_home").outerHeight();

$('#content_home_container').css({"margin-top": -Math.abs(result), "height": (result)});

    $('#content_home').css({"margin-top": (result),"display":"block"}).animate({marginTop: '0px'},1000);
});

// Homepage navigatie animatie + url click event
$('nav a').click(function(event){
    event.preventDefault();
    var href = this.href;

    $('nav').animate({
        marginTop: '-635px'}, 
        1000,
        function(){
            window.location = href;
        });
    $('footer').fadeOut(200);
});
Run Code Online (Sandbox Code Playgroud)

我尝试在这里包装代码:

$('#component-homepage').ready(function(){
    // code …
Run Code Online (Sandbox Code Playgroud)

jquery

4
推荐指数
1
解决办法
2972
查看次数

您正在尝试在更改Gemfile后以部署模式安装

我正在尝试将我的Rails应用程序部署到我的DigitalOcean服务器上

cap production deploy
Run Code Online (Sandbox Code Playgroud)

但我收到一个错误,

(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@178.62.204.53: bundle exit status: 16
bundle stdout: You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

You have deleted from the Gemfile:
* rails-assets-angular-devise

You have changed in the Gemfile:
* rails-assets-angular-devise from `no specified source` to `rubygems repository
https://rubygems.org/, https://rails-assets.org/`
bundle stderr: Nothing written

SSHKit::Command::Failed: bundle exit …
Run Code Online (Sandbox Code Playgroud)

deployment capistrano ruby-on-rails

4
推荐指数
1
解决办法
3062
查看次数

MissingServletRequestParameterException

我将一个 formData 对象传递给我的 Spring 后端:

imageBanner(banner: File, bannerPath: string, id: number, callback: (response) => void){
    var formData = new FormData();
    formData.append('name', banner.name);
    console.log(formData.get('name'));
    formData.append('file', banner);
    console.log(formData.get('file'));

    this.sendPost("/upload/" + bannerPath, formData, response => {
        callback(response);
    });

}
Run Code Online (Sandbox Code Playgroud)

控制台日志显示:

1.jpg 
File {name: "1.jpg", lastModified: 1496737372408, lastModifiedDate: Tue Jun 06 2017 10:22:52 GMT+0200 (W. Europe Daylight Time), webkitRelativePath: "", size: 38983…}
Run Code Online (Sandbox Code Playgroud)

所以看起来 formData 有一些值。

在后端我有这个:

@RequestMapping(value="/rest/upload/localeventbanner", method=RequestMethod.POST, headers = "content-type!=multipart/form-data")
    public @ResponseBody String uploadFileHandler(@RequestParam("name") String name, @RequestParam("file") MultipartFile file) {

    if (!file.isEmpty()) { …
Run Code Online (Sandbox Code Playgroud)

spring angular

4
推荐指数
1
解决办法
1万
查看次数

使用 Azure CLI 检索 Azure 存储帐户密钥

在我的发布管道中,我使用 Azure CLI 将我的构建文件传输到 Azure 存储 blob:

call az storage blob upload-batch --source "$(System.DefaultWorkingDirectory)/_ClientWeb-Build-CI/ShellArtifact/out/build" --destination "$web" --account-key "****QxjclDGftOY/agnqUDzwNe/gOIAzsQ==" --account-name "*****estx"
Run Code Online (Sandbox Code Playgroud)

这有效,但我想account-key动态检索。

当我使用:

az storage account keys list -g CustomersV2 -n ****estx
Run Code Online (Sandbox Code Playgroud)

我得到一个包含 2 个对象的数组,它们都保存一个键值:

[
    {
    "keyName": "key1",
    "permissions": "Full",
    "value": "f/eybpcl*****************Vm9uT1PwFC1D82QxjclDGftOY/agnqUDzwNe/gOIAzsQ=="
    },
    {
    "keyName": "key2",
    "permissions": "Full",
    "value": "bNM**********L6OxAemK1U2oudW5WGRQW++/bzD6jVw=="
    }
]
Run Code Online (Sandbox Code Playgroud)

如何使用upload-batch命令中的两个键之一?

azure azure-devops

4
推荐指数
2
解决办法
8606
查看次数

如果断言失败则停止测试

我有一个简单的赛普拉斯测试:

    describe('My First Test', () => {
      it('Go to login page', () => {
        cy.visit('http://localhost:3000')
        cy.contains('Log in').click()
      })

      it('Login with local account', () => {
        cy.get('input[type=email]').type('123@123.com')
        cy.get('input[type=password]').type('asd123')
        cy.contains('Log in').type('{enter}')
      })
    })
Run Code Online (Sandbox Code Playgroud)

第一个断言检查是否存在带有 text 的元素Log in,然后单击它。第二个断言尝试登录。

我已将按钮中的文本更改Log inAssertion Failed。所以现在第一个断言失败了,但它仍然运行第二个断言,即使我没有重定向到登录页面。

当断言失败时,有没有办法取消正在运行的规范?

cypress

4
推荐指数
1
解决办法
4944
查看次数

Prisma 无法验证数据库服务器

我正在使用 docker 启动 postgres 数据库:

\n
version: \'3.8\'\nservices:\n  postgres:\n    image: postgres:13\n    restart: always\n    environment:\n      POSTGRES_USER: db_user\n      POSTGRES_PASSWORD: db_password\n    volumes:\n      - postgres:/var/lib/postgresql/data\n    ports:\n      - \'5432:5432\'\nvolumes:\n    postgres:\n
Run Code Online (Sandbox Code Playgroud)\n

在我的/.env文件中我有:

\n
DATABASE_URL="postgresql://db_user:db_password@localhost:5432/college_db?schema=public"\n
Run Code Online (Sandbox Code Playgroud)\n

我启动码头工人:

\n
PS C:\\Users\\alucardu\\Documents\\projects\\**-react> docker-compose up -d\nStarting **-react_postgres_1 ... done\n
Run Code Online (Sandbox Code Playgroud)\n

检查服务器是否正在运行:

\n
PS C:\\Users\\alucardu\\Documents\\projects\\**-react> docker ps\nCONTAINER ID   IMAGE         COMMAND                  CREATED         STATUS          PORTS                                       NAMES\ne0f9233ce34b   postgres:13   "docker-entrypoint.s\xe2\x80\xa6"   2 minutes ago   Up 33 seconds   0.0.0.0:5432->5432/tcp, :::5432->5432/tcp   **-react_postgres_1\n
Run Code Online (Sandbox Code Playgroud)\n

但是当我运行 Prisma 迁移时,出现身份验证错误:

\n
PS C:\\Users\\alucardu\\Documents\\projects\\movieseat-react> npx prisma migrate dev --name "init"\nEnvironment …
Run Code Online (Sandbox Code Playgroud)

docker docker-compose prisma

4
推荐指数
1
解决办法
2万
查看次数

将所有ng-if设置为false,单击除了单击的项目

我有一个ng-repeat,它有一个按钮,其功能可以在ng-repeat中切换ng-show元素.

movie_option跨度内部有ng-click=toggleInfo($index):

div additional_info有一个显示或隐藏元素的ng-show.

    <ul ng-cloak="showResult">
        <li class="search_results" ng-repeat="movie in movies | orderBy: '-release_date'  track by $index">
            <div class="movie_info">
                <div class="movie_options">
                    <div class="slide">
                        <span class="movie_option">
                            <span><i class="fa fa-question-circle" aria-hidden="true" ng-click="toggleInfo($index)"></i></span>
                        </span>
                    </div>
                </div>
            </div>
            <div class="additional_info" ng-show="hiddenDiv[$index]">
                {{movie.overview}}
            </div>
        </li>
    </ul>
Run Code Online (Sandbox Code Playgroud)

当用户点击图标时,它会调用此函数:

    $scope.toggleInfo = function (index) {
         $scope.hiddenDiv[index] = !$scope.hiddenDiv[index];
    }
Run Code Online (Sandbox Code Playgroud)

这会从hiddenDiv ng-show切换ng-show状态.这很好用.

我想要做的是将所有hiddenDiv状态设置为false,除了单击的那个,因此只有一个ng-show是真的.

html javascript angularjs angularjs-ng-repeat angularjs-ng-show

3
推荐指数
1
解决办法
795
查看次数

在失败的任务上继续 Azure Pipeline

我有一个运行 Cypress 的任务:

-ErrorAction SilentlyContinue
cd $(System.DefaultWorkingDirectory)/_ClientWeb-Build-CI/ShellArtifact/
npx cypress run
Run Code Online (Sandbox Code Playgroud)

我已经设定的ErrorActionPreferencecontinue。但是当我的 Cypress 出现故障时:

##[error]PowerShell exited with code '1'.
Run Code Online (Sandbox Code Playgroud)

下一个任务被取消,发布失败。即使赛普拉斯失败,我如何继续发布,是否可以根据赛普拉斯任务结果为布尔值提供真/假值?

azure azure-devops azure-pipelines

3
推荐指数
4
解决办法
1万
查看次数

如何使用“拉取请求查询”?

我想根据提交返回拉取请求。我发现了这个> https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull%20request%20query/get?view=azure-devops-rest-5.1

此 API 用于查找与给定提交相关的拉取请求。

我正在使用以下代码:

$body = @"
{
    "items": [
        {
            "59c1c31397b266116ff6d735e5638ef5d1b598a0"
        }
    ]
}
"@ 

$someLink = "https://dev.something.com/embrace/somethingSomething/_apis/git/repositories/****-bf64-47d9-8b10-53f21220d54d/pullrequestquery?api-version=5.1"
Invoke-RestMethod -Uri $someLink -Headers @{Authorization = $pat } -Body $body -Method Post -ContentType 'application/json'
Run Code Online (Sandbox Code Playgroud)

当我运行该版本时,我得到:

远程服务器返回错误:(400) 错误请求。

azure azure-devops

3
推荐指数
1
解决办法
3326
查看次数

Start-server-and-test "server closed unexpectedly"

I'm using the start-server-and-test package to start a server on my Azure pipeline to run Cypress.

This is the yarn command I use to start everything: yarn cy:build:workspace

"cy:build:workspace": "yarn cy:clean && start-server-and-test start http://localhost:8080 cy:run:workspace"

I'm running NODE_VERSION: "12.10.0" on the Azure env.

"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "d:\a\_temp\ce28689e-eef6-4eeb-bad2-82310f748e1b.cmd""
yarn run v1.22.4
$ yarn cy:clean && start-server-and-test start http://localhost:3000 cy:run:workspace
$ rimraf cypress/reports/*
1: starting server using command "npm run start"
and when url "[ 'http://localhost:3000' ]" …
Run Code Online (Sandbox Code Playgroud)

azure node.js cypress

3
推荐指数
1
解决办法
2006
查看次数